babylon.module.d.ts 6.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808
  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/Misc/andOrNotEvaluator" {
  1646. /**
  1647. * Class used to evalaute queries containing `and` and `or` operators
  1648. */
  1649. export class AndOrNotEvaluator {
  1650. /**
  1651. * Evaluate a query
  1652. * @param query defines the query to evaluate
  1653. * @param evaluateCallback defines the callback used to filter result
  1654. * @returns true if the query matches
  1655. */
  1656. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1657. private static _HandleParenthesisContent;
  1658. private static _SimplifyNegation;
  1659. }
  1660. }
  1661. declare module "babylonjs/Misc/tags" {
  1662. /**
  1663. * Class used to store custom tags
  1664. */
  1665. export class Tags {
  1666. /**
  1667. * Adds support for tags on the given object
  1668. * @param obj defines the object to use
  1669. */
  1670. static EnableFor(obj: any): void;
  1671. /**
  1672. * Removes tags support
  1673. * @param obj defines the object to use
  1674. */
  1675. static DisableFor(obj: any): void;
  1676. /**
  1677. * Gets a boolean indicating if the given object has tags
  1678. * @param obj defines the object to use
  1679. * @returns a boolean
  1680. */
  1681. static HasTags(obj: any): boolean;
  1682. /**
  1683. * Gets the tags available on a given object
  1684. * @param obj defines the object to use
  1685. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1686. * @returns the tags
  1687. */
  1688. static GetTags(obj: any, asString?: boolean): any;
  1689. /**
  1690. * Adds tags to an object
  1691. * @param obj defines the object to use
  1692. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1693. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1694. */
  1695. static AddTagsTo(obj: any, tagsString: string): void;
  1696. /**
  1697. * @hidden
  1698. */
  1699. static _AddTagTo(obj: any, tag: string): void;
  1700. /**
  1701. * Removes specific tags from a specific object
  1702. * @param obj defines the object to use
  1703. * @param tagsString defines the tags to remove
  1704. */
  1705. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1706. /**
  1707. * @hidden
  1708. */
  1709. static _RemoveTagFrom(obj: any, tag: string): void;
  1710. /**
  1711. * Defines if tags hosted on an object match a given query
  1712. * @param obj defines the object to use
  1713. * @param tagsQuery defines the tag query
  1714. * @returns a boolean
  1715. */
  1716. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1717. }
  1718. }
  1719. declare module "babylonjs/Maths/math.scalar" {
  1720. /**
  1721. * Scalar computation library
  1722. */
  1723. export class Scalar {
  1724. /**
  1725. * Two pi constants convenient for computation.
  1726. */
  1727. static TwoPi: number;
  1728. /**
  1729. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1730. * @param a number
  1731. * @param b number
  1732. * @param epsilon (default = 1.401298E-45)
  1733. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1734. */
  1735. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1736. /**
  1737. * Returns a string : the upper case translation of the number i to hexadecimal.
  1738. * @param i number
  1739. * @returns the upper case translation of the number i to hexadecimal.
  1740. */
  1741. static ToHex(i: number): string;
  1742. /**
  1743. * Returns -1 if value is negative and +1 is value is positive.
  1744. * @param value the value
  1745. * @returns the value itself if it's equal to zero.
  1746. */
  1747. static Sign(value: number): number;
  1748. /**
  1749. * Returns the value itself if it's between min and max.
  1750. * Returns min if the value is lower than min.
  1751. * Returns max if the value is greater than max.
  1752. * @param value the value to clmap
  1753. * @param min the min value to clamp to (default: 0)
  1754. * @param max the max value to clamp to (default: 1)
  1755. * @returns the clamped value
  1756. */
  1757. static Clamp(value: number, min?: number, max?: number): number;
  1758. /**
  1759. * the log2 of value.
  1760. * @param value the value to compute log2 of
  1761. * @returns the log2 of value.
  1762. */
  1763. static Log2(value: number): number;
  1764. /**
  1765. * Loops the value, so that it is never larger than length and never smaller than 0.
  1766. *
  1767. * This is similar to the modulo operator but it works with floating point numbers.
  1768. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1769. * With t = 5 and length = 2.5, the result would be 0.0.
  1770. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1771. * @param value the value
  1772. * @param length the length
  1773. * @returns the looped value
  1774. */
  1775. static Repeat(value: number, length: number): number;
  1776. /**
  1777. * Normalize the value between 0.0 and 1.0 using min and max values
  1778. * @param value value to normalize
  1779. * @param min max to normalize between
  1780. * @param max min to normalize between
  1781. * @returns the normalized value
  1782. */
  1783. static Normalize(value: number, min: number, max: number): number;
  1784. /**
  1785. * Denormalize the value from 0.0 and 1.0 using min and max values
  1786. * @param normalized value to denormalize
  1787. * @param min max to denormalize between
  1788. * @param max min to denormalize between
  1789. * @returns the denormalized value
  1790. */
  1791. static Denormalize(normalized: number, min: number, max: number): number;
  1792. /**
  1793. * Calculates the shortest difference between two given angles given in degrees.
  1794. * @param current current angle in degrees
  1795. * @param target target angle in degrees
  1796. * @returns the delta
  1797. */
  1798. static DeltaAngle(current: number, target: number): number;
  1799. /**
  1800. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1801. * @param tx value
  1802. * @param length length
  1803. * @returns The returned value will move back and forth between 0 and length
  1804. */
  1805. static PingPong(tx: number, length: number): number;
  1806. /**
  1807. * Interpolates between min and max with smoothing at the limits.
  1808. *
  1809. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1810. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1811. * @param from from
  1812. * @param to to
  1813. * @param tx value
  1814. * @returns the smooth stepped value
  1815. */
  1816. static SmoothStep(from: number, to: number, tx: number): number;
  1817. /**
  1818. * Moves a value current towards target.
  1819. *
  1820. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1821. * Negative values of maxDelta pushes the value away from target.
  1822. * @param current current value
  1823. * @param target target value
  1824. * @param maxDelta max distance to move
  1825. * @returns resulting value
  1826. */
  1827. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1828. /**
  1829. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1830. *
  1831. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1832. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1833. * @param current current value
  1834. * @param target target value
  1835. * @param maxDelta max distance to move
  1836. * @returns resulting angle
  1837. */
  1838. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1839. /**
  1840. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1841. * @param start start value
  1842. * @param end target value
  1843. * @param amount amount to lerp between
  1844. * @returns the lerped value
  1845. */
  1846. static Lerp(start: number, end: number, amount: number): number;
  1847. /**
  1848. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1849. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1850. * @param start start value
  1851. * @param end target value
  1852. * @param amount amount to lerp between
  1853. * @returns the lerped value
  1854. */
  1855. static LerpAngle(start: number, end: number, amount: number): number;
  1856. /**
  1857. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1858. * @param a start value
  1859. * @param b target value
  1860. * @param value value between a and b
  1861. * @returns the inverseLerp value
  1862. */
  1863. static InverseLerp(a: number, b: number, value: number): number;
  1864. /**
  1865. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1866. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1867. * @param value1 spline value
  1868. * @param tangent1 spline value
  1869. * @param value2 spline value
  1870. * @param tangent2 spline value
  1871. * @param amount input value
  1872. * @returns hermite result
  1873. */
  1874. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1875. /**
  1876. * Returns a random float number between and min and max values
  1877. * @param min min value of random
  1878. * @param max max value of random
  1879. * @returns random value
  1880. */
  1881. static RandomRange(min: number, max: number): number;
  1882. /**
  1883. * This function returns percentage of a number in a given range.
  1884. *
  1885. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1886. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1887. * @param number to convert to percentage
  1888. * @param min min range
  1889. * @param max max range
  1890. * @returns the percentage
  1891. */
  1892. static RangeToPercent(number: number, min: number, max: number): number;
  1893. /**
  1894. * This function returns number that corresponds to the percentage in a given range.
  1895. *
  1896. * PercentToRange(0.34,0,100) will return 34.
  1897. * @param percent to convert to number
  1898. * @param min min range
  1899. * @param max max range
  1900. * @returns the number
  1901. */
  1902. static PercentToRange(percent: number, min: number, max: number): number;
  1903. /**
  1904. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1905. * @param angle The angle to normalize in radian.
  1906. * @return The converted angle.
  1907. */
  1908. static NormalizeRadians(angle: number): number;
  1909. }
  1910. }
  1911. declare module "babylonjs/Maths/math.constants" {
  1912. /**
  1913. * Constant used to convert a value to gamma space
  1914. * @ignorenaming
  1915. */
  1916. export const ToGammaSpace: number;
  1917. /**
  1918. * Constant used to convert a value to linear space
  1919. * @ignorenaming
  1920. */
  1921. export const ToLinearSpace = 2.2;
  1922. /**
  1923. * Constant used to define the minimal number value in Babylon.js
  1924. * @ignorenaming
  1925. */
  1926. let Epsilon: number;
  1927. export { Epsilon };
  1928. }
  1929. declare module "babylonjs/Maths/math.viewport" {
  1930. /**
  1931. * Class used to represent a viewport on screen
  1932. */
  1933. export class Viewport {
  1934. /** viewport left coordinate */
  1935. x: number;
  1936. /** viewport top coordinate */
  1937. y: number;
  1938. /**viewport width */
  1939. width: number;
  1940. /** viewport height */
  1941. height: number;
  1942. /**
  1943. * Creates a Viewport object located at (x, y) and sized (width, height)
  1944. * @param x defines viewport left coordinate
  1945. * @param y defines viewport top coordinate
  1946. * @param width defines the viewport width
  1947. * @param height defines the viewport height
  1948. */
  1949. constructor(
  1950. /** viewport left coordinate */
  1951. x: number,
  1952. /** viewport top coordinate */
  1953. y: number,
  1954. /**viewport width */
  1955. width: number,
  1956. /** viewport height */
  1957. height: number);
  1958. /**
  1959. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1960. * @param renderWidth defines the rendering width
  1961. * @param renderHeight defines the rendering height
  1962. * @returns a new Viewport
  1963. */
  1964. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1965. /**
  1966. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1967. * @param renderWidth defines the rendering width
  1968. * @param renderHeight defines the rendering height
  1969. * @param ref defines the target viewport
  1970. * @returns the current viewport
  1971. */
  1972. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1973. /**
  1974. * Returns a new Viewport copied from the current one
  1975. * @returns a new Viewport
  1976. */
  1977. clone(): Viewport;
  1978. }
  1979. }
  1980. declare module "babylonjs/Misc/arrayTools" {
  1981. /**
  1982. * Class containing a set of static utilities functions for arrays.
  1983. */
  1984. export class ArrayTools {
  1985. /**
  1986. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1987. * @param size the number of element to construct and put in the array
  1988. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1989. * @returns a new array filled with new objects
  1990. */
  1991. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1992. }
  1993. }
  1994. declare module "babylonjs/Maths/math.plane" {
  1995. import { DeepImmutable } from "babylonjs/types";
  1996. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1997. /**
  1998. * Represents a plane by the equation ax + by + cz + d = 0
  1999. */
  2000. export class Plane {
  2001. private static _TmpMatrix;
  2002. /**
  2003. * Normal of the plane (a,b,c)
  2004. */
  2005. normal: Vector3;
  2006. /**
  2007. * d component of the plane
  2008. */
  2009. d: number;
  2010. /**
  2011. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2012. * @param a a component of the plane
  2013. * @param b b component of the plane
  2014. * @param c c component of the plane
  2015. * @param d d component of the plane
  2016. */
  2017. constructor(a: number, b: number, c: number, d: number);
  2018. /**
  2019. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2020. */
  2021. asArray(): number[];
  2022. /**
  2023. * @returns a new plane copied from the current Plane.
  2024. */
  2025. clone(): Plane;
  2026. /**
  2027. * @returns the string "Plane".
  2028. */
  2029. getClassName(): string;
  2030. /**
  2031. * @returns the Plane hash code.
  2032. */
  2033. getHashCode(): number;
  2034. /**
  2035. * Normalize the current Plane in place.
  2036. * @returns the updated Plane.
  2037. */
  2038. normalize(): Plane;
  2039. /**
  2040. * Applies a transformation the plane and returns the result
  2041. * @param transformation the transformation matrix to be applied to the plane
  2042. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2043. */
  2044. transform(transformation: DeepImmutable<Matrix>): Plane;
  2045. /**
  2046. * Compute the dot product between the point and the plane normal
  2047. * @param point point to calculate the dot product with
  2048. * @returns the dot product (float) of the point coordinates and the plane normal.
  2049. */
  2050. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2051. /**
  2052. * Updates the current Plane from the plane defined by the three given points.
  2053. * @param point1 one of the points used to contruct the plane
  2054. * @param point2 one of the points used to contruct the plane
  2055. * @param point3 one of the points used to contruct the plane
  2056. * @returns the updated Plane.
  2057. */
  2058. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2059. /**
  2060. * Checks if the plane is facing a given direction
  2061. * @param direction the direction to check if the plane is facing
  2062. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2063. * @returns True is the vector "direction" is the same side than the plane normal.
  2064. */
  2065. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2066. /**
  2067. * Calculates the distance to a point
  2068. * @param point point to calculate distance to
  2069. * @returns the signed distance (float) from the given point to the Plane.
  2070. */
  2071. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2072. /**
  2073. * Creates a plane from an array
  2074. * @param array the array to create a plane from
  2075. * @returns a new Plane from the given array.
  2076. */
  2077. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2078. /**
  2079. * Creates a plane from three points
  2080. * @param point1 point used to create the plane
  2081. * @param point2 point used to create the plane
  2082. * @param point3 point used to create the plane
  2083. * @returns a new Plane defined by the three given points.
  2084. */
  2085. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2086. /**
  2087. * Creates a plane from an origin point and a normal
  2088. * @param origin origin of the plane to be constructed
  2089. * @param normal normal of the plane to be constructed
  2090. * @returns a new Plane the normal vector to this plane at the given origin point.
  2091. * Note : the vector "normal" is updated because normalized.
  2092. */
  2093. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2094. /**
  2095. * Calculates the distance from a plane and a point
  2096. * @param origin origin of the plane to be constructed
  2097. * @param normal normal of the plane to be constructed
  2098. * @param point point to calculate distance to
  2099. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2100. */
  2101. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2102. }
  2103. }
  2104. declare module "babylonjs/Engines/performanceConfigurator" {
  2105. /** @hidden */
  2106. export class PerformanceConfigurator {
  2107. /** @hidden */
  2108. static MatrixUse64Bits: boolean;
  2109. /** @hidden */
  2110. static MatrixTrackPrecisionChange: boolean;
  2111. /** @hidden */
  2112. static MatrixCurrentType: any;
  2113. /** @hidden */
  2114. static MatrixTrackedMatrices: Array<any> | null;
  2115. /** @hidden */
  2116. static SetMatrixPrecision(use64bits: boolean): void;
  2117. }
  2118. }
  2119. declare module "babylonjs/Maths/math.vector" {
  2120. import { Viewport } from "babylonjs/Maths/math.viewport";
  2121. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2122. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2123. import { Plane } from "babylonjs/Maths/math.plane";
  2124. /**
  2125. * Class representing a vector containing 2 coordinates
  2126. */
  2127. export class Vector2 {
  2128. /** defines the first coordinate */
  2129. x: number;
  2130. /** defines the second coordinate */
  2131. y: number;
  2132. /**
  2133. * Creates a new Vector2 from the given x and y coordinates
  2134. * @param x defines the first coordinate
  2135. * @param y defines the second coordinate
  2136. */
  2137. constructor(
  2138. /** defines the first coordinate */
  2139. x?: number,
  2140. /** defines the second coordinate */
  2141. y?: number);
  2142. /**
  2143. * Gets a string with the Vector2 coordinates
  2144. * @returns a string with the Vector2 coordinates
  2145. */
  2146. toString(): string;
  2147. /**
  2148. * Gets class name
  2149. * @returns the string "Vector2"
  2150. */
  2151. getClassName(): string;
  2152. /**
  2153. * Gets current vector hash code
  2154. * @returns the Vector2 hash code as a number
  2155. */
  2156. getHashCode(): number;
  2157. /**
  2158. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2159. * @param array defines the source array
  2160. * @param index defines the offset in source array
  2161. * @returns the current Vector2
  2162. */
  2163. toArray(array: FloatArray, index?: number): Vector2;
  2164. /**
  2165. * Update the current vector from an array
  2166. * @param array defines the destination array
  2167. * @param index defines the offset in the destination array
  2168. * @returns the current Vector3
  2169. */
  2170. fromArray(array: FloatArray, index?: number): Vector2;
  2171. /**
  2172. * Copy the current vector to an array
  2173. * @returns a new array with 2 elements: the Vector2 coordinates.
  2174. */
  2175. asArray(): number[];
  2176. /**
  2177. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2178. * @param source defines the source Vector2
  2179. * @returns the current updated Vector2
  2180. */
  2181. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2182. /**
  2183. * Sets the Vector2 coordinates with the given floats
  2184. * @param x defines the first coordinate
  2185. * @param y defines the second coordinate
  2186. * @returns the current updated Vector2
  2187. */
  2188. copyFromFloats(x: number, y: number): Vector2;
  2189. /**
  2190. * Sets the Vector2 coordinates with the given floats
  2191. * @param x defines the first coordinate
  2192. * @param y defines the second coordinate
  2193. * @returns the current updated Vector2
  2194. */
  2195. set(x: number, y: number): Vector2;
  2196. /**
  2197. * Add another vector with the current one
  2198. * @param otherVector defines the other vector
  2199. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2200. */
  2201. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2202. /**
  2203. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2204. * @param otherVector defines the other vector
  2205. * @param result defines the target vector
  2206. * @returns the unmodified current Vector2
  2207. */
  2208. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2209. /**
  2210. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2211. * @param otherVector defines the other vector
  2212. * @returns the current updated Vector2
  2213. */
  2214. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2215. /**
  2216. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2217. * @param otherVector defines the other vector
  2218. * @returns a new Vector2
  2219. */
  2220. addVector3(otherVector: Vector3): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2223. * @param otherVector defines the other vector
  2224. * @returns a new Vector2
  2225. */
  2226. subtract(otherVector: Vector2): Vector2;
  2227. /**
  2228. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2229. * @param otherVector defines the other vector
  2230. * @param result defines the target vector
  2231. * @returns the unmodified current Vector2
  2232. */
  2233. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2234. /**
  2235. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2236. * @param otherVector defines the other vector
  2237. * @returns the current updated Vector2
  2238. */
  2239. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2240. /**
  2241. * Multiplies in place the current Vector2 coordinates by the given ones
  2242. * @param otherVector defines the other vector
  2243. * @returns the current updated Vector2
  2244. */
  2245. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2246. /**
  2247. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2248. * @param otherVector defines the other vector
  2249. * @returns a new Vector2
  2250. */
  2251. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2254. * @param otherVector defines the other vector
  2255. * @param result defines the target vector
  2256. * @returns the unmodified current Vector2
  2257. */
  2258. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2259. /**
  2260. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2261. * @param x defines the first coordinate
  2262. * @param y defines the second coordinate
  2263. * @returns a new Vector2
  2264. */
  2265. multiplyByFloats(x: number, y: number): Vector2;
  2266. /**
  2267. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2268. * @param otherVector defines the other vector
  2269. * @returns a new Vector2
  2270. */
  2271. divide(otherVector: Vector2): Vector2;
  2272. /**
  2273. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2274. * @param otherVector defines the other vector
  2275. * @param result defines the target vector
  2276. * @returns the unmodified current Vector2
  2277. */
  2278. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2279. /**
  2280. * Divides the current Vector2 coordinates by the given ones
  2281. * @param otherVector defines the other vector
  2282. * @returns the current updated Vector2
  2283. */
  2284. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2285. /**
  2286. * Gets a new Vector2 with current Vector2 negated coordinates
  2287. * @returns a new Vector2
  2288. */
  2289. negate(): Vector2;
  2290. /**
  2291. * Negate this vector in place
  2292. * @returns this
  2293. */
  2294. negateInPlace(): Vector2;
  2295. /**
  2296. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2297. * @param result defines the Vector3 object where to store the result
  2298. * @returns the current Vector2
  2299. */
  2300. negateToRef(result: Vector2): Vector2;
  2301. /**
  2302. * Multiply the Vector2 coordinates by scale
  2303. * @param scale defines the scaling factor
  2304. * @returns the current updated Vector2
  2305. */
  2306. scaleInPlace(scale: number): Vector2;
  2307. /**
  2308. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2309. * @param scale defines the scaling factor
  2310. * @returns a new Vector2
  2311. */
  2312. scale(scale: number): Vector2;
  2313. /**
  2314. * Scale the current Vector2 values by a factor to a given Vector2
  2315. * @param scale defines the scale factor
  2316. * @param result defines the Vector2 object where to store the result
  2317. * @returns the unmodified current Vector2
  2318. */
  2319. scaleToRef(scale: number, result: Vector2): Vector2;
  2320. /**
  2321. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2322. * @param scale defines the scale factor
  2323. * @param result defines the Vector2 object where to store the result
  2324. * @returns the unmodified current Vector2
  2325. */
  2326. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2327. /**
  2328. * Gets a boolean if two vectors are equals
  2329. * @param otherVector defines the other vector
  2330. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2331. */
  2332. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2333. /**
  2334. * Gets a boolean if two vectors are equals (using an epsilon value)
  2335. * @param otherVector defines the other vector
  2336. * @param epsilon defines the minimal distance to consider equality
  2337. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2338. */
  2339. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2340. /**
  2341. * Gets a new Vector2 from current Vector2 floored values
  2342. * @returns a new Vector2
  2343. */
  2344. floor(): Vector2;
  2345. /**
  2346. * Gets a new Vector2 from current Vector2 floored values
  2347. * @returns a new Vector2
  2348. */
  2349. fract(): Vector2;
  2350. /**
  2351. * Gets the length of the vector
  2352. * @returns the vector length (float)
  2353. */
  2354. length(): number;
  2355. /**
  2356. * Gets the vector squared length
  2357. * @returns the vector squared length (float)
  2358. */
  2359. lengthSquared(): number;
  2360. /**
  2361. * Normalize the vector
  2362. * @returns the current updated Vector2
  2363. */
  2364. normalize(): Vector2;
  2365. /**
  2366. * Gets a new Vector2 copied from the Vector2
  2367. * @returns a new Vector2
  2368. */
  2369. clone(): Vector2;
  2370. /**
  2371. * Gets a new Vector2(0, 0)
  2372. * @returns a new Vector2
  2373. */
  2374. static Zero(): Vector2;
  2375. /**
  2376. * Gets a new Vector2(1, 1)
  2377. * @returns a new Vector2
  2378. */
  2379. static One(): Vector2;
  2380. /**
  2381. * Gets a new Vector2 set from the given index element of the given array
  2382. * @param array defines the data source
  2383. * @param offset defines the offset in the data source
  2384. * @returns a new Vector2
  2385. */
  2386. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2387. /**
  2388. * Sets "result" from the given index element of the given array
  2389. * @param array defines the data source
  2390. * @param offset defines the offset in the data source
  2391. * @param result defines the target vector
  2392. */
  2393. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2394. /**
  2395. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2396. * @param value1 defines 1st point of control
  2397. * @param value2 defines 2nd point of control
  2398. * @param value3 defines 3rd point of control
  2399. * @param value4 defines 4th point of control
  2400. * @param amount defines the interpolation factor
  2401. * @returns a new Vector2
  2402. */
  2403. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2404. /**
  2405. * 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".
  2406. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2407. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2408. * @param value defines the value to clamp
  2409. * @param min defines the lower limit
  2410. * @param max defines the upper limit
  2411. * @returns a new Vector2
  2412. */
  2413. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2414. /**
  2415. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2416. * @param value1 defines the 1st control point
  2417. * @param tangent1 defines the outgoing tangent
  2418. * @param value2 defines the 2nd control point
  2419. * @param tangent2 defines the incoming tangent
  2420. * @param amount defines the interpolation factor
  2421. * @returns a new Vector2
  2422. */
  2423. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2424. /**
  2425. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2426. * @param start defines the start vector
  2427. * @param end defines the end vector
  2428. * @param amount defines the interpolation factor
  2429. * @returns a new Vector2
  2430. */
  2431. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2432. /**
  2433. * Gets the dot product of the vector "left" and the vector "right"
  2434. * @param left defines first vector
  2435. * @param right defines second vector
  2436. * @returns the dot product (float)
  2437. */
  2438. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2439. /**
  2440. * Returns a new Vector2 equal to the normalized given vector
  2441. * @param vector defines the vector to normalize
  2442. * @returns a new Vector2
  2443. */
  2444. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2445. /**
  2446. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2447. * @param left defines 1st vector
  2448. * @param right defines 2nd vector
  2449. * @returns a new Vector2
  2450. */
  2451. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2452. /**
  2453. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2454. * @param left defines 1st vector
  2455. * @param right defines 2nd vector
  2456. * @returns a new Vector2
  2457. */
  2458. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2459. /**
  2460. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2461. * @param vector defines the vector to transform
  2462. * @param transformation defines the matrix to apply
  2463. * @returns a new Vector2
  2464. */
  2465. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2466. /**
  2467. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2468. * @param vector defines the vector to transform
  2469. * @param transformation defines the matrix to apply
  2470. * @param result defines the target vector
  2471. */
  2472. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2473. /**
  2474. * Determines if a given vector is included in a triangle
  2475. * @param p defines the vector to test
  2476. * @param p0 defines 1st triangle point
  2477. * @param p1 defines 2nd triangle point
  2478. * @param p2 defines 3rd triangle point
  2479. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2480. */
  2481. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2482. /**
  2483. * Gets the distance between the vectors "value1" and "value2"
  2484. * @param value1 defines first vector
  2485. * @param value2 defines second vector
  2486. * @returns the distance between vectors
  2487. */
  2488. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2489. /**
  2490. * Returns the squared distance between the vectors "value1" and "value2"
  2491. * @param value1 defines first vector
  2492. * @param value2 defines second vector
  2493. * @returns the squared distance between vectors
  2494. */
  2495. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2496. /**
  2497. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2498. * @param value1 defines first vector
  2499. * @param value2 defines second vector
  2500. * @returns a new Vector2
  2501. */
  2502. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2503. /**
  2504. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2505. * @param p defines the middle point
  2506. * @param segA defines one point of the segment
  2507. * @param segB defines the other point of the segment
  2508. * @returns the shortest distance
  2509. */
  2510. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2511. }
  2512. /**
  2513. * Class used to store (x,y,z) vector representation
  2514. * A Vector3 is the main object used in 3D geometry
  2515. * It can represent etiher the coordinates of a point the space, either a direction
  2516. * Reminder: js uses a left handed forward facing system
  2517. */
  2518. export class Vector3 {
  2519. private static _UpReadOnly;
  2520. private static _ZeroReadOnly;
  2521. /** @hidden */
  2522. _x: number;
  2523. /** @hidden */
  2524. _y: number;
  2525. /** @hidden */
  2526. _z: number;
  2527. /** @hidden */
  2528. _isDirty: boolean;
  2529. /** Gets or sets the x coordinate */
  2530. get x(): number;
  2531. set x(value: number);
  2532. /** Gets or sets the y coordinate */
  2533. get y(): number;
  2534. set y(value: number);
  2535. /** Gets or sets the z coordinate */
  2536. get z(): number;
  2537. set z(value: number);
  2538. /**
  2539. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2540. * @param x defines the first coordinates (on X axis)
  2541. * @param y defines the second coordinates (on Y axis)
  2542. * @param z defines the third coordinates (on Z axis)
  2543. */
  2544. constructor(x?: number, y?: number, z?: number);
  2545. /**
  2546. * Creates a string representation of the Vector3
  2547. * @returns a string with the Vector3 coordinates.
  2548. */
  2549. toString(): string;
  2550. /**
  2551. * Gets the class name
  2552. * @returns the string "Vector3"
  2553. */
  2554. getClassName(): string;
  2555. /**
  2556. * Creates the Vector3 hash code
  2557. * @returns a number which tends to be unique between Vector3 instances
  2558. */
  2559. getHashCode(): number;
  2560. /**
  2561. * Creates an array containing three elements : the coordinates of the Vector3
  2562. * @returns a new array of numbers
  2563. */
  2564. asArray(): number[];
  2565. /**
  2566. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2567. * @param array defines the destination array
  2568. * @param index defines the offset in the destination array
  2569. * @returns the current Vector3
  2570. */
  2571. toArray(array: FloatArray, index?: number): Vector3;
  2572. /**
  2573. * Update the current vector from an array
  2574. * @param array defines the destination array
  2575. * @param index defines the offset in the destination array
  2576. * @returns the current Vector3
  2577. */
  2578. fromArray(array: FloatArray, index?: number): Vector3;
  2579. /**
  2580. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2581. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2582. */
  2583. toQuaternion(): Quaternion;
  2584. /**
  2585. * Adds the given vector to the current Vector3
  2586. * @param otherVector defines the second operand
  2587. * @returns the current updated Vector3
  2588. */
  2589. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Adds the given coordinates to the current Vector3
  2592. * @param x defines the x coordinate of the operand
  2593. * @param y defines the y coordinate of the operand
  2594. * @param z defines the z coordinate of the operand
  2595. * @returns the current updated Vector3
  2596. */
  2597. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2598. /**
  2599. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2600. * @param otherVector defines the second operand
  2601. * @returns the resulting Vector3
  2602. */
  2603. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2604. /**
  2605. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2606. * @param otherVector defines the second operand
  2607. * @param result defines the Vector3 object where to store the result
  2608. * @returns the current Vector3
  2609. */
  2610. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2611. /**
  2612. * Subtract the given vector from the current Vector3
  2613. * @param otherVector defines the second operand
  2614. * @returns the current updated Vector3
  2615. */
  2616. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2617. /**
  2618. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2619. * @param otherVector defines the second operand
  2620. * @returns the resulting Vector3
  2621. */
  2622. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2623. /**
  2624. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2625. * @param otherVector defines the second operand
  2626. * @param result defines the Vector3 object where to store the result
  2627. * @returns the current Vector3
  2628. */
  2629. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2630. /**
  2631. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2632. * @param x defines the x coordinate of the operand
  2633. * @param y defines the y coordinate of the operand
  2634. * @param z defines the z coordinate of the operand
  2635. * @returns the resulting Vector3
  2636. */
  2637. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2638. /**
  2639. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2640. * @param x defines the x coordinate of the operand
  2641. * @param y defines the y coordinate of the operand
  2642. * @param z defines the z coordinate of the operand
  2643. * @param result defines the Vector3 object where to store the result
  2644. * @returns the current Vector3
  2645. */
  2646. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2647. /**
  2648. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2649. * @returns a new Vector3
  2650. */
  2651. negate(): Vector3;
  2652. /**
  2653. * Negate this vector in place
  2654. * @returns this
  2655. */
  2656. negateInPlace(): Vector3;
  2657. /**
  2658. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2659. * @param result defines the Vector3 object where to store the result
  2660. * @returns the current Vector3
  2661. */
  2662. negateToRef(result: Vector3): Vector3;
  2663. /**
  2664. * Multiplies the Vector3 coordinates by the float "scale"
  2665. * @param scale defines the multiplier factor
  2666. * @returns the current updated Vector3
  2667. */
  2668. scaleInPlace(scale: number): Vector3;
  2669. /**
  2670. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2671. * @param scale defines the multiplier factor
  2672. * @returns a new Vector3
  2673. */
  2674. scale(scale: number): Vector3;
  2675. /**
  2676. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2677. * @param scale defines the multiplier factor
  2678. * @param result defines the Vector3 object where to store the result
  2679. * @returns the current Vector3
  2680. */
  2681. scaleToRef(scale: number, result: Vector3): Vector3;
  2682. /**
  2683. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2684. * @param scale defines the scale factor
  2685. * @param result defines the Vector3 object where to store the result
  2686. * @returns the unmodified current Vector3
  2687. */
  2688. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2689. /**
  2690. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2691. * @param origin defines the origin of the projection ray
  2692. * @param plane defines the plane to project to
  2693. * @returns the projected vector3
  2694. */
  2695. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2696. /**
  2697. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2698. * @param origin defines the origin of the projection ray
  2699. * @param plane defines the plane to project to
  2700. * @param result defines the Vector3 where to store the result
  2701. */
  2702. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2703. /**
  2704. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2705. * @param otherVector defines the second operand
  2706. * @returns true if both vectors are equals
  2707. */
  2708. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2709. /**
  2710. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2711. * @param otherVector defines the second operand
  2712. * @param epsilon defines the minimal distance to define values as equals
  2713. * @returns true if both vectors are distant less than epsilon
  2714. */
  2715. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2716. /**
  2717. * Returns true if the current Vector3 coordinates equals the given floats
  2718. * @param x defines the x coordinate of the operand
  2719. * @param y defines the y coordinate of the operand
  2720. * @param z defines the z coordinate of the operand
  2721. * @returns true if both vectors are equals
  2722. */
  2723. equalsToFloats(x: number, y: number, z: number): boolean;
  2724. /**
  2725. * Multiplies the current Vector3 coordinates by the given ones
  2726. * @param otherVector defines the second operand
  2727. * @returns the current updated Vector3
  2728. */
  2729. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2730. /**
  2731. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2732. * @param otherVector defines the second operand
  2733. * @returns the new Vector3
  2734. */
  2735. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2736. /**
  2737. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2738. * @param otherVector defines the second operand
  2739. * @param result defines the Vector3 object where to store the result
  2740. * @returns the current Vector3
  2741. */
  2742. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2743. /**
  2744. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2745. * @param x defines the x coordinate of the operand
  2746. * @param y defines the y coordinate of the operand
  2747. * @param z defines the z coordinate of the operand
  2748. * @returns the new Vector3
  2749. */
  2750. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2751. /**
  2752. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2753. * @param otherVector defines the second operand
  2754. * @returns the new Vector3
  2755. */
  2756. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2757. /**
  2758. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2759. * @param otherVector defines the second operand
  2760. * @param result defines the Vector3 object where to store the result
  2761. * @returns the current Vector3
  2762. */
  2763. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2764. /**
  2765. * Divides the current Vector3 coordinates by the given ones.
  2766. * @param otherVector defines the second operand
  2767. * @returns the current updated Vector3
  2768. */
  2769. divideInPlace(otherVector: Vector3): Vector3;
  2770. /**
  2771. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2772. * @param other defines the second operand
  2773. * @returns the current updated Vector3
  2774. */
  2775. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2776. /**
  2777. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2778. * @param other defines the second operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2782. /**
  2783. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2784. * @param x defines the x coordinate of the operand
  2785. * @param y defines the y coordinate of the operand
  2786. * @param z defines the z coordinate of the operand
  2787. * @returns the current updated Vector3
  2788. */
  2789. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2790. /**
  2791. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2792. * @param x defines the x coordinate of the operand
  2793. * @param y defines the y coordinate of the operand
  2794. * @param z defines the z coordinate of the operand
  2795. * @returns the current updated Vector3
  2796. */
  2797. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2798. /**
  2799. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2800. * Check if is non uniform within a certain amount of decimal places to account for this
  2801. * @param epsilon the amount the values can differ
  2802. * @returns if the the vector is non uniform to a certain number of decimal places
  2803. */
  2804. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2805. /**
  2806. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2807. */
  2808. get isNonUniform(): boolean;
  2809. /**
  2810. * Gets a new Vector3 from current Vector3 floored values
  2811. * @returns a new Vector3
  2812. */
  2813. floor(): Vector3;
  2814. /**
  2815. * Gets a new Vector3 from current Vector3 floored values
  2816. * @returns a new Vector3
  2817. */
  2818. fract(): Vector3;
  2819. /**
  2820. * Gets the length of the Vector3
  2821. * @returns the length of the Vector3
  2822. */
  2823. length(): number;
  2824. /**
  2825. * Gets the squared length of the Vector3
  2826. * @returns squared length of the Vector3
  2827. */
  2828. lengthSquared(): number;
  2829. /**
  2830. * Normalize the current Vector3.
  2831. * Please note that this is an in place operation.
  2832. * @returns the current updated Vector3
  2833. */
  2834. normalize(): Vector3;
  2835. /**
  2836. * Reorders the x y z properties of the vector in place
  2837. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2838. * @returns the current updated vector
  2839. */
  2840. reorderInPlace(order: string): this;
  2841. /**
  2842. * Rotates the vector around 0,0,0 by a quaternion
  2843. * @param quaternion the rotation quaternion
  2844. * @param result vector to store the result
  2845. * @returns the resulting vector
  2846. */
  2847. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2848. /**
  2849. * Rotates a vector around a given point
  2850. * @param quaternion the rotation quaternion
  2851. * @param point the point to rotate around
  2852. * @param result vector to store the result
  2853. * @returns the resulting vector
  2854. */
  2855. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2856. /**
  2857. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2858. * The cross product is then orthogonal to both current and "other"
  2859. * @param other defines the right operand
  2860. * @returns the cross product
  2861. */
  2862. cross(other: Vector3): Vector3;
  2863. /**
  2864. * Normalize the current Vector3 with the given input length.
  2865. * Please note that this is an in place operation.
  2866. * @param len the length of the vector
  2867. * @returns the current updated Vector3
  2868. */
  2869. normalizeFromLength(len: number): Vector3;
  2870. /**
  2871. * Normalize the current Vector3 to a new vector
  2872. * @returns the new Vector3
  2873. */
  2874. normalizeToNew(): Vector3;
  2875. /**
  2876. * Normalize the current Vector3 to the reference
  2877. * @param reference define the Vector3 to update
  2878. * @returns the updated Vector3
  2879. */
  2880. normalizeToRef(reference: Vector3): Vector3;
  2881. /**
  2882. * Creates a new Vector3 copied from the current Vector3
  2883. * @returns the new Vector3
  2884. */
  2885. clone(): Vector3;
  2886. /**
  2887. * Copies the given vector coordinates to the current Vector3 ones
  2888. * @param source defines the source Vector3
  2889. * @returns the current updated Vector3
  2890. */
  2891. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2892. /**
  2893. * Copies the given floats to the current Vector3 coordinates
  2894. * @param x defines the x coordinate of the operand
  2895. * @param y defines the y coordinate of the operand
  2896. * @param z defines the z coordinate of the operand
  2897. * @returns the current updated Vector3
  2898. */
  2899. copyFromFloats(x: number, y: number, z: number): Vector3;
  2900. /**
  2901. * Copies the given floats to the current Vector3 coordinates
  2902. * @param x defines the x coordinate of the operand
  2903. * @param y defines the y coordinate of the operand
  2904. * @param z defines the z coordinate of the operand
  2905. * @returns the current updated Vector3
  2906. */
  2907. set(x: number, y: number, z: number): Vector3;
  2908. /**
  2909. * Copies the given float to the current Vector3 coordinates
  2910. * @param v defines the x, y and z coordinates of the operand
  2911. * @returns the current updated Vector3
  2912. */
  2913. setAll(v: number): Vector3;
  2914. /**
  2915. * Get the clip factor between two vectors
  2916. * @param vector0 defines the first operand
  2917. * @param vector1 defines the second operand
  2918. * @param axis defines the axis to use
  2919. * @param size defines the size along the axis
  2920. * @returns the clip factor
  2921. */
  2922. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2923. /**
  2924. * Get angle between two vectors
  2925. * @param vector0 angle between vector0 and vector1
  2926. * @param vector1 angle between vector0 and vector1
  2927. * @param normal direction of the normal
  2928. * @return the angle between vector0 and vector1
  2929. */
  2930. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2931. /**
  2932. * Returns a new Vector3 set from the index "offset" of the given array
  2933. * @param array defines the source array
  2934. * @param offset defines the offset in the source array
  2935. * @returns the new Vector3
  2936. */
  2937. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2938. /**
  2939. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2940. * @param array defines the source array
  2941. * @param offset defines the offset in the source array
  2942. * @returns the new Vector3
  2943. * @deprecated Please use FromArray instead.
  2944. */
  2945. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2946. /**
  2947. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2948. * @param array defines the source array
  2949. * @param offset defines the offset in the source array
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2953. /**
  2954. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2955. * @param array defines the source array
  2956. * @param offset defines the offset in the source array
  2957. * @param result defines the Vector3 where to store the result
  2958. * @deprecated Please use FromArrayToRef instead.
  2959. */
  2960. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2961. /**
  2962. * Sets the given vector "result" with the given floats.
  2963. * @param x defines the x coordinate of the source
  2964. * @param y defines the y coordinate of the source
  2965. * @param z defines the z coordinate of the source
  2966. * @param result defines the Vector3 where to store the result
  2967. */
  2968. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2969. /**
  2970. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2971. * @returns a new empty Vector3
  2972. */
  2973. static Zero(): Vector3;
  2974. /**
  2975. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2976. * @returns a new unit Vector3
  2977. */
  2978. static One(): Vector3;
  2979. /**
  2980. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2981. * @returns a new up Vector3
  2982. */
  2983. static Up(): Vector3;
  2984. /**
  2985. * Gets a up Vector3 that must not be updated
  2986. */
  2987. static get UpReadOnly(): DeepImmutable<Vector3>;
  2988. /**
  2989. * Gets a zero Vector3 that must not be updated
  2990. */
  2991. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2992. /**
  2993. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2994. * @returns a new down Vector3
  2995. */
  2996. static Down(): Vector3;
  2997. /**
  2998. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2999. * @param rightHandedSystem is the scene right-handed (negative z)
  3000. * @returns a new forward Vector3
  3001. */
  3002. static Forward(rightHandedSystem?: boolean): Vector3;
  3003. /**
  3004. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3005. * @param rightHandedSystem is the scene right-handed (negative-z)
  3006. * @returns a new forward Vector3
  3007. */
  3008. static Backward(rightHandedSystem?: boolean): Vector3;
  3009. /**
  3010. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3011. * @returns a new right Vector3
  3012. */
  3013. static Right(): Vector3;
  3014. /**
  3015. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3016. * @returns a new left Vector3
  3017. */
  3018. static Left(): Vector3;
  3019. /**
  3020. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3021. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3022. * @param vector defines the Vector3 to transform
  3023. * @param transformation defines the transformation matrix
  3024. * @returns the transformed Vector3
  3025. */
  3026. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3027. /**
  3028. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3029. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3030. * @param vector defines the Vector3 to transform
  3031. * @param transformation defines the transformation matrix
  3032. * @param result defines the Vector3 where to store the result
  3033. */
  3034. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3035. /**
  3036. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3037. * This method computes tranformed coordinates only, not transformed direction vectors
  3038. * @param x define the x coordinate of the source vector
  3039. * @param y define the y coordinate of the source vector
  3040. * @param z define the z coordinate of the source vector
  3041. * @param transformation defines the transformation matrix
  3042. * @param result defines the Vector3 where to store the result
  3043. */
  3044. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3045. /**
  3046. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3047. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3048. * @param vector defines the Vector3 to transform
  3049. * @param transformation defines the transformation matrix
  3050. * @returns the new Vector3
  3051. */
  3052. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3053. /**
  3054. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3055. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3056. * @param vector defines the Vector3 to transform
  3057. * @param transformation defines the transformation matrix
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3061. /**
  3062. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3063. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3064. * @param x define the x coordinate of the source vector
  3065. * @param y define the y coordinate of the source vector
  3066. * @param z define the z coordinate of the source vector
  3067. * @param transformation defines the transformation matrix
  3068. * @param result defines the Vector3 where to store the result
  3069. */
  3070. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3071. /**
  3072. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3073. * @param value1 defines the first control point
  3074. * @param value2 defines the second control point
  3075. * @param value3 defines the third control point
  3076. * @param value4 defines the fourth control point
  3077. * @param amount defines the amount on the spline to use
  3078. * @returns the new Vector3
  3079. */
  3080. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3081. /**
  3082. * 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"
  3083. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3084. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3085. * @param value defines the current value
  3086. * @param min defines the lower range value
  3087. * @param max defines the upper range value
  3088. * @returns the new Vector3
  3089. */
  3090. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3091. /**
  3092. * 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"
  3093. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3094. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3095. * @param value defines the current value
  3096. * @param min defines the lower range value
  3097. * @param max defines the upper range value
  3098. * @param result defines the Vector3 where to store the result
  3099. */
  3100. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3101. /**
  3102. * Checks if a given vector is inside a specific range
  3103. * @param v defines the vector to test
  3104. * @param min defines the minimum range
  3105. * @param max defines the maximum range
  3106. */
  3107. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3108. /**
  3109. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3110. * @param value1 defines the first control point
  3111. * @param tangent1 defines the first tangent vector
  3112. * @param value2 defines the second control point
  3113. * @param tangent2 defines the second tangent vector
  3114. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3115. * @returns the new Vector3
  3116. */
  3117. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3118. /**
  3119. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3120. * @param start defines the start value
  3121. * @param end defines the end value
  3122. * @param amount max defines amount between both (between 0 and 1)
  3123. * @returns the new Vector3
  3124. */
  3125. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3126. /**
  3127. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3128. * @param start defines the start value
  3129. * @param end defines the end value
  3130. * @param amount max defines amount between both (between 0 and 1)
  3131. * @param result defines the Vector3 where to store the result
  3132. */
  3133. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3134. /**
  3135. * Returns the dot product (float) between the vectors "left" and "right"
  3136. * @param left defines the left operand
  3137. * @param right defines the right operand
  3138. * @returns the dot product
  3139. */
  3140. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3141. /**
  3142. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3143. * The cross product is then orthogonal to both "left" and "right"
  3144. * @param left defines the left operand
  3145. * @param right defines the right operand
  3146. * @returns the cross product
  3147. */
  3148. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3149. /**
  3150. * Sets the given vector "result" with the cross product of "left" and "right"
  3151. * The cross product is then orthogonal to both "left" and "right"
  3152. * @param left defines the left operand
  3153. * @param right defines the right operand
  3154. * @param result defines the Vector3 where to store the result
  3155. */
  3156. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3157. /**
  3158. * Returns a new Vector3 as the normalization of the given vector
  3159. * @param vector defines the Vector3 to normalize
  3160. * @returns the new Vector3
  3161. */
  3162. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * Sets the given vector "result" with the normalization of the given first vector
  3165. * @param vector defines the Vector3 to normalize
  3166. * @param result defines the Vector3 where to store the result
  3167. */
  3168. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3169. /**
  3170. * Project a Vector3 onto screen space
  3171. * @param vector defines the Vector3 to project
  3172. * @param world defines the world matrix to use
  3173. * @param transform defines the transform (view x projection) matrix to use
  3174. * @param viewport defines the screen viewport to use
  3175. * @returns the new Vector3
  3176. */
  3177. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3178. /**
  3179. * Project a Vector3 onto screen space to reference
  3180. * @param vector defines the Vector3 to project
  3181. * @param world defines the world matrix to use
  3182. * @param transform defines the transform (view x projection) matrix to use
  3183. * @param viewport defines the screen viewport to use
  3184. * @param result the vector in which the screen space will be stored
  3185. * @returns the new Vector3
  3186. */
  3187. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3188. /** @hidden */
  3189. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3190. /**
  3191. * Unproject from screen space to object space
  3192. * @param source defines the screen space Vector3 to use
  3193. * @param viewportWidth defines the current width of the viewport
  3194. * @param viewportHeight defines the current height of the viewport
  3195. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3196. * @param transform defines the transform (view x projection) matrix to use
  3197. * @returns the new Vector3
  3198. */
  3199. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3200. /**
  3201. * Unproject from screen space to object space
  3202. * @param source defines the screen space Vector3 to use
  3203. * @param viewportWidth defines the current width of the viewport
  3204. * @param viewportHeight defines the current height of the viewport
  3205. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3206. * @param view defines the view matrix to use
  3207. * @param projection defines the projection matrix to use
  3208. * @returns the new Vector3
  3209. */
  3210. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3211. /**
  3212. * Unproject from screen space to object space
  3213. * @param source defines the screen space Vector3 to use
  3214. * @param viewportWidth defines the current width of the viewport
  3215. * @param viewportHeight defines the current height of the viewport
  3216. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3217. * @param view defines the view matrix to use
  3218. * @param projection defines the projection matrix to use
  3219. * @param result defines the Vector3 where to store the result
  3220. */
  3221. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3222. /**
  3223. * Unproject from screen space to object space
  3224. * @param sourceX defines the screen space x coordinate to use
  3225. * @param sourceY defines the screen space y coordinate to use
  3226. * @param sourceZ defines the screen space z coordinate to use
  3227. * @param viewportWidth defines the current width of the viewport
  3228. * @param viewportHeight defines the current height of the viewport
  3229. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3230. * @param view defines the view matrix to use
  3231. * @param projection defines the projection matrix to use
  3232. * @param result defines the Vector3 where to store the result
  3233. */
  3234. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3235. /**
  3236. * Gets the minimal coordinate values between two Vector3
  3237. * @param left defines the first operand
  3238. * @param right defines the second operand
  3239. * @returns the new Vector3
  3240. */
  3241. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3242. /**
  3243. * Gets the maximal coordinate values between two Vector3
  3244. * @param left defines the first operand
  3245. * @param right defines the second operand
  3246. * @returns the new Vector3
  3247. */
  3248. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3249. /**
  3250. * Returns the distance between the vectors "value1" and "value2"
  3251. * @param value1 defines the first operand
  3252. * @param value2 defines the second operand
  3253. * @returns the distance
  3254. */
  3255. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3256. /**
  3257. * Returns the squared distance between the vectors "value1" and "value2"
  3258. * @param value1 defines the first operand
  3259. * @param value2 defines the second operand
  3260. * @returns the squared distance
  3261. */
  3262. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3263. /**
  3264. * Returns a new Vector3 located at the center between "value1" and "value2"
  3265. * @param value1 defines the first operand
  3266. * @param value2 defines the second operand
  3267. * @returns the new Vector3
  3268. */
  3269. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3270. /**
  3271. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3272. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3273. * to something in order to rotate it from its local system to the given target system
  3274. * Note: axis1, axis2 and axis3 are normalized during this operation
  3275. * @param axis1 defines the first axis
  3276. * @param axis2 defines the second axis
  3277. * @param axis3 defines the third axis
  3278. * @returns a new Vector3
  3279. */
  3280. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3281. /**
  3282. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3283. * @param axis1 defines the first axis
  3284. * @param axis2 defines the second axis
  3285. * @param axis3 defines the third axis
  3286. * @param ref defines the Vector3 where to store the result
  3287. */
  3288. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3289. }
  3290. /**
  3291. * Vector4 class created for EulerAngle class conversion to Quaternion
  3292. */
  3293. export class Vector4 {
  3294. /** x value of the vector */
  3295. x: number;
  3296. /** y value of the vector */
  3297. y: number;
  3298. /** z value of the vector */
  3299. z: number;
  3300. /** w value of the vector */
  3301. w: number;
  3302. /**
  3303. * Creates a Vector4 object from the given floats.
  3304. * @param x x value of the vector
  3305. * @param y y value of the vector
  3306. * @param z z value of the vector
  3307. * @param w w value of the vector
  3308. */
  3309. constructor(
  3310. /** x value of the vector */
  3311. x: number,
  3312. /** y value of the vector */
  3313. y: number,
  3314. /** z value of the vector */
  3315. z: number,
  3316. /** w value of the vector */
  3317. w: number);
  3318. /**
  3319. * Returns the string with the Vector4 coordinates.
  3320. * @returns a string containing all the vector values
  3321. */
  3322. toString(): string;
  3323. /**
  3324. * Returns the string "Vector4".
  3325. * @returns "Vector4"
  3326. */
  3327. getClassName(): string;
  3328. /**
  3329. * Returns the Vector4 hash code.
  3330. * @returns a unique hash code
  3331. */
  3332. getHashCode(): number;
  3333. /**
  3334. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3335. * @returns the resulting array
  3336. */
  3337. asArray(): number[];
  3338. /**
  3339. * Populates the given array from the given index with the Vector4 coordinates.
  3340. * @param array array to populate
  3341. * @param index index of the array to start at (default: 0)
  3342. * @returns the Vector4.
  3343. */
  3344. toArray(array: FloatArray, index?: number): Vector4;
  3345. /**
  3346. * Update the current vector from an array
  3347. * @param array defines the destination array
  3348. * @param index defines the offset in the destination array
  3349. * @returns the current Vector3
  3350. */
  3351. fromArray(array: FloatArray, index?: number): Vector4;
  3352. /**
  3353. * Adds the given vector to the current Vector4.
  3354. * @param otherVector the vector to add
  3355. * @returns the updated Vector4.
  3356. */
  3357. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3358. /**
  3359. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3360. * @param otherVector the vector to add
  3361. * @returns the resulting vector
  3362. */
  3363. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3364. /**
  3365. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3366. * @param otherVector the vector to add
  3367. * @param result the vector to store the result
  3368. * @returns the current Vector4.
  3369. */
  3370. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3371. /**
  3372. * Subtract in place the given vector from the current Vector4.
  3373. * @param otherVector the vector to subtract
  3374. * @returns the updated Vector4.
  3375. */
  3376. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3377. /**
  3378. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3379. * @param otherVector the vector to add
  3380. * @returns the new vector with the result
  3381. */
  3382. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3383. /**
  3384. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3385. * @param otherVector the vector to subtract
  3386. * @param result the vector to store the result
  3387. * @returns the current Vector4.
  3388. */
  3389. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3390. /**
  3391. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3392. */
  3393. /**
  3394. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3395. * @param x value to subtract
  3396. * @param y value to subtract
  3397. * @param z value to subtract
  3398. * @param w value to subtract
  3399. * @returns new vector containing the result
  3400. */
  3401. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3402. /**
  3403. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3404. * @param x value to subtract
  3405. * @param y value to subtract
  3406. * @param z value to subtract
  3407. * @param w value to subtract
  3408. * @param result the vector to store the result in
  3409. * @returns the current Vector4.
  3410. */
  3411. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3412. /**
  3413. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3414. * @returns a new vector with the negated values
  3415. */
  3416. negate(): Vector4;
  3417. /**
  3418. * Negate this vector in place
  3419. * @returns this
  3420. */
  3421. negateInPlace(): Vector4;
  3422. /**
  3423. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3424. * @param result defines the Vector3 object where to store the result
  3425. * @returns the current Vector4
  3426. */
  3427. negateToRef(result: Vector4): Vector4;
  3428. /**
  3429. * Multiplies the current Vector4 coordinates by scale (float).
  3430. * @param scale the number to scale with
  3431. * @returns the updated Vector4.
  3432. */
  3433. scaleInPlace(scale: number): Vector4;
  3434. /**
  3435. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3436. * @param scale the number to scale with
  3437. * @returns a new vector with the result
  3438. */
  3439. scale(scale: number): Vector4;
  3440. /**
  3441. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3442. * @param scale the number to scale with
  3443. * @param result a vector to store the result in
  3444. * @returns the current Vector4.
  3445. */
  3446. scaleToRef(scale: number, result: Vector4): Vector4;
  3447. /**
  3448. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3449. * @param scale defines the scale factor
  3450. * @param result defines the Vector4 object where to store the result
  3451. * @returns the unmodified current Vector4
  3452. */
  3453. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3454. /**
  3455. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3456. * @param otherVector the vector to compare against
  3457. * @returns true if they are equal
  3458. */
  3459. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3460. /**
  3461. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3462. * @param otherVector vector to compare against
  3463. * @param epsilon (Default: very small number)
  3464. * @returns true if they are equal
  3465. */
  3466. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3467. /**
  3468. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3469. * @param x x value to compare against
  3470. * @param y y value to compare against
  3471. * @param z z value to compare against
  3472. * @param w w value to compare against
  3473. * @returns true if equal
  3474. */
  3475. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3476. /**
  3477. * Multiplies in place the current Vector4 by the given one.
  3478. * @param otherVector vector to multiple with
  3479. * @returns the updated Vector4.
  3480. */
  3481. multiplyInPlace(otherVector: Vector4): Vector4;
  3482. /**
  3483. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3484. * @param otherVector vector to multiple with
  3485. * @returns resulting new vector
  3486. */
  3487. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3488. /**
  3489. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3490. * @param otherVector vector to multiple with
  3491. * @param result vector to store the result
  3492. * @returns the current Vector4.
  3493. */
  3494. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3495. /**
  3496. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3497. * @param x x value multiply with
  3498. * @param y y value multiply with
  3499. * @param z z value multiply with
  3500. * @param w w value multiply with
  3501. * @returns resulting new vector
  3502. */
  3503. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3504. /**
  3505. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3506. * @param otherVector vector to devide with
  3507. * @returns resulting new vector
  3508. */
  3509. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3510. /**
  3511. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3512. * @param otherVector vector to devide with
  3513. * @param result vector to store the result
  3514. * @returns the current Vector4.
  3515. */
  3516. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3517. /**
  3518. * Divides the current Vector3 coordinates by the given ones.
  3519. * @param otherVector vector to devide with
  3520. * @returns the updated Vector3.
  3521. */
  3522. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3523. /**
  3524. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3525. * @param other defines the second operand
  3526. * @returns the current updated Vector4
  3527. */
  3528. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3529. /**
  3530. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3531. * @param other defines the second operand
  3532. * @returns the current updated Vector4
  3533. */
  3534. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3535. /**
  3536. * Gets a new Vector4 from current Vector4 floored values
  3537. * @returns a new Vector4
  3538. */
  3539. floor(): Vector4;
  3540. /**
  3541. * Gets a new Vector4 from current Vector3 floored values
  3542. * @returns a new Vector4
  3543. */
  3544. fract(): Vector4;
  3545. /**
  3546. * Returns the Vector4 length (float).
  3547. * @returns the length
  3548. */
  3549. length(): number;
  3550. /**
  3551. * Returns the Vector4 squared length (float).
  3552. * @returns the length squared
  3553. */
  3554. lengthSquared(): number;
  3555. /**
  3556. * Normalizes in place the Vector4.
  3557. * @returns the updated Vector4.
  3558. */
  3559. normalize(): Vector4;
  3560. /**
  3561. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3562. * @returns this converted to a new vector3
  3563. */
  3564. toVector3(): Vector3;
  3565. /**
  3566. * Returns a new Vector4 copied from the current one.
  3567. * @returns the new cloned vector
  3568. */
  3569. clone(): Vector4;
  3570. /**
  3571. * Updates the current Vector4 with the given one coordinates.
  3572. * @param source the source vector to copy from
  3573. * @returns the updated Vector4.
  3574. */
  3575. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3576. /**
  3577. * Updates the current Vector4 coordinates with the given floats.
  3578. * @param x float to copy from
  3579. * @param y float to copy from
  3580. * @param z float to copy from
  3581. * @param w float to copy from
  3582. * @returns the updated Vector4.
  3583. */
  3584. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3585. /**
  3586. * Updates the current Vector4 coordinates with the given floats.
  3587. * @param x float to set from
  3588. * @param y float to set from
  3589. * @param z float to set from
  3590. * @param w float to set from
  3591. * @returns the updated Vector4.
  3592. */
  3593. set(x: number, y: number, z: number, w: number): Vector4;
  3594. /**
  3595. * Copies the given float to the current Vector3 coordinates
  3596. * @param v defines the x, y, z and w coordinates of the operand
  3597. * @returns the current updated Vector3
  3598. */
  3599. setAll(v: number): Vector4;
  3600. /**
  3601. * Returns a new Vector4 set from the starting index of the given array.
  3602. * @param array the array to pull values from
  3603. * @param offset the offset into the array to start at
  3604. * @returns the new vector
  3605. */
  3606. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3607. /**
  3608. * Updates the given vector "result" from the starting index of the given array.
  3609. * @param array the array to pull values from
  3610. * @param offset the offset into the array to start at
  3611. * @param result the vector to store the result in
  3612. */
  3613. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3614. /**
  3615. * Updates the given vector "result" from the starting index of the given Float32Array.
  3616. * @param array the array to pull values from
  3617. * @param offset the offset into the array to start at
  3618. * @param result the vector to store the result in
  3619. */
  3620. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3621. /**
  3622. * Updates the given vector "result" coordinates from the given floats.
  3623. * @param x float to set from
  3624. * @param y float to set from
  3625. * @param z float to set from
  3626. * @param w float to set from
  3627. * @param result the vector to the floats in
  3628. */
  3629. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3630. /**
  3631. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3632. * @returns the new vector
  3633. */
  3634. static Zero(): Vector4;
  3635. /**
  3636. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3637. * @returns the new vector
  3638. */
  3639. static One(): Vector4;
  3640. /**
  3641. * Returns a new normalized Vector4 from the given one.
  3642. * @param vector the vector to normalize
  3643. * @returns the vector
  3644. */
  3645. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3646. /**
  3647. * Updates the given vector "result" from the normalization of the given one.
  3648. * @param vector the vector to normalize
  3649. * @param result the vector to store the result in
  3650. */
  3651. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3652. /**
  3653. * Returns a vector with the minimum values from the left and right vectors
  3654. * @param left left vector to minimize
  3655. * @param right right vector to minimize
  3656. * @returns a new vector with the minimum of the left and right vector values
  3657. */
  3658. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3659. /**
  3660. * Returns a vector with the maximum values from the left and right vectors
  3661. * @param left left vector to maximize
  3662. * @param right right vector to maximize
  3663. * @returns a new vector with the maximum of the left and right vector values
  3664. */
  3665. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3666. /**
  3667. * Returns the distance (float) between the vectors "value1" and "value2".
  3668. * @param value1 value to calulate the distance between
  3669. * @param value2 value to calulate the distance between
  3670. * @return the distance between the two vectors
  3671. */
  3672. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3673. /**
  3674. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3675. * @param value1 value to calulate the distance between
  3676. * @param value2 value to calulate the distance between
  3677. * @return the distance between the two vectors squared
  3678. */
  3679. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3680. /**
  3681. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3682. * @param value1 value to calulate the center between
  3683. * @param value2 value to calulate the center between
  3684. * @return the center between the two vectors
  3685. */
  3686. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3687. /**
  3688. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3689. * This methods computes transformed normalized direction vectors only.
  3690. * @param vector the vector to transform
  3691. * @param transformation the transformation matrix to apply
  3692. * @returns the new vector
  3693. */
  3694. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3695. /**
  3696. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3697. * This methods computes transformed normalized direction vectors only.
  3698. * @param vector the vector to transform
  3699. * @param transformation the transformation matrix to apply
  3700. * @param result the vector to store the result in
  3701. */
  3702. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3703. /**
  3704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3705. * This methods computes transformed normalized direction vectors only.
  3706. * @param x value to transform
  3707. * @param y value to transform
  3708. * @param z value to transform
  3709. * @param w value to transform
  3710. * @param transformation the transformation matrix to apply
  3711. * @param result the vector to store the results in
  3712. */
  3713. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3714. /**
  3715. * Creates a new Vector4 from a Vector3
  3716. * @param source defines the source data
  3717. * @param w defines the 4th component (default is 0)
  3718. * @returns a new Vector4
  3719. */
  3720. static FromVector3(source: Vector3, w?: number): Vector4;
  3721. }
  3722. /**
  3723. * Class used to store quaternion data
  3724. * @see https://en.wikipedia.org/wiki/Quaternion
  3725. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3726. */
  3727. export class Quaternion {
  3728. /** @hidden */
  3729. _x: number;
  3730. /** @hidden */
  3731. _y: number;
  3732. /** @hidden */
  3733. _z: number;
  3734. /** @hidden */
  3735. _w: number;
  3736. /** @hidden */
  3737. _isDirty: boolean;
  3738. /** Gets or sets the x coordinate */
  3739. get x(): number;
  3740. set x(value: number);
  3741. /** Gets or sets the y coordinate */
  3742. get y(): number;
  3743. set y(value: number);
  3744. /** Gets or sets the z coordinate */
  3745. get z(): number;
  3746. set z(value: number);
  3747. /** Gets or sets the w coordinate */
  3748. get w(): number;
  3749. set w(value: number);
  3750. /**
  3751. * Creates a new Quaternion from the given floats
  3752. * @param x defines the first component (0 by default)
  3753. * @param y defines the second component (0 by default)
  3754. * @param z defines the third component (0 by default)
  3755. * @param w defines the fourth component (1.0 by default)
  3756. */
  3757. constructor(x?: number, y?: number, z?: number, w?: number);
  3758. /**
  3759. * Gets a string representation for the current quaternion
  3760. * @returns a string with the Quaternion coordinates
  3761. */
  3762. toString(): string;
  3763. /**
  3764. * Gets the class name of the quaternion
  3765. * @returns the string "Quaternion"
  3766. */
  3767. getClassName(): string;
  3768. /**
  3769. * Gets a hash code for this quaternion
  3770. * @returns the quaternion hash code
  3771. */
  3772. getHashCode(): number;
  3773. /**
  3774. * Copy the quaternion to an array
  3775. * @returns a new array populated with 4 elements from the quaternion coordinates
  3776. */
  3777. asArray(): number[];
  3778. /**
  3779. * Check if two quaternions are equals
  3780. * @param otherQuaternion defines the second operand
  3781. * @return true if the current quaternion and the given one coordinates are strictly equals
  3782. */
  3783. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3784. /**
  3785. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3786. * @param otherQuaternion defines the other quaternion
  3787. * @param epsilon defines the minimal distance to consider equality
  3788. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3789. */
  3790. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3791. /**
  3792. * Clone the current quaternion
  3793. * @returns a new quaternion copied from the current one
  3794. */
  3795. clone(): Quaternion;
  3796. /**
  3797. * Copy a quaternion to the current one
  3798. * @param other defines the other quaternion
  3799. * @returns the updated current quaternion
  3800. */
  3801. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3802. /**
  3803. * Updates the current quaternion with the given float coordinates
  3804. * @param x defines the x coordinate
  3805. * @param y defines the y coordinate
  3806. * @param z defines the z coordinate
  3807. * @param w defines the w coordinate
  3808. * @returns the updated current quaternion
  3809. */
  3810. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3811. /**
  3812. * Updates the current quaternion from the given float coordinates
  3813. * @param x defines the x coordinate
  3814. * @param y defines the y coordinate
  3815. * @param z defines the z coordinate
  3816. * @param w defines the w coordinate
  3817. * @returns the updated current quaternion
  3818. */
  3819. set(x: number, y: number, z: number, w: number): Quaternion;
  3820. /**
  3821. * Adds two quaternions
  3822. * @param other defines the second operand
  3823. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3824. */
  3825. add(other: DeepImmutable<Quaternion>): Quaternion;
  3826. /**
  3827. * Add a quaternion to the current one
  3828. * @param other defines the quaternion to add
  3829. * @returns the current quaternion
  3830. */
  3831. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3832. /**
  3833. * Subtract two quaternions
  3834. * @param other defines the second operand
  3835. * @returns a new quaternion as the subtraction result of the given one from the current one
  3836. */
  3837. subtract(other: Quaternion): Quaternion;
  3838. /**
  3839. * Multiplies the current quaternion by a scale factor
  3840. * @param value defines the scale factor
  3841. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3842. */
  3843. scale(value: number): Quaternion;
  3844. /**
  3845. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3846. * @param scale defines the scale factor
  3847. * @param result defines the Quaternion object where to store the result
  3848. * @returns the unmodified current quaternion
  3849. */
  3850. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3851. /**
  3852. * Multiplies in place the current quaternion by a scale factor
  3853. * @param value defines the scale factor
  3854. * @returns the current modified quaternion
  3855. */
  3856. scaleInPlace(value: number): Quaternion;
  3857. /**
  3858. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3859. * @param scale defines the scale factor
  3860. * @param result defines the Quaternion object where to store the result
  3861. * @returns the unmodified current quaternion
  3862. */
  3863. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3864. /**
  3865. * Multiplies two quaternions
  3866. * @param q1 defines the second operand
  3867. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3868. */
  3869. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3870. /**
  3871. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3872. * @param q1 defines the second operand
  3873. * @param result defines the target quaternion
  3874. * @returns the current quaternion
  3875. */
  3876. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3877. /**
  3878. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3879. * @param q1 defines the second operand
  3880. * @returns the currentupdated quaternion
  3881. */
  3882. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3883. /**
  3884. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3885. * @param ref defines the target quaternion
  3886. * @returns the current quaternion
  3887. */
  3888. conjugateToRef(ref: Quaternion): Quaternion;
  3889. /**
  3890. * Conjugates in place (1-q) the current quaternion
  3891. * @returns the current updated quaternion
  3892. */
  3893. conjugateInPlace(): Quaternion;
  3894. /**
  3895. * Conjugates in place (1-q) the current quaternion
  3896. * @returns a new quaternion
  3897. */
  3898. conjugate(): Quaternion;
  3899. /**
  3900. * Gets length of current quaternion
  3901. * @returns the quaternion length (float)
  3902. */
  3903. length(): number;
  3904. /**
  3905. * Normalize in place the current quaternion
  3906. * @returns the current updated quaternion
  3907. */
  3908. normalize(): Quaternion;
  3909. /**
  3910. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3911. * @param order is a reserved parameter and is ignored for now
  3912. * @returns a new Vector3 containing the Euler angles
  3913. */
  3914. toEulerAngles(order?: string): Vector3;
  3915. /**
  3916. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3917. * @param result defines the vector which will be filled with the Euler angles
  3918. * @returns the current unchanged quaternion
  3919. */
  3920. toEulerAnglesToRef(result: Vector3): Quaternion;
  3921. /**
  3922. * Updates the given rotation matrix with the current quaternion values
  3923. * @param result defines the target matrix
  3924. * @returns the current unchanged quaternion
  3925. */
  3926. toRotationMatrix(result: Matrix): Quaternion;
  3927. /**
  3928. * Updates the current quaternion from the given rotation matrix values
  3929. * @param matrix defines the source matrix
  3930. * @returns the current updated quaternion
  3931. */
  3932. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3933. /**
  3934. * Creates a new quaternion from a rotation matrix
  3935. * @param matrix defines the source matrix
  3936. * @returns a new quaternion created from the given rotation matrix values
  3937. */
  3938. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3939. /**
  3940. * Updates the given quaternion with the given rotation matrix values
  3941. * @param matrix defines the source matrix
  3942. * @param result defines the target quaternion
  3943. */
  3944. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3945. /**
  3946. * Returns the dot product (float) between the quaternions "left" and "right"
  3947. * @param left defines the left operand
  3948. * @param right defines the right operand
  3949. * @returns the dot product
  3950. */
  3951. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3952. /**
  3953. * Checks if the two quaternions are close to each other
  3954. * @param quat0 defines the first quaternion to check
  3955. * @param quat1 defines the second quaternion to check
  3956. * @returns true if the two quaternions are close to each other
  3957. */
  3958. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3959. /**
  3960. * Creates an empty quaternion
  3961. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3962. */
  3963. static Zero(): Quaternion;
  3964. /**
  3965. * Inverse a given quaternion
  3966. * @param q defines the source quaternion
  3967. * @returns a new quaternion as the inverted current quaternion
  3968. */
  3969. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3970. /**
  3971. * Inverse a given quaternion
  3972. * @param q defines the source quaternion
  3973. * @param result the quaternion the result will be stored in
  3974. * @returns the result quaternion
  3975. */
  3976. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3977. /**
  3978. * Creates an identity quaternion
  3979. * @returns the identity quaternion
  3980. */
  3981. static Identity(): Quaternion;
  3982. /**
  3983. * Gets a boolean indicating if the given quaternion is identity
  3984. * @param quaternion defines the quaternion to check
  3985. * @returns true if the quaternion is identity
  3986. */
  3987. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3988. /**
  3989. * Creates a quaternion from a rotation around an axis
  3990. * @param axis defines the axis to use
  3991. * @param angle defines the angle to use
  3992. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3993. */
  3994. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3995. /**
  3996. * Creates a rotation around an axis and stores it into the given quaternion
  3997. * @param axis defines the axis to use
  3998. * @param angle defines the angle to use
  3999. * @param result defines the target quaternion
  4000. * @returns the target quaternion
  4001. */
  4002. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4003. /**
  4004. * Creates a new quaternion from data stored into an array
  4005. * @param array defines the data source
  4006. * @param offset defines the offset in the source array where the data starts
  4007. * @returns a new quaternion
  4008. */
  4009. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4010. /**
  4011. * Updates the given quaternion "result" from the starting index of the given array.
  4012. * @param array the array to pull values from
  4013. * @param offset the offset into the array to start at
  4014. * @param result the quaternion to store the result in
  4015. */
  4016. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4017. /**
  4018. * Create a quaternion from Euler rotation angles
  4019. * @param x Pitch
  4020. * @param y Yaw
  4021. * @param z Roll
  4022. * @returns the new Quaternion
  4023. */
  4024. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4025. /**
  4026. * Updates a quaternion from Euler rotation angles
  4027. * @param x Pitch
  4028. * @param y Yaw
  4029. * @param z Roll
  4030. * @param result the quaternion to store the result
  4031. * @returns the updated quaternion
  4032. */
  4033. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4034. /**
  4035. * Create a quaternion from Euler rotation vector
  4036. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4037. * @returns the new Quaternion
  4038. */
  4039. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4040. /**
  4041. * Updates a quaternion from Euler rotation vector
  4042. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4043. * @param result the quaternion to store the result
  4044. * @returns the updated quaternion
  4045. */
  4046. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4047. /**
  4048. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4049. * @param yaw defines the rotation around Y axis
  4050. * @param pitch defines the rotation around X axis
  4051. * @param roll defines the rotation around Z axis
  4052. * @returns the new quaternion
  4053. */
  4054. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4055. /**
  4056. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4057. * @param yaw defines the rotation around Y axis
  4058. * @param pitch defines the rotation around X axis
  4059. * @param roll defines the rotation around Z axis
  4060. * @param result defines the target quaternion
  4061. */
  4062. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4063. /**
  4064. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4065. * @param alpha defines the rotation around first axis
  4066. * @param beta defines the rotation around second axis
  4067. * @param gamma defines the rotation around third axis
  4068. * @returns the new quaternion
  4069. */
  4070. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4071. /**
  4072. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4073. * @param alpha defines the rotation around first axis
  4074. * @param beta defines the rotation around second axis
  4075. * @param gamma defines the rotation around third axis
  4076. * @param result defines the target quaternion
  4077. */
  4078. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4079. /**
  4080. * 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)
  4081. * @param axis1 defines the first axis
  4082. * @param axis2 defines the second axis
  4083. * @param axis3 defines the third axis
  4084. * @returns the new quaternion
  4085. */
  4086. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4087. /**
  4088. * 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
  4089. * @param axis1 defines the first axis
  4090. * @param axis2 defines the second axis
  4091. * @param axis3 defines the third axis
  4092. * @param ref defines the target quaternion
  4093. */
  4094. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4095. /**
  4096. * Interpolates between two quaternions
  4097. * @param left defines first quaternion
  4098. * @param right defines second quaternion
  4099. * @param amount defines the gradient to use
  4100. * @returns the new interpolated quaternion
  4101. */
  4102. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4103. /**
  4104. * Interpolates between two quaternions and stores it into a target quaternion
  4105. * @param left defines first quaternion
  4106. * @param right defines second quaternion
  4107. * @param amount defines the gradient to use
  4108. * @param result defines the target quaternion
  4109. */
  4110. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4111. /**
  4112. * Interpolate between two quaternions using Hermite interpolation
  4113. * @param value1 defines first quaternion
  4114. * @param tangent1 defines the incoming tangent
  4115. * @param value2 defines second quaternion
  4116. * @param tangent2 defines the outgoing tangent
  4117. * @param amount defines the target quaternion
  4118. * @returns the new interpolated quaternion
  4119. */
  4120. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4121. }
  4122. /**
  4123. * Class used to store matrix data (4x4)
  4124. */
  4125. export class Matrix {
  4126. /**
  4127. * Gets the precision of matrix computations
  4128. */
  4129. static get Use64Bits(): boolean;
  4130. private static _updateFlagSeed;
  4131. private static _identityReadOnly;
  4132. private _isIdentity;
  4133. private _isIdentityDirty;
  4134. private _isIdentity3x2;
  4135. private _isIdentity3x2Dirty;
  4136. /**
  4137. * Gets the update flag of the matrix which is an unique number for the matrix.
  4138. * It will be incremented every time the matrix data change.
  4139. * You can use it to speed the comparison between two versions of the same matrix.
  4140. */
  4141. updateFlag: number;
  4142. private readonly _m;
  4143. /**
  4144. * Gets the internal data of the matrix
  4145. */
  4146. get m(): DeepImmutable<Float32Array | Array<number>>;
  4147. /** @hidden */
  4148. _markAsUpdated(): void;
  4149. /** @hidden */
  4150. private _updateIdentityStatus;
  4151. /**
  4152. * Creates an empty matrix (filled with zeros)
  4153. */
  4154. constructor();
  4155. /**
  4156. * Check if the current matrix is identity
  4157. * @returns true is the matrix is the identity matrix
  4158. */
  4159. isIdentity(): boolean;
  4160. /**
  4161. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4162. * @returns true is the matrix is the identity matrix
  4163. */
  4164. isIdentityAs3x2(): boolean;
  4165. /**
  4166. * Gets the determinant of the matrix
  4167. * @returns the matrix determinant
  4168. */
  4169. determinant(): number;
  4170. /**
  4171. * Returns the matrix as a Float32Array or Array<number>
  4172. * @returns the matrix underlying array
  4173. */
  4174. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4175. /**
  4176. * Returns the matrix as a Float32Array or Array<number>
  4177. * @returns the matrix underlying array.
  4178. */
  4179. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4180. /**
  4181. * Inverts the current matrix in place
  4182. * @returns the current inverted matrix
  4183. */
  4184. invert(): Matrix;
  4185. /**
  4186. * Sets all the matrix elements to zero
  4187. * @returns the current matrix
  4188. */
  4189. reset(): Matrix;
  4190. /**
  4191. * Adds the current matrix with a second one
  4192. * @param other defines the matrix to add
  4193. * @returns a new matrix as the addition of the current matrix and the given one
  4194. */
  4195. add(other: DeepImmutable<Matrix>): Matrix;
  4196. /**
  4197. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4198. * @param other defines the matrix to add
  4199. * @param result defines the target matrix
  4200. * @returns the current matrix
  4201. */
  4202. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4203. /**
  4204. * Adds in place the given matrix to the current matrix
  4205. * @param other defines the second operand
  4206. * @returns the current updated matrix
  4207. */
  4208. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4209. /**
  4210. * Sets the given matrix to the current inverted Matrix
  4211. * @param other defines the target matrix
  4212. * @returns the unmodified current matrix
  4213. */
  4214. invertToRef(other: Matrix): Matrix;
  4215. /**
  4216. * add a value at the specified position in the current Matrix
  4217. * @param index the index of the value within the matrix. between 0 and 15.
  4218. * @param value the value to be added
  4219. * @returns the current updated matrix
  4220. */
  4221. addAtIndex(index: number, value: number): Matrix;
  4222. /**
  4223. * mutiply the specified position in the current Matrix by a value
  4224. * @param index the index of the value within the matrix. between 0 and 15.
  4225. * @param value the value to be added
  4226. * @returns the current updated matrix
  4227. */
  4228. multiplyAtIndex(index: number, value: number): Matrix;
  4229. /**
  4230. * Inserts the translation vector (using 3 floats) in the current matrix
  4231. * @param x defines the 1st component of the translation
  4232. * @param y defines the 2nd component of the translation
  4233. * @param z defines the 3rd component of the translation
  4234. * @returns the current updated matrix
  4235. */
  4236. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4237. /**
  4238. * Adds the translation vector (using 3 floats) in the current matrix
  4239. * @param x defines the 1st component of the translation
  4240. * @param y defines the 2nd component of the translation
  4241. * @param z defines the 3rd component of the translation
  4242. * @returns the current updated matrix
  4243. */
  4244. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4245. /**
  4246. * Inserts the translation vector in the current matrix
  4247. * @param vector3 defines the translation to insert
  4248. * @returns the current updated matrix
  4249. */
  4250. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4251. /**
  4252. * Gets the translation value of the current matrix
  4253. * @returns a new Vector3 as the extracted translation from the matrix
  4254. */
  4255. getTranslation(): Vector3;
  4256. /**
  4257. * Fill a Vector3 with the extracted translation from the matrix
  4258. * @param result defines the Vector3 where to store the translation
  4259. * @returns the current matrix
  4260. */
  4261. getTranslationToRef(result: Vector3): Matrix;
  4262. /**
  4263. * Remove rotation and scaling part from the matrix
  4264. * @returns the updated matrix
  4265. */
  4266. removeRotationAndScaling(): Matrix;
  4267. /**
  4268. * Multiply two matrices
  4269. * @param other defines the second operand
  4270. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4271. */
  4272. multiply(other: DeepImmutable<Matrix>): Matrix;
  4273. /**
  4274. * Copy the current matrix from the given one
  4275. * @param other defines the source matrix
  4276. * @returns the current updated matrix
  4277. */
  4278. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4279. /**
  4280. * Populates the given array from the starting index with the current matrix values
  4281. * @param array defines the target array
  4282. * @param offset defines the offset in the target array where to start storing values
  4283. * @returns the current matrix
  4284. */
  4285. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4286. /**
  4287. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4288. * @param other defines the second operand
  4289. * @param result defines the matrix where to store the multiplication
  4290. * @returns the current matrix
  4291. */
  4292. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4293. /**
  4294. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4295. * @param other defines the second operand
  4296. * @param result defines the array where to store the multiplication
  4297. * @param offset defines the offset in the target array where to start storing values
  4298. * @returns the current matrix
  4299. */
  4300. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4301. /**
  4302. * Check equality between this matrix and a second one
  4303. * @param value defines the second matrix to compare
  4304. * @returns true is the current matrix and the given one values are strictly equal
  4305. */
  4306. equals(value: DeepImmutable<Matrix>): boolean;
  4307. /**
  4308. * Clone the current matrix
  4309. * @returns a new matrix from the current matrix
  4310. */
  4311. clone(): Matrix;
  4312. /**
  4313. * Returns the name of the current matrix class
  4314. * @returns the string "Matrix"
  4315. */
  4316. getClassName(): string;
  4317. /**
  4318. * Gets the hash code of the current matrix
  4319. * @returns the hash code
  4320. */
  4321. getHashCode(): number;
  4322. /**
  4323. * Decomposes the current Matrix into a translation, rotation and scaling components
  4324. * @param scale defines the scale vector3 given as a reference to update
  4325. * @param rotation defines the rotation quaternion given as a reference to update
  4326. * @param translation defines the translation vector3 given as a reference to update
  4327. * @returns true if operation was successful
  4328. */
  4329. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4330. /**
  4331. * Gets specific row of the matrix
  4332. * @param index defines the number of the row to get
  4333. * @returns the index-th row of the current matrix as a new Vector4
  4334. */
  4335. getRow(index: number): Nullable<Vector4>;
  4336. /**
  4337. * Sets the index-th row of the current matrix to the vector4 values
  4338. * @param index defines the number of the row to set
  4339. * @param row defines the target vector4
  4340. * @returns the updated current matrix
  4341. */
  4342. setRow(index: number, row: Vector4): Matrix;
  4343. /**
  4344. * Compute the transpose of the matrix
  4345. * @returns the new transposed matrix
  4346. */
  4347. transpose(): Matrix;
  4348. /**
  4349. * Compute the transpose of the matrix and store it in a given matrix
  4350. * @param result defines the target matrix
  4351. * @returns the current matrix
  4352. */
  4353. transposeToRef(result: Matrix): Matrix;
  4354. /**
  4355. * Sets the index-th row of the current matrix with the given 4 x float values
  4356. * @param index defines the row index
  4357. * @param x defines the x component to set
  4358. * @param y defines the y component to set
  4359. * @param z defines the z component to set
  4360. * @param w defines the w component to set
  4361. * @returns the updated current matrix
  4362. */
  4363. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4364. /**
  4365. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4366. * @param scale defines the scale factor
  4367. * @returns a new matrix
  4368. */
  4369. scale(scale: number): Matrix;
  4370. /**
  4371. * Scale the current matrix values by a factor to a given result matrix
  4372. * @param scale defines the scale factor
  4373. * @param result defines the matrix to store the result
  4374. * @returns the current matrix
  4375. */
  4376. scaleToRef(scale: number, result: Matrix): Matrix;
  4377. /**
  4378. * Scale the current matrix values by a factor and add the result to a given matrix
  4379. * @param scale defines the scale factor
  4380. * @param result defines the Matrix to store the result
  4381. * @returns the current matrix
  4382. */
  4383. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4384. /**
  4385. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4386. * @param ref matrix to store the result
  4387. */
  4388. toNormalMatrix(ref: Matrix): void;
  4389. /**
  4390. * Gets only rotation part of the current matrix
  4391. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4392. */
  4393. getRotationMatrix(): Matrix;
  4394. /**
  4395. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4396. * @param result defines the target matrix to store data to
  4397. * @returns the current matrix
  4398. */
  4399. getRotationMatrixToRef(result: Matrix): Matrix;
  4400. /**
  4401. * Toggles model matrix from being right handed to left handed in place and vice versa
  4402. */
  4403. toggleModelMatrixHandInPlace(): void;
  4404. /**
  4405. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4406. */
  4407. toggleProjectionMatrixHandInPlace(): void;
  4408. /**
  4409. * Creates a matrix from an array
  4410. * @param array defines the source array
  4411. * @param offset defines an offset in the source array
  4412. * @returns a new Matrix set from the starting index of the given array
  4413. */
  4414. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4415. /**
  4416. * Copy the content of an array into a given matrix
  4417. * @param array defines the source array
  4418. * @param offset defines an offset in the source array
  4419. * @param result defines the target matrix
  4420. */
  4421. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4422. /**
  4423. * Stores an array into a matrix after having multiplied each component by a given factor
  4424. * @param array defines the source array
  4425. * @param offset defines the offset in the source array
  4426. * @param scale defines the scaling factor
  4427. * @param result defines the target matrix
  4428. */
  4429. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4430. /**
  4431. * Gets an identity matrix that must not be updated
  4432. */
  4433. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4434. /**
  4435. * Stores a list of values (16) inside a given matrix
  4436. * @param initialM11 defines 1st value of 1st row
  4437. * @param initialM12 defines 2nd value of 1st row
  4438. * @param initialM13 defines 3rd value of 1st row
  4439. * @param initialM14 defines 4th value of 1st row
  4440. * @param initialM21 defines 1st value of 2nd row
  4441. * @param initialM22 defines 2nd value of 2nd row
  4442. * @param initialM23 defines 3rd value of 2nd row
  4443. * @param initialM24 defines 4th value of 2nd row
  4444. * @param initialM31 defines 1st value of 3rd row
  4445. * @param initialM32 defines 2nd value of 3rd row
  4446. * @param initialM33 defines 3rd value of 3rd row
  4447. * @param initialM34 defines 4th value of 3rd row
  4448. * @param initialM41 defines 1st value of 4th row
  4449. * @param initialM42 defines 2nd value of 4th row
  4450. * @param initialM43 defines 3rd value of 4th row
  4451. * @param initialM44 defines 4th value of 4th row
  4452. * @param result defines the target matrix
  4453. */
  4454. 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;
  4455. /**
  4456. * Creates new matrix from a list of values (16)
  4457. * @param initialM11 defines 1st value of 1st row
  4458. * @param initialM12 defines 2nd value of 1st row
  4459. * @param initialM13 defines 3rd value of 1st row
  4460. * @param initialM14 defines 4th value of 1st row
  4461. * @param initialM21 defines 1st value of 2nd row
  4462. * @param initialM22 defines 2nd value of 2nd row
  4463. * @param initialM23 defines 3rd value of 2nd row
  4464. * @param initialM24 defines 4th value of 2nd row
  4465. * @param initialM31 defines 1st value of 3rd row
  4466. * @param initialM32 defines 2nd value of 3rd row
  4467. * @param initialM33 defines 3rd value of 3rd row
  4468. * @param initialM34 defines 4th value of 3rd row
  4469. * @param initialM41 defines 1st value of 4th row
  4470. * @param initialM42 defines 2nd value of 4th row
  4471. * @param initialM43 defines 3rd value of 4th row
  4472. * @param initialM44 defines 4th value of 4th row
  4473. * @returns the new matrix
  4474. */
  4475. 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;
  4476. /**
  4477. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4478. * @param scale defines the scale vector3
  4479. * @param rotation defines the rotation quaternion
  4480. * @param translation defines the translation vector3
  4481. * @returns a new matrix
  4482. */
  4483. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4484. /**
  4485. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4486. * @param scale defines the scale vector3
  4487. * @param rotation defines the rotation quaternion
  4488. * @param translation defines the translation vector3
  4489. * @param result defines the target matrix
  4490. */
  4491. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4492. /**
  4493. * Creates a new identity matrix
  4494. * @returns a new identity matrix
  4495. */
  4496. static Identity(): Matrix;
  4497. /**
  4498. * Creates a new identity matrix and stores the result in a given matrix
  4499. * @param result defines the target matrix
  4500. */
  4501. static IdentityToRef(result: Matrix): void;
  4502. /**
  4503. * Creates a new zero matrix
  4504. * @returns a new zero matrix
  4505. */
  4506. static Zero(): Matrix;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the X axis
  4509. * @param angle defines the angle (in radians) to use
  4510. * @return the new matrix
  4511. */
  4512. static RotationX(angle: number): Matrix;
  4513. /**
  4514. * Creates a new matrix as the invert of a given matrix
  4515. * @param source defines the source matrix
  4516. * @returns the new matrix
  4517. */
  4518. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4519. /**
  4520. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4521. * @param angle defines the angle (in radians) to use
  4522. * @param result defines the target matrix
  4523. */
  4524. static RotationXToRef(angle: number, result: Matrix): void;
  4525. /**
  4526. * Creates a new rotation matrix for "angle" radians around the Y axis
  4527. * @param angle defines the angle (in radians) to use
  4528. * @return the new matrix
  4529. */
  4530. static RotationY(angle: number): Matrix;
  4531. /**
  4532. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4533. * @param angle defines the angle (in radians) to use
  4534. * @param result defines the target matrix
  4535. */
  4536. static RotationYToRef(angle: number, result: Matrix): void;
  4537. /**
  4538. * Creates a new rotation matrix for "angle" radians around the Z axis
  4539. * @param angle defines the angle (in radians) to use
  4540. * @return the new matrix
  4541. */
  4542. static RotationZ(angle: number): Matrix;
  4543. /**
  4544. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4545. * @param angle defines the angle (in radians) to use
  4546. * @param result defines the target matrix
  4547. */
  4548. static RotationZToRef(angle: number, result: Matrix): void;
  4549. /**
  4550. * Creates a new rotation matrix for "angle" radians around the given axis
  4551. * @param axis defines the axis to use
  4552. * @param angle defines the angle (in radians) to use
  4553. * @return the new matrix
  4554. */
  4555. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4556. /**
  4557. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4558. * @param axis defines the axis to use
  4559. * @param angle defines the angle (in radians) to use
  4560. * @param result defines the target matrix
  4561. */
  4562. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4563. /**
  4564. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4565. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4566. * @param from defines the vector to align
  4567. * @param to defines the vector to align to
  4568. * @param result defines the target matrix
  4569. */
  4570. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4571. /**
  4572. * Creates a rotation matrix
  4573. * @param yaw defines the yaw angle in radians (Y axis)
  4574. * @param pitch defines the pitch angle in radians (X axis)
  4575. * @param roll defines the roll angle in radians (Z axis)
  4576. * @returns the new rotation matrix
  4577. */
  4578. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4579. /**
  4580. * Creates a rotation matrix and stores it in a given matrix
  4581. * @param yaw defines the yaw angle in radians (Y axis)
  4582. * @param pitch defines the pitch angle in radians (X axis)
  4583. * @param roll defines the roll angle in radians (Z axis)
  4584. * @param result defines the target matrix
  4585. */
  4586. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4587. /**
  4588. * Creates a scaling matrix
  4589. * @param x defines the scale factor on X axis
  4590. * @param y defines the scale factor on Y axis
  4591. * @param z defines the scale factor on Z axis
  4592. * @returns the new matrix
  4593. */
  4594. static Scaling(x: number, y: number, z: number): Matrix;
  4595. /**
  4596. * Creates a scaling matrix and stores it in a given matrix
  4597. * @param x defines the scale factor on X axis
  4598. * @param y defines the scale factor on Y axis
  4599. * @param z defines the scale factor on Z axis
  4600. * @param result defines the target matrix
  4601. */
  4602. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4603. /**
  4604. * Creates a translation matrix
  4605. * @param x defines the translation on X axis
  4606. * @param y defines the translation on Y axis
  4607. * @param z defines the translationon Z axis
  4608. * @returns the new matrix
  4609. */
  4610. static Translation(x: number, y: number, z: number): Matrix;
  4611. /**
  4612. * Creates a translation matrix and stores it in a given matrix
  4613. * @param x defines the translation on X axis
  4614. * @param y defines the translation on Y axis
  4615. * @param z defines the translationon Z axis
  4616. * @param result defines the target matrix
  4617. */
  4618. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4619. /**
  4620. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4621. * @param startValue defines the start value
  4622. * @param endValue defines the end value
  4623. * @param gradient defines the gradient factor
  4624. * @returns the new matrix
  4625. */
  4626. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4627. /**
  4628. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4629. * @param startValue defines the start value
  4630. * @param endValue defines the end value
  4631. * @param gradient defines the gradient factor
  4632. * @param result defines the Matrix object where to store data
  4633. */
  4634. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4635. /**
  4636. * Builds a new matrix whose values are computed by:
  4637. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4638. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4639. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4640. * @param startValue defines the first matrix
  4641. * @param endValue defines the second matrix
  4642. * @param gradient defines the gradient between the two matrices
  4643. * @returns the new matrix
  4644. */
  4645. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4646. /**
  4647. * Update a matrix to values which are computed by:
  4648. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4649. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4650. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4651. * @param startValue defines the first matrix
  4652. * @param endValue defines the second matrix
  4653. * @param gradient defines the gradient between the two matrices
  4654. * @param result defines the target matrix
  4655. */
  4656. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4657. /**
  4658. * 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"
  4659. * This function works in left handed mode
  4660. * @param eye defines the final position of the entity
  4661. * @param target defines where the entity should look at
  4662. * @param up defines the up vector for the entity
  4663. * @returns the new matrix
  4664. */
  4665. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4666. /**
  4667. * 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".
  4668. * This function works in left handed mode
  4669. * @param eye defines the final position of the entity
  4670. * @param target defines where the entity should look at
  4671. * @param up defines the up vector for the entity
  4672. * @param result defines the target matrix
  4673. */
  4674. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4675. /**
  4676. * 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"
  4677. * This function works in right handed mode
  4678. * @param eye defines the final position of the entity
  4679. * @param target defines where the entity should look at
  4680. * @param up defines the up vector for the entity
  4681. * @returns the new matrix
  4682. */
  4683. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4684. /**
  4685. * 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".
  4686. * This function works in right handed mode
  4687. * @param eye defines the final position of the entity
  4688. * @param target defines where the entity should look at
  4689. * @param up defines the up vector for the entity
  4690. * @param result defines the target matrix
  4691. */
  4692. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4693. /**
  4694. * Create a left-handed orthographic projection matrix
  4695. * @param width defines the viewport width
  4696. * @param height defines the viewport height
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a left-handed orthographic projection matrix
  4700. */
  4701. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Store a left-handed orthographic projection to a given matrix
  4704. * @param width defines the viewport width
  4705. * @param height defines the viewport height
  4706. * @param znear defines the near clip plane
  4707. * @param zfar defines the far clip plane
  4708. * @param result defines the target matrix
  4709. */
  4710. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4711. /**
  4712. * Create a left-handed orthographic projection matrix
  4713. * @param left defines the viewport left coordinate
  4714. * @param right defines the viewport right coordinate
  4715. * @param bottom defines the viewport bottom coordinate
  4716. * @param top defines the viewport top coordinate
  4717. * @param znear defines the near clip plane
  4718. * @param zfar defines the far clip plane
  4719. * @returns a new matrix as a left-handed orthographic projection matrix
  4720. */
  4721. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4722. /**
  4723. * Stores a left-handed orthographic projection into a given matrix
  4724. * @param left defines the viewport left coordinate
  4725. * @param right defines the viewport right coordinate
  4726. * @param bottom defines the viewport bottom coordinate
  4727. * @param top defines the viewport top coordinate
  4728. * @param znear defines the near clip plane
  4729. * @param zfar defines the far clip plane
  4730. * @param result defines the target matrix
  4731. */
  4732. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4733. /**
  4734. * Creates a right-handed orthographic projection matrix
  4735. * @param left defines the viewport left coordinate
  4736. * @param right defines the viewport right coordinate
  4737. * @param bottom defines the viewport bottom coordinate
  4738. * @param top defines the viewport top coordinate
  4739. * @param znear defines the near clip plane
  4740. * @param zfar defines the far clip plane
  4741. * @returns a new matrix as a right-handed orthographic projection matrix
  4742. */
  4743. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4744. /**
  4745. * Stores a right-handed orthographic projection into a given matrix
  4746. * @param left defines the viewport left coordinate
  4747. * @param right defines the viewport right coordinate
  4748. * @param bottom defines the viewport bottom coordinate
  4749. * @param top defines the viewport top coordinate
  4750. * @param znear defines the near clip plane
  4751. * @param zfar defines the far clip plane
  4752. * @param result defines the target matrix
  4753. */
  4754. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4755. /**
  4756. * Creates a left-handed perspective projection matrix
  4757. * @param width defines the viewport width
  4758. * @param height defines the viewport height
  4759. * @param znear defines the near clip plane
  4760. * @param zfar defines the far clip plane
  4761. * @returns a new matrix as a left-handed perspective projection matrix
  4762. */
  4763. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4764. /**
  4765. * Creates a left-handed perspective projection matrix
  4766. * @param fov defines the horizontal field of view
  4767. * @param aspect defines the aspect ratio
  4768. * @param znear defines the near clip plane
  4769. * @param zfar defines the far clip plane
  4770. * @returns a new matrix as a left-handed perspective projection matrix
  4771. */
  4772. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4773. /**
  4774. * Stores a left-handed perspective projection into a given matrix
  4775. * @param fov defines the horizontal field of view
  4776. * @param aspect defines the aspect ratio
  4777. * @param znear defines the near clip plane
  4778. * @param zfar defines the far clip plane
  4779. * @param result defines the target matrix
  4780. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4781. */
  4782. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4783. /**
  4784. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4785. * @param fov defines the horizontal field of view
  4786. * @param aspect defines the aspect ratio
  4787. * @param znear defines the near clip plane
  4788. * @param zfar not used as infinity is used as far clip
  4789. * @param result defines the target matrix
  4790. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4791. */
  4792. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4793. /**
  4794. * Creates a right-handed perspective projection matrix
  4795. * @param fov defines the horizontal field of view
  4796. * @param aspect defines the aspect ratio
  4797. * @param znear defines the near clip plane
  4798. * @param zfar defines the far clip plane
  4799. * @returns a new matrix as a right-handed perspective projection matrix
  4800. */
  4801. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4802. /**
  4803. * Stores a right-handed perspective projection into a given matrix
  4804. * @param fov defines the horizontal field of view
  4805. * @param aspect defines the aspect ratio
  4806. * @param znear defines the near clip plane
  4807. * @param zfar defines the far clip plane
  4808. * @param result defines the target matrix
  4809. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4810. */
  4811. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4812. /**
  4813. * Stores a right-handed perspective projection into a given matrix
  4814. * @param fov defines the horizontal field of view
  4815. * @param aspect defines the aspect ratio
  4816. * @param znear defines the near clip plane
  4817. * @param zfar not used as infinity is used as far clip
  4818. * @param result defines the target matrix
  4819. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4820. */
  4821. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4822. /**
  4823. * Stores a perspective projection for WebVR info a given matrix
  4824. * @param fov defines the field of view
  4825. * @param znear defines the near clip plane
  4826. * @param zfar defines the far clip plane
  4827. * @param result defines the target matrix
  4828. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4829. */
  4830. static PerspectiveFovWebVRToRef(fov: {
  4831. upDegrees: number;
  4832. downDegrees: number;
  4833. leftDegrees: number;
  4834. rightDegrees: number;
  4835. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4836. /**
  4837. * Computes a complete transformation matrix
  4838. * @param viewport defines the viewport to use
  4839. * @param world defines the world matrix
  4840. * @param view defines the view matrix
  4841. * @param projection defines the projection matrix
  4842. * @param zmin defines the near clip plane
  4843. * @param zmax defines the far clip plane
  4844. * @returns the transformation matrix
  4845. */
  4846. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4847. /**
  4848. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4849. * @param matrix defines the matrix to use
  4850. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4851. */
  4852. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4853. /**
  4854. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4855. * @param matrix defines the matrix to use
  4856. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4857. */
  4858. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4859. /**
  4860. * Compute the transpose of a given matrix
  4861. * @param matrix defines the matrix to transpose
  4862. * @returns the new matrix
  4863. */
  4864. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4865. /**
  4866. * Compute the transpose of a matrix and store it in a target matrix
  4867. * @param matrix defines the matrix to transpose
  4868. * @param result defines the target matrix
  4869. */
  4870. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4871. /**
  4872. * Computes a reflection matrix from a plane
  4873. * @param plane defines the reflection plane
  4874. * @returns a new matrix
  4875. */
  4876. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4877. /**
  4878. * Computes a reflection matrix from a plane
  4879. * @param plane defines the reflection plane
  4880. * @param result defines the target matrix
  4881. */
  4882. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4883. /**
  4884. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4885. * @param xaxis defines the value of the 1st axis
  4886. * @param yaxis defines the value of the 2nd axis
  4887. * @param zaxis defines the value of the 3rd axis
  4888. * @param result defines the target matrix
  4889. */
  4890. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4891. /**
  4892. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4893. * @param quat defines the quaternion to use
  4894. * @param result defines the target matrix
  4895. */
  4896. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4897. }
  4898. /**
  4899. * @hidden
  4900. */
  4901. export class TmpVectors {
  4902. static Vector2: Vector2[];
  4903. static Vector3: Vector3[];
  4904. static Vector4: Vector4[];
  4905. static Quaternion: Quaternion[];
  4906. static Matrix: Matrix[];
  4907. }
  4908. }
  4909. declare module "babylonjs/Maths/math.path" {
  4910. import { DeepImmutable, Nullable } from "babylonjs/types";
  4911. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4912. /**
  4913. * Defines potential orientation for back face culling
  4914. */
  4915. export enum Orientation {
  4916. /**
  4917. * Clockwise
  4918. */
  4919. CW = 0,
  4920. /** Counter clockwise */
  4921. CCW = 1
  4922. }
  4923. /** Class used to represent a Bezier curve */
  4924. export class BezierCurve {
  4925. /**
  4926. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4927. * @param t defines the time
  4928. * @param x1 defines the left coordinate on X axis
  4929. * @param y1 defines the left coordinate on Y axis
  4930. * @param x2 defines the right coordinate on X axis
  4931. * @param y2 defines the right coordinate on Y axis
  4932. * @returns the interpolated value
  4933. */
  4934. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4935. }
  4936. /**
  4937. * Defines angle representation
  4938. */
  4939. export class Angle {
  4940. private _radians;
  4941. /**
  4942. * Creates an Angle object of "radians" radians (float).
  4943. * @param radians the angle in radians
  4944. */
  4945. constructor(radians: number);
  4946. /**
  4947. * Get value in degrees
  4948. * @returns the Angle value in degrees (float)
  4949. */
  4950. degrees(): number;
  4951. /**
  4952. * Get value in radians
  4953. * @returns the Angle value in radians (float)
  4954. */
  4955. radians(): number;
  4956. /**
  4957. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4958. * @param a defines first point as the origin
  4959. * @param b defines point
  4960. * @returns a new Angle
  4961. */
  4962. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4963. /**
  4964. * Gets a new Angle object from the given float in radians
  4965. * @param radians defines the angle value in radians
  4966. * @returns a new Angle
  4967. */
  4968. static FromRadians(radians: number): Angle;
  4969. /**
  4970. * Gets a new Angle object from the given float in degrees
  4971. * @param degrees defines the angle value in degrees
  4972. * @returns a new Angle
  4973. */
  4974. static FromDegrees(degrees: number): Angle;
  4975. }
  4976. /**
  4977. * This represents an arc in a 2d space.
  4978. */
  4979. export class Arc2 {
  4980. /** Defines the start point of the arc */
  4981. startPoint: Vector2;
  4982. /** Defines the mid point of the arc */
  4983. midPoint: Vector2;
  4984. /** Defines the end point of the arc */
  4985. endPoint: Vector2;
  4986. /**
  4987. * Defines the center point of the arc.
  4988. */
  4989. centerPoint: Vector2;
  4990. /**
  4991. * Defines the radius of the arc.
  4992. */
  4993. radius: number;
  4994. /**
  4995. * Defines the angle of the arc (from mid point to end point).
  4996. */
  4997. angle: Angle;
  4998. /**
  4999. * Defines the start angle of the arc (from start point to middle point).
  5000. */
  5001. startAngle: Angle;
  5002. /**
  5003. * Defines the orientation of the arc (clock wise/counter clock wise).
  5004. */
  5005. orientation: Orientation;
  5006. /**
  5007. * Creates an Arc object from the three given points : start, middle and end.
  5008. * @param startPoint Defines the start point of the arc
  5009. * @param midPoint Defines the midlle point of the arc
  5010. * @param endPoint Defines the end point of the arc
  5011. */
  5012. constructor(
  5013. /** Defines the start point of the arc */
  5014. startPoint: Vector2,
  5015. /** Defines the mid point of the arc */
  5016. midPoint: Vector2,
  5017. /** Defines the end point of the arc */
  5018. endPoint: Vector2);
  5019. }
  5020. /**
  5021. * Represents a 2D path made up of multiple 2D points
  5022. */
  5023. export class Path2 {
  5024. private _points;
  5025. private _length;
  5026. /**
  5027. * If the path start and end point are the same
  5028. */
  5029. closed: boolean;
  5030. /**
  5031. * Creates a Path2 object from the starting 2D coordinates x and y.
  5032. * @param x the starting points x value
  5033. * @param y the starting points y value
  5034. */
  5035. constructor(x: number, y: number);
  5036. /**
  5037. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5038. * @param x the added points x value
  5039. * @param y the added points y value
  5040. * @returns the updated Path2.
  5041. */
  5042. addLineTo(x: number, y: number): Path2;
  5043. /**
  5044. * 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.
  5045. * @param midX middle point x value
  5046. * @param midY middle point y value
  5047. * @param endX end point x value
  5048. * @param endY end point y value
  5049. * @param numberOfSegments (default: 36)
  5050. * @returns the updated Path2.
  5051. */
  5052. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5053. /**
  5054. * Closes the Path2.
  5055. * @returns the Path2.
  5056. */
  5057. close(): Path2;
  5058. /**
  5059. * Gets the sum of the distance between each sequential point in the path
  5060. * @returns the Path2 total length (float).
  5061. */
  5062. length(): number;
  5063. /**
  5064. * Gets the points which construct the path
  5065. * @returns the Path2 internal array of points.
  5066. */
  5067. getPoints(): Vector2[];
  5068. /**
  5069. * Retreives the point at the distance aways from the starting point
  5070. * @param normalizedLengthPosition the length along the path to retreive the point from
  5071. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5072. */
  5073. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5074. /**
  5075. * Creates a new path starting from an x and y position
  5076. * @param x starting x value
  5077. * @param y starting y value
  5078. * @returns a new Path2 starting at the coordinates (x, y).
  5079. */
  5080. static StartingAt(x: number, y: number): Path2;
  5081. }
  5082. /**
  5083. * Represents a 3D path made up of multiple 3D points
  5084. */
  5085. export class Path3D {
  5086. /**
  5087. * an array of Vector3, the curve axis of the Path3D
  5088. */
  5089. path: Vector3[];
  5090. private _curve;
  5091. private _distances;
  5092. private _tangents;
  5093. private _normals;
  5094. private _binormals;
  5095. private _raw;
  5096. private _alignTangentsWithPath;
  5097. private readonly _pointAtData;
  5098. /**
  5099. * new Path3D(path, normal, raw)
  5100. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5101. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5102. * @param path an array of Vector3, the curve axis of the Path3D
  5103. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5104. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5105. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5106. */
  5107. constructor(
  5108. /**
  5109. * an array of Vector3, the curve axis of the Path3D
  5110. */
  5111. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5112. /**
  5113. * Returns the Path3D array of successive Vector3 designing its curve.
  5114. * @returns the Path3D array of successive Vector3 designing its curve.
  5115. */
  5116. getCurve(): Vector3[];
  5117. /**
  5118. * Returns the Path3D array of successive Vector3 designing its curve.
  5119. * @returns the Path3D array of successive Vector3 designing its curve.
  5120. */
  5121. getPoints(): Vector3[];
  5122. /**
  5123. * @returns the computed length (float) of the path.
  5124. */
  5125. length(): number;
  5126. /**
  5127. * Returns an array populated with tangent vectors on each Path3D curve point.
  5128. * @returns an array populated with tangent vectors on each Path3D curve point.
  5129. */
  5130. getTangents(): Vector3[];
  5131. /**
  5132. * Returns an array populated with normal vectors on each Path3D curve point.
  5133. * @returns an array populated with normal vectors on each Path3D curve point.
  5134. */
  5135. getNormals(): Vector3[];
  5136. /**
  5137. * Returns an array populated with binormal vectors on each Path3D curve point.
  5138. * @returns an array populated with binormal vectors on each Path3D curve point.
  5139. */
  5140. getBinormals(): Vector3[];
  5141. /**
  5142. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5143. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5144. */
  5145. getDistances(): number[];
  5146. /**
  5147. * Returns an interpolated point along this path
  5148. * @param position the position of the point along this path, from 0.0 to 1.0
  5149. * @returns a new Vector3 as the point
  5150. */
  5151. getPointAt(position: number): Vector3;
  5152. /**
  5153. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5154. * @param position the position of the point along this path, from 0.0 to 1.0
  5155. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5156. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5157. */
  5158. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5159. /**
  5160. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5161. * @param position the position of the point along this path, from 0.0 to 1.0
  5162. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5163. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5164. */
  5165. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5166. /**
  5167. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5168. * @param position the position of the point along this path, from 0.0 to 1.0
  5169. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5170. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5171. */
  5172. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5173. /**
  5174. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5175. * @param position the position of the point along this path, from 0.0 to 1.0
  5176. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5177. */
  5178. getDistanceAt(position: number): number;
  5179. /**
  5180. * Returns the array index of the previous point of an interpolated point along this path
  5181. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5182. * @returns the array index
  5183. */
  5184. getPreviousPointIndexAt(position: number): number;
  5185. /**
  5186. * 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)
  5187. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5188. * @returns the sub position
  5189. */
  5190. getSubPositionAt(position: number): number;
  5191. /**
  5192. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5193. * @param target the vector of which to get the closest position to
  5194. * @returns the position of the closest virtual point on this path to the target vector
  5195. */
  5196. getClosestPositionTo(target: Vector3): number;
  5197. /**
  5198. * Returns a sub path (slice) of this path
  5199. * @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
  5200. * @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
  5201. * @returns a sub path (slice) of this path
  5202. */
  5203. slice(start?: number, end?: number): Path3D;
  5204. /**
  5205. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5206. * @param path path which all values are copied into the curves points
  5207. * @param firstNormal which should be projected onto the curve
  5208. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5209. * @returns the same object updated.
  5210. */
  5211. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5212. private _compute;
  5213. private _getFirstNonNullVector;
  5214. private _getLastNonNullVector;
  5215. private _normalVector;
  5216. /**
  5217. * Updates the point at data for an interpolated point along this curve
  5218. * @param position the position of the point along this curve, from 0.0 to 1.0
  5219. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5220. * @returns the (updated) point at data
  5221. */
  5222. private _updatePointAtData;
  5223. /**
  5224. * Updates the point at data from the specified parameters
  5225. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5226. * @param point the interpolated point
  5227. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5228. */
  5229. private _setPointAtData;
  5230. /**
  5231. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5232. */
  5233. private _updateInterpolationMatrix;
  5234. }
  5235. /**
  5236. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5237. * A Curve3 is designed from a series of successive Vector3.
  5238. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5239. */
  5240. export class Curve3 {
  5241. private _points;
  5242. private _length;
  5243. /**
  5244. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5245. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5246. * @param v1 (Vector3) the control point
  5247. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5248. * @param nbPoints (integer) the wanted number of points in the curve
  5249. * @returns the created Curve3
  5250. */
  5251. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5252. /**
  5253. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5254. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5255. * @param v1 (Vector3) the first control point
  5256. * @param v2 (Vector3) the second control point
  5257. * @param v3 (Vector3) the end point of the Cubic Bezier
  5258. * @param nbPoints (integer) the wanted number of points in the curve
  5259. * @returns the created Curve3
  5260. */
  5261. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5262. /**
  5263. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5264. * @param p1 (Vector3) the origin point of the Hermite Spline
  5265. * @param t1 (Vector3) the tangent vector at the origin point
  5266. * @param p2 (Vector3) the end point of the Hermite Spline
  5267. * @param t2 (Vector3) the tangent vector at the end point
  5268. * @param nbPoints (integer) the wanted number of points in the curve
  5269. * @returns the created Curve3
  5270. */
  5271. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5272. /**
  5273. * Returns a Curve3 object along a CatmullRom Spline curve :
  5274. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5275. * @param nbPoints (integer) the wanted number of points between each curve control points
  5276. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5277. * @returns the created Curve3
  5278. */
  5279. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5280. /**
  5281. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5282. * A Curve3 is designed from a series of successive Vector3.
  5283. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5284. * @param points points which make up the curve
  5285. */
  5286. constructor(points: Vector3[]);
  5287. /**
  5288. * @returns the Curve3 stored array of successive Vector3
  5289. */
  5290. getPoints(): Vector3[];
  5291. /**
  5292. * @returns the computed length (float) of the curve.
  5293. */
  5294. length(): number;
  5295. /**
  5296. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5297. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5298. * curveA and curveB keep unchanged.
  5299. * @param curve the curve to continue from this curve
  5300. * @returns the newly constructed curve
  5301. */
  5302. continue(curve: DeepImmutable<Curve3>): Curve3;
  5303. private _computeLength;
  5304. }
  5305. }
  5306. declare module "babylonjs/Animations/easing" {
  5307. /**
  5308. * This represents the main contract an easing function should follow.
  5309. * Easing functions are used throughout the animation system.
  5310. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5311. */
  5312. export interface IEasingFunction {
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5315. * of the easing function.
  5316. * The link below provides some of the most common examples of easing functions.
  5317. * @see https://easings.net/
  5318. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5319. * @returns the corresponding value on the curve defined by the easing function
  5320. */
  5321. ease(gradient: number): number;
  5322. }
  5323. /**
  5324. * Base class used for every default easing function.
  5325. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5326. */
  5327. export class EasingFunction implements IEasingFunction {
  5328. /**
  5329. * Interpolation follows the mathematical formula associated with the easing function.
  5330. */
  5331. static readonly EASINGMODE_EASEIN: number;
  5332. /**
  5333. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5334. */
  5335. static readonly EASINGMODE_EASEOUT: number;
  5336. /**
  5337. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5338. */
  5339. static readonly EASINGMODE_EASEINOUT: number;
  5340. private _easingMode;
  5341. /**
  5342. * Sets the easing mode of the current function.
  5343. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5344. */
  5345. setEasingMode(easingMode: number): void;
  5346. /**
  5347. * Gets the current easing mode.
  5348. * @returns the easing mode
  5349. */
  5350. getEasingMode(): number;
  5351. /**
  5352. * @hidden
  5353. */
  5354. easeInCore(gradient: number): number;
  5355. /**
  5356. * Given an input gradient between 0 and 1, this returns the corresponding value
  5357. * of the easing function.
  5358. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5359. * @returns the corresponding value on the curve defined by the easing function
  5360. */
  5361. ease(gradient: number): number;
  5362. }
  5363. /**
  5364. * Easing function with a circle shape (see link below).
  5365. * @see https://easings.net/#easeInCirc
  5366. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5367. */
  5368. export class CircleEase extends EasingFunction implements IEasingFunction {
  5369. /** @hidden */
  5370. easeInCore(gradient: number): number;
  5371. }
  5372. /**
  5373. * Easing function with a ease back shape (see link below).
  5374. * @see https://easings.net/#easeInBack
  5375. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5376. */
  5377. export class BackEase extends EasingFunction implements IEasingFunction {
  5378. /** Defines the amplitude of the function */
  5379. amplitude: number;
  5380. /**
  5381. * Instantiates a back ease easing
  5382. * @see https://easings.net/#easeInBack
  5383. * @param amplitude Defines the amplitude of the function
  5384. */
  5385. constructor(
  5386. /** Defines the amplitude of the function */
  5387. amplitude?: number);
  5388. /** @hidden */
  5389. easeInCore(gradient: number): number;
  5390. }
  5391. /**
  5392. * Easing function with a bouncing shape (see link below).
  5393. * @see https://easings.net/#easeInBounce
  5394. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5395. */
  5396. export class BounceEase extends EasingFunction implements IEasingFunction {
  5397. /** Defines the number of bounces */
  5398. bounces: number;
  5399. /** Defines the amplitude of the bounce */
  5400. bounciness: number;
  5401. /**
  5402. * Instantiates a bounce easing
  5403. * @see https://easings.net/#easeInBounce
  5404. * @param bounces Defines the number of bounces
  5405. * @param bounciness Defines the amplitude of the bounce
  5406. */
  5407. constructor(
  5408. /** Defines the number of bounces */
  5409. bounces?: number,
  5410. /** Defines the amplitude of the bounce */
  5411. bounciness?: number);
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power of 3 shape (see link below).
  5417. * @see https://easings.net/#easeInCubic
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class CubicEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with an elastic shape (see link below).
  5426. * @see https://easings.net/#easeInElastic
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the number of oscillations*/
  5431. oscillations: number;
  5432. /** Defines the amplitude of the oscillations*/
  5433. springiness: number;
  5434. /**
  5435. * Instantiates an elastic easing function
  5436. * @see https://easings.net/#easeInElastic
  5437. * @param oscillations Defines the number of oscillations
  5438. * @param springiness Defines the amplitude of the oscillations
  5439. */
  5440. constructor(
  5441. /** Defines the number of oscillations*/
  5442. oscillations?: number,
  5443. /** Defines the amplitude of the oscillations*/
  5444. springiness?: number);
  5445. /** @hidden */
  5446. easeInCore(gradient: number): number;
  5447. }
  5448. /**
  5449. * Easing function with an exponential shape (see link below).
  5450. * @see https://easings.net/#easeInExpo
  5451. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5452. */
  5453. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5454. /** Defines the exponent of the function */
  5455. exponent: number;
  5456. /**
  5457. * Instantiates an exponential easing function
  5458. * @see https://easings.net/#easeInExpo
  5459. * @param exponent Defines the exponent of the function
  5460. */
  5461. constructor(
  5462. /** Defines the exponent of the function */
  5463. exponent?: number);
  5464. /** @hidden */
  5465. easeInCore(gradient: number): number;
  5466. }
  5467. /**
  5468. * Easing function with a power shape (see link below).
  5469. * @see https://easings.net/#easeInQuad
  5470. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5471. */
  5472. export class PowerEase extends EasingFunction implements IEasingFunction {
  5473. /** Defines the power of the function */
  5474. power: number;
  5475. /**
  5476. * Instantiates an power base easing function
  5477. * @see https://easings.net/#easeInQuad
  5478. * @param power Defines the power of the function
  5479. */
  5480. constructor(
  5481. /** Defines the power of the function */
  5482. power?: number);
  5483. /** @hidden */
  5484. easeInCore(gradient: number): number;
  5485. }
  5486. /**
  5487. * Easing function with a power of 2 shape (see link below).
  5488. * @see https://easings.net/#easeInQuad
  5489. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5490. */
  5491. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5492. /** @hidden */
  5493. easeInCore(gradient: number): number;
  5494. }
  5495. /**
  5496. * Easing function with a power of 4 shape (see link below).
  5497. * @see https://easings.net/#easeInQuart
  5498. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5499. */
  5500. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5501. /** @hidden */
  5502. easeInCore(gradient: number): number;
  5503. }
  5504. /**
  5505. * Easing function with a power of 5 shape (see link below).
  5506. * @see https://easings.net/#easeInQuint
  5507. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5508. */
  5509. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5510. /** @hidden */
  5511. easeInCore(gradient: number): number;
  5512. }
  5513. /**
  5514. * Easing function with a sin shape (see link below).
  5515. * @see https://easings.net/#easeInSine
  5516. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5517. */
  5518. export class SineEase extends EasingFunction implements IEasingFunction {
  5519. /** @hidden */
  5520. easeInCore(gradient: number): number;
  5521. }
  5522. /**
  5523. * Easing function with a bezier shape (see link below).
  5524. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5525. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5526. */
  5527. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5528. /** Defines the x component of the start tangent in the bezier curve */
  5529. x1: number;
  5530. /** Defines the y component of the start tangent in the bezier curve */
  5531. y1: number;
  5532. /** Defines the x component of the end tangent in the bezier curve */
  5533. x2: number;
  5534. /** Defines the y component of the end tangent in the bezier curve */
  5535. y2: number;
  5536. /**
  5537. * Instantiates a bezier function
  5538. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5539. * @param x1 Defines the x component of the start tangent in the bezier curve
  5540. * @param y1 Defines the y component of the start tangent in the bezier curve
  5541. * @param x2 Defines the x component of the end tangent in the bezier curve
  5542. * @param y2 Defines the y component of the end tangent in the bezier curve
  5543. */
  5544. constructor(
  5545. /** Defines the x component of the start tangent in the bezier curve */
  5546. x1?: number,
  5547. /** Defines the y component of the start tangent in the bezier curve */
  5548. y1?: number,
  5549. /** Defines the x component of the end tangent in the bezier curve */
  5550. x2?: number,
  5551. /** Defines the y component of the end tangent in the bezier curve */
  5552. y2?: number);
  5553. /** @hidden */
  5554. easeInCore(gradient: number): number;
  5555. }
  5556. }
  5557. declare module "babylonjs/Maths/math.color" {
  5558. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5559. /**
  5560. * Class used to hold a RBG color
  5561. */
  5562. export class Color3 {
  5563. /**
  5564. * Defines the red component (between 0 and 1, default is 0)
  5565. */
  5566. r: number;
  5567. /**
  5568. * Defines the green component (between 0 and 1, default is 0)
  5569. */
  5570. g: number;
  5571. /**
  5572. * Defines the blue component (between 0 and 1, default is 0)
  5573. */
  5574. b: number;
  5575. /**
  5576. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5577. * @param r defines the red component (between 0 and 1, default is 0)
  5578. * @param g defines the green component (between 0 and 1, default is 0)
  5579. * @param b defines the blue component (between 0 and 1, default is 0)
  5580. */
  5581. constructor(
  5582. /**
  5583. * Defines the red component (between 0 and 1, default is 0)
  5584. */
  5585. r?: number,
  5586. /**
  5587. * Defines the green component (between 0 and 1, default is 0)
  5588. */
  5589. g?: number,
  5590. /**
  5591. * Defines the blue component (between 0 and 1, default is 0)
  5592. */
  5593. b?: number);
  5594. /**
  5595. * Creates a string with the Color3 current values
  5596. * @returns the string representation of the Color3 object
  5597. */
  5598. toString(): string;
  5599. /**
  5600. * Returns the string "Color3"
  5601. * @returns "Color3"
  5602. */
  5603. getClassName(): string;
  5604. /**
  5605. * Compute the Color3 hash code
  5606. * @returns an unique number that can be used to hash Color3 objects
  5607. */
  5608. getHashCode(): number;
  5609. /**
  5610. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5611. * @param array defines the array where to store the r,g,b components
  5612. * @param index defines an optional index in the target array to define where to start storing values
  5613. * @returns the current Color3 object
  5614. */
  5615. toArray(array: FloatArray, index?: number): Color3;
  5616. /**
  5617. * Update the current color with values stored in an array from the starting index of the given array
  5618. * @param array defines the source array
  5619. * @param offset defines an offset in the source array
  5620. * @returns the current Color3 object
  5621. */
  5622. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5623. /**
  5624. * Returns a new Color4 object from the current Color3 and the given alpha
  5625. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5626. * @returns a new Color4 object
  5627. */
  5628. toColor4(alpha?: number): Color4;
  5629. /**
  5630. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5631. * @returns the new array
  5632. */
  5633. asArray(): number[];
  5634. /**
  5635. * Returns the luminance value
  5636. * @returns a float value
  5637. */
  5638. toLuminance(): number;
  5639. /**
  5640. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5641. * @param otherColor defines the second operand
  5642. * @returns the new Color3 object
  5643. */
  5644. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5645. /**
  5646. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5647. * @param otherColor defines the second operand
  5648. * @param result defines the Color3 object where to store the result
  5649. * @returns the current Color3
  5650. */
  5651. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5652. /**
  5653. * Determines equality between Color3 objects
  5654. * @param otherColor defines the second operand
  5655. * @returns true if the rgb values are equal to the given ones
  5656. */
  5657. equals(otherColor: DeepImmutable<Color3>): boolean;
  5658. /**
  5659. * Determines equality between the current Color3 object and a set of r,b,g values
  5660. * @param r defines the red component to check
  5661. * @param g defines the green component to check
  5662. * @param b defines the blue component to check
  5663. * @returns true if the rgb values are equal to the given ones
  5664. */
  5665. equalsFloats(r: number, g: number, b: number): boolean;
  5666. /**
  5667. * Multiplies in place each rgb value by scale
  5668. * @param scale defines the scaling factor
  5669. * @returns the updated Color3
  5670. */
  5671. scale(scale: number): Color3;
  5672. /**
  5673. * Multiplies the rgb values by scale and stores the result into "result"
  5674. * @param scale defines the scaling factor
  5675. * @param result defines the Color3 object where to store the result
  5676. * @returns the unmodified current Color3
  5677. */
  5678. scaleToRef(scale: number, result: Color3): Color3;
  5679. /**
  5680. * Scale the current Color3 values by a factor and add the result to a given Color3
  5681. * @param scale defines the scale factor
  5682. * @param result defines color to store the result into
  5683. * @returns the unmodified current Color3
  5684. */
  5685. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5686. /**
  5687. * Clamps the rgb values by the min and max values and stores the result into "result"
  5688. * @param min defines minimum clamping value (default is 0)
  5689. * @param max defines maximum clamping value (default is 1)
  5690. * @param result defines color to store the result into
  5691. * @returns the original Color3
  5692. */
  5693. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5694. /**
  5695. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5696. * @param otherColor defines the second operand
  5697. * @returns the new Color3
  5698. */
  5699. add(otherColor: DeepImmutable<Color3>): Color3;
  5700. /**
  5701. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5702. * @param otherColor defines the second operand
  5703. * @param result defines Color3 object to store the result into
  5704. * @returns the unmodified current Color3
  5705. */
  5706. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5707. /**
  5708. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5709. * @param otherColor defines the second operand
  5710. * @returns the new Color3
  5711. */
  5712. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5713. /**
  5714. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5715. * @param otherColor defines the second operand
  5716. * @param result defines Color3 object to store the result into
  5717. * @returns the unmodified current Color3
  5718. */
  5719. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5720. /**
  5721. * Copy the current object
  5722. * @returns a new Color3 copied the current one
  5723. */
  5724. clone(): Color3;
  5725. /**
  5726. * Copies the rgb values from the source in the current Color3
  5727. * @param source defines the source Color3 object
  5728. * @returns the updated Color3 object
  5729. */
  5730. copyFrom(source: DeepImmutable<Color3>): Color3;
  5731. /**
  5732. * Updates the Color3 rgb values from the given floats
  5733. * @param r defines the red component to read from
  5734. * @param g defines the green component to read from
  5735. * @param b defines the blue component to read from
  5736. * @returns the current Color3 object
  5737. */
  5738. copyFromFloats(r: number, g: number, b: number): Color3;
  5739. /**
  5740. * Updates the Color3 rgb values from the given floats
  5741. * @param r defines the red component to read from
  5742. * @param g defines the green component to read from
  5743. * @param b defines the blue component to read from
  5744. * @returns the current Color3 object
  5745. */
  5746. set(r: number, g: number, b: number): Color3;
  5747. /**
  5748. * Compute the Color3 hexadecimal code as a string
  5749. * @returns a string containing the hexadecimal representation of the Color3 object
  5750. */
  5751. toHexString(): string;
  5752. /**
  5753. * Computes a new Color3 converted from the current one to linear space
  5754. * @returns a new Color3 object
  5755. */
  5756. toLinearSpace(): Color3;
  5757. /**
  5758. * Converts current color in rgb space to HSV values
  5759. * @returns a new color3 representing the HSV values
  5760. */
  5761. toHSV(): Color3;
  5762. /**
  5763. * Converts current color in rgb space to HSV values
  5764. * @param result defines the Color3 where to store the HSV values
  5765. */
  5766. toHSVToRef(result: Color3): void;
  5767. /**
  5768. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5769. * @param convertedColor defines the Color3 object where to store the linear space version
  5770. * @returns the unmodified Color3
  5771. */
  5772. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5773. /**
  5774. * Computes a new Color3 converted from the current one to gamma space
  5775. * @returns a new Color3 object
  5776. */
  5777. toGammaSpace(): Color3;
  5778. /**
  5779. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5780. * @param convertedColor defines the Color3 object where to store the gamma space version
  5781. * @returns the unmodified Color3
  5782. */
  5783. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5784. private static _BlackReadOnly;
  5785. /**
  5786. * Convert Hue, saturation and value to a Color3 (RGB)
  5787. * @param hue defines the hue
  5788. * @param saturation defines the saturation
  5789. * @param value defines the value
  5790. * @param result defines the Color3 where to store the RGB values
  5791. */
  5792. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5793. /**
  5794. * Creates a new Color3 from the string containing valid hexadecimal values
  5795. * @param hex defines a string containing valid hexadecimal values
  5796. * @returns a new Color3 object
  5797. */
  5798. static FromHexString(hex: string): Color3;
  5799. /**
  5800. * Creates a new Color3 from the starting index of the given array
  5801. * @param array defines the source array
  5802. * @param offset defines an offset in the source array
  5803. * @returns a new Color3 object
  5804. */
  5805. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5806. /**
  5807. * Creates a new Color3 from the starting index element of the given array
  5808. * @param array defines the source array to read from
  5809. * @param offset defines the offset in the source array
  5810. * @param result defines the target Color3 object
  5811. */
  5812. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5813. /**
  5814. * Creates a new Color3 from integer values (< 256)
  5815. * @param r defines the red component to read from (value between 0 and 255)
  5816. * @param g defines the green component to read from (value between 0 and 255)
  5817. * @param b defines the blue component to read from (value between 0 and 255)
  5818. * @returns a new Color3 object
  5819. */
  5820. static FromInts(r: number, g: number, b: number): Color3;
  5821. /**
  5822. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5823. * @param start defines the start Color3 value
  5824. * @param end defines the end Color3 value
  5825. * @param amount defines the gradient value between start and end
  5826. * @returns a new Color3 object
  5827. */
  5828. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5829. /**
  5830. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5831. * @param left defines the start value
  5832. * @param right defines the end value
  5833. * @param amount defines the gradient factor
  5834. * @param result defines the Color3 object where to store the result
  5835. */
  5836. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5837. /**
  5838. * Returns a Color3 value containing a red color
  5839. * @returns a new Color3 object
  5840. */
  5841. static Red(): Color3;
  5842. /**
  5843. * Returns a Color3 value containing a green color
  5844. * @returns a new Color3 object
  5845. */
  5846. static Green(): Color3;
  5847. /**
  5848. * Returns a Color3 value containing a blue color
  5849. * @returns a new Color3 object
  5850. */
  5851. static Blue(): Color3;
  5852. /**
  5853. * Returns a Color3 value containing a black color
  5854. * @returns a new Color3 object
  5855. */
  5856. static Black(): Color3;
  5857. /**
  5858. * Gets a Color3 value containing a black color that must not be updated
  5859. */
  5860. static get BlackReadOnly(): DeepImmutable<Color3>;
  5861. /**
  5862. * Returns a Color3 value containing a white color
  5863. * @returns a new Color3 object
  5864. */
  5865. static White(): Color3;
  5866. /**
  5867. * Returns a Color3 value containing a purple color
  5868. * @returns a new Color3 object
  5869. */
  5870. static Purple(): Color3;
  5871. /**
  5872. * Returns a Color3 value containing a magenta color
  5873. * @returns a new Color3 object
  5874. */
  5875. static Magenta(): Color3;
  5876. /**
  5877. * Returns a Color3 value containing a yellow color
  5878. * @returns a new Color3 object
  5879. */
  5880. static Yellow(): Color3;
  5881. /**
  5882. * Returns a Color3 value containing a gray color
  5883. * @returns a new Color3 object
  5884. */
  5885. static Gray(): Color3;
  5886. /**
  5887. * Returns a Color3 value containing a teal color
  5888. * @returns a new Color3 object
  5889. */
  5890. static Teal(): Color3;
  5891. /**
  5892. * Returns a Color3 value containing a random color
  5893. * @returns a new Color3 object
  5894. */
  5895. static Random(): Color3;
  5896. }
  5897. /**
  5898. * Class used to hold a RBGA color
  5899. */
  5900. export class Color4 {
  5901. /**
  5902. * Defines the red component (between 0 and 1, default is 0)
  5903. */
  5904. r: number;
  5905. /**
  5906. * Defines the green component (between 0 and 1, default is 0)
  5907. */
  5908. g: number;
  5909. /**
  5910. * Defines the blue component (between 0 and 1, default is 0)
  5911. */
  5912. b: number;
  5913. /**
  5914. * Defines the alpha component (between 0 and 1, default is 1)
  5915. */
  5916. a: number;
  5917. /**
  5918. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5919. * @param r defines the red component (between 0 and 1, default is 0)
  5920. * @param g defines the green component (between 0 and 1, default is 0)
  5921. * @param b defines the blue component (between 0 and 1, default is 0)
  5922. * @param a defines the alpha component (between 0 and 1, default is 1)
  5923. */
  5924. constructor(
  5925. /**
  5926. * Defines the red component (between 0 and 1, default is 0)
  5927. */
  5928. r?: number,
  5929. /**
  5930. * Defines the green component (between 0 and 1, default is 0)
  5931. */
  5932. g?: number,
  5933. /**
  5934. * Defines the blue component (between 0 and 1, default is 0)
  5935. */
  5936. b?: number,
  5937. /**
  5938. * Defines the alpha component (between 0 and 1, default is 1)
  5939. */
  5940. a?: number);
  5941. /**
  5942. * Adds in place the given Color4 values to the current Color4 object
  5943. * @param right defines the second operand
  5944. * @returns the current updated Color4 object
  5945. */
  5946. addInPlace(right: DeepImmutable<Color4>): Color4;
  5947. /**
  5948. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5949. * @returns the new array
  5950. */
  5951. asArray(): number[];
  5952. /**
  5953. * Stores from the starting index in the given array the Color4 successive values
  5954. * @param array defines the array where to store the r,g,b components
  5955. * @param index defines an optional index in the target array to define where to start storing values
  5956. * @returns the current Color4 object
  5957. */
  5958. toArray(array: number[], index?: number): Color4;
  5959. /**
  5960. * Update the current color with values stored in an array from the starting index of the given array
  5961. * @param array defines the source array
  5962. * @param offset defines an offset in the source array
  5963. * @returns the current Color4 object
  5964. */
  5965. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5966. /**
  5967. * Determines equality between Color4 objects
  5968. * @param otherColor defines the second operand
  5969. * @returns true if the rgba values are equal to the given ones
  5970. */
  5971. equals(otherColor: DeepImmutable<Color4>): boolean;
  5972. /**
  5973. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5974. * @param right defines the second operand
  5975. * @returns a new Color4 object
  5976. */
  5977. add(right: DeepImmutable<Color4>): Color4;
  5978. /**
  5979. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5980. * @param right defines the second operand
  5981. * @returns a new Color4 object
  5982. */
  5983. subtract(right: DeepImmutable<Color4>): Color4;
  5984. /**
  5985. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5986. * @param right defines the second operand
  5987. * @param result defines the Color4 object where to store the result
  5988. * @returns the current Color4 object
  5989. */
  5990. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5991. /**
  5992. * Creates a new Color4 with the current Color4 values multiplied by scale
  5993. * @param scale defines the scaling factor to apply
  5994. * @returns a new Color4 object
  5995. */
  5996. scale(scale: number): Color4;
  5997. /**
  5998. * Multiplies the current Color4 values by scale and stores the result in "result"
  5999. * @param scale defines the scaling factor to apply
  6000. * @param result defines the Color4 object where to store the result
  6001. * @returns the current unmodified Color4
  6002. */
  6003. scaleToRef(scale: number, result: Color4): Color4;
  6004. /**
  6005. * Scale the current Color4 values by a factor and add the result to a given Color4
  6006. * @param scale defines the scale factor
  6007. * @param result defines the Color4 object where to store the result
  6008. * @returns the unmodified current Color4
  6009. */
  6010. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6011. /**
  6012. * Clamps the rgb values by the min and max values and stores the result into "result"
  6013. * @param min defines minimum clamping value (default is 0)
  6014. * @param max defines maximum clamping value (default is 1)
  6015. * @param result defines color to store the result into.
  6016. * @returns the cuurent Color4
  6017. */
  6018. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6019. /**
  6020. * Multipy an Color4 value by another and return a new Color4 object
  6021. * @param color defines the Color4 value to multiply by
  6022. * @returns a new Color4 object
  6023. */
  6024. multiply(color: Color4): Color4;
  6025. /**
  6026. * Multipy a Color4 value by another and push the result in a reference value
  6027. * @param color defines the Color4 value to multiply by
  6028. * @param result defines the Color4 to fill the result in
  6029. * @returns the result Color4
  6030. */
  6031. multiplyToRef(color: Color4, result: Color4): Color4;
  6032. /**
  6033. * Creates a string with the Color4 current values
  6034. * @returns the string representation of the Color4 object
  6035. */
  6036. toString(): string;
  6037. /**
  6038. * Returns the string "Color4"
  6039. * @returns "Color4"
  6040. */
  6041. getClassName(): string;
  6042. /**
  6043. * Compute the Color4 hash code
  6044. * @returns an unique number that can be used to hash Color4 objects
  6045. */
  6046. getHashCode(): number;
  6047. /**
  6048. * Creates a new Color4 copied from the current one
  6049. * @returns a new Color4 object
  6050. */
  6051. clone(): Color4;
  6052. /**
  6053. * Copies the given Color4 values into the current one
  6054. * @param source defines the source Color4 object
  6055. * @returns the current updated Color4 object
  6056. */
  6057. copyFrom(source: Color4): Color4;
  6058. /**
  6059. * Copies the given float values into the current one
  6060. * @param r defines the red component to read from
  6061. * @param g defines the green component to read from
  6062. * @param b defines the blue component to read from
  6063. * @param a defines the alpha component to read from
  6064. * @returns the current updated Color4 object
  6065. */
  6066. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6067. /**
  6068. * Copies the given float values into the current one
  6069. * @param r defines the red component to read from
  6070. * @param g defines the green component to read from
  6071. * @param b defines the blue component to read from
  6072. * @param a defines the alpha component to read from
  6073. * @returns the current updated Color4 object
  6074. */
  6075. set(r: number, g: number, b: number, a: number): Color4;
  6076. /**
  6077. * Compute the Color4 hexadecimal code as a string
  6078. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6079. * @returns a string containing the hexadecimal representation of the Color4 object
  6080. */
  6081. toHexString(returnAsColor3?: boolean): string;
  6082. /**
  6083. * Computes a new Color4 converted from the current one to linear space
  6084. * @returns a new Color4 object
  6085. */
  6086. toLinearSpace(): Color4;
  6087. /**
  6088. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6089. * @param convertedColor defines the Color4 object where to store the linear space version
  6090. * @returns the unmodified Color4
  6091. */
  6092. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6093. /**
  6094. * Computes a new Color4 converted from the current one to gamma space
  6095. * @returns a new Color4 object
  6096. */
  6097. toGammaSpace(): Color4;
  6098. /**
  6099. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6100. * @param convertedColor defines the Color4 object where to store the gamma space version
  6101. * @returns the unmodified Color4
  6102. */
  6103. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6104. /**
  6105. * Creates a new Color4 from the string containing valid hexadecimal values
  6106. * @param hex defines a string containing valid hexadecimal values
  6107. * @returns a new Color4 object
  6108. */
  6109. static FromHexString(hex: string): Color4;
  6110. /**
  6111. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6112. * @param left defines the start value
  6113. * @param right defines the end value
  6114. * @param amount defines the gradient factor
  6115. * @returns a new Color4 object
  6116. */
  6117. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6118. /**
  6119. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6120. * @param left defines the start value
  6121. * @param right defines the end value
  6122. * @param amount defines the gradient factor
  6123. * @param result defines the Color4 object where to store data
  6124. */
  6125. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6126. /**
  6127. * Creates a new Color4 from a Color3 and an alpha value
  6128. * @param color3 defines the source Color3 to read from
  6129. * @param alpha defines the alpha component (1.0 by default)
  6130. * @returns a new Color4 object
  6131. */
  6132. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6133. /**
  6134. * Creates a new Color4 from the starting index element of the given array
  6135. * @param array defines the source array to read from
  6136. * @param offset defines the offset in the source array
  6137. * @returns a new Color4 object
  6138. */
  6139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6140. /**
  6141. * Creates a new Color4 from the starting index element of the given array
  6142. * @param array defines the source array to read from
  6143. * @param offset defines the offset in the source array
  6144. * @param result defines the target Color4 object
  6145. */
  6146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6147. /**
  6148. * Creates a new Color3 from integer values (< 256)
  6149. * @param r defines the red component to read from (value between 0 and 255)
  6150. * @param g defines the green component to read from (value between 0 and 255)
  6151. * @param b defines the blue component to read from (value between 0 and 255)
  6152. * @param a defines the alpha component to read from (value between 0 and 255)
  6153. * @returns a new Color3 object
  6154. */
  6155. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6156. /**
  6157. * Check the content of a given array and convert it to an array containing RGBA data
  6158. * If the original array was already containing count * 4 values then it is returned directly
  6159. * @param colors defines the array to check
  6160. * @param count defines the number of RGBA data to expect
  6161. * @returns an array containing count * 4 values (RGBA)
  6162. */
  6163. static CheckColors4(colors: number[], count: number): number[];
  6164. }
  6165. /**
  6166. * @hidden
  6167. */
  6168. export class TmpColors {
  6169. static Color3: Color3[];
  6170. static Color4: Color4[];
  6171. }
  6172. }
  6173. declare module "babylonjs/Animations/animationKey" {
  6174. /**
  6175. * Defines an interface which represents an animation key frame
  6176. */
  6177. export interface IAnimationKey {
  6178. /**
  6179. * Frame of the key frame
  6180. */
  6181. frame: number;
  6182. /**
  6183. * Value at the specifies key frame
  6184. */
  6185. value: any;
  6186. /**
  6187. * The input tangent for the cubic hermite spline
  6188. */
  6189. inTangent?: any;
  6190. /**
  6191. * The output tangent for the cubic hermite spline
  6192. */
  6193. outTangent?: any;
  6194. /**
  6195. * The animation interpolation type
  6196. */
  6197. interpolation?: AnimationKeyInterpolation;
  6198. }
  6199. /**
  6200. * Enum for the animation key frame interpolation type
  6201. */
  6202. export enum AnimationKeyInterpolation {
  6203. /**
  6204. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6205. */
  6206. STEP = 1
  6207. }
  6208. }
  6209. declare module "babylonjs/Animations/animationRange" {
  6210. /**
  6211. * Represents the range of an animation
  6212. */
  6213. export class AnimationRange {
  6214. /**The name of the animation range**/
  6215. name: string;
  6216. /**The starting frame of the animation */
  6217. from: number;
  6218. /**The ending frame of the animation*/
  6219. to: number;
  6220. /**
  6221. * Initializes the range of an animation
  6222. * @param name The name of the animation range
  6223. * @param from The starting frame of the animation
  6224. * @param to The ending frame of the animation
  6225. */
  6226. constructor(
  6227. /**The name of the animation range**/
  6228. name: string,
  6229. /**The starting frame of the animation */
  6230. from: number,
  6231. /**The ending frame of the animation*/
  6232. to: number);
  6233. /**
  6234. * Makes a copy of the animation range
  6235. * @returns A copy of the animation range
  6236. */
  6237. clone(): AnimationRange;
  6238. }
  6239. }
  6240. declare module "babylonjs/Animations/animationEvent" {
  6241. /**
  6242. * Composed of a frame, and an action function
  6243. */
  6244. export class AnimationEvent {
  6245. /** The frame for which the event is triggered **/
  6246. frame: number;
  6247. /** The event to perform when triggered **/
  6248. action: (currentFrame: number) => void;
  6249. /** Specifies if the event should be triggered only once**/
  6250. onlyOnce?: boolean | undefined;
  6251. /**
  6252. * Specifies if the animation event is done
  6253. */
  6254. isDone: boolean;
  6255. /**
  6256. * Initializes the animation event
  6257. * @param frame The frame for which the event is triggered
  6258. * @param action The event to perform when triggered
  6259. * @param onlyOnce Specifies if the event should be triggered only once
  6260. */
  6261. constructor(
  6262. /** The frame for which the event is triggered **/
  6263. frame: number,
  6264. /** The event to perform when triggered **/
  6265. action: (currentFrame: number) => void,
  6266. /** Specifies if the event should be triggered only once**/
  6267. onlyOnce?: boolean | undefined);
  6268. /** @hidden */
  6269. _clone(): AnimationEvent;
  6270. }
  6271. }
  6272. declare module "babylonjs/Behaviors/behavior" {
  6273. import { Nullable } from "babylonjs/types";
  6274. /**
  6275. * Interface used to define a behavior
  6276. */
  6277. export interface Behavior<T> {
  6278. /** gets or sets behavior's name */
  6279. name: string;
  6280. /**
  6281. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6282. */
  6283. init(): void;
  6284. /**
  6285. * Called when the behavior is attached to a target
  6286. * @param target defines the target where the behavior is attached to
  6287. */
  6288. attach(target: T): void;
  6289. /**
  6290. * Called when the behavior is detached from its target
  6291. */
  6292. detach(): void;
  6293. }
  6294. /**
  6295. * Interface implemented by classes supporting behaviors
  6296. */
  6297. export interface IBehaviorAware<T> {
  6298. /**
  6299. * Attach a behavior
  6300. * @param behavior defines the behavior to attach
  6301. * @returns the current host
  6302. */
  6303. addBehavior(behavior: Behavior<T>): T;
  6304. /**
  6305. * Remove a behavior from the current object
  6306. * @param behavior defines the behavior to detach
  6307. * @returns the current host
  6308. */
  6309. removeBehavior(behavior: Behavior<T>): T;
  6310. /**
  6311. * Gets a behavior using its name to search
  6312. * @param name defines the name to search
  6313. * @returns the behavior or null if not found
  6314. */
  6315. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6316. }
  6317. }
  6318. declare module "babylonjs/Misc/smartArray" {
  6319. /**
  6320. * Defines an array and its length.
  6321. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6322. */
  6323. export interface ISmartArrayLike<T> {
  6324. /**
  6325. * The data of the array.
  6326. */
  6327. data: Array<T>;
  6328. /**
  6329. * The active length of the array.
  6330. */
  6331. length: number;
  6332. }
  6333. /**
  6334. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6335. */
  6336. export class SmartArray<T> implements ISmartArrayLike<T> {
  6337. /**
  6338. * The full set of data from the array.
  6339. */
  6340. data: Array<T>;
  6341. /**
  6342. * The active length of the array.
  6343. */
  6344. length: number;
  6345. protected _id: number;
  6346. /**
  6347. * Instantiates a Smart Array.
  6348. * @param capacity defines the default capacity of the array.
  6349. */
  6350. constructor(capacity: number);
  6351. /**
  6352. * Pushes a value at the end of the active data.
  6353. * @param value defines the object to push in the array.
  6354. */
  6355. push(value: T): void;
  6356. /**
  6357. * Iterates over the active data and apply the lambda to them.
  6358. * @param func defines the action to apply on each value.
  6359. */
  6360. forEach(func: (content: T) => void): void;
  6361. /**
  6362. * Sorts the full sets of data.
  6363. * @param compareFn defines the comparison function to apply.
  6364. */
  6365. sort(compareFn: (a: T, b: T) => number): void;
  6366. /**
  6367. * Resets the active data to an empty array.
  6368. */
  6369. reset(): void;
  6370. /**
  6371. * Releases all the data from the array as well as the array.
  6372. */
  6373. dispose(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * @param array defines the data to concatenate with.
  6377. */
  6378. concat(array: any): void;
  6379. /**
  6380. * Returns the position of a value in the active data.
  6381. * @param value defines the value to find the index for
  6382. * @returns the index if found in the active data otherwise -1
  6383. */
  6384. indexOf(value: T): number;
  6385. /**
  6386. * Returns whether an element is part of the active data.
  6387. * @param value defines the value to look for
  6388. * @returns true if found in the active data otherwise false
  6389. */
  6390. contains(value: T): boolean;
  6391. private static _GlobalId;
  6392. }
  6393. /**
  6394. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6395. * The data in this array can only be present once
  6396. */
  6397. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6398. private _duplicateId;
  6399. /**
  6400. * Pushes a value at the end of the active data.
  6401. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6402. * @param value defines the object to push in the array.
  6403. */
  6404. push(value: T): void;
  6405. /**
  6406. * Pushes a value at the end of the active data.
  6407. * If the data is already present, it won t be added again
  6408. * @param value defines the object to push in the array.
  6409. * @returns true if added false if it was already present
  6410. */
  6411. pushNoDuplicate(value: T): boolean;
  6412. /**
  6413. * Resets the active data to an empty array.
  6414. */
  6415. reset(): void;
  6416. /**
  6417. * Concats the active data with a given array.
  6418. * This ensures no dupplicate will be present in the result.
  6419. * @param array defines the data to concatenate with.
  6420. */
  6421. concatWithNoDuplicate(array: any): void;
  6422. }
  6423. }
  6424. declare module "babylonjs/Cameras/cameraInputsManager" {
  6425. import { Nullable } from "babylonjs/types";
  6426. import { Camera } from "babylonjs/Cameras/camera";
  6427. /**
  6428. * @ignore
  6429. * This is a list of all the different input types that are available in the application.
  6430. * Fo instance: ArcRotateCameraGamepadInput...
  6431. */
  6432. export var CameraInputTypes: {};
  6433. /**
  6434. * This is the contract to implement in order to create a new input class.
  6435. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6436. */
  6437. export interface ICameraInput<TCamera extends Camera> {
  6438. /**
  6439. * Defines the camera the input is attached to.
  6440. */
  6441. camera: Nullable<TCamera>;
  6442. /**
  6443. * Gets the class name of the current intput.
  6444. * @returns the class name
  6445. */
  6446. getClassName(): string;
  6447. /**
  6448. * Get the friendly name associated with the input class.
  6449. * @returns the input friendly name
  6450. */
  6451. getSimpleName(): string;
  6452. /**
  6453. * Attach the input controls to a specific dom element to get the input from.
  6454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6455. */
  6456. attachControl(noPreventDefault?: boolean): void;
  6457. /**
  6458. * Detach the current controls from the specified dom element.
  6459. */
  6460. detachControl(): void;
  6461. /**
  6462. * Update the current camera state depending on the inputs that have been used this frame.
  6463. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6464. */
  6465. checkInputs?: () => void;
  6466. }
  6467. /**
  6468. * Represents a map of input types to input instance or input index to input instance.
  6469. */
  6470. export interface CameraInputsMap<TCamera extends Camera> {
  6471. /**
  6472. * Accessor to the input by input type.
  6473. */
  6474. [name: string]: ICameraInput<TCamera>;
  6475. /**
  6476. * Accessor to the input by input index.
  6477. */
  6478. [idx: number]: ICameraInput<TCamera>;
  6479. }
  6480. /**
  6481. * This represents the input manager used within a camera.
  6482. * It helps dealing with all the different kind of input attached to a camera.
  6483. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6484. */
  6485. export class CameraInputsManager<TCamera extends Camera> {
  6486. /**
  6487. * Defines the list of inputs attahed to the camera.
  6488. */
  6489. attached: CameraInputsMap<TCamera>;
  6490. /**
  6491. * Defines the dom element the camera is collecting inputs from.
  6492. * This is null if the controls have not been attached.
  6493. */
  6494. attachedToElement: boolean;
  6495. /**
  6496. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6497. */
  6498. noPreventDefault: boolean;
  6499. /**
  6500. * Defined the camera the input manager belongs to.
  6501. */
  6502. camera: TCamera;
  6503. /**
  6504. * Update the current camera state depending on the inputs that have been used this frame.
  6505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6506. */
  6507. checkInputs: () => void;
  6508. /**
  6509. * Instantiate a new Camera Input Manager.
  6510. * @param camera Defines the camera the input manager blongs to
  6511. */
  6512. constructor(camera: TCamera);
  6513. /**
  6514. * Add an input method to a camera
  6515. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6516. * @param input camera input method
  6517. */
  6518. add(input: ICameraInput<TCamera>): void;
  6519. /**
  6520. * Remove a specific input method from a camera
  6521. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6522. * @param inputToRemove camera input method
  6523. */
  6524. remove(inputToRemove: ICameraInput<TCamera>): void;
  6525. /**
  6526. * Remove a specific input type from a camera
  6527. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6528. * @param inputType the type of the input to remove
  6529. */
  6530. removeByType(inputType: string): void;
  6531. private _addCheckInputs;
  6532. /**
  6533. * Attach the input controls to the currently attached dom element to listen the events from.
  6534. * @param input Defines the input to attach
  6535. */
  6536. attachInput(input: ICameraInput<TCamera>): void;
  6537. /**
  6538. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6539. * @param element Defines the dom element to collect the events from
  6540. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6541. */
  6542. attachElement(noPreventDefault?: boolean): void;
  6543. /**
  6544. * Detach the current manager inputs controls from a specific dom element.
  6545. * @param element Defines the dom element to collect the events from
  6546. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6547. */
  6548. detachElement(disconnect?: boolean): void;
  6549. /**
  6550. * Rebuild the dynamic inputCheck function from the current list of
  6551. * defined inputs in the manager.
  6552. */
  6553. rebuildInputCheck(): void;
  6554. /**
  6555. * Remove all attached input methods from a camera
  6556. */
  6557. clear(): void;
  6558. /**
  6559. * Serialize the current input manager attached to a camera.
  6560. * This ensures than once parsed,
  6561. * the input associated to the camera will be identical to the current ones
  6562. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6563. */
  6564. serialize(serializedCamera: any): void;
  6565. /**
  6566. * Parses an input manager serialized JSON to restore the previous list of inputs
  6567. * and states associated to a camera.
  6568. * @param parsedCamera Defines the JSON to parse
  6569. */
  6570. parse(parsedCamera: any): void;
  6571. }
  6572. }
  6573. declare module "babylonjs/Meshes/buffer" {
  6574. import { Nullable, DataArray } from "babylonjs/types";
  6575. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6576. /**
  6577. * Class used to store data that will be store in GPU memory
  6578. */
  6579. export class Buffer {
  6580. private _engine;
  6581. private _buffer;
  6582. /** @hidden */
  6583. _data: Nullable<DataArray>;
  6584. private _updatable;
  6585. private _instanced;
  6586. private _divisor;
  6587. /**
  6588. * Gets the byte stride.
  6589. */
  6590. readonly byteStride: number;
  6591. /**
  6592. * Constructor
  6593. * @param engine the engine
  6594. * @param data the data to use for this buffer
  6595. * @param updatable whether the data is updatable
  6596. * @param stride the stride (optional)
  6597. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6598. * @param instanced whether the buffer is instanced (optional)
  6599. * @param useBytes set to true if the stride in in bytes (optional)
  6600. * @param divisor sets an optional divisor for instances (1 by default)
  6601. */
  6602. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6603. /**
  6604. * Create a new VertexBuffer based on the current buffer
  6605. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6606. * @param offset defines offset in the buffer (0 by default)
  6607. * @param size defines the size in floats of attributes (position is 3 for instance)
  6608. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6609. * @param instanced defines if the vertex buffer contains indexed data
  6610. * @param useBytes defines if the offset and stride are in bytes *
  6611. * @param divisor sets an optional divisor for instances (1 by default)
  6612. * @returns the new vertex buffer
  6613. */
  6614. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6615. /**
  6616. * Gets a boolean indicating if the Buffer is updatable?
  6617. * @returns true if the buffer is updatable
  6618. */
  6619. isUpdatable(): boolean;
  6620. /**
  6621. * Gets current buffer's data
  6622. * @returns a DataArray or null
  6623. */
  6624. getData(): Nullable<DataArray>;
  6625. /**
  6626. * Gets underlying native buffer
  6627. * @returns underlying native buffer
  6628. */
  6629. getBuffer(): Nullable<DataBuffer>;
  6630. /**
  6631. * Gets the stride in float32 units (i.e. byte stride / 4).
  6632. * May not be an integer if the byte stride is not divisible by 4.
  6633. * @returns the stride in float32 units
  6634. * @deprecated Please use byteStride instead.
  6635. */
  6636. getStrideSize(): number;
  6637. /**
  6638. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6639. * @param data defines the data to store
  6640. */
  6641. create(data?: Nullable<DataArray>): void;
  6642. /** @hidden */
  6643. _rebuild(): void;
  6644. /**
  6645. * Update current buffer data
  6646. * @param data defines the data to store
  6647. */
  6648. update(data: DataArray): void;
  6649. /**
  6650. * Updates the data directly.
  6651. * @param data the new data
  6652. * @param offset the new offset
  6653. * @param vertexCount the vertex count (optional)
  6654. * @param useBytes set to true if the offset is in bytes
  6655. */
  6656. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6657. /**
  6658. * Release all resources
  6659. */
  6660. dispose(): void;
  6661. }
  6662. /**
  6663. * Specialized buffer used to store vertex data
  6664. */
  6665. export class VertexBuffer {
  6666. /** @hidden */
  6667. _buffer: Buffer;
  6668. private _kind;
  6669. private _size;
  6670. private _ownsBuffer;
  6671. private _instanced;
  6672. private _instanceDivisor;
  6673. /**
  6674. * The byte type.
  6675. */
  6676. static readonly BYTE: number;
  6677. /**
  6678. * The unsigned byte type.
  6679. */
  6680. static readonly UNSIGNED_BYTE: number;
  6681. /**
  6682. * The short type.
  6683. */
  6684. static readonly SHORT: number;
  6685. /**
  6686. * The unsigned short type.
  6687. */
  6688. static readonly UNSIGNED_SHORT: number;
  6689. /**
  6690. * The integer type.
  6691. */
  6692. static readonly INT: number;
  6693. /**
  6694. * The unsigned integer type.
  6695. */
  6696. static readonly UNSIGNED_INT: number;
  6697. /**
  6698. * The float type.
  6699. */
  6700. static readonly FLOAT: number;
  6701. /**
  6702. * Gets or sets the instance divisor when in instanced mode
  6703. */
  6704. get instanceDivisor(): number;
  6705. set instanceDivisor(value: number);
  6706. /**
  6707. * Gets the byte stride.
  6708. */
  6709. readonly byteStride: number;
  6710. /**
  6711. * Gets the byte offset.
  6712. */
  6713. readonly byteOffset: number;
  6714. /**
  6715. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6716. */
  6717. readonly normalized: boolean;
  6718. /**
  6719. * Gets the data type of each component in the array.
  6720. */
  6721. readonly type: number;
  6722. /**
  6723. * Constructor
  6724. * @param engine the engine
  6725. * @param data the data to use for this vertex buffer
  6726. * @param kind the vertex buffer kind
  6727. * @param updatable whether the data is updatable
  6728. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6729. * @param stride the stride (optional)
  6730. * @param instanced whether the buffer is instanced (optional)
  6731. * @param offset the offset of the data (optional)
  6732. * @param size the number of components (optional)
  6733. * @param type the type of the component (optional)
  6734. * @param normalized whether the data contains normalized data (optional)
  6735. * @param useBytes set to true if stride and offset are in bytes (optional)
  6736. * @param divisor defines the instance divisor to use (1 by default)
  6737. */
  6738. 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);
  6739. /** @hidden */
  6740. _rebuild(): void;
  6741. /**
  6742. * Returns the kind of the VertexBuffer (string)
  6743. * @returns a string
  6744. */
  6745. getKind(): string;
  6746. /**
  6747. * Gets a boolean indicating if the VertexBuffer is updatable?
  6748. * @returns true if the buffer is updatable
  6749. */
  6750. isUpdatable(): boolean;
  6751. /**
  6752. * Gets current buffer's data
  6753. * @returns a DataArray or null
  6754. */
  6755. getData(): Nullable<DataArray>;
  6756. /**
  6757. * Gets underlying native buffer
  6758. * @returns underlying native buffer
  6759. */
  6760. getBuffer(): Nullable<DataBuffer>;
  6761. /**
  6762. * Gets the stride in float32 units (i.e. byte stride / 4).
  6763. * May not be an integer if the byte stride is not divisible by 4.
  6764. * @returns the stride in float32 units
  6765. * @deprecated Please use byteStride instead.
  6766. */
  6767. getStrideSize(): number;
  6768. /**
  6769. * Returns the offset as a multiple of the type byte length.
  6770. * @returns the offset in bytes
  6771. * @deprecated Please use byteOffset instead.
  6772. */
  6773. getOffset(): number;
  6774. /**
  6775. * Returns the number of components per vertex attribute (integer)
  6776. * @returns the size in float
  6777. */
  6778. getSize(): number;
  6779. /**
  6780. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6781. * @returns true if this buffer is instanced
  6782. */
  6783. getIsInstanced(): boolean;
  6784. /**
  6785. * Returns the instancing divisor, zero for non-instanced (integer).
  6786. * @returns a number
  6787. */
  6788. getInstanceDivisor(): number;
  6789. /**
  6790. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6791. * @param data defines the data to store
  6792. */
  6793. create(data?: DataArray): void;
  6794. /**
  6795. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6796. * This function will create a new buffer if the current one is not updatable
  6797. * @param data defines the data to store
  6798. */
  6799. update(data: DataArray): void;
  6800. /**
  6801. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6802. * Returns the directly updated WebGLBuffer.
  6803. * @param data the new data
  6804. * @param offset the new offset
  6805. * @param useBytes set to true if the offset is in bytes
  6806. */
  6807. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6808. /**
  6809. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6810. */
  6811. dispose(): void;
  6812. /**
  6813. * Enumerates each value of this vertex buffer as numbers.
  6814. * @param count the number of values to enumerate
  6815. * @param callback the callback function called for each value
  6816. */
  6817. forEach(count: number, callback: (value: number, index: number) => void): void;
  6818. /**
  6819. * Positions
  6820. */
  6821. static readonly PositionKind: string;
  6822. /**
  6823. * Normals
  6824. */
  6825. static readonly NormalKind: string;
  6826. /**
  6827. * Tangents
  6828. */
  6829. static readonly TangentKind: string;
  6830. /**
  6831. * Texture coordinates
  6832. */
  6833. static readonly UVKind: string;
  6834. /**
  6835. * Texture coordinates 2
  6836. */
  6837. static readonly UV2Kind: string;
  6838. /**
  6839. * Texture coordinates 3
  6840. */
  6841. static readonly UV3Kind: string;
  6842. /**
  6843. * Texture coordinates 4
  6844. */
  6845. static readonly UV4Kind: string;
  6846. /**
  6847. * Texture coordinates 5
  6848. */
  6849. static readonly UV5Kind: string;
  6850. /**
  6851. * Texture coordinates 6
  6852. */
  6853. static readonly UV6Kind: string;
  6854. /**
  6855. * Colors
  6856. */
  6857. static readonly ColorKind: string;
  6858. /**
  6859. * Matrix indices (for bones)
  6860. */
  6861. static readonly MatricesIndicesKind: string;
  6862. /**
  6863. * Matrix weights (for bones)
  6864. */
  6865. static readonly MatricesWeightsKind: string;
  6866. /**
  6867. * Additional matrix indices (for bones)
  6868. */
  6869. static readonly MatricesIndicesExtraKind: string;
  6870. /**
  6871. * Additional matrix weights (for bones)
  6872. */
  6873. static readonly MatricesWeightsExtraKind: string;
  6874. /**
  6875. * Deduces the stride given a kind.
  6876. * @param kind The kind string to deduce
  6877. * @returns The deduced stride
  6878. */
  6879. static DeduceStride(kind: string): number;
  6880. /**
  6881. * Gets the byte length of the given type.
  6882. * @param type the type
  6883. * @returns the number of bytes
  6884. */
  6885. static GetTypeByteLength(type: number): number;
  6886. /**
  6887. * Enumerates each value of the given parameters as numbers.
  6888. * @param data the data to enumerate
  6889. * @param byteOffset the byte offset of the data
  6890. * @param byteStride the byte stride of the data
  6891. * @param componentCount the number of components per element
  6892. * @param componentType the type of the component
  6893. * @param count the number of values to enumerate
  6894. * @param normalized whether the data is normalized
  6895. * @param callback the callback function called for each value
  6896. */
  6897. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6898. private static _GetFloatValue;
  6899. }
  6900. }
  6901. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6902. import { Vector3 } from "babylonjs/Maths/math.vector";
  6903. import { Mesh } from "babylonjs/Meshes/mesh";
  6904. /**
  6905. * The options Interface for creating a Capsule Mesh
  6906. */
  6907. export interface ICreateCapsuleOptions {
  6908. /** The Orientation of the capsule. Default : Vector3.Up() */
  6909. orientation?: Vector3;
  6910. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6911. subdivisions: number;
  6912. /** Number of cylindrical segments on the capsule. */
  6913. tessellation: number;
  6914. /** Height or Length of the capsule. */
  6915. height: number;
  6916. /** Radius of the capsule. */
  6917. radius: number;
  6918. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6919. capSubdivisions: number;
  6920. /** Overwrite for the top radius. */
  6921. radiusTop?: number;
  6922. /** Overwrite for the bottom radius. */
  6923. radiusBottom?: number;
  6924. /** Overwrite for the top capSubdivisions. */
  6925. topCapSubdivisions?: number;
  6926. /** Overwrite for the bottom capSubdivisions. */
  6927. bottomCapSubdivisions?: number;
  6928. }
  6929. /**
  6930. * Class containing static functions to help procedurally build meshes
  6931. */
  6932. export class CapsuleBuilder {
  6933. /**
  6934. * Creates a capsule or a pill mesh
  6935. * @param name defines the name of the mesh
  6936. * @param options The constructors options.
  6937. * @param scene The scene the mesh is scoped to.
  6938. * @returns Capsule Mesh
  6939. */
  6940. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6941. }
  6942. }
  6943. declare module "babylonjs/Collisions/intersectionInfo" {
  6944. import { Nullable } from "babylonjs/types";
  6945. /**
  6946. * @hidden
  6947. */
  6948. export class IntersectionInfo {
  6949. bu: Nullable<number>;
  6950. bv: Nullable<number>;
  6951. distance: number;
  6952. faceId: number;
  6953. subMeshId: number;
  6954. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6955. }
  6956. }
  6957. declare module "babylonjs/Culling/boundingSphere" {
  6958. import { DeepImmutable } from "babylonjs/types";
  6959. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6960. import { Plane } from "babylonjs/Maths/math.plane";
  6961. /**
  6962. * Class used to store bounding sphere information
  6963. */
  6964. export class BoundingSphere {
  6965. /**
  6966. * Gets the center of the bounding sphere in local space
  6967. */
  6968. readonly center: Vector3;
  6969. /**
  6970. * Radius of the bounding sphere in local space
  6971. */
  6972. radius: number;
  6973. /**
  6974. * Gets the center of the bounding sphere in world space
  6975. */
  6976. readonly centerWorld: Vector3;
  6977. /**
  6978. * Radius of the bounding sphere in world space
  6979. */
  6980. radiusWorld: number;
  6981. /**
  6982. * Gets the minimum vector in local space
  6983. */
  6984. readonly minimum: Vector3;
  6985. /**
  6986. * Gets the maximum vector in local space
  6987. */
  6988. readonly maximum: Vector3;
  6989. private _worldMatrix;
  6990. private static readonly TmpVector3;
  6991. /**
  6992. * Creates a new bounding sphere
  6993. * @param min defines the minimum vector (in local space)
  6994. * @param max defines the maximum vector (in local space)
  6995. * @param worldMatrix defines the new world matrix
  6996. */
  6997. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6998. /**
  6999. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7000. * @param min defines the new minimum vector (in local space)
  7001. * @param max defines the new maximum vector (in local space)
  7002. * @param worldMatrix defines the new world matrix
  7003. */
  7004. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7005. /**
  7006. * Scale the current bounding sphere by applying a scale factor
  7007. * @param factor defines the scale factor to apply
  7008. * @returns the current bounding box
  7009. */
  7010. scale(factor: number): BoundingSphere;
  7011. /**
  7012. * Gets the world matrix of the bounding box
  7013. * @returns a matrix
  7014. */
  7015. getWorldMatrix(): DeepImmutable<Matrix>;
  7016. /** @hidden */
  7017. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7018. /**
  7019. * Tests if the bounding sphere is intersecting the frustum planes
  7020. * @param frustumPlanes defines the frustum planes to test
  7021. * @returns true if there is an intersection
  7022. */
  7023. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7024. /**
  7025. * Tests if the bounding sphere center is in between the frustum planes.
  7026. * Used for optimistic fast inclusion.
  7027. * @param frustumPlanes defines the frustum planes to test
  7028. * @returns true if the sphere center is in between the frustum planes
  7029. */
  7030. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7031. /**
  7032. * Tests if a point is inside the bounding sphere
  7033. * @param point defines the point to test
  7034. * @returns true if the point is inside the bounding sphere
  7035. */
  7036. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7037. /**
  7038. * Checks if two sphere intersct
  7039. * @param sphere0 sphere 0
  7040. * @param sphere1 sphere 1
  7041. * @returns true if the speres intersect
  7042. */
  7043. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7044. }
  7045. }
  7046. declare module "babylonjs/Culling/boundingBox" {
  7047. import { DeepImmutable } from "babylonjs/types";
  7048. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7049. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7050. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7051. import { Plane } from "babylonjs/Maths/math.plane";
  7052. /**
  7053. * Class used to store bounding box information
  7054. */
  7055. export class BoundingBox implements ICullable {
  7056. /**
  7057. * Gets the 8 vectors representing the bounding box in local space
  7058. */
  7059. readonly vectors: Vector3[];
  7060. /**
  7061. * Gets the center of the bounding box in local space
  7062. */
  7063. readonly center: Vector3;
  7064. /**
  7065. * Gets the center of the bounding box in world space
  7066. */
  7067. readonly centerWorld: Vector3;
  7068. /**
  7069. * Gets the extend size in local space
  7070. */
  7071. readonly extendSize: Vector3;
  7072. /**
  7073. * Gets the extend size in world space
  7074. */
  7075. readonly extendSizeWorld: Vector3;
  7076. /**
  7077. * Gets the OBB (object bounding box) directions
  7078. */
  7079. readonly directions: Vector3[];
  7080. /**
  7081. * Gets the 8 vectors representing the bounding box in world space
  7082. */
  7083. readonly vectorsWorld: Vector3[];
  7084. /**
  7085. * Gets the minimum vector in world space
  7086. */
  7087. readonly minimumWorld: Vector3;
  7088. /**
  7089. * Gets the maximum vector in world space
  7090. */
  7091. readonly maximumWorld: Vector3;
  7092. /**
  7093. * Gets the minimum vector in local space
  7094. */
  7095. readonly minimum: Vector3;
  7096. /**
  7097. * Gets the maximum vector in local space
  7098. */
  7099. readonly maximum: Vector3;
  7100. private _worldMatrix;
  7101. private static readonly TmpVector3;
  7102. /**
  7103. * @hidden
  7104. */
  7105. _tag: number;
  7106. /**
  7107. * Creates a new bounding box
  7108. * @param min defines the minimum vector (in local space)
  7109. * @param max defines the maximum vector (in local space)
  7110. * @param worldMatrix defines the new world matrix
  7111. */
  7112. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7113. /**
  7114. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7115. * @param min defines the new minimum vector (in local space)
  7116. * @param max defines the new maximum vector (in local space)
  7117. * @param worldMatrix defines the new world matrix
  7118. */
  7119. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7120. /**
  7121. * Scale the current bounding box by applying a scale factor
  7122. * @param factor defines the scale factor to apply
  7123. * @returns the current bounding box
  7124. */
  7125. scale(factor: number): BoundingBox;
  7126. /**
  7127. * Gets the world matrix of the bounding box
  7128. * @returns a matrix
  7129. */
  7130. getWorldMatrix(): DeepImmutable<Matrix>;
  7131. /** @hidden */
  7132. _update(world: DeepImmutable<Matrix>): void;
  7133. /**
  7134. * Tests if the bounding box is intersecting the frustum planes
  7135. * @param frustumPlanes defines the frustum planes to test
  7136. * @returns true if there is an intersection
  7137. */
  7138. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7139. /**
  7140. * Tests if the bounding box is entirely inside the frustum planes
  7141. * @param frustumPlanes defines the frustum planes to test
  7142. * @returns true if there is an inclusion
  7143. */
  7144. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7145. /**
  7146. * Tests if a point is inside the bounding box
  7147. * @param point defines the point to test
  7148. * @returns true if the point is inside the bounding box
  7149. */
  7150. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7151. /**
  7152. * Tests if the bounding box intersects with a bounding sphere
  7153. * @param sphere defines the sphere to test
  7154. * @returns true if there is an intersection
  7155. */
  7156. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7157. /**
  7158. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7159. * @param min defines the min vector to use
  7160. * @param max defines the max vector to use
  7161. * @returns true if there is an intersection
  7162. */
  7163. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7164. /**
  7165. * Tests if two bounding boxes are intersections
  7166. * @param box0 defines the first box to test
  7167. * @param box1 defines the second box to test
  7168. * @returns true if there is an intersection
  7169. */
  7170. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7171. /**
  7172. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7173. * @param minPoint defines the minimum vector of the bounding box
  7174. * @param maxPoint defines the maximum vector of the bounding box
  7175. * @param sphereCenter defines the sphere center
  7176. * @param sphereRadius defines the sphere radius
  7177. * @returns true if there is an intersection
  7178. */
  7179. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7180. /**
  7181. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7182. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7183. * @param frustumPlanes defines the frustum planes to test
  7184. * @return true if there is an inclusion
  7185. */
  7186. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7187. /**
  7188. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7189. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7190. * @param frustumPlanes defines the frustum planes to test
  7191. * @return true if there is an intersection
  7192. */
  7193. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7194. }
  7195. }
  7196. declare module "babylonjs/Collisions/collider" {
  7197. import { Nullable, IndicesArray } from "babylonjs/types";
  7198. import { Vector3 } from "babylonjs/Maths/math.vector";
  7199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7200. import { Plane } from "babylonjs/Maths/math.plane";
  7201. /** @hidden */
  7202. export class Collider {
  7203. /** Define if a collision was found */
  7204. collisionFound: boolean;
  7205. /**
  7206. * Define last intersection point in local space
  7207. */
  7208. intersectionPoint: Vector3;
  7209. /**
  7210. * Define last collided mesh
  7211. */
  7212. collidedMesh: Nullable<AbstractMesh>;
  7213. private _collisionPoint;
  7214. private _planeIntersectionPoint;
  7215. private _tempVector;
  7216. private _tempVector2;
  7217. private _tempVector3;
  7218. private _tempVector4;
  7219. private _edge;
  7220. private _baseToVertex;
  7221. private _destinationPoint;
  7222. private _slidePlaneNormal;
  7223. private _displacementVector;
  7224. /** @hidden */
  7225. _radius: Vector3;
  7226. /** @hidden */
  7227. _retry: number;
  7228. private _velocity;
  7229. private _basePoint;
  7230. private _epsilon;
  7231. /** @hidden */
  7232. _velocityWorldLength: number;
  7233. /** @hidden */
  7234. _basePointWorld: Vector3;
  7235. private _velocityWorld;
  7236. private _normalizedVelocity;
  7237. /** @hidden */
  7238. _initialVelocity: Vector3;
  7239. /** @hidden */
  7240. _initialPosition: Vector3;
  7241. private _nearestDistance;
  7242. private _collisionMask;
  7243. get collisionMask(): number;
  7244. set collisionMask(mask: number);
  7245. /**
  7246. * Gets the plane normal used to compute the sliding response (in local space)
  7247. */
  7248. get slidePlaneNormal(): Vector3;
  7249. /** @hidden */
  7250. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7251. /** @hidden */
  7252. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7253. /** @hidden */
  7254. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7255. /** @hidden */
  7256. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7257. /** @hidden */
  7258. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7259. /** @hidden */
  7260. _getResponse(pos: Vector3, vel: Vector3): void;
  7261. }
  7262. }
  7263. declare module "babylonjs/Culling/boundingInfo" {
  7264. import { DeepImmutable } from "babylonjs/types";
  7265. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7266. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7267. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7268. import { Plane } from "babylonjs/Maths/math.plane";
  7269. import { Collider } from "babylonjs/Collisions/collider";
  7270. /**
  7271. * Interface for cullable objects
  7272. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7273. */
  7274. export interface ICullable {
  7275. /**
  7276. * Checks if the object or part of the object is in the frustum
  7277. * @param frustumPlanes Camera near/planes
  7278. * @returns true if the object is in frustum otherwise false
  7279. */
  7280. isInFrustum(frustumPlanes: Plane[]): boolean;
  7281. /**
  7282. * Checks if a cullable object (mesh...) is in the camera frustum
  7283. * Unlike isInFrustum this cheks the full bounding box
  7284. * @param frustumPlanes Camera near/planes
  7285. * @returns true if the object is in frustum otherwise false
  7286. */
  7287. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7288. }
  7289. /**
  7290. * Info for a bounding data of a mesh
  7291. */
  7292. export class BoundingInfo implements ICullable {
  7293. /**
  7294. * Bounding box for the mesh
  7295. */
  7296. readonly boundingBox: BoundingBox;
  7297. /**
  7298. * Bounding sphere for the mesh
  7299. */
  7300. readonly boundingSphere: BoundingSphere;
  7301. private _isLocked;
  7302. private static readonly TmpVector3;
  7303. /**
  7304. * Constructs bounding info
  7305. * @param minimum min vector of the bounding box/sphere
  7306. * @param maximum max vector of the bounding box/sphere
  7307. * @param worldMatrix defines the new world matrix
  7308. */
  7309. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7310. /**
  7311. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7312. * @param min defines the new minimum vector (in local space)
  7313. * @param max defines the new maximum vector (in local space)
  7314. * @param worldMatrix defines the new world matrix
  7315. */
  7316. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7317. /**
  7318. * min vector of the bounding box/sphere
  7319. */
  7320. get minimum(): Vector3;
  7321. /**
  7322. * max vector of the bounding box/sphere
  7323. */
  7324. get maximum(): Vector3;
  7325. /**
  7326. * If the info is locked and won't be updated to avoid perf overhead
  7327. */
  7328. get isLocked(): boolean;
  7329. set isLocked(value: boolean);
  7330. /**
  7331. * Updates the bounding sphere and box
  7332. * @param world world matrix to be used to update
  7333. */
  7334. update(world: DeepImmutable<Matrix>): void;
  7335. /**
  7336. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7337. * @param center New center of the bounding info
  7338. * @param extend New extend of the bounding info
  7339. * @returns the current bounding info
  7340. */
  7341. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7342. /**
  7343. * Scale the current bounding info by applying a scale factor
  7344. * @param factor defines the scale factor to apply
  7345. * @returns the current bounding info
  7346. */
  7347. scale(factor: number): BoundingInfo;
  7348. /**
  7349. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7350. * @param frustumPlanes defines the frustum to test
  7351. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7352. * @returns true if the bounding info is in the frustum planes
  7353. */
  7354. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7355. /**
  7356. * Gets the world distance between the min and max points of the bounding box
  7357. */
  7358. get diagonalLength(): number;
  7359. /**
  7360. * Checks if a cullable object (mesh...) is in the camera frustum
  7361. * Unlike isInFrustum this cheks the full bounding box
  7362. * @param frustumPlanes Camera near/planes
  7363. * @returns true if the object is in frustum otherwise false
  7364. */
  7365. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7366. /** @hidden */
  7367. _checkCollision(collider: Collider): boolean;
  7368. /**
  7369. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7370. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7371. * @param point the point to check intersection with
  7372. * @returns if the point intersects
  7373. */
  7374. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7375. /**
  7376. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7377. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7378. * @param boundingInfo the bounding info to check intersection with
  7379. * @param precise if the intersection should be done using OBB
  7380. * @returns if the bounding info intersects
  7381. */
  7382. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7383. }
  7384. }
  7385. declare module "babylonjs/Maths/math.functions" {
  7386. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7387. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7388. /**
  7389. * Extracts minimum and maximum values from a list of indexed positions
  7390. * @param positions defines the positions to use
  7391. * @param indices defines the indices to the positions
  7392. * @param indexStart defines the start index
  7393. * @param indexCount defines the end index
  7394. * @param bias defines bias value to add to the result
  7395. * @return minimum and maximum values
  7396. */
  7397. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7398. minimum: Vector3;
  7399. maximum: Vector3;
  7400. };
  7401. /**
  7402. * Extracts minimum and maximum values from a list of positions
  7403. * @param positions defines the positions to use
  7404. * @param start defines the start index in the positions array
  7405. * @param count defines the number of positions to handle
  7406. * @param bias defines bias value to add to the result
  7407. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7408. * @return minimum and maximum values
  7409. */
  7410. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7411. minimum: Vector3;
  7412. maximum: Vector3;
  7413. };
  7414. }
  7415. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7416. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7417. /** @hidden */
  7418. export class WebGLDataBuffer extends DataBuffer {
  7419. private _buffer;
  7420. constructor(resource: WebGLBuffer);
  7421. get underlyingResource(): any;
  7422. }
  7423. }
  7424. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7425. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7426. import { Nullable } from "babylonjs/types";
  7427. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7428. /** @hidden */
  7429. export class WebGLPipelineContext implements IPipelineContext {
  7430. engine: ThinEngine;
  7431. program: Nullable<WebGLProgram>;
  7432. context?: WebGLRenderingContext;
  7433. vertexShader?: WebGLShader;
  7434. fragmentShader?: WebGLShader;
  7435. isParallelCompiled: boolean;
  7436. onCompiled?: () => void;
  7437. transformFeedback?: WebGLTransformFeedback | null;
  7438. vertexCompilationError: Nullable<string>;
  7439. fragmentCompilationError: Nullable<string>;
  7440. programLinkError: Nullable<string>;
  7441. programValidationError: Nullable<string>;
  7442. get isAsync(): boolean;
  7443. get isReady(): boolean;
  7444. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7445. _getVertexShaderCode(): string | null;
  7446. _getFragmentShaderCode(): string | null;
  7447. }
  7448. }
  7449. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7450. import { FloatArray, Nullable } from "babylonjs/types";
  7451. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7452. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7453. module "babylonjs/Engines/thinEngine" {
  7454. interface ThinEngine {
  7455. /**
  7456. * Create an uniform buffer
  7457. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7458. * @param elements defines the content of the uniform buffer
  7459. * @returns the webGL uniform buffer
  7460. */
  7461. createUniformBuffer(elements: FloatArray): DataBuffer;
  7462. /**
  7463. * Create a dynamic uniform buffer
  7464. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7465. * @param elements defines the content of the uniform buffer
  7466. * @returns the webGL uniform buffer
  7467. */
  7468. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7469. /**
  7470. * Update an existing uniform buffer
  7471. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7472. * @param uniformBuffer defines the target uniform buffer
  7473. * @param elements defines the content to update
  7474. * @param offset defines the offset in the uniform buffer where update should start
  7475. * @param count defines the size of the data to update
  7476. */
  7477. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7478. /**
  7479. * Bind an uniform buffer to the current webGL context
  7480. * @param buffer defines the buffer to bind
  7481. */
  7482. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7483. /**
  7484. * Bind a buffer to the current webGL context at a given location
  7485. * @param buffer defines the buffer to bind
  7486. * @param location defines the index where to bind the buffer
  7487. */
  7488. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7489. /**
  7490. * Bind a specific block at a given index in a specific shader program
  7491. * @param pipelineContext defines the pipeline context to use
  7492. * @param blockName defines the block name
  7493. * @param index defines the index where to bind the block
  7494. */
  7495. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7496. }
  7497. }
  7498. }
  7499. declare module "babylonjs/Materials/uniformBuffer" {
  7500. import { Nullable, FloatArray } from "babylonjs/types";
  7501. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7502. import { Engine } from "babylonjs/Engines/engine";
  7503. import { Effect } from "babylonjs/Materials/effect";
  7504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7505. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7506. import { Color3 } from "babylonjs/Maths/math.color";
  7507. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7508. /**
  7509. * Uniform buffer objects.
  7510. *
  7511. * Handles blocks of uniform on the GPU.
  7512. *
  7513. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7514. *
  7515. * For more information, please refer to :
  7516. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7517. */
  7518. export class UniformBuffer {
  7519. private _engine;
  7520. private _buffer;
  7521. private _data;
  7522. private _bufferData;
  7523. private _dynamic?;
  7524. private _uniformLocations;
  7525. private _uniformSizes;
  7526. private _uniformLocationPointer;
  7527. private _needSync;
  7528. private _noUBO;
  7529. private _currentEffect;
  7530. /** @hidden */
  7531. _alreadyBound: boolean;
  7532. private static _MAX_UNIFORM_SIZE;
  7533. private static _tempBuffer;
  7534. /**
  7535. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7536. * This is dynamic to allow compat with webgl 1 and 2.
  7537. * You will need to pass the name of the uniform as well as the value.
  7538. */
  7539. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7540. /**
  7541. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7542. * This is dynamic to allow compat with webgl 1 and 2.
  7543. * You will need to pass the name of the uniform as well as the value.
  7544. */
  7545. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7546. /**
  7547. * Lambda to Update a single float in a uniform buffer.
  7548. * This is dynamic to allow compat with webgl 1 and 2.
  7549. * You will need to pass the name of the uniform as well as the value.
  7550. */
  7551. updateFloat: (name: string, x: number) => void;
  7552. /**
  7553. * Lambda to Update a vec2 of float in a uniform buffer.
  7554. * This is dynamic to allow compat with webgl 1 and 2.
  7555. * You will need to pass the name of the uniform as well as the value.
  7556. */
  7557. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7558. /**
  7559. * Lambda to Update a vec3 of float in a uniform buffer.
  7560. * This is dynamic to allow compat with webgl 1 and 2.
  7561. * You will need to pass the name of the uniform as well as the value.
  7562. */
  7563. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7564. /**
  7565. * Lambda to Update a vec4 of float in a uniform buffer.
  7566. * This is dynamic to allow compat with webgl 1 and 2.
  7567. * You will need to pass the name of the uniform as well as the value.
  7568. */
  7569. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7570. /**
  7571. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7572. * This is dynamic to allow compat with webgl 1 and 2.
  7573. * You will need to pass the name of the uniform as well as the value.
  7574. */
  7575. updateMatrix: (name: string, mat: Matrix) => void;
  7576. /**
  7577. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7578. * This is dynamic to allow compat with webgl 1 and 2.
  7579. * You will need to pass the name of the uniform as well as the value.
  7580. */
  7581. updateVector3: (name: string, vector: Vector3) => void;
  7582. /**
  7583. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7584. * This is dynamic to allow compat with webgl 1 and 2.
  7585. * You will need to pass the name of the uniform as well as the value.
  7586. */
  7587. updateVector4: (name: string, vector: Vector4) => void;
  7588. /**
  7589. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7590. * This is dynamic to allow compat with webgl 1 and 2.
  7591. * You will need to pass the name of the uniform as well as the value.
  7592. */
  7593. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7594. /**
  7595. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7596. * This is dynamic to allow compat with webgl 1 and 2.
  7597. * You will need to pass the name of the uniform as well as the value.
  7598. */
  7599. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7600. /**
  7601. * Instantiates a new Uniform buffer objects.
  7602. *
  7603. * Handles blocks of uniform on the GPU.
  7604. *
  7605. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7606. *
  7607. * For more information, please refer to :
  7608. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7609. * @param engine Define the engine the buffer is associated with
  7610. * @param data Define the data contained in the buffer
  7611. * @param dynamic Define if the buffer is updatable
  7612. */
  7613. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7614. /**
  7615. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7616. * or just falling back on setUniformXXX calls.
  7617. */
  7618. get useUbo(): boolean;
  7619. /**
  7620. * Indicates if the WebGL underlying uniform buffer is in sync
  7621. * with the javascript cache data.
  7622. */
  7623. get isSync(): boolean;
  7624. /**
  7625. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7626. * Also, a dynamic UniformBuffer will disable cache verification and always
  7627. * update the underlying WebGL uniform buffer to the GPU.
  7628. * @returns if Dynamic, otherwise false
  7629. */
  7630. isDynamic(): boolean;
  7631. /**
  7632. * The data cache on JS side.
  7633. * @returns the underlying data as a float array
  7634. */
  7635. getData(): Float32Array;
  7636. /**
  7637. * The underlying WebGL Uniform buffer.
  7638. * @returns the webgl buffer
  7639. */
  7640. getBuffer(): Nullable<DataBuffer>;
  7641. /**
  7642. * std140 layout specifies how to align data within an UBO structure.
  7643. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7644. * for specs.
  7645. */
  7646. private _fillAlignment;
  7647. /**
  7648. * Adds an uniform in the buffer.
  7649. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7650. * for the layout to be correct !
  7651. * @param name Name of the uniform, as used in the uniform block in the shader.
  7652. * @param size Data size, or data directly.
  7653. */
  7654. addUniform(name: string, size: number | number[]): void;
  7655. /**
  7656. * Adds a Matrix 4x4 to the uniform buffer.
  7657. * @param name Name of the uniform, as used in the uniform block in the shader.
  7658. * @param mat A 4x4 matrix.
  7659. */
  7660. addMatrix(name: string, mat: Matrix): void;
  7661. /**
  7662. * Adds a vec2 to the uniform buffer.
  7663. * @param name Name of the uniform, as used in the uniform block in the shader.
  7664. * @param x Define the x component value of the vec2
  7665. * @param y Define the y component value of the vec2
  7666. */
  7667. addFloat2(name: string, x: number, y: number): void;
  7668. /**
  7669. * Adds a vec3 to the uniform buffer.
  7670. * @param name Name of the uniform, as used in the uniform block in the shader.
  7671. * @param x Define the x component value of the vec3
  7672. * @param y Define the y component value of the vec3
  7673. * @param z Define the z component value of the vec3
  7674. */
  7675. addFloat3(name: string, x: number, y: number, z: number): void;
  7676. /**
  7677. * Adds a vec3 to the uniform buffer.
  7678. * @param name Name of the uniform, as used in the uniform block in the shader.
  7679. * @param color Define the vec3 from a Color
  7680. */
  7681. addColor3(name: string, color: Color3): void;
  7682. /**
  7683. * Adds a vec4 to the uniform buffer.
  7684. * @param name Name of the uniform, as used in the uniform block in the shader.
  7685. * @param color Define the rgb components from a Color
  7686. * @param alpha Define the a component of the vec4
  7687. */
  7688. addColor4(name: string, color: Color3, alpha: number): void;
  7689. /**
  7690. * Adds a vec3 to the uniform buffer.
  7691. * @param name Name of the uniform, as used in the uniform block in the shader.
  7692. * @param vector Define the vec3 components from a Vector
  7693. */
  7694. addVector3(name: string, vector: Vector3): void;
  7695. /**
  7696. * Adds a Matrix 3x3 to the uniform buffer.
  7697. * @param name Name of the uniform, as used in the uniform block in the shader.
  7698. */
  7699. addMatrix3x3(name: string): void;
  7700. /**
  7701. * Adds a Matrix 2x2 to the uniform buffer.
  7702. * @param name Name of the uniform, as used in the uniform block in the shader.
  7703. */
  7704. addMatrix2x2(name: string): void;
  7705. /**
  7706. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7707. */
  7708. create(): void;
  7709. /** @hidden */
  7710. _rebuild(): void;
  7711. /**
  7712. * Updates the WebGL Uniform Buffer on the GPU.
  7713. * If the `dynamic` flag is set to true, no cache comparison is done.
  7714. * Otherwise, the buffer will be updated only if the cache differs.
  7715. */
  7716. update(): void;
  7717. /**
  7718. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7719. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7720. * @param data Define the flattened data
  7721. * @param size Define the size of the data.
  7722. */
  7723. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7724. private _valueCache;
  7725. private _cacheMatrix;
  7726. private _updateMatrix3x3ForUniform;
  7727. private _updateMatrix3x3ForEffect;
  7728. private _updateMatrix2x2ForEffect;
  7729. private _updateMatrix2x2ForUniform;
  7730. private _updateFloatForEffect;
  7731. private _updateFloatForUniform;
  7732. private _updateFloat2ForEffect;
  7733. private _updateFloat2ForUniform;
  7734. private _updateFloat3ForEffect;
  7735. private _updateFloat3ForUniform;
  7736. private _updateFloat4ForEffect;
  7737. private _updateFloat4ForUniform;
  7738. private _updateMatrixForEffect;
  7739. private _updateMatrixForUniform;
  7740. private _updateVector3ForEffect;
  7741. private _updateVector3ForUniform;
  7742. private _updateVector4ForEffect;
  7743. private _updateVector4ForUniform;
  7744. private _updateColor3ForEffect;
  7745. private _updateColor3ForUniform;
  7746. private _updateColor4ForEffect;
  7747. private _updateColor4ForUniform;
  7748. /**
  7749. * Sets a sampler uniform on the effect.
  7750. * @param name Define the name of the sampler.
  7751. * @param texture Define the texture to set in the sampler
  7752. */
  7753. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7754. /**
  7755. * Directly updates the value of the uniform in the cache AND on the GPU.
  7756. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7757. * @param data Define the flattened data
  7758. */
  7759. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7760. /**
  7761. * Binds this uniform buffer to an effect.
  7762. * @param effect Define the effect to bind the buffer to
  7763. * @param name Name of the uniform block in the shader.
  7764. */
  7765. bindToEffect(effect: Effect, name: string): void;
  7766. /**
  7767. * Disposes the uniform buffer.
  7768. */
  7769. dispose(): void;
  7770. }
  7771. }
  7772. declare module "babylonjs/Misc/iInspectable" {
  7773. /**
  7774. * Enum that determines the text-wrapping mode to use.
  7775. */
  7776. export enum InspectableType {
  7777. /**
  7778. * Checkbox for booleans
  7779. */
  7780. Checkbox = 0,
  7781. /**
  7782. * Sliders for numbers
  7783. */
  7784. Slider = 1,
  7785. /**
  7786. * Vector3
  7787. */
  7788. Vector3 = 2,
  7789. /**
  7790. * Quaternions
  7791. */
  7792. Quaternion = 3,
  7793. /**
  7794. * Color3
  7795. */
  7796. Color3 = 4,
  7797. /**
  7798. * String
  7799. */
  7800. String = 5
  7801. }
  7802. /**
  7803. * Interface used to define custom inspectable properties.
  7804. * This interface is used by the inspector to display custom property grids
  7805. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7806. */
  7807. export interface IInspectable {
  7808. /**
  7809. * Gets the label to display
  7810. */
  7811. label: string;
  7812. /**
  7813. * Gets the name of the property to edit
  7814. */
  7815. propertyName: string;
  7816. /**
  7817. * Gets the type of the editor to use
  7818. */
  7819. type: InspectableType;
  7820. /**
  7821. * Gets the minimum value of the property when using in "slider" mode
  7822. */
  7823. min?: number;
  7824. /**
  7825. * Gets the maximum value of the property when using in "slider" mode
  7826. */
  7827. max?: number;
  7828. /**
  7829. * Gets the setp to use when using in "slider" mode
  7830. */
  7831. step?: number;
  7832. }
  7833. }
  7834. declare module "babylonjs/Misc/timingTools" {
  7835. /**
  7836. * Class used to provide helper for timing
  7837. */
  7838. export class TimingTools {
  7839. /**
  7840. * Polyfill for setImmediate
  7841. * @param action defines the action to execute after the current execution block
  7842. */
  7843. static SetImmediate(action: () => void): void;
  7844. }
  7845. }
  7846. declare module "babylonjs/Misc/instantiationTools" {
  7847. /**
  7848. * Class used to enable instatition of objects by class name
  7849. */
  7850. export class InstantiationTools {
  7851. /**
  7852. * Use this object to register external classes like custom textures or material
  7853. * to allow the laoders to instantiate them
  7854. */
  7855. static RegisteredExternalClasses: {
  7856. [key: string]: Object;
  7857. };
  7858. /**
  7859. * Tries to instantiate a new object from a given class name
  7860. * @param className defines the class name to instantiate
  7861. * @returns the new object or null if the system was not able to do the instantiation
  7862. */
  7863. static Instantiate(className: string): any;
  7864. }
  7865. }
  7866. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7867. /**
  7868. * Define options used to create a depth texture
  7869. */
  7870. export class DepthTextureCreationOptions {
  7871. /** Specifies whether or not a stencil should be allocated in the texture */
  7872. generateStencil?: boolean;
  7873. /** Specifies whether or not bilinear filtering is enable on the texture */
  7874. bilinearFiltering?: boolean;
  7875. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7876. comparisonFunction?: number;
  7877. /** Specifies if the created texture is a cube texture */
  7878. isCube?: boolean;
  7879. }
  7880. }
  7881. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7882. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7883. import { Nullable } from "babylonjs/types";
  7884. import { Scene } from "babylonjs/scene";
  7885. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7886. module "babylonjs/Engines/thinEngine" {
  7887. interface ThinEngine {
  7888. /**
  7889. * Creates a depth stencil cube texture.
  7890. * This is only available in WebGL 2.
  7891. * @param size The size of face edge in the cube texture.
  7892. * @param options The options defining the cube texture.
  7893. * @returns The cube texture
  7894. */
  7895. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7896. /**
  7897. * Creates a cube texture
  7898. * @param rootUrl defines the url where the files to load is located
  7899. * @param scene defines the current scene
  7900. * @param files defines the list of files to load (1 per face)
  7901. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7902. * @param onLoad defines an optional callback raised when the texture is loaded
  7903. * @param onError defines an optional callback raised if there is an issue to load the texture
  7904. * @param format defines the format of the data
  7905. * @param forcedExtension defines the extension to use to pick the right loader
  7906. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7907. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7908. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7909. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7910. * @param loaderOptions options to be passed to the loader
  7911. * @returns the cube texture as an InternalTexture
  7912. */
  7913. 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;
  7914. /**
  7915. * Creates a cube texture
  7916. * @param rootUrl defines the url where the files to load is located
  7917. * @param scene defines the current scene
  7918. * @param files defines the list of files to load (1 per face)
  7919. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7920. * @param onLoad defines an optional callback raised when the texture is loaded
  7921. * @param onError defines an optional callback raised if there is an issue to load the texture
  7922. * @param format defines the format of the data
  7923. * @param forcedExtension defines the extension to use to pick the right loader
  7924. * @returns the cube texture as an InternalTexture
  7925. */
  7926. 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;
  7927. /**
  7928. * Creates a cube texture
  7929. * @param rootUrl defines the url where the files to load is located
  7930. * @param scene defines the current scene
  7931. * @param files defines the list of files to load (1 per face)
  7932. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7933. * @param onLoad defines an optional callback raised when the texture is loaded
  7934. * @param onError defines an optional callback raised if there is an issue to load the texture
  7935. * @param format defines the format of the data
  7936. * @param forcedExtension defines the extension to use to pick the right loader
  7937. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7938. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7939. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7940. * @returns the cube texture as an InternalTexture
  7941. */
  7942. 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;
  7943. /** @hidden */
  7944. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7945. /** @hidden */
  7946. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7947. /** @hidden */
  7948. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7949. /** @hidden */
  7950. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7951. /**
  7952. * @hidden
  7953. */
  7954. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  7955. }
  7956. }
  7957. }
  7958. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7959. import { Nullable } from "babylonjs/types";
  7960. import { Scene } from "babylonjs/scene";
  7961. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7962. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7963. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7964. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7965. import { Observable } from "babylonjs/Misc/observable";
  7966. /**
  7967. * Class for creating a cube texture
  7968. */
  7969. export class CubeTexture extends BaseTexture {
  7970. private _delayedOnLoad;
  7971. /**
  7972. * Observable triggered once the texture has been loaded.
  7973. */
  7974. onLoadObservable: Observable<CubeTexture>;
  7975. /**
  7976. * The url of the texture
  7977. */
  7978. url: string;
  7979. /**
  7980. * Gets or sets the center of the bounding box associated with the cube texture.
  7981. * It must define where the camera used to render the texture was set
  7982. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7983. */
  7984. boundingBoxPosition: Vector3;
  7985. private _boundingBoxSize;
  7986. /**
  7987. * Gets or sets the size of the bounding box associated with the cube texture
  7988. * When defined, the cubemap will switch to local mode
  7989. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7990. * @example https://www.babylonjs-playground.com/#RNASML
  7991. */
  7992. set boundingBoxSize(value: Vector3);
  7993. /**
  7994. * Returns the bounding box size
  7995. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7996. */
  7997. get boundingBoxSize(): Vector3;
  7998. protected _rotationY: number;
  7999. /**
  8000. * Sets texture matrix rotation angle around Y axis in radians.
  8001. */
  8002. set rotationY(value: number);
  8003. /**
  8004. * Gets texture matrix rotation angle around Y axis radians.
  8005. */
  8006. get rotationY(): number;
  8007. /**
  8008. * Are mip maps generated for this texture or not.
  8009. */
  8010. get noMipmap(): boolean;
  8011. private _noMipmap;
  8012. private _files;
  8013. protected _forcedExtension: Nullable<string>;
  8014. private _extensions;
  8015. private _textureMatrix;
  8016. private _format;
  8017. private _createPolynomials;
  8018. private _loaderOptions;
  8019. /**
  8020. * Creates a cube texture from an array of image urls
  8021. * @param files defines an array of image urls
  8022. * @param scene defines the hosting scene
  8023. * @param noMipmap specifies if mip maps are not used
  8024. * @returns a cube texture
  8025. */
  8026. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8027. /**
  8028. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8029. * @param url defines the url of the prefiltered texture
  8030. * @param scene defines the scene the texture is attached to
  8031. * @param forcedExtension defines the extension of the file if different from the url
  8032. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8033. * @return the prefiltered texture
  8034. */
  8035. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8036. /**
  8037. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8038. * as prefiltered data.
  8039. * @param rootUrl defines the url of the texture or the root name of the six images
  8040. * @param null defines the scene or engine the texture is attached to
  8041. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8042. * @param noMipmap defines if mipmaps should be created or not
  8043. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8044. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8045. * @param onError defines a callback triggered in case of error during load
  8046. * @param format defines the internal format to use for the texture once loaded
  8047. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8048. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8049. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8050. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8051. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8052. * @param loaderOptions options to be passed to the loader
  8053. * @return the cube texture
  8054. */
  8055. 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);
  8056. /**
  8057. * Get the current class name of the texture useful for serialization or dynamic coding.
  8058. * @returns "CubeTexture"
  8059. */
  8060. getClassName(): string;
  8061. /**
  8062. * Update the url (and optional buffer) of this texture if url was null during construction.
  8063. * @param url the url of the texture
  8064. * @param forcedExtension defines the extension to use
  8065. * @param onLoad callback called when the texture is loaded (defaults to null)
  8066. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8067. */
  8068. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8069. /**
  8070. * Delays loading of the cube texture
  8071. * @param forcedExtension defines the extension to use
  8072. */
  8073. delayLoad(forcedExtension?: string): void;
  8074. /**
  8075. * Returns the reflection texture matrix
  8076. * @returns the reflection texture matrix
  8077. */
  8078. getReflectionTextureMatrix(): Matrix;
  8079. /**
  8080. * Sets the reflection texture matrix
  8081. * @param value Reflection texture matrix
  8082. */
  8083. setReflectionTextureMatrix(value: Matrix): void;
  8084. /**
  8085. * Parses text to create a cube texture
  8086. * @param parsedTexture define the serialized text to read from
  8087. * @param scene defines the hosting scene
  8088. * @param rootUrl defines the root url of the cube texture
  8089. * @returns a cube texture
  8090. */
  8091. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8092. /**
  8093. * Makes a clone, or deep copy, of the cube texture
  8094. * @returns a new cube texture
  8095. */
  8096. clone(): CubeTexture;
  8097. }
  8098. }
  8099. declare module "babylonjs/Materials/materialDefines" {
  8100. /**
  8101. * Manages the defines for the Material
  8102. */
  8103. export class MaterialDefines {
  8104. /** @hidden */
  8105. protected _keys: string[];
  8106. private _isDirty;
  8107. /** @hidden */
  8108. _renderId: number;
  8109. /** @hidden */
  8110. _areLightsDirty: boolean;
  8111. /** @hidden */
  8112. _areLightsDisposed: boolean;
  8113. /** @hidden */
  8114. _areAttributesDirty: boolean;
  8115. /** @hidden */
  8116. _areTexturesDirty: boolean;
  8117. /** @hidden */
  8118. _areFresnelDirty: boolean;
  8119. /** @hidden */
  8120. _areMiscDirty: boolean;
  8121. /** @hidden */
  8122. _arePrePassDirty: boolean;
  8123. /** @hidden */
  8124. _areImageProcessingDirty: boolean;
  8125. /** @hidden */
  8126. _normals: boolean;
  8127. /** @hidden */
  8128. _uvs: boolean;
  8129. /** @hidden */
  8130. _needNormals: boolean;
  8131. /** @hidden */
  8132. _needUVs: boolean;
  8133. [id: string]: any;
  8134. /**
  8135. * Specifies if the material needs to be re-calculated
  8136. */
  8137. get isDirty(): boolean;
  8138. /**
  8139. * Marks the material to indicate that it has been re-calculated
  8140. */
  8141. markAsProcessed(): void;
  8142. /**
  8143. * Marks the material to indicate that it needs to be re-calculated
  8144. */
  8145. markAsUnprocessed(): void;
  8146. /**
  8147. * Marks the material to indicate all of its defines need to be re-calculated
  8148. */
  8149. markAllAsDirty(): void;
  8150. /**
  8151. * Marks the material to indicate that image processing needs to be re-calculated
  8152. */
  8153. markAsImageProcessingDirty(): void;
  8154. /**
  8155. * Marks the material to indicate the lights need to be re-calculated
  8156. * @param disposed Defines whether the light is dirty due to dispose or not
  8157. */
  8158. markAsLightDirty(disposed?: boolean): void;
  8159. /**
  8160. * Marks the attribute state as changed
  8161. */
  8162. markAsAttributesDirty(): void;
  8163. /**
  8164. * Marks the texture state as changed
  8165. */
  8166. markAsTexturesDirty(): void;
  8167. /**
  8168. * Marks the fresnel state as changed
  8169. */
  8170. markAsFresnelDirty(): void;
  8171. /**
  8172. * Marks the misc state as changed
  8173. */
  8174. markAsMiscDirty(): void;
  8175. /**
  8176. * Marks the prepass state as changed
  8177. */
  8178. markAsPrePassDirty(): void;
  8179. /**
  8180. * Rebuilds the material defines
  8181. */
  8182. rebuild(): void;
  8183. /**
  8184. * Specifies if two material defines are equal
  8185. * @param other - A material define instance to compare to
  8186. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8187. */
  8188. isEqual(other: MaterialDefines): boolean;
  8189. /**
  8190. * Clones this instance's defines to another instance
  8191. * @param other - material defines to clone values to
  8192. */
  8193. cloneTo(other: MaterialDefines): void;
  8194. /**
  8195. * Resets the material define values
  8196. */
  8197. reset(): void;
  8198. /**
  8199. * Converts the material define values to a string
  8200. * @returns - String of material define information
  8201. */
  8202. toString(): string;
  8203. }
  8204. }
  8205. declare module "babylonjs/Materials/colorCurves" {
  8206. import { Effect } from "babylonjs/Materials/effect";
  8207. /**
  8208. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8209. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8210. * 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;
  8211. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8212. */
  8213. export class ColorCurves {
  8214. private _dirty;
  8215. private _tempColor;
  8216. private _globalCurve;
  8217. private _highlightsCurve;
  8218. private _midtonesCurve;
  8219. private _shadowsCurve;
  8220. private _positiveCurve;
  8221. private _negativeCurve;
  8222. private _globalHue;
  8223. private _globalDensity;
  8224. private _globalSaturation;
  8225. private _globalExposure;
  8226. /**
  8227. * Gets the global Hue value.
  8228. * 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).
  8229. */
  8230. get globalHue(): number;
  8231. /**
  8232. * Sets the global Hue value.
  8233. * 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).
  8234. */
  8235. set globalHue(value: number);
  8236. /**
  8237. * Gets the global Density value.
  8238. * 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.
  8239. * Values less than zero provide a filter of opposite hue.
  8240. */
  8241. get globalDensity(): number;
  8242. /**
  8243. * Sets the global Density value.
  8244. * 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.
  8245. * Values less than zero provide a filter of opposite hue.
  8246. */
  8247. set globalDensity(value: number);
  8248. /**
  8249. * Gets the global Saturation value.
  8250. * 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.
  8251. */
  8252. get globalSaturation(): number;
  8253. /**
  8254. * Sets the global Saturation value.
  8255. * 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.
  8256. */
  8257. set globalSaturation(value: number);
  8258. /**
  8259. * Gets the global Exposure value.
  8260. * 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.
  8261. */
  8262. get globalExposure(): number;
  8263. /**
  8264. * Sets the global Exposure value.
  8265. * 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.
  8266. */
  8267. set globalExposure(value: number);
  8268. private _highlightsHue;
  8269. private _highlightsDensity;
  8270. private _highlightsSaturation;
  8271. private _highlightsExposure;
  8272. /**
  8273. * Gets the highlights Hue value.
  8274. * 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).
  8275. */
  8276. get highlightsHue(): number;
  8277. /**
  8278. * Sets the highlights Hue value.
  8279. * 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).
  8280. */
  8281. set highlightsHue(value: number);
  8282. /**
  8283. * Gets the highlights Density value.
  8284. * 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.
  8285. * Values less than zero provide a filter of opposite hue.
  8286. */
  8287. get highlightsDensity(): number;
  8288. /**
  8289. * Sets the highlights Density value.
  8290. * 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.
  8291. * Values less than zero provide a filter of opposite hue.
  8292. */
  8293. set highlightsDensity(value: number);
  8294. /**
  8295. * Gets the highlights Saturation value.
  8296. * 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.
  8297. */
  8298. get highlightsSaturation(): number;
  8299. /**
  8300. * Sets the highlights Saturation value.
  8301. * 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.
  8302. */
  8303. set highlightsSaturation(value: number);
  8304. /**
  8305. * Gets the highlights Exposure value.
  8306. * 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.
  8307. */
  8308. get highlightsExposure(): number;
  8309. /**
  8310. * Sets the highlights Exposure value.
  8311. * 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.
  8312. */
  8313. set highlightsExposure(value: number);
  8314. private _midtonesHue;
  8315. private _midtonesDensity;
  8316. private _midtonesSaturation;
  8317. private _midtonesExposure;
  8318. /**
  8319. * Gets the midtones Hue value.
  8320. * 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).
  8321. */
  8322. get midtonesHue(): number;
  8323. /**
  8324. * Sets the midtones Hue value.
  8325. * 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).
  8326. */
  8327. set midtonesHue(value: number);
  8328. /**
  8329. * Gets the midtones Density value.
  8330. * 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.
  8331. * Values less than zero provide a filter of opposite hue.
  8332. */
  8333. get midtonesDensity(): number;
  8334. /**
  8335. * Sets the midtones Density value.
  8336. * 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.
  8337. * Values less than zero provide a filter of opposite hue.
  8338. */
  8339. set midtonesDensity(value: number);
  8340. /**
  8341. * Gets the midtones Saturation value.
  8342. * 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.
  8343. */
  8344. get midtonesSaturation(): number;
  8345. /**
  8346. * Sets the midtones Saturation value.
  8347. * 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.
  8348. */
  8349. set midtonesSaturation(value: number);
  8350. /**
  8351. * Gets the midtones Exposure value.
  8352. * 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.
  8353. */
  8354. get midtonesExposure(): number;
  8355. /**
  8356. * Sets the midtones Exposure value.
  8357. * 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.
  8358. */
  8359. set midtonesExposure(value: number);
  8360. private _shadowsHue;
  8361. private _shadowsDensity;
  8362. private _shadowsSaturation;
  8363. private _shadowsExposure;
  8364. /**
  8365. * Gets the shadows Hue value.
  8366. * 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).
  8367. */
  8368. get shadowsHue(): number;
  8369. /**
  8370. * Sets the shadows Hue value.
  8371. * 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).
  8372. */
  8373. set shadowsHue(value: number);
  8374. /**
  8375. * Gets the shadows Density value.
  8376. * 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.
  8377. * Values less than zero provide a filter of opposite hue.
  8378. */
  8379. get shadowsDensity(): number;
  8380. /**
  8381. * Sets the shadows Density value.
  8382. * 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.
  8383. * Values less than zero provide a filter of opposite hue.
  8384. */
  8385. set shadowsDensity(value: number);
  8386. /**
  8387. * Gets the shadows Saturation value.
  8388. * 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.
  8389. */
  8390. get shadowsSaturation(): number;
  8391. /**
  8392. * Sets the shadows Saturation value.
  8393. * 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.
  8394. */
  8395. set shadowsSaturation(value: number);
  8396. /**
  8397. * Gets the shadows Exposure value.
  8398. * 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.
  8399. */
  8400. get shadowsExposure(): number;
  8401. /**
  8402. * Sets the shadows Exposure value.
  8403. * 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.
  8404. */
  8405. set shadowsExposure(value: number);
  8406. /**
  8407. * Returns the class name
  8408. * @returns The class name
  8409. */
  8410. getClassName(): string;
  8411. /**
  8412. * Binds the color curves to the shader.
  8413. * @param colorCurves The color curve to bind
  8414. * @param effect The effect to bind to
  8415. * @param positiveUniform The positive uniform shader parameter
  8416. * @param neutralUniform The neutral uniform shader parameter
  8417. * @param negativeUniform The negative uniform shader parameter
  8418. */
  8419. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8420. /**
  8421. * Prepare the list of uniforms associated with the ColorCurves effects.
  8422. * @param uniformsList The list of uniforms used in the effect
  8423. */
  8424. static PrepareUniforms(uniformsList: string[]): void;
  8425. /**
  8426. * Returns color grading data based on a hue, density, saturation and exposure value.
  8427. * @param filterHue The hue of the color filter.
  8428. * @param filterDensity The density of the color filter.
  8429. * @param saturation The saturation.
  8430. * @param exposure The exposure.
  8431. * @param result The result data container.
  8432. */
  8433. private getColorGradingDataToRef;
  8434. /**
  8435. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8436. * @param value The input slider value in range [-100,100].
  8437. * @returns Adjusted value.
  8438. */
  8439. private static applyColorGradingSliderNonlinear;
  8440. /**
  8441. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8442. * @param hue The hue (H) input.
  8443. * @param saturation The saturation (S) input.
  8444. * @param brightness The brightness (B) input.
  8445. * @result An RGBA color represented as Vector4.
  8446. */
  8447. private static fromHSBToRef;
  8448. /**
  8449. * Returns a value clamped between min and max
  8450. * @param value The value to clamp
  8451. * @param min The minimum of value
  8452. * @param max The maximum of value
  8453. * @returns The clamped value.
  8454. */
  8455. private static clamp;
  8456. /**
  8457. * Clones the current color curve instance.
  8458. * @return The cloned curves
  8459. */
  8460. clone(): ColorCurves;
  8461. /**
  8462. * Serializes the current color curve instance to a json representation.
  8463. * @return a JSON representation
  8464. */
  8465. serialize(): any;
  8466. /**
  8467. * Parses the color curve from a json representation.
  8468. * @param source the JSON source to parse
  8469. * @return The parsed curves
  8470. */
  8471. static Parse(source: any): ColorCurves;
  8472. }
  8473. }
  8474. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8475. import { Observable } from "babylonjs/Misc/observable";
  8476. import { Nullable } from "babylonjs/types";
  8477. import { Color4 } from "babylonjs/Maths/math.color";
  8478. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8479. import { Effect } from "babylonjs/Materials/effect";
  8480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8481. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8482. /**
  8483. * Interface to follow in your material defines to integrate easily the
  8484. * Image proccessing functions.
  8485. * @hidden
  8486. */
  8487. export interface IImageProcessingConfigurationDefines {
  8488. IMAGEPROCESSING: boolean;
  8489. VIGNETTE: boolean;
  8490. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8491. VIGNETTEBLENDMODEOPAQUE: boolean;
  8492. TONEMAPPING: boolean;
  8493. TONEMAPPING_ACES: boolean;
  8494. CONTRAST: boolean;
  8495. EXPOSURE: boolean;
  8496. COLORCURVES: boolean;
  8497. COLORGRADING: boolean;
  8498. COLORGRADING3D: boolean;
  8499. SAMPLER3DGREENDEPTH: boolean;
  8500. SAMPLER3DBGRMAP: boolean;
  8501. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8502. }
  8503. /**
  8504. * @hidden
  8505. */
  8506. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8507. IMAGEPROCESSING: boolean;
  8508. VIGNETTE: boolean;
  8509. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8510. VIGNETTEBLENDMODEOPAQUE: boolean;
  8511. TONEMAPPING: boolean;
  8512. TONEMAPPING_ACES: boolean;
  8513. CONTRAST: boolean;
  8514. COLORCURVES: boolean;
  8515. COLORGRADING: boolean;
  8516. COLORGRADING3D: boolean;
  8517. SAMPLER3DGREENDEPTH: boolean;
  8518. SAMPLER3DBGRMAP: boolean;
  8519. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8520. EXPOSURE: boolean;
  8521. constructor();
  8522. }
  8523. /**
  8524. * This groups together the common properties used for image processing either in direct forward pass
  8525. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8526. * or not.
  8527. */
  8528. export class ImageProcessingConfiguration {
  8529. /**
  8530. * Default tone mapping applied in BabylonJS.
  8531. */
  8532. static readonly TONEMAPPING_STANDARD: number;
  8533. /**
  8534. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8535. * to other engines rendering to increase portability.
  8536. */
  8537. static readonly TONEMAPPING_ACES: number;
  8538. /**
  8539. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8540. */
  8541. colorCurves: Nullable<ColorCurves>;
  8542. private _colorCurvesEnabled;
  8543. /**
  8544. * Gets wether the color curves effect is enabled.
  8545. */
  8546. get colorCurvesEnabled(): boolean;
  8547. /**
  8548. * Sets wether the color curves effect is enabled.
  8549. */
  8550. set colorCurvesEnabled(value: boolean);
  8551. private _colorGradingTexture;
  8552. /**
  8553. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8554. */
  8555. get colorGradingTexture(): Nullable<BaseTexture>;
  8556. /**
  8557. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8558. */
  8559. set colorGradingTexture(value: Nullable<BaseTexture>);
  8560. private _colorGradingEnabled;
  8561. /**
  8562. * Gets wether the color grading effect is enabled.
  8563. */
  8564. get colorGradingEnabled(): boolean;
  8565. /**
  8566. * Sets wether the color grading effect is enabled.
  8567. */
  8568. set colorGradingEnabled(value: boolean);
  8569. private _colorGradingWithGreenDepth;
  8570. /**
  8571. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8572. */
  8573. get colorGradingWithGreenDepth(): boolean;
  8574. /**
  8575. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8576. */
  8577. set colorGradingWithGreenDepth(value: boolean);
  8578. private _colorGradingBGR;
  8579. /**
  8580. * Gets wether the color grading texture contains BGR values.
  8581. */
  8582. get colorGradingBGR(): boolean;
  8583. /**
  8584. * Sets wether the color grading texture contains BGR values.
  8585. */
  8586. set colorGradingBGR(value: boolean);
  8587. /** @hidden */
  8588. _exposure: number;
  8589. /**
  8590. * Gets the Exposure used in the effect.
  8591. */
  8592. get exposure(): number;
  8593. /**
  8594. * Sets the Exposure used in the effect.
  8595. */
  8596. set exposure(value: number);
  8597. private _toneMappingEnabled;
  8598. /**
  8599. * Gets wether the tone mapping effect is enabled.
  8600. */
  8601. get toneMappingEnabled(): boolean;
  8602. /**
  8603. * Sets wether the tone mapping effect is enabled.
  8604. */
  8605. set toneMappingEnabled(value: boolean);
  8606. private _toneMappingType;
  8607. /**
  8608. * Gets the type of tone mapping effect.
  8609. */
  8610. get toneMappingType(): number;
  8611. /**
  8612. * Sets the type of tone mapping effect used in BabylonJS.
  8613. */
  8614. set toneMappingType(value: number);
  8615. protected _contrast: number;
  8616. /**
  8617. * Gets the contrast used in the effect.
  8618. */
  8619. get contrast(): number;
  8620. /**
  8621. * Sets the contrast used in the effect.
  8622. */
  8623. set contrast(value: number);
  8624. /**
  8625. * Vignette stretch size.
  8626. */
  8627. vignetteStretch: number;
  8628. /**
  8629. * Vignette centre X Offset.
  8630. */
  8631. vignetteCentreX: number;
  8632. /**
  8633. * Vignette centre Y Offset.
  8634. */
  8635. vignetteCentreY: number;
  8636. /**
  8637. * Vignette weight or intensity of the vignette effect.
  8638. */
  8639. vignetteWeight: number;
  8640. /**
  8641. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8642. * if vignetteEnabled is set to true.
  8643. */
  8644. vignetteColor: Color4;
  8645. /**
  8646. * Camera field of view used by the Vignette effect.
  8647. */
  8648. vignetteCameraFov: number;
  8649. private _vignetteBlendMode;
  8650. /**
  8651. * Gets the vignette blend mode allowing different kind of effect.
  8652. */
  8653. get vignetteBlendMode(): number;
  8654. /**
  8655. * Sets the vignette blend mode allowing different kind of effect.
  8656. */
  8657. set vignetteBlendMode(value: number);
  8658. private _vignetteEnabled;
  8659. /**
  8660. * Gets wether the vignette effect is enabled.
  8661. */
  8662. get vignetteEnabled(): boolean;
  8663. /**
  8664. * Sets wether the vignette effect is enabled.
  8665. */
  8666. set vignetteEnabled(value: boolean);
  8667. private _applyByPostProcess;
  8668. /**
  8669. * Gets wether the image processing is applied through a post process or not.
  8670. */
  8671. get applyByPostProcess(): boolean;
  8672. /**
  8673. * Sets wether the image processing is applied through a post process or not.
  8674. */
  8675. set applyByPostProcess(value: boolean);
  8676. private _isEnabled;
  8677. /**
  8678. * Gets wether the image processing is enabled or not.
  8679. */
  8680. get isEnabled(): boolean;
  8681. /**
  8682. * Sets wether the image processing is enabled or not.
  8683. */
  8684. set isEnabled(value: boolean);
  8685. /**
  8686. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8687. */
  8688. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8689. /**
  8690. * Method called each time the image processing information changes requires to recompile the effect.
  8691. */
  8692. protected _updateParameters(): void;
  8693. /**
  8694. * Gets the current class name.
  8695. * @return "ImageProcessingConfiguration"
  8696. */
  8697. getClassName(): string;
  8698. /**
  8699. * Prepare the list of uniforms associated with the Image Processing effects.
  8700. * @param uniforms The list of uniforms used in the effect
  8701. * @param defines the list of defines currently in use
  8702. */
  8703. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8704. /**
  8705. * Prepare the list of samplers associated with the Image Processing effects.
  8706. * @param samplersList The list of uniforms used in the effect
  8707. * @param defines the list of defines currently in use
  8708. */
  8709. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8710. /**
  8711. * Prepare the list of defines associated to the shader.
  8712. * @param defines the list of defines to complete
  8713. * @param forPostProcess Define if we are currently in post process mode or not
  8714. */
  8715. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8716. /**
  8717. * Returns true if all the image processing information are ready.
  8718. * @returns True if ready, otherwise, false
  8719. */
  8720. isReady(): boolean;
  8721. /**
  8722. * Binds the image processing to the shader.
  8723. * @param effect The effect to bind to
  8724. * @param overrideAspectRatio Override the aspect ratio of the effect
  8725. */
  8726. bind(effect: Effect, overrideAspectRatio?: number): void;
  8727. /**
  8728. * Clones the current image processing instance.
  8729. * @return The cloned image processing
  8730. */
  8731. clone(): ImageProcessingConfiguration;
  8732. /**
  8733. * Serializes the current image processing instance to a json representation.
  8734. * @return a JSON representation
  8735. */
  8736. serialize(): any;
  8737. /**
  8738. * Parses the image processing from a json representation.
  8739. * @param source the JSON source to parse
  8740. * @return The parsed image processing
  8741. */
  8742. static Parse(source: any): ImageProcessingConfiguration;
  8743. private static _VIGNETTEMODE_MULTIPLY;
  8744. private static _VIGNETTEMODE_OPAQUE;
  8745. /**
  8746. * Used to apply the vignette as a mix with the pixel color.
  8747. */
  8748. static get VIGNETTEMODE_MULTIPLY(): number;
  8749. /**
  8750. * Used to apply the vignette as a replacement of the pixel color.
  8751. */
  8752. static get VIGNETTEMODE_OPAQUE(): number;
  8753. }
  8754. }
  8755. declare module "babylonjs/Shaders/postprocess.vertex" {
  8756. /** @hidden */
  8757. export var postprocessVertexShader: {
  8758. name: string;
  8759. shader: string;
  8760. };
  8761. }
  8762. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8763. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8764. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8765. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8766. /**
  8767. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8768. */
  8769. export type RenderTargetTextureSize = number | {
  8770. width: number;
  8771. height: number;
  8772. layers?: number;
  8773. };
  8774. module "babylonjs/Engines/thinEngine" {
  8775. interface ThinEngine {
  8776. /**
  8777. * Creates a new render target texture
  8778. * @param size defines the size of the texture
  8779. * @param options defines the options used to create the texture
  8780. * @returns a new render target texture stored in an InternalTexture
  8781. */
  8782. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8783. /**
  8784. * Creates a depth stencil texture.
  8785. * This is only available in WebGL 2 or with the depth texture extension available.
  8786. * @param size The size of face edge in the texture.
  8787. * @param options The options defining the texture.
  8788. * @returns The texture
  8789. */
  8790. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8791. /** @hidden */
  8792. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8793. }
  8794. }
  8795. }
  8796. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8797. /**
  8798. * Defines the kind of connection point for node based material
  8799. */
  8800. export enum NodeMaterialBlockConnectionPointTypes {
  8801. /** Float */
  8802. Float = 1,
  8803. /** Int */
  8804. Int = 2,
  8805. /** Vector2 */
  8806. Vector2 = 4,
  8807. /** Vector3 */
  8808. Vector3 = 8,
  8809. /** Vector4 */
  8810. Vector4 = 16,
  8811. /** Color3 */
  8812. Color3 = 32,
  8813. /** Color4 */
  8814. Color4 = 64,
  8815. /** Matrix */
  8816. Matrix = 128,
  8817. /** Custom object */
  8818. Object = 256,
  8819. /** Detect type based on connection */
  8820. AutoDetect = 1024,
  8821. /** Output type that will be defined by input type */
  8822. BasedOnInput = 2048
  8823. }
  8824. }
  8825. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8826. /**
  8827. * Enum used to define the target of a block
  8828. */
  8829. export enum NodeMaterialBlockTargets {
  8830. /** Vertex shader */
  8831. Vertex = 1,
  8832. /** Fragment shader */
  8833. Fragment = 2,
  8834. /** Neutral */
  8835. Neutral = 4,
  8836. /** Vertex and Fragment */
  8837. VertexAndFragment = 3
  8838. }
  8839. }
  8840. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8841. /**
  8842. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8843. */
  8844. export enum NodeMaterialBlockConnectionPointMode {
  8845. /** Value is an uniform */
  8846. Uniform = 0,
  8847. /** Value is a mesh attribute */
  8848. Attribute = 1,
  8849. /** Value is a varying between vertex and fragment shaders */
  8850. Varying = 2,
  8851. /** Mode is undefined */
  8852. Undefined = 3
  8853. }
  8854. }
  8855. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8856. /**
  8857. * Enum used to define system values e.g. values automatically provided by the system
  8858. */
  8859. export enum NodeMaterialSystemValues {
  8860. /** World */
  8861. World = 1,
  8862. /** View */
  8863. View = 2,
  8864. /** Projection */
  8865. Projection = 3,
  8866. /** ViewProjection */
  8867. ViewProjection = 4,
  8868. /** WorldView */
  8869. WorldView = 5,
  8870. /** WorldViewProjection */
  8871. WorldViewProjection = 6,
  8872. /** CameraPosition */
  8873. CameraPosition = 7,
  8874. /** Fog Color */
  8875. FogColor = 8,
  8876. /** Delta time */
  8877. DeltaTime = 9
  8878. }
  8879. }
  8880. declare module "babylonjs/Maths/math.axis" {
  8881. import { Vector3 } from "babylonjs/Maths/math.vector";
  8882. /** Defines supported spaces */
  8883. export enum Space {
  8884. /** Local (object) space */
  8885. LOCAL = 0,
  8886. /** World space */
  8887. WORLD = 1,
  8888. /** Bone space */
  8889. BONE = 2
  8890. }
  8891. /** Defines the 3 main axes */
  8892. export class Axis {
  8893. /** X axis */
  8894. static X: Vector3;
  8895. /** Y axis */
  8896. static Y: Vector3;
  8897. /** Z axis */
  8898. static Z: Vector3;
  8899. }
  8900. /**
  8901. * Defines cartesian components.
  8902. */
  8903. export enum Coordinate {
  8904. /** X axis */
  8905. X = 0,
  8906. /** Y axis */
  8907. Y = 1,
  8908. /** Z axis */
  8909. Z = 2
  8910. }
  8911. }
  8912. declare module "babylonjs/Maths/math.frustum" {
  8913. import { Matrix } from "babylonjs/Maths/math.vector";
  8914. import { DeepImmutable } from "babylonjs/types";
  8915. import { Plane } from "babylonjs/Maths/math.plane";
  8916. /**
  8917. * Represents a camera frustum
  8918. */
  8919. export class Frustum {
  8920. /**
  8921. * Gets the planes representing the frustum
  8922. * @param transform matrix to be applied to the returned planes
  8923. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8924. */
  8925. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8926. /**
  8927. * Gets the near frustum plane transformed by the transform matrix
  8928. * @param transform transformation matrix to be applied to the resulting frustum plane
  8929. * @param frustumPlane the resuling frustum plane
  8930. */
  8931. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8932. /**
  8933. * Gets the far frustum plane transformed by the transform matrix
  8934. * @param transform transformation matrix to be applied to the resulting frustum plane
  8935. * @param frustumPlane the resuling frustum plane
  8936. */
  8937. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8938. /**
  8939. * Gets the left frustum plane transformed by the transform matrix
  8940. * @param transform transformation matrix to be applied to the resulting frustum plane
  8941. * @param frustumPlane the resuling frustum plane
  8942. */
  8943. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8944. /**
  8945. * Gets the right frustum plane transformed by the transform matrix
  8946. * @param transform transformation matrix to be applied to the resulting frustum plane
  8947. * @param frustumPlane the resuling frustum plane
  8948. */
  8949. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8950. /**
  8951. * Gets the top frustum plane transformed by the transform matrix
  8952. * @param transform transformation matrix to be applied to the resulting frustum plane
  8953. * @param frustumPlane the resuling frustum plane
  8954. */
  8955. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8956. /**
  8957. * Gets the bottom frustum plane transformed by the transform matrix
  8958. * @param transform transformation matrix to be applied to the resulting frustum plane
  8959. * @param frustumPlane the resuling frustum plane
  8960. */
  8961. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8962. /**
  8963. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8964. * @param transform transformation matrix to be applied to the resulting frustum planes
  8965. * @param frustumPlanes the resuling frustum planes
  8966. */
  8967. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8968. }
  8969. }
  8970. declare module "babylonjs/Maths/math.size" {
  8971. /**
  8972. * Interface for the size containing width and height
  8973. */
  8974. export interface ISize {
  8975. /**
  8976. * Width
  8977. */
  8978. width: number;
  8979. /**
  8980. * Heighht
  8981. */
  8982. height: number;
  8983. }
  8984. /**
  8985. * Size containing widht and height
  8986. */
  8987. export class Size implements ISize {
  8988. /**
  8989. * Width
  8990. */
  8991. width: number;
  8992. /**
  8993. * Height
  8994. */
  8995. height: number;
  8996. /**
  8997. * Creates a Size object from the given width and height (floats).
  8998. * @param width width of the new size
  8999. * @param height height of the new size
  9000. */
  9001. constructor(width: number, height: number);
  9002. /**
  9003. * Returns a string with the Size width and height
  9004. * @returns a string with the Size width and height
  9005. */
  9006. toString(): string;
  9007. /**
  9008. * "Size"
  9009. * @returns the string "Size"
  9010. */
  9011. getClassName(): string;
  9012. /**
  9013. * Returns the Size hash code.
  9014. * @returns a hash code for a unique width and height
  9015. */
  9016. getHashCode(): number;
  9017. /**
  9018. * Updates the current size from the given one.
  9019. * @param src the given size
  9020. */
  9021. copyFrom(src: Size): void;
  9022. /**
  9023. * Updates in place the current Size from the given floats.
  9024. * @param width width of the new size
  9025. * @param height height of the new size
  9026. * @returns the updated Size.
  9027. */
  9028. copyFromFloats(width: number, height: number): Size;
  9029. /**
  9030. * Updates in place the current Size from the given floats.
  9031. * @param width width to set
  9032. * @param height height to set
  9033. * @returns the updated Size.
  9034. */
  9035. set(width: number, height: number): Size;
  9036. /**
  9037. * Multiplies the width and height by numbers
  9038. * @param w factor to multiple the width by
  9039. * @param h factor to multiple the height by
  9040. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9041. */
  9042. multiplyByFloats(w: number, h: number): Size;
  9043. /**
  9044. * Clones the size
  9045. * @returns a new Size copied from the given one.
  9046. */
  9047. clone(): Size;
  9048. /**
  9049. * True if the current Size and the given one width and height are strictly equal.
  9050. * @param other the other size to compare against
  9051. * @returns True if the current Size and the given one width and height are strictly equal.
  9052. */
  9053. equals(other: Size): boolean;
  9054. /**
  9055. * The surface of the Size : width * height (float).
  9056. */
  9057. get surface(): number;
  9058. /**
  9059. * Create a new size of zero
  9060. * @returns a new Size set to (0.0, 0.0)
  9061. */
  9062. static Zero(): Size;
  9063. /**
  9064. * Sums the width and height of two sizes
  9065. * @param otherSize size to add to this size
  9066. * @returns a new Size set as the addition result of the current Size and the given one.
  9067. */
  9068. add(otherSize: Size): Size;
  9069. /**
  9070. * Subtracts the width and height of two
  9071. * @param otherSize size to subtract to this size
  9072. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9073. */
  9074. subtract(otherSize: Size): Size;
  9075. /**
  9076. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9077. * @param start starting size to lerp between
  9078. * @param end end size to lerp between
  9079. * @param amount amount to lerp between the start and end values
  9080. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9081. */
  9082. static Lerp(start: Size, end: Size, amount: number): Size;
  9083. }
  9084. }
  9085. declare module "babylonjs/Maths/math.vertexFormat" {
  9086. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9087. /**
  9088. * Contains position and normal vectors for a vertex
  9089. */
  9090. export class PositionNormalVertex {
  9091. /** the position of the vertex (defaut: 0,0,0) */
  9092. position: Vector3;
  9093. /** the normal of the vertex (defaut: 0,1,0) */
  9094. normal: Vector3;
  9095. /**
  9096. * Creates a PositionNormalVertex
  9097. * @param position the position of the vertex (defaut: 0,0,0)
  9098. * @param normal the normal of the vertex (defaut: 0,1,0)
  9099. */
  9100. constructor(
  9101. /** the position of the vertex (defaut: 0,0,0) */
  9102. position?: Vector3,
  9103. /** the normal of the vertex (defaut: 0,1,0) */
  9104. normal?: Vector3);
  9105. /**
  9106. * Clones the PositionNormalVertex
  9107. * @returns the cloned PositionNormalVertex
  9108. */
  9109. clone(): PositionNormalVertex;
  9110. }
  9111. /**
  9112. * Contains position, normal and uv vectors for a vertex
  9113. */
  9114. export class PositionNormalTextureVertex {
  9115. /** the position of the vertex (defaut: 0,0,0) */
  9116. position: Vector3;
  9117. /** the normal of the vertex (defaut: 0,1,0) */
  9118. normal: Vector3;
  9119. /** the uv of the vertex (default: 0,0) */
  9120. uv: Vector2;
  9121. /**
  9122. * Creates a PositionNormalTextureVertex
  9123. * @param position the position of the vertex (defaut: 0,0,0)
  9124. * @param normal the normal of the vertex (defaut: 0,1,0)
  9125. * @param uv the uv of the vertex (default: 0,0)
  9126. */
  9127. constructor(
  9128. /** the position of the vertex (defaut: 0,0,0) */
  9129. position?: Vector3,
  9130. /** the normal of the vertex (defaut: 0,1,0) */
  9131. normal?: Vector3,
  9132. /** the uv of the vertex (default: 0,0) */
  9133. uv?: Vector2);
  9134. /**
  9135. * Clones the PositionNormalTextureVertex
  9136. * @returns the cloned PositionNormalTextureVertex
  9137. */
  9138. clone(): PositionNormalTextureVertex;
  9139. }
  9140. }
  9141. declare module "babylonjs/Maths/math" {
  9142. export * from "babylonjs/Maths/math.axis";
  9143. export * from "babylonjs/Maths/math.color";
  9144. export * from "babylonjs/Maths/math.constants";
  9145. export * from "babylonjs/Maths/math.frustum";
  9146. export * from "babylonjs/Maths/math.path";
  9147. export * from "babylonjs/Maths/math.plane";
  9148. export * from "babylonjs/Maths/math.size";
  9149. export * from "babylonjs/Maths/math.vector";
  9150. export * from "babylonjs/Maths/math.vertexFormat";
  9151. export * from "babylonjs/Maths/math.viewport";
  9152. }
  9153. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9154. /**
  9155. * Enum defining the type of animations supported by InputBlock
  9156. */
  9157. export enum AnimatedInputBlockTypes {
  9158. /** No animation */
  9159. None = 0,
  9160. /** Time based animation. Will only work for floats */
  9161. Time = 1
  9162. }
  9163. }
  9164. declare module "babylonjs/Lights/shadowLight" {
  9165. import { Camera } from "babylonjs/Cameras/camera";
  9166. import { Scene } from "babylonjs/scene";
  9167. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9169. import { Light } from "babylonjs/Lights/light";
  9170. /**
  9171. * Interface describing all the common properties and methods a shadow light needs to implement.
  9172. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9173. * as well as binding the different shadow properties to the effects.
  9174. */
  9175. export interface IShadowLight extends Light {
  9176. /**
  9177. * The light id in the scene (used in scene.findLighById for instance)
  9178. */
  9179. id: string;
  9180. /**
  9181. * The position the shdow will be casted from.
  9182. */
  9183. position: Vector3;
  9184. /**
  9185. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9186. */
  9187. direction: Vector3;
  9188. /**
  9189. * The transformed position. Position of the light in world space taking parenting in account.
  9190. */
  9191. transformedPosition: Vector3;
  9192. /**
  9193. * The transformed direction. Direction of the light in world space taking parenting in account.
  9194. */
  9195. transformedDirection: Vector3;
  9196. /**
  9197. * The friendly name of the light in the scene.
  9198. */
  9199. name: string;
  9200. /**
  9201. * Defines the shadow projection clipping minimum z value.
  9202. */
  9203. shadowMinZ: number;
  9204. /**
  9205. * Defines the shadow projection clipping maximum z value.
  9206. */
  9207. shadowMaxZ: number;
  9208. /**
  9209. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9210. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9211. */
  9212. computeTransformedInformation(): boolean;
  9213. /**
  9214. * Gets the scene the light belongs to.
  9215. * @returns The scene
  9216. */
  9217. getScene(): Scene;
  9218. /**
  9219. * Callback defining a custom Projection Matrix Builder.
  9220. * This can be used to override the default projection matrix computation.
  9221. */
  9222. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9223. /**
  9224. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9225. * @param matrix The materix to updated with the projection information
  9226. * @param viewMatrix The transform matrix of the light
  9227. * @param renderList The list of mesh to render in the map
  9228. * @returns The current light
  9229. */
  9230. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9231. /**
  9232. * Gets the current depth scale used in ESM.
  9233. * @returns The scale
  9234. */
  9235. getDepthScale(): number;
  9236. /**
  9237. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9238. * @returns true if a cube texture needs to be use
  9239. */
  9240. needCube(): boolean;
  9241. /**
  9242. * Detects if the projection matrix requires to be recomputed this frame.
  9243. * @returns true if it requires to be recomputed otherwise, false.
  9244. */
  9245. needProjectionMatrixCompute(): boolean;
  9246. /**
  9247. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9248. */
  9249. forceProjectionMatrixCompute(): void;
  9250. /**
  9251. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9252. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9253. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9254. */
  9255. getShadowDirection(faceIndex?: number): Vector3;
  9256. /**
  9257. * Gets the minZ used for shadow according to both the scene and the light.
  9258. * @param activeCamera The camera we are returning the min for
  9259. * @returns the depth min z
  9260. */
  9261. getDepthMinZ(activeCamera: Camera): number;
  9262. /**
  9263. * Gets the maxZ used for shadow according to both the scene and the light.
  9264. * @param activeCamera The camera we are returning the max for
  9265. * @returns the depth max z
  9266. */
  9267. getDepthMaxZ(activeCamera: Camera): number;
  9268. }
  9269. /**
  9270. * Base implementation IShadowLight
  9271. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9272. */
  9273. export abstract class ShadowLight extends Light implements IShadowLight {
  9274. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9275. protected _position: Vector3;
  9276. protected _setPosition(value: Vector3): void;
  9277. /**
  9278. * Sets the position the shadow will be casted from. Also use as the light position for both
  9279. * point and spot lights.
  9280. */
  9281. get position(): Vector3;
  9282. /**
  9283. * Sets the position the shadow will be casted from. Also use as the light position for both
  9284. * point and spot lights.
  9285. */
  9286. set position(value: Vector3);
  9287. protected _direction: Vector3;
  9288. protected _setDirection(value: Vector3): void;
  9289. /**
  9290. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9291. * Also use as the light direction on spot and directional lights.
  9292. */
  9293. get direction(): Vector3;
  9294. /**
  9295. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9296. * Also use as the light direction on spot and directional lights.
  9297. */
  9298. set direction(value: Vector3);
  9299. protected _shadowMinZ: number;
  9300. /**
  9301. * Gets the shadow projection clipping minimum z value.
  9302. */
  9303. get shadowMinZ(): number;
  9304. /**
  9305. * Sets the shadow projection clipping minimum z value.
  9306. */
  9307. set shadowMinZ(value: number);
  9308. protected _shadowMaxZ: number;
  9309. /**
  9310. * Sets the shadow projection clipping maximum z value.
  9311. */
  9312. get shadowMaxZ(): number;
  9313. /**
  9314. * Gets the shadow projection clipping maximum z value.
  9315. */
  9316. set shadowMaxZ(value: number);
  9317. /**
  9318. * Callback defining a custom Projection Matrix Builder.
  9319. * This can be used to override the default projection matrix computation.
  9320. */
  9321. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9322. /**
  9323. * The transformed position. Position of the light in world space taking parenting in account.
  9324. */
  9325. transformedPosition: Vector3;
  9326. /**
  9327. * The transformed direction. Direction of the light in world space taking parenting in account.
  9328. */
  9329. transformedDirection: Vector3;
  9330. private _needProjectionMatrixCompute;
  9331. /**
  9332. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9333. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9334. */
  9335. computeTransformedInformation(): boolean;
  9336. /**
  9337. * Return the depth scale used for the shadow map.
  9338. * @returns the depth scale.
  9339. */
  9340. getDepthScale(): number;
  9341. /**
  9342. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9343. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9344. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9345. */
  9346. getShadowDirection(faceIndex?: number): Vector3;
  9347. /**
  9348. * Returns the ShadowLight absolute position in the World.
  9349. * @returns the position vector in world space
  9350. */
  9351. getAbsolutePosition(): Vector3;
  9352. /**
  9353. * Sets the ShadowLight direction toward the passed target.
  9354. * @param target The point to target in local space
  9355. * @returns the updated ShadowLight direction
  9356. */
  9357. setDirectionToTarget(target: Vector3): Vector3;
  9358. /**
  9359. * Returns the light rotation in euler definition.
  9360. * @returns the x y z rotation in local space.
  9361. */
  9362. getRotation(): Vector3;
  9363. /**
  9364. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9365. * @returns true if a cube texture needs to be use
  9366. */
  9367. needCube(): boolean;
  9368. /**
  9369. * Detects if the projection matrix requires to be recomputed this frame.
  9370. * @returns true if it requires to be recomputed otherwise, false.
  9371. */
  9372. needProjectionMatrixCompute(): boolean;
  9373. /**
  9374. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9375. */
  9376. forceProjectionMatrixCompute(): void;
  9377. /** @hidden */
  9378. _initCache(): void;
  9379. /** @hidden */
  9380. _isSynchronized(): boolean;
  9381. /**
  9382. * Computes the world matrix of the node
  9383. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9384. * @returns the world matrix
  9385. */
  9386. computeWorldMatrix(force?: boolean): Matrix;
  9387. /**
  9388. * Gets the minZ used for shadow according to both the scene and the light.
  9389. * @param activeCamera The camera we are returning the min for
  9390. * @returns the depth min z
  9391. */
  9392. getDepthMinZ(activeCamera: Camera): number;
  9393. /**
  9394. * Gets the maxZ used for shadow according to both the scene and the light.
  9395. * @param activeCamera The camera we are returning the max for
  9396. * @returns the depth max z
  9397. */
  9398. getDepthMaxZ(activeCamera: Camera): number;
  9399. /**
  9400. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9401. * @param matrix The materix to updated with the projection information
  9402. * @param viewMatrix The transform matrix of the light
  9403. * @param renderList The list of mesh to render in the map
  9404. * @returns The current light
  9405. */
  9406. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9407. }
  9408. }
  9409. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9410. /** @hidden */
  9411. export var packingFunctions: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9417. /** @hidden */
  9418. export var bayerDitherFunctions: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9424. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9425. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9426. /** @hidden */
  9427. export var shadowMapFragmentDeclaration: {
  9428. name: string;
  9429. shader: string;
  9430. };
  9431. }
  9432. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9433. /** @hidden */
  9434. export var clipPlaneFragmentDeclaration: {
  9435. name: string;
  9436. shader: string;
  9437. };
  9438. }
  9439. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9440. /** @hidden */
  9441. export var clipPlaneFragment: {
  9442. name: string;
  9443. shader: string;
  9444. };
  9445. }
  9446. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9447. /** @hidden */
  9448. export var shadowMapFragment: {
  9449. name: string;
  9450. shader: string;
  9451. };
  9452. }
  9453. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9454. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9455. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9456. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9457. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9458. /** @hidden */
  9459. export var shadowMapPixelShader: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9465. /** @hidden */
  9466. export var bonesDeclaration: {
  9467. name: string;
  9468. shader: string;
  9469. };
  9470. }
  9471. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9472. /** @hidden */
  9473. export var morphTargetsVertexGlobalDeclaration: {
  9474. name: string;
  9475. shader: string;
  9476. };
  9477. }
  9478. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9479. /** @hidden */
  9480. export var morphTargetsVertexDeclaration: {
  9481. name: string;
  9482. shader: string;
  9483. };
  9484. }
  9485. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9486. /** @hidden */
  9487. export var instancesDeclaration: {
  9488. name: string;
  9489. shader: string;
  9490. };
  9491. }
  9492. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9493. /** @hidden */
  9494. export var helperFunctions: {
  9495. name: string;
  9496. shader: string;
  9497. };
  9498. }
  9499. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9500. /** @hidden */
  9501. export var shadowMapVertexDeclaration: {
  9502. name: string;
  9503. shader: string;
  9504. };
  9505. }
  9506. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9507. /** @hidden */
  9508. export var clipPlaneVertexDeclaration: {
  9509. name: string;
  9510. shader: string;
  9511. };
  9512. }
  9513. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9514. /** @hidden */
  9515. export var morphTargetsVertex: {
  9516. name: string;
  9517. shader: string;
  9518. };
  9519. }
  9520. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9521. /** @hidden */
  9522. export var instancesVertex: {
  9523. name: string;
  9524. shader: string;
  9525. };
  9526. }
  9527. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9528. /** @hidden */
  9529. export var bonesVertex: {
  9530. name: string;
  9531. shader: string;
  9532. };
  9533. }
  9534. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9535. /** @hidden */
  9536. export var shadowMapVertexNormalBias: {
  9537. name: string;
  9538. shader: string;
  9539. };
  9540. }
  9541. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9542. /** @hidden */
  9543. export var shadowMapVertexMetric: {
  9544. name: string;
  9545. shader: string;
  9546. };
  9547. }
  9548. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9549. /** @hidden */
  9550. export var clipPlaneVertex: {
  9551. name: string;
  9552. shader: string;
  9553. };
  9554. }
  9555. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9556. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9557. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9558. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9559. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9560. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9561. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9562. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9563. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9564. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9565. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9566. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9567. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9568. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9569. /** @hidden */
  9570. export var shadowMapVertexShader: {
  9571. name: string;
  9572. shader: string;
  9573. };
  9574. }
  9575. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9576. /** @hidden */
  9577. export var depthBoxBlurPixelShader: {
  9578. name: string;
  9579. shader: string;
  9580. };
  9581. }
  9582. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9583. /** @hidden */
  9584. export var shadowMapFragmentSoftTransparentShadow: {
  9585. name: string;
  9586. shader: string;
  9587. };
  9588. }
  9589. declare module "babylonjs/Materials/effectFallbacks" {
  9590. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9591. import { Effect } from "babylonjs/Materials/effect";
  9592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9593. /**
  9594. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9595. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9596. */
  9597. export class EffectFallbacks implements IEffectFallbacks {
  9598. private _defines;
  9599. private _currentRank;
  9600. private _maxRank;
  9601. private _mesh;
  9602. /**
  9603. * Removes the fallback from the bound mesh.
  9604. */
  9605. unBindMesh(): void;
  9606. /**
  9607. * Adds a fallback on the specified property.
  9608. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9609. * @param define The name of the define in the shader
  9610. */
  9611. addFallback(rank: number, define: string): void;
  9612. /**
  9613. * Sets the mesh to use CPU skinning when needing to fallback.
  9614. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9615. * @param mesh The mesh to use the fallbacks.
  9616. */
  9617. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9618. /**
  9619. * Checks to see if more fallbacks are still availible.
  9620. */
  9621. get hasMoreFallbacks(): boolean;
  9622. /**
  9623. * Removes the defines that should be removed when falling back.
  9624. * @param currentDefines defines the current define statements for the shader.
  9625. * @param effect defines the current effect we try to compile
  9626. * @returns The resulting defines with defines of the current rank removed.
  9627. */
  9628. reduce(currentDefines: string, effect: Effect): string;
  9629. }
  9630. }
  9631. declare module "babylonjs/Actions/action" {
  9632. import { Observable } from "babylonjs/Misc/observable";
  9633. import { Condition } from "babylonjs/Actions/condition";
  9634. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9635. import { Nullable } from "babylonjs/types";
  9636. import { Scene } from "babylonjs/scene";
  9637. import { ActionManager } from "babylonjs/Actions/actionManager";
  9638. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9639. import { Node } from "babylonjs/node";
  9640. /**
  9641. * Interface used to define Action
  9642. */
  9643. export interface IAction {
  9644. /**
  9645. * Trigger for the action
  9646. */
  9647. trigger: number;
  9648. /** Options of the trigger */
  9649. triggerOptions: any;
  9650. /**
  9651. * Gets the trigger parameters
  9652. * @returns the trigger parameters
  9653. */
  9654. getTriggerParameter(): any;
  9655. /**
  9656. * Internal only - executes current action event
  9657. * @hidden
  9658. */
  9659. _executeCurrent(evt?: ActionEvent): void;
  9660. /**
  9661. * Serialize placeholder for child classes
  9662. * @param parent of child
  9663. * @returns the serialized object
  9664. */
  9665. serialize(parent: any): any;
  9666. /**
  9667. * Internal only
  9668. * @hidden
  9669. */
  9670. _prepare(): void;
  9671. /**
  9672. * Internal only - manager for action
  9673. * @hidden
  9674. */
  9675. _actionManager: Nullable<AbstractActionManager>;
  9676. /**
  9677. * Adds action to chain of actions, may be a DoNothingAction
  9678. * @param action defines the next action to execute
  9679. * @returns The action passed in
  9680. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9681. */
  9682. then(action: IAction): IAction;
  9683. }
  9684. /**
  9685. * The action to be carried out following a trigger
  9686. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9687. */
  9688. export class Action implements IAction {
  9689. /** the trigger, with or without parameters, for the action */
  9690. triggerOptions: any;
  9691. /**
  9692. * Trigger for the action
  9693. */
  9694. trigger: number;
  9695. /**
  9696. * Internal only - manager for action
  9697. * @hidden
  9698. */
  9699. _actionManager: ActionManager;
  9700. private _nextActiveAction;
  9701. private _child;
  9702. private _condition?;
  9703. private _triggerParameter;
  9704. /**
  9705. * An event triggered prior to action being executed.
  9706. */
  9707. onBeforeExecuteObservable: Observable<Action>;
  9708. /**
  9709. * Creates a new Action
  9710. * @param triggerOptions the trigger, with or without parameters, for the action
  9711. * @param condition an optional determinant of action
  9712. */
  9713. constructor(
  9714. /** the trigger, with or without parameters, for the action */
  9715. triggerOptions: any, condition?: Condition);
  9716. /**
  9717. * Internal only
  9718. * @hidden
  9719. */
  9720. _prepare(): void;
  9721. /**
  9722. * Gets the trigger parameters
  9723. * @returns the trigger parameters
  9724. */
  9725. getTriggerParameter(): any;
  9726. /**
  9727. * Internal only - executes current action event
  9728. * @hidden
  9729. */
  9730. _executeCurrent(evt?: ActionEvent): void;
  9731. /**
  9732. * Execute placeholder for child classes
  9733. * @param evt optional action event
  9734. */
  9735. execute(evt?: ActionEvent): void;
  9736. /**
  9737. * Skips to next active action
  9738. */
  9739. skipToNextActiveAction(): void;
  9740. /**
  9741. * Adds action to chain of actions, may be a DoNothingAction
  9742. * @param action defines the next action to execute
  9743. * @returns The action passed in
  9744. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9745. */
  9746. then(action: Action): Action;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. _getProperty(propertyPath: string): string;
  9752. /**
  9753. * Internal only
  9754. * @hidden
  9755. */
  9756. _getEffectiveTarget(target: any, propertyPath: string): any;
  9757. /**
  9758. * Serialize placeholder for child classes
  9759. * @param parent of child
  9760. * @returns the serialized object
  9761. */
  9762. serialize(parent: any): any;
  9763. /**
  9764. * Internal only called by serialize
  9765. * @hidden
  9766. */
  9767. protected _serialize(serializedAction: any, parent?: any): any;
  9768. /**
  9769. * Internal only
  9770. * @hidden
  9771. */
  9772. static _SerializeValueAsString: (value: any) => string;
  9773. /**
  9774. * Internal only
  9775. * @hidden
  9776. */
  9777. static _GetTargetProperty: (target: Scene | Node) => {
  9778. name: string;
  9779. targetType: string;
  9780. value: string;
  9781. };
  9782. }
  9783. }
  9784. declare module "babylonjs/Actions/condition" {
  9785. import { ActionManager } from "babylonjs/Actions/actionManager";
  9786. /**
  9787. * A Condition applied to an Action
  9788. */
  9789. export class Condition {
  9790. /**
  9791. * Internal only - manager for action
  9792. * @hidden
  9793. */
  9794. _actionManager: ActionManager;
  9795. /**
  9796. * Internal only
  9797. * @hidden
  9798. */
  9799. _evaluationId: number;
  9800. /**
  9801. * Internal only
  9802. * @hidden
  9803. */
  9804. _currentResult: boolean;
  9805. /**
  9806. * Creates a new Condition
  9807. * @param actionManager the manager of the action the condition is applied to
  9808. */
  9809. constructor(actionManager: ActionManager);
  9810. /**
  9811. * Check if the current condition is valid
  9812. * @returns a boolean
  9813. */
  9814. isValid(): boolean;
  9815. /**
  9816. * Internal only
  9817. * @hidden
  9818. */
  9819. _getProperty(propertyPath: string): string;
  9820. /**
  9821. * Internal only
  9822. * @hidden
  9823. */
  9824. _getEffectiveTarget(target: any, propertyPath: string): any;
  9825. /**
  9826. * Serialize placeholder for child classes
  9827. * @returns the serialized object
  9828. */
  9829. serialize(): any;
  9830. /**
  9831. * Internal only
  9832. * @hidden
  9833. */
  9834. protected _serialize(serializedCondition: any): any;
  9835. }
  9836. /**
  9837. * Defines specific conditional operators as extensions of Condition
  9838. */
  9839. export class ValueCondition extends Condition {
  9840. /** path to specify the property of the target the conditional operator uses */
  9841. propertyPath: string;
  9842. /** the value compared by the conditional operator against the current value of the property */
  9843. value: any;
  9844. /** the conditional operator, default ValueCondition.IsEqual */
  9845. operator: number;
  9846. /**
  9847. * Internal only
  9848. * @hidden
  9849. */
  9850. private static _IsEqual;
  9851. /**
  9852. * Internal only
  9853. * @hidden
  9854. */
  9855. private static _IsDifferent;
  9856. /**
  9857. * Internal only
  9858. * @hidden
  9859. */
  9860. private static _IsGreater;
  9861. /**
  9862. * Internal only
  9863. * @hidden
  9864. */
  9865. private static _IsLesser;
  9866. /**
  9867. * returns the number for IsEqual
  9868. */
  9869. static get IsEqual(): number;
  9870. /**
  9871. * Returns the number for IsDifferent
  9872. */
  9873. static get IsDifferent(): number;
  9874. /**
  9875. * Returns the number for IsGreater
  9876. */
  9877. static get IsGreater(): number;
  9878. /**
  9879. * Returns the number for IsLesser
  9880. */
  9881. static get IsLesser(): number;
  9882. /**
  9883. * Internal only The action manager for the condition
  9884. * @hidden
  9885. */
  9886. _actionManager: ActionManager;
  9887. /**
  9888. * Internal only
  9889. * @hidden
  9890. */
  9891. private _target;
  9892. /**
  9893. * Internal only
  9894. * @hidden
  9895. */
  9896. private _effectiveTarget;
  9897. /**
  9898. * Internal only
  9899. * @hidden
  9900. */
  9901. private _property;
  9902. /**
  9903. * Creates a new ValueCondition
  9904. * @param actionManager manager for the action the condition applies to
  9905. * @param target for the action
  9906. * @param propertyPath path to specify the property of the target the conditional operator uses
  9907. * @param value the value compared by the conditional operator against the current value of the property
  9908. * @param operator the conditional operator, default ValueCondition.IsEqual
  9909. */
  9910. constructor(actionManager: ActionManager, target: any,
  9911. /** path to specify the property of the target the conditional operator uses */
  9912. propertyPath: string,
  9913. /** the value compared by the conditional operator against the current value of the property */
  9914. value: any,
  9915. /** the conditional operator, default ValueCondition.IsEqual */
  9916. operator?: number);
  9917. /**
  9918. * Compares the given value with the property value for the specified conditional operator
  9919. * @returns the result of the comparison
  9920. */
  9921. isValid(): boolean;
  9922. /**
  9923. * Serialize the ValueCondition into a JSON compatible object
  9924. * @returns serialization object
  9925. */
  9926. serialize(): any;
  9927. /**
  9928. * Gets the name of the conditional operator for the ValueCondition
  9929. * @param operator the conditional operator
  9930. * @returns the name
  9931. */
  9932. static GetOperatorName(operator: number): string;
  9933. }
  9934. /**
  9935. * Defines a predicate condition as an extension of Condition
  9936. */
  9937. export class PredicateCondition extends Condition {
  9938. /** defines the predicate function used to validate the condition */
  9939. predicate: () => boolean;
  9940. /**
  9941. * Internal only - manager for action
  9942. * @hidden
  9943. */
  9944. _actionManager: ActionManager;
  9945. /**
  9946. * Creates a new PredicateCondition
  9947. * @param actionManager manager for the action the condition applies to
  9948. * @param predicate defines the predicate function used to validate the condition
  9949. */
  9950. constructor(actionManager: ActionManager,
  9951. /** defines the predicate function used to validate the condition */
  9952. predicate: () => boolean);
  9953. /**
  9954. * @returns the validity of the predicate condition
  9955. */
  9956. isValid(): boolean;
  9957. }
  9958. /**
  9959. * Defines a state condition as an extension of Condition
  9960. */
  9961. export class StateCondition extends Condition {
  9962. /** Value to compare with target state */
  9963. value: string;
  9964. /**
  9965. * Internal only - manager for action
  9966. * @hidden
  9967. */
  9968. _actionManager: ActionManager;
  9969. /**
  9970. * Internal only
  9971. * @hidden
  9972. */
  9973. private _target;
  9974. /**
  9975. * Creates a new StateCondition
  9976. * @param actionManager manager for the action the condition applies to
  9977. * @param target of the condition
  9978. * @param value to compare with target state
  9979. */
  9980. constructor(actionManager: ActionManager, target: any,
  9981. /** Value to compare with target state */
  9982. value: string);
  9983. /**
  9984. * Gets a boolean indicating if the current condition is met
  9985. * @returns the validity of the state
  9986. */
  9987. isValid(): boolean;
  9988. /**
  9989. * Serialize the StateCondition into a JSON compatible object
  9990. * @returns serialization object
  9991. */
  9992. serialize(): any;
  9993. }
  9994. }
  9995. declare module "babylonjs/Actions/directActions" {
  9996. import { Action } from "babylonjs/Actions/action";
  9997. import { Condition } from "babylonjs/Actions/condition";
  9998. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9999. /**
  10000. * This defines an action responsible to toggle a boolean once triggered.
  10001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10002. */
  10003. export class SwitchBooleanAction extends Action {
  10004. /**
  10005. * The path to the boolean property in the target object
  10006. */
  10007. propertyPath: string;
  10008. private _target;
  10009. private _effectiveTarget;
  10010. private _property;
  10011. /**
  10012. * Instantiate the action
  10013. * @param triggerOptions defines the trigger options
  10014. * @param target defines the object containing the boolean
  10015. * @param propertyPath defines the path to the boolean property in the target object
  10016. * @param condition defines the trigger related conditions
  10017. */
  10018. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10019. /** @hidden */
  10020. _prepare(): void;
  10021. /**
  10022. * Execute the action toggle the boolean value.
  10023. */
  10024. execute(): void;
  10025. /**
  10026. * Serializes the actions and its related information.
  10027. * @param parent defines the object to serialize in
  10028. * @returns the serialized object
  10029. */
  10030. serialize(parent: any): any;
  10031. }
  10032. /**
  10033. * This defines an action responsible to set a the state field of the target
  10034. * to a desired value once triggered.
  10035. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10036. */
  10037. export class SetStateAction extends Action {
  10038. /**
  10039. * The value to store in the state field.
  10040. */
  10041. value: string;
  10042. private _target;
  10043. /**
  10044. * Instantiate the action
  10045. * @param triggerOptions defines the trigger options
  10046. * @param target defines the object containing the state property
  10047. * @param value defines the value to store in the state field
  10048. * @param condition defines the trigger related conditions
  10049. */
  10050. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10051. /**
  10052. * Execute the action and store the value on the target state property.
  10053. */
  10054. execute(): void;
  10055. /**
  10056. * Serializes the actions and its related information.
  10057. * @param parent defines the object to serialize in
  10058. * @returns the serialized object
  10059. */
  10060. serialize(parent: any): any;
  10061. }
  10062. /**
  10063. * This defines an action responsible to set a property of the target
  10064. * to a desired value once triggered.
  10065. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10066. */
  10067. export class SetValueAction extends Action {
  10068. /**
  10069. * The path of the property to set in the target.
  10070. */
  10071. propertyPath: string;
  10072. /**
  10073. * The value to set in the property
  10074. */
  10075. value: any;
  10076. private _target;
  10077. private _effectiveTarget;
  10078. private _property;
  10079. /**
  10080. * Instantiate the action
  10081. * @param triggerOptions defines the trigger options
  10082. * @param target defines the object containing the property
  10083. * @param propertyPath defines the path of the property to set in the target
  10084. * @param value defines the value to set in the property
  10085. * @param condition defines the trigger related conditions
  10086. */
  10087. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10088. /** @hidden */
  10089. _prepare(): void;
  10090. /**
  10091. * Execute the action and set the targetted property to the desired value.
  10092. */
  10093. execute(): void;
  10094. /**
  10095. * Serializes the actions and its related information.
  10096. * @param parent defines the object to serialize in
  10097. * @returns the serialized object
  10098. */
  10099. serialize(parent: any): any;
  10100. }
  10101. /**
  10102. * This defines an action responsible to increment the target value
  10103. * to a desired value once triggered.
  10104. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10105. */
  10106. export class IncrementValueAction extends Action {
  10107. /**
  10108. * The path of the property to increment in the target.
  10109. */
  10110. propertyPath: string;
  10111. /**
  10112. * The value we should increment the property by.
  10113. */
  10114. value: any;
  10115. private _target;
  10116. private _effectiveTarget;
  10117. private _property;
  10118. /**
  10119. * Instantiate the action
  10120. * @param triggerOptions defines the trigger options
  10121. * @param target defines the object containing the property
  10122. * @param propertyPath defines the path of the property to increment in the target
  10123. * @param value defines the value value we should increment the property by
  10124. * @param condition defines the trigger related conditions
  10125. */
  10126. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10127. /** @hidden */
  10128. _prepare(): void;
  10129. /**
  10130. * Execute the action and increment the target of the value amount.
  10131. */
  10132. execute(): void;
  10133. /**
  10134. * Serializes the actions and its related information.
  10135. * @param parent defines the object to serialize in
  10136. * @returns the serialized object
  10137. */
  10138. serialize(parent: any): any;
  10139. }
  10140. /**
  10141. * This defines an action responsible to start an animation once triggered.
  10142. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10143. */
  10144. export class PlayAnimationAction extends Action {
  10145. /**
  10146. * Where the animation should start (animation frame)
  10147. */
  10148. from: number;
  10149. /**
  10150. * Where the animation should stop (animation frame)
  10151. */
  10152. to: number;
  10153. /**
  10154. * Define if the animation should loop or stop after the first play.
  10155. */
  10156. loop?: boolean;
  10157. private _target;
  10158. /**
  10159. * Instantiate the action
  10160. * @param triggerOptions defines the trigger options
  10161. * @param target defines the target animation or animation name
  10162. * @param from defines from where the animation should start (animation frame)
  10163. * @param end defines where the animation should stop (animation frame)
  10164. * @param loop defines if the animation should loop or stop after the first play
  10165. * @param condition defines the trigger related conditions
  10166. */
  10167. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10168. /** @hidden */
  10169. _prepare(): void;
  10170. /**
  10171. * Execute the action and play the animation.
  10172. */
  10173. execute(): void;
  10174. /**
  10175. * Serializes the actions and its related information.
  10176. * @param parent defines the object to serialize in
  10177. * @returns the serialized object
  10178. */
  10179. serialize(parent: any): any;
  10180. }
  10181. /**
  10182. * This defines an action responsible to stop an animation once triggered.
  10183. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10184. */
  10185. export class StopAnimationAction extends Action {
  10186. private _target;
  10187. /**
  10188. * Instantiate the action
  10189. * @param triggerOptions defines the trigger options
  10190. * @param target defines the target animation or animation name
  10191. * @param condition defines the trigger related conditions
  10192. */
  10193. constructor(triggerOptions: any, target: any, condition?: Condition);
  10194. /** @hidden */
  10195. _prepare(): void;
  10196. /**
  10197. * Execute the action and stop the animation.
  10198. */
  10199. execute(): void;
  10200. /**
  10201. * Serializes the actions and its related information.
  10202. * @param parent defines the object to serialize in
  10203. * @returns the serialized object
  10204. */
  10205. serialize(parent: any): any;
  10206. }
  10207. /**
  10208. * This defines an action responsible that does nothing once triggered.
  10209. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10210. */
  10211. export class DoNothingAction extends Action {
  10212. /**
  10213. * Instantiate the action
  10214. * @param triggerOptions defines the trigger options
  10215. * @param condition defines the trigger related conditions
  10216. */
  10217. constructor(triggerOptions?: any, condition?: Condition);
  10218. /**
  10219. * Execute the action and do nothing.
  10220. */
  10221. execute(): void;
  10222. /**
  10223. * Serializes the actions and its related information.
  10224. * @param parent defines the object to serialize in
  10225. * @returns the serialized object
  10226. */
  10227. serialize(parent: any): any;
  10228. }
  10229. /**
  10230. * This defines an action responsible to trigger several actions once triggered.
  10231. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10232. */
  10233. export class CombineAction extends Action {
  10234. /**
  10235. * The list of aggregated animations to run.
  10236. */
  10237. children: Action[];
  10238. /**
  10239. * Instantiate the action
  10240. * @param triggerOptions defines the trigger options
  10241. * @param children defines the list of aggregated animations to run
  10242. * @param condition defines the trigger related conditions
  10243. */
  10244. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10245. /** @hidden */
  10246. _prepare(): void;
  10247. /**
  10248. * Execute the action and executes all the aggregated actions.
  10249. */
  10250. execute(evt: ActionEvent): void;
  10251. /**
  10252. * Serializes the actions and its related information.
  10253. * @param parent defines the object to serialize in
  10254. * @returns the serialized object
  10255. */
  10256. serialize(parent: any): any;
  10257. }
  10258. /**
  10259. * This defines an action responsible to run code (external event) once triggered.
  10260. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10261. */
  10262. export class ExecuteCodeAction extends Action {
  10263. /**
  10264. * The callback function to run.
  10265. */
  10266. func: (evt: ActionEvent) => void;
  10267. /**
  10268. * Instantiate the action
  10269. * @param triggerOptions defines the trigger options
  10270. * @param func defines the callback function to run
  10271. * @param condition defines the trigger related conditions
  10272. */
  10273. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10274. /**
  10275. * Execute the action and run the attached code.
  10276. */
  10277. execute(evt: ActionEvent): void;
  10278. }
  10279. /**
  10280. * This defines an action responsible to set the parent property of the target once triggered.
  10281. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10282. */
  10283. export class SetParentAction extends Action {
  10284. private _parent;
  10285. private _target;
  10286. /**
  10287. * Instantiate the action
  10288. * @param triggerOptions defines the trigger options
  10289. * @param target defines the target containing the parent property
  10290. * @param parent defines from where the animation should start (animation frame)
  10291. * @param condition defines the trigger related conditions
  10292. */
  10293. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10294. /** @hidden */
  10295. _prepare(): void;
  10296. /**
  10297. * Execute the action and set the parent property.
  10298. */
  10299. execute(): void;
  10300. /**
  10301. * Serializes the actions and its related information.
  10302. * @param parent defines the object to serialize in
  10303. * @returns the serialized object
  10304. */
  10305. serialize(parent: any): any;
  10306. }
  10307. }
  10308. declare module "babylonjs/Actions/actionManager" {
  10309. import { Nullable } from "babylonjs/types";
  10310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10311. import { Scene } from "babylonjs/scene";
  10312. import { IAction } from "babylonjs/Actions/action";
  10313. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10314. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10315. /**
  10316. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10317. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10318. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10319. */
  10320. export class ActionManager extends AbstractActionManager {
  10321. /**
  10322. * Nothing
  10323. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10324. */
  10325. static readonly NothingTrigger: number;
  10326. /**
  10327. * On pick
  10328. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10329. */
  10330. static readonly OnPickTrigger: number;
  10331. /**
  10332. * On left pick
  10333. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10334. */
  10335. static readonly OnLeftPickTrigger: number;
  10336. /**
  10337. * On right pick
  10338. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10339. */
  10340. static readonly OnRightPickTrigger: number;
  10341. /**
  10342. * On center pick
  10343. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10344. */
  10345. static readonly OnCenterPickTrigger: number;
  10346. /**
  10347. * On pick down
  10348. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10349. */
  10350. static readonly OnPickDownTrigger: number;
  10351. /**
  10352. * On double pick
  10353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10354. */
  10355. static readonly OnDoublePickTrigger: number;
  10356. /**
  10357. * On pick up
  10358. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10359. */
  10360. static readonly OnPickUpTrigger: number;
  10361. /**
  10362. * On pick out.
  10363. * This trigger will only be raised if you also declared a OnPickDown
  10364. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10365. */
  10366. static readonly OnPickOutTrigger: number;
  10367. /**
  10368. * On long press
  10369. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10370. */
  10371. static readonly OnLongPressTrigger: number;
  10372. /**
  10373. * On pointer over
  10374. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10375. */
  10376. static readonly OnPointerOverTrigger: number;
  10377. /**
  10378. * On pointer out
  10379. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10380. */
  10381. static readonly OnPointerOutTrigger: number;
  10382. /**
  10383. * On every frame
  10384. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10385. */
  10386. static readonly OnEveryFrameTrigger: number;
  10387. /**
  10388. * On intersection enter
  10389. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10390. */
  10391. static readonly OnIntersectionEnterTrigger: number;
  10392. /**
  10393. * On intersection exit
  10394. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10395. */
  10396. static readonly OnIntersectionExitTrigger: number;
  10397. /**
  10398. * On key down
  10399. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10400. */
  10401. static readonly OnKeyDownTrigger: number;
  10402. /**
  10403. * On key up
  10404. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10405. */
  10406. static readonly OnKeyUpTrigger: number;
  10407. private _scene;
  10408. /**
  10409. * Creates a new action manager
  10410. * @param scene defines the hosting scene
  10411. */
  10412. constructor(scene: Scene);
  10413. /**
  10414. * Releases all associated resources
  10415. */
  10416. dispose(): void;
  10417. /**
  10418. * Gets hosting scene
  10419. * @returns the hosting scene
  10420. */
  10421. getScene(): Scene;
  10422. /**
  10423. * Does this action manager handles actions of any of the given triggers
  10424. * @param triggers defines the triggers to be tested
  10425. * @return a boolean indicating whether one (or more) of the triggers is handled
  10426. */
  10427. hasSpecificTriggers(triggers: number[]): boolean;
  10428. /**
  10429. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10430. * speed.
  10431. * @param triggerA defines the trigger to be tested
  10432. * @param triggerB defines the trigger to be tested
  10433. * @return a boolean indicating whether one (or more) of the triggers is handled
  10434. */
  10435. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10436. /**
  10437. * Does this action manager handles actions of a given trigger
  10438. * @param trigger defines the trigger to be tested
  10439. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10440. * @return whether the trigger is handled
  10441. */
  10442. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10443. /**
  10444. * Does this action manager has pointer triggers
  10445. */
  10446. get hasPointerTriggers(): boolean;
  10447. /**
  10448. * Does this action manager has pick triggers
  10449. */
  10450. get hasPickTriggers(): boolean;
  10451. /**
  10452. * Registers an action to this action manager
  10453. * @param action defines the action to be registered
  10454. * @return the action amended (prepared) after registration
  10455. */
  10456. registerAction(action: IAction): Nullable<IAction>;
  10457. /**
  10458. * Unregisters an action to this action manager
  10459. * @param action defines the action to be unregistered
  10460. * @return a boolean indicating whether the action has been unregistered
  10461. */
  10462. unregisterAction(action: IAction): Boolean;
  10463. /**
  10464. * Process a specific trigger
  10465. * @param trigger defines the trigger to process
  10466. * @param evt defines the event details to be processed
  10467. */
  10468. processTrigger(trigger: number, evt?: IActionEvent): void;
  10469. /** @hidden */
  10470. _getEffectiveTarget(target: any, propertyPath: string): any;
  10471. /** @hidden */
  10472. _getProperty(propertyPath: string): string;
  10473. /**
  10474. * Serialize this manager to a JSON object
  10475. * @param name defines the property name to store this manager
  10476. * @returns a JSON representation of this manager
  10477. */
  10478. serialize(name: string): any;
  10479. /**
  10480. * Creates a new ActionManager from a JSON data
  10481. * @param parsedActions defines the JSON data to read from
  10482. * @param object defines the hosting mesh
  10483. * @param scene defines the hosting scene
  10484. */
  10485. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10486. /**
  10487. * Get a trigger name by index
  10488. * @param trigger defines the trigger index
  10489. * @returns a trigger name
  10490. */
  10491. static GetTriggerName(trigger: number): string;
  10492. }
  10493. }
  10494. declare module "babylonjs/Sprites/sprite" {
  10495. import { Vector3 } from "babylonjs/Maths/math.vector";
  10496. import { Nullable } from "babylonjs/types";
  10497. import { ActionManager } from "babylonjs/Actions/actionManager";
  10498. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10499. import { Color4 } from "babylonjs/Maths/math.color";
  10500. import { Observable } from "babylonjs/Misc/observable";
  10501. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10502. import { Animation } from "babylonjs/Animations/animation";
  10503. /**
  10504. * Class used to represent a sprite
  10505. * @see https://doc.babylonjs.com/babylon101/sprites
  10506. */
  10507. export class Sprite implements IAnimatable {
  10508. /** defines the name */
  10509. name: string;
  10510. /** Gets or sets the current world position */
  10511. position: Vector3;
  10512. /** Gets or sets the main color */
  10513. color: Color4;
  10514. /** Gets or sets the width */
  10515. width: number;
  10516. /** Gets or sets the height */
  10517. height: number;
  10518. /** Gets or sets rotation angle */
  10519. angle: number;
  10520. /** Gets or sets the cell index in the sprite sheet */
  10521. cellIndex: number;
  10522. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10523. cellRef: string;
  10524. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10525. invertU: boolean;
  10526. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10527. invertV: boolean;
  10528. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10529. disposeWhenFinishedAnimating: boolean;
  10530. /** Gets the list of attached animations */
  10531. animations: Nullable<Array<Animation>>;
  10532. /** Gets or sets a boolean indicating if the sprite can be picked */
  10533. isPickable: boolean;
  10534. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10535. useAlphaForPicking: boolean;
  10536. /** @hidden */
  10537. _xOffset: number;
  10538. /** @hidden */
  10539. _yOffset: number;
  10540. /** @hidden */
  10541. _xSize: number;
  10542. /** @hidden */
  10543. _ySize: number;
  10544. /**
  10545. * Gets or sets the associated action manager
  10546. */
  10547. actionManager: Nullable<ActionManager>;
  10548. /**
  10549. * An event triggered when the control has been disposed
  10550. */
  10551. onDisposeObservable: Observable<Sprite>;
  10552. private _animationStarted;
  10553. private _loopAnimation;
  10554. private _fromIndex;
  10555. private _toIndex;
  10556. private _delay;
  10557. private _direction;
  10558. private _manager;
  10559. private _time;
  10560. private _onAnimationEnd;
  10561. /**
  10562. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10563. */
  10564. isVisible: boolean;
  10565. /**
  10566. * Gets or sets the sprite size
  10567. */
  10568. get size(): number;
  10569. set size(value: number);
  10570. /**
  10571. * Returns a boolean indicating if the animation is started
  10572. */
  10573. get animationStarted(): boolean;
  10574. /**
  10575. * Gets or sets the unique id of the sprite
  10576. */
  10577. uniqueId: number;
  10578. /**
  10579. * Gets the manager of this sprite
  10580. */
  10581. get manager(): ISpriteManager;
  10582. /**
  10583. * Creates a new Sprite
  10584. * @param name defines the name
  10585. * @param manager defines the manager
  10586. */
  10587. constructor(
  10588. /** defines the name */
  10589. name: string, manager: ISpriteManager);
  10590. /**
  10591. * Returns the string "Sprite"
  10592. * @returns "Sprite"
  10593. */
  10594. getClassName(): string;
  10595. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10596. get fromIndex(): number;
  10597. set fromIndex(value: number);
  10598. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10599. get toIndex(): number;
  10600. set toIndex(value: number);
  10601. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10602. get loopAnimation(): boolean;
  10603. set loopAnimation(value: boolean);
  10604. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10605. get delay(): number;
  10606. set delay(value: number);
  10607. /**
  10608. * Starts an animation
  10609. * @param from defines the initial key
  10610. * @param to defines the end key
  10611. * @param loop defines if the animation must loop
  10612. * @param delay defines the start delay (in ms)
  10613. * @param onAnimationEnd defines a callback to call when animation ends
  10614. */
  10615. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10616. /** Stops current animation (if any) */
  10617. stopAnimation(): void;
  10618. /** @hidden */
  10619. _animate(deltaTime: number): void;
  10620. /** Release associated resources */
  10621. dispose(): void;
  10622. /**
  10623. * Serializes the sprite to a JSON object
  10624. * @returns the JSON object
  10625. */
  10626. serialize(): any;
  10627. /**
  10628. * Parses a JSON object to create a new sprite
  10629. * @param parsedSprite The JSON object to parse
  10630. * @param manager defines the hosting manager
  10631. * @returns the new sprite
  10632. */
  10633. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10634. }
  10635. }
  10636. declare module "babylonjs/Collisions/pickingInfo" {
  10637. import { Nullable } from "babylonjs/types";
  10638. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10640. import { Sprite } from "babylonjs/Sprites/sprite";
  10641. import { Ray } from "babylonjs/Culling/ray";
  10642. /**
  10643. * Information about the result of picking within a scene
  10644. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10645. */
  10646. export class PickingInfo {
  10647. /** @hidden */
  10648. _pickingUnavailable: boolean;
  10649. /**
  10650. * If the pick collided with an object
  10651. */
  10652. hit: boolean;
  10653. /**
  10654. * Distance away where the pick collided
  10655. */
  10656. distance: number;
  10657. /**
  10658. * The location of pick collision
  10659. */
  10660. pickedPoint: Nullable<Vector3>;
  10661. /**
  10662. * The mesh corresponding the the pick collision
  10663. */
  10664. pickedMesh: Nullable<AbstractMesh>;
  10665. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10666. bu: number;
  10667. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10668. bv: number;
  10669. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10670. faceId: number;
  10671. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10672. subMeshFaceId: number;
  10673. /** Id of the the submesh that was picked */
  10674. subMeshId: number;
  10675. /** If a sprite was picked, this will be the sprite the pick collided with */
  10676. pickedSprite: Nullable<Sprite>;
  10677. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10678. thinInstanceIndex: number;
  10679. /**
  10680. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10681. */
  10682. originMesh: Nullable<AbstractMesh>;
  10683. /**
  10684. * The ray that was used to perform the picking.
  10685. */
  10686. ray: Nullable<Ray>;
  10687. /**
  10688. * Gets the normal correspodning to the face the pick collided with
  10689. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10690. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10691. * @returns The normal correspodning to the face the pick collided with
  10692. */
  10693. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10694. /**
  10695. * Gets the texture coordinates of where the pick occured
  10696. * @returns the vector containing the coordnates of the texture
  10697. */
  10698. getTextureCoordinates(): Nullable<Vector2>;
  10699. }
  10700. }
  10701. declare module "babylonjs/Culling/ray" {
  10702. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10703. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10705. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10706. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10707. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10708. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10709. import { Plane } from "babylonjs/Maths/math.plane";
  10710. /**
  10711. * Class representing a ray with position and direction
  10712. */
  10713. export class Ray {
  10714. /** origin point */
  10715. origin: Vector3;
  10716. /** direction */
  10717. direction: Vector3;
  10718. /** length of the ray */
  10719. length: number;
  10720. private static readonly _TmpVector3;
  10721. private _tmpRay;
  10722. /**
  10723. * Creates a new ray
  10724. * @param origin origin point
  10725. * @param direction direction
  10726. * @param length length of the ray
  10727. */
  10728. constructor(
  10729. /** origin point */
  10730. origin: Vector3,
  10731. /** direction */
  10732. direction: Vector3,
  10733. /** length of the ray */
  10734. length?: number);
  10735. /**
  10736. * Checks if the ray intersects a box
  10737. * This does not account for the ray lenght by design to improve perfs.
  10738. * @param minimum bound of the box
  10739. * @param maximum bound of the box
  10740. * @param intersectionTreshold extra extend to be added to the box in all direction
  10741. * @returns if the box was hit
  10742. */
  10743. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10744. /**
  10745. * Checks if the ray intersects a box
  10746. * This does not account for the ray lenght by design to improve perfs.
  10747. * @param box the bounding box to check
  10748. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10749. * @returns if the box was hit
  10750. */
  10751. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10752. /**
  10753. * If the ray hits a sphere
  10754. * @param sphere the bounding sphere to check
  10755. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10756. * @returns true if it hits the sphere
  10757. */
  10758. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10759. /**
  10760. * If the ray hits a triange
  10761. * @param vertex0 triangle vertex
  10762. * @param vertex1 triangle vertex
  10763. * @param vertex2 triangle vertex
  10764. * @returns intersection information if hit
  10765. */
  10766. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10767. /**
  10768. * Checks if ray intersects a plane
  10769. * @param plane the plane to check
  10770. * @returns the distance away it was hit
  10771. */
  10772. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10773. /**
  10774. * Calculate the intercept of a ray on a given axis
  10775. * @param axis to check 'x' | 'y' | 'z'
  10776. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10777. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10778. */
  10779. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10780. /**
  10781. * Checks if ray intersects a mesh
  10782. * @param mesh the mesh to check
  10783. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10784. * @returns picking info of the intersecton
  10785. */
  10786. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10787. /**
  10788. * Checks if ray intersects a mesh
  10789. * @param meshes the meshes to check
  10790. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10791. * @param results array to store result in
  10792. * @returns Array of picking infos
  10793. */
  10794. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10795. private _comparePickingInfo;
  10796. private static smallnum;
  10797. private static rayl;
  10798. /**
  10799. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10800. * @param sega the first point of the segment to test the intersection against
  10801. * @param segb the second point of the segment to test the intersection against
  10802. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10803. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10804. */
  10805. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10806. /**
  10807. * Update the ray from viewport position
  10808. * @param x position
  10809. * @param y y position
  10810. * @param viewportWidth viewport width
  10811. * @param viewportHeight viewport height
  10812. * @param world world matrix
  10813. * @param view view matrix
  10814. * @param projection projection matrix
  10815. * @returns this ray updated
  10816. */
  10817. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10818. /**
  10819. * Creates a ray with origin and direction of 0,0,0
  10820. * @returns the new ray
  10821. */
  10822. static Zero(): Ray;
  10823. /**
  10824. * Creates a new ray from screen space and viewport
  10825. * @param x position
  10826. * @param y y position
  10827. * @param viewportWidth viewport width
  10828. * @param viewportHeight viewport height
  10829. * @param world world matrix
  10830. * @param view view matrix
  10831. * @param projection projection matrix
  10832. * @returns new ray
  10833. */
  10834. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10835. /**
  10836. * 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
  10837. * transformed to the given world matrix.
  10838. * @param origin The origin point
  10839. * @param end The end point
  10840. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10841. * @returns the new ray
  10842. */
  10843. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10844. /**
  10845. * Transforms a ray by a matrix
  10846. * @param ray ray to transform
  10847. * @param matrix matrix to apply
  10848. * @returns the resulting new ray
  10849. */
  10850. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10851. /**
  10852. * Transforms a ray by a matrix
  10853. * @param ray ray to transform
  10854. * @param matrix matrix to apply
  10855. * @param result ray to store result in
  10856. */
  10857. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10858. /**
  10859. * Unproject a ray from screen space to object space
  10860. * @param sourceX defines the screen space x coordinate to use
  10861. * @param sourceY defines the screen space y coordinate to use
  10862. * @param viewportWidth defines the current width of the viewport
  10863. * @param viewportHeight defines the current height of the viewport
  10864. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10865. * @param view defines the view matrix to use
  10866. * @param projection defines the projection matrix to use
  10867. */
  10868. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10869. }
  10870. /**
  10871. * Type used to define predicate used to select faces when a mesh intersection is detected
  10872. */
  10873. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10874. module "babylonjs/scene" {
  10875. interface Scene {
  10876. /** @hidden */
  10877. _tempPickingRay: Nullable<Ray>;
  10878. /** @hidden */
  10879. _cachedRayForTransform: Ray;
  10880. /** @hidden */
  10881. _pickWithRayInverseMatrix: Matrix;
  10882. /** @hidden */
  10883. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10884. /** @hidden */
  10885. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10886. /** @hidden */
  10887. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10888. }
  10889. }
  10890. }
  10891. declare module "babylonjs/sceneComponent" {
  10892. import { Scene } from "babylonjs/scene";
  10893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10894. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10895. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10896. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10897. import { Nullable } from "babylonjs/types";
  10898. import { Camera } from "babylonjs/Cameras/camera";
  10899. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10900. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10901. import { AbstractScene } from "babylonjs/abstractScene";
  10902. import { Mesh } from "babylonjs/Meshes/mesh";
  10903. /**
  10904. * Groups all the scene component constants in one place to ease maintenance.
  10905. * @hidden
  10906. */
  10907. export class SceneComponentConstants {
  10908. static readonly NAME_EFFECTLAYER: string;
  10909. static readonly NAME_LAYER: string;
  10910. static readonly NAME_LENSFLARESYSTEM: string;
  10911. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10912. static readonly NAME_PARTICLESYSTEM: string;
  10913. static readonly NAME_GAMEPAD: string;
  10914. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10915. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10916. static readonly NAME_PREPASSRENDERER: string;
  10917. static readonly NAME_DEPTHRENDERER: string;
  10918. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10919. static readonly NAME_SPRITE: string;
  10920. static readonly NAME_SUBSURFACE: string;
  10921. static readonly NAME_OUTLINERENDERER: string;
  10922. static readonly NAME_PROCEDURALTEXTURE: string;
  10923. static readonly NAME_SHADOWGENERATOR: string;
  10924. static readonly NAME_OCTREE: string;
  10925. static readonly NAME_PHYSICSENGINE: string;
  10926. static readonly NAME_AUDIO: string;
  10927. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10928. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10929. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10930. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10931. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10932. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10933. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10934. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10935. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10936. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10937. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10938. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10939. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10940. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10941. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10942. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10943. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10944. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10945. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10946. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10947. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10948. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10949. static readonly STEP_AFTERRENDER_AUDIO: number;
  10950. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10951. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10952. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10953. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10954. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10955. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10956. static readonly STEP_POINTERMOVE_SPRITE: number;
  10957. static readonly STEP_POINTERDOWN_SPRITE: number;
  10958. static readonly STEP_POINTERUP_SPRITE: number;
  10959. }
  10960. /**
  10961. * This represents a scene component.
  10962. *
  10963. * This is used to decouple the dependency the scene is having on the different workloads like
  10964. * layers, post processes...
  10965. */
  10966. export interface ISceneComponent {
  10967. /**
  10968. * The name of the component. Each component must have a unique name.
  10969. */
  10970. name: string;
  10971. /**
  10972. * The scene the component belongs to.
  10973. */
  10974. scene: Scene;
  10975. /**
  10976. * Register the component to one instance of a scene.
  10977. */
  10978. register(): void;
  10979. /**
  10980. * Rebuilds the elements related to this component in case of
  10981. * context lost for instance.
  10982. */
  10983. rebuild(): void;
  10984. /**
  10985. * Disposes the component and the associated ressources.
  10986. */
  10987. dispose(): void;
  10988. }
  10989. /**
  10990. * This represents a SERIALIZABLE scene component.
  10991. *
  10992. * This extends Scene Component to add Serialization methods on top.
  10993. */
  10994. export interface ISceneSerializableComponent extends ISceneComponent {
  10995. /**
  10996. * Adds all the elements from the container to the scene
  10997. * @param container the container holding the elements
  10998. */
  10999. addFromContainer(container: AbstractScene): void;
  11000. /**
  11001. * Removes all the elements in the container from the scene
  11002. * @param container contains the elements to remove
  11003. * @param dispose if the removed element should be disposed (default: false)
  11004. */
  11005. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11006. /**
  11007. * Serializes the component data to the specified json object
  11008. * @param serializationObject The object to serialize to
  11009. */
  11010. serialize(serializationObject: any): void;
  11011. }
  11012. /**
  11013. * Strong typing of a Mesh related stage step action
  11014. */
  11015. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11016. /**
  11017. * Strong typing of a Evaluate Sub Mesh related stage step action
  11018. */
  11019. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11020. /**
  11021. * Strong typing of a pre active Mesh related stage step action
  11022. */
  11023. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11024. /**
  11025. * Strong typing of a Camera related stage step action
  11026. */
  11027. export type CameraStageAction = (camera: Camera) => void;
  11028. /**
  11029. * Strong typing of a Camera Frame buffer related stage step action
  11030. */
  11031. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11032. /**
  11033. * Strong typing of a Render Target related stage step action
  11034. */
  11035. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11036. /**
  11037. * Strong typing of a RenderingGroup related stage step action
  11038. */
  11039. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11040. /**
  11041. * Strong typing of a Mesh Render related stage step action
  11042. */
  11043. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11044. /**
  11045. * Strong typing of a simple stage step action
  11046. */
  11047. export type SimpleStageAction = () => void;
  11048. /**
  11049. * Strong typing of a render target action.
  11050. */
  11051. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11052. /**
  11053. * Strong typing of a pointer move action.
  11054. */
  11055. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11056. /**
  11057. * Strong typing of a pointer up/down action.
  11058. */
  11059. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11060. /**
  11061. * Representation of a stage in the scene (Basically a list of ordered steps)
  11062. * @hidden
  11063. */
  11064. export class Stage<T extends Function> extends Array<{
  11065. index: number;
  11066. component: ISceneComponent;
  11067. action: T;
  11068. }> {
  11069. /**
  11070. * Hide ctor from the rest of the world.
  11071. * @param items The items to add.
  11072. */
  11073. private constructor();
  11074. /**
  11075. * Creates a new Stage.
  11076. * @returns A new instance of a Stage
  11077. */
  11078. static Create<T extends Function>(): Stage<T>;
  11079. /**
  11080. * Registers a step in an ordered way in the targeted stage.
  11081. * @param index Defines the position to register the step in
  11082. * @param component Defines the component attached to the step
  11083. * @param action Defines the action to launch during the step
  11084. */
  11085. registerStep(index: number, component: ISceneComponent, action: T): void;
  11086. /**
  11087. * Clears all the steps from the stage.
  11088. */
  11089. clear(): void;
  11090. }
  11091. }
  11092. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11093. import { Nullable } from "babylonjs/types";
  11094. import { Observable } from "babylonjs/Misc/observable";
  11095. import { Scene } from "babylonjs/scene";
  11096. import { Sprite } from "babylonjs/Sprites/sprite";
  11097. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11098. import { Ray } from "babylonjs/Culling/ray";
  11099. import { Camera } from "babylonjs/Cameras/camera";
  11100. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11101. import { ISceneComponent } from "babylonjs/sceneComponent";
  11102. module "babylonjs/scene" {
  11103. interface Scene {
  11104. /** @hidden */
  11105. _pointerOverSprite: Nullable<Sprite>;
  11106. /** @hidden */
  11107. _pickedDownSprite: Nullable<Sprite>;
  11108. /** @hidden */
  11109. _tempSpritePickingRay: Nullable<Ray>;
  11110. /**
  11111. * All of the sprite managers added to this scene
  11112. * @see https://doc.babylonjs.com/babylon101/sprites
  11113. */
  11114. spriteManagers: Array<ISpriteManager>;
  11115. /**
  11116. * An event triggered when sprites rendering is about to start
  11117. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11118. */
  11119. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11120. /**
  11121. * An event triggered when sprites rendering is done
  11122. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11123. */
  11124. onAfterSpritesRenderingObservable: Observable<Scene>;
  11125. /** @hidden */
  11126. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11127. /** Launch a ray to try to pick a sprite in the scene
  11128. * @param x position on screen
  11129. * @param y position on screen
  11130. * @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
  11131. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11132. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11133. * @returns a PickingInfo
  11134. */
  11135. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11136. /** Use the given ray to pick a sprite in the scene
  11137. * @param ray The ray (in world space) to use to pick meshes
  11138. * @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
  11139. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11140. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11141. * @returns a PickingInfo
  11142. */
  11143. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11144. /** @hidden */
  11145. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11146. /** Launch a ray to try to pick sprites in the scene
  11147. * @param x position on screen
  11148. * @param y position on screen
  11149. * @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
  11150. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11151. * @returns a PickingInfo array
  11152. */
  11153. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11154. /** Use the given ray to pick sprites in the scene
  11155. * @param ray The ray (in world space) to use to pick meshes
  11156. * @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
  11157. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11158. * @returns a PickingInfo array
  11159. */
  11160. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11161. /**
  11162. * Force the sprite under the pointer
  11163. * @param sprite defines the sprite to use
  11164. */
  11165. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11166. /**
  11167. * Gets the sprite under the pointer
  11168. * @returns a Sprite or null if no sprite is under the pointer
  11169. */
  11170. getPointerOverSprite(): Nullable<Sprite>;
  11171. }
  11172. }
  11173. /**
  11174. * Defines the sprite scene component responsible to manage sprites
  11175. * in a given scene.
  11176. */
  11177. export class SpriteSceneComponent implements ISceneComponent {
  11178. /**
  11179. * The component name helpfull to identify the component in the list of scene components.
  11180. */
  11181. readonly name: string;
  11182. /**
  11183. * The scene the component belongs to.
  11184. */
  11185. scene: Scene;
  11186. /** @hidden */
  11187. private _spritePredicate;
  11188. /**
  11189. * Creates a new instance of the component for the given scene
  11190. * @param scene Defines the scene to register the component in
  11191. */
  11192. constructor(scene: Scene);
  11193. /**
  11194. * Registers the component in a given scene
  11195. */
  11196. register(): void;
  11197. /**
  11198. * Rebuilds the elements related to this component in case of
  11199. * context lost for instance.
  11200. */
  11201. rebuild(): void;
  11202. /**
  11203. * Disposes the component and the associated ressources.
  11204. */
  11205. dispose(): void;
  11206. private _pickSpriteButKeepRay;
  11207. private _pointerMove;
  11208. private _pointerDown;
  11209. private _pointerUp;
  11210. }
  11211. }
  11212. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11213. /** @hidden */
  11214. export var fogFragmentDeclaration: {
  11215. name: string;
  11216. shader: string;
  11217. };
  11218. }
  11219. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11220. /** @hidden */
  11221. export var fogFragment: {
  11222. name: string;
  11223. shader: string;
  11224. };
  11225. }
  11226. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  11227. /** @hidden */
  11228. export var imageProcessingCompatibility: {
  11229. name: string;
  11230. shader: string;
  11231. };
  11232. }
  11233. declare module "babylonjs/Shaders/sprites.fragment" {
  11234. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11235. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11236. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  11237. /** @hidden */
  11238. export var spritesPixelShader: {
  11239. name: string;
  11240. shader: string;
  11241. };
  11242. }
  11243. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11244. /** @hidden */
  11245. export var fogVertexDeclaration: {
  11246. name: string;
  11247. shader: string;
  11248. };
  11249. }
  11250. declare module "babylonjs/Shaders/sprites.vertex" {
  11251. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11252. /** @hidden */
  11253. export var spritesVertexShader: {
  11254. name: string;
  11255. shader: string;
  11256. };
  11257. }
  11258. declare module "babylonjs/Sprites/spriteManager" {
  11259. import { IDisposable, Scene } from "babylonjs/scene";
  11260. import { Nullable } from "babylonjs/types";
  11261. import { Observable } from "babylonjs/Misc/observable";
  11262. import { Sprite } from "babylonjs/Sprites/sprite";
  11263. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11264. import { Camera } from "babylonjs/Cameras/camera";
  11265. import { Texture } from "babylonjs/Materials/Textures/texture";
  11266. import "babylonjs/Shaders/sprites.fragment";
  11267. import "babylonjs/Shaders/sprites.vertex";
  11268. import { Ray } from "babylonjs/Culling/ray";
  11269. /**
  11270. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11271. */
  11272. export interface ISpriteManager extends IDisposable {
  11273. /**
  11274. * Gets manager's name
  11275. */
  11276. name: string;
  11277. /**
  11278. * Restricts the camera to viewing objects with the same layerMask.
  11279. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11280. */
  11281. layerMask: number;
  11282. /**
  11283. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11284. */
  11285. isPickable: boolean;
  11286. /**
  11287. * Gets the hosting scene
  11288. */
  11289. scene: Scene;
  11290. /**
  11291. * Specifies the rendering group id for this mesh (0 by default)
  11292. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11293. */
  11294. renderingGroupId: number;
  11295. /**
  11296. * Defines the list of sprites managed by the manager.
  11297. */
  11298. sprites: Array<Sprite>;
  11299. /**
  11300. * Gets or sets the spritesheet texture
  11301. */
  11302. texture: Texture;
  11303. /** Defines the default width of a cell in the spritesheet */
  11304. cellWidth: number;
  11305. /** Defines the default height of a cell in the spritesheet */
  11306. cellHeight: number;
  11307. /**
  11308. * Tests the intersection of a sprite with a specific ray.
  11309. * @param ray The ray we are sending to test the collision
  11310. * @param camera The camera space we are sending rays in
  11311. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11312. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11313. * @returns picking info or null.
  11314. */
  11315. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11316. /**
  11317. * Intersects the sprites with a ray
  11318. * @param ray defines the ray to intersect with
  11319. * @param camera defines the current active camera
  11320. * @param predicate defines a predicate used to select candidate sprites
  11321. * @returns null if no hit or a PickingInfo array
  11322. */
  11323. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11324. /**
  11325. * Renders the list of sprites on screen.
  11326. */
  11327. render(): void;
  11328. }
  11329. /**
  11330. * Class used to manage multiple sprites on the same spritesheet
  11331. * @see https://doc.babylonjs.com/babylon101/sprites
  11332. */
  11333. export class SpriteManager implements ISpriteManager {
  11334. /** defines the manager's name */
  11335. name: string;
  11336. /** Define the Url to load snippets */
  11337. static SnippetUrl: string;
  11338. /** Snippet ID if the manager was created from the snippet server */
  11339. snippetId: string;
  11340. /** Gets the list of sprites */
  11341. sprites: Sprite[];
  11342. /** Gets or sets the rendering group id (0 by default) */
  11343. renderingGroupId: number;
  11344. /** Gets or sets camera layer mask */
  11345. layerMask: number;
  11346. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11347. fogEnabled: boolean;
  11348. /** Gets or sets a boolean indicating if the sprites are pickable */
  11349. isPickable: boolean;
  11350. /** Defines the default width of a cell in the spritesheet */
  11351. cellWidth: number;
  11352. /** Defines the default height of a cell in the spritesheet */
  11353. cellHeight: number;
  11354. /** Associative array from JSON sprite data file */
  11355. private _cellData;
  11356. /** Array of sprite names from JSON sprite data file */
  11357. private _spriteMap;
  11358. /** True when packed cell data from JSON file is ready*/
  11359. private _packedAndReady;
  11360. private _textureContent;
  11361. private _useInstancing;
  11362. /**
  11363. * An event triggered when the manager is disposed.
  11364. */
  11365. onDisposeObservable: Observable<SpriteManager>;
  11366. private _onDisposeObserver;
  11367. /**
  11368. * Callback called when the manager is disposed
  11369. */
  11370. set onDispose(callback: () => void);
  11371. private _capacity;
  11372. private _fromPacked;
  11373. private _spriteTexture;
  11374. private _epsilon;
  11375. private _scene;
  11376. private _vertexData;
  11377. private _buffer;
  11378. private _vertexBuffers;
  11379. private _spriteBuffer;
  11380. private _indexBuffer;
  11381. private _effectBase;
  11382. private _effectFog;
  11383. private _vertexBufferSize;
  11384. /**
  11385. * Gets or sets the unique id of the sprite
  11386. */
  11387. uniqueId: number;
  11388. /**
  11389. * Gets the array of sprites
  11390. */
  11391. get children(): Sprite[];
  11392. /**
  11393. * Gets the hosting scene
  11394. */
  11395. get scene(): Scene;
  11396. /**
  11397. * Gets the capacity of the manager
  11398. */
  11399. get capacity(): number;
  11400. /**
  11401. * Gets or sets the spritesheet texture
  11402. */
  11403. get texture(): Texture;
  11404. set texture(value: Texture);
  11405. private _blendMode;
  11406. /**
  11407. * Blend mode use to render the particle, it can be any of
  11408. * the static Constants.ALPHA_x properties provided in this class.
  11409. * Default value is Constants.ALPHA_COMBINE
  11410. */
  11411. get blendMode(): number;
  11412. set blendMode(blendMode: number);
  11413. /** Disables writing to the depth buffer when rendering the sprites.
  11414. * It can be handy to disable depth writing when using textures without alpha channel
  11415. * and setting some specific blend modes.
  11416. */
  11417. disableDepthWrite: boolean;
  11418. /**
  11419. * Creates a new sprite manager
  11420. * @param name defines the manager's name
  11421. * @param imgUrl defines the sprite sheet url
  11422. * @param capacity defines the maximum allowed number of sprites
  11423. * @param cellSize defines the size of a sprite cell
  11424. * @param scene defines the hosting scene
  11425. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11426. * @param samplingMode defines the smapling mode to use with spritesheet
  11427. * @param fromPacked set to false; do not alter
  11428. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11429. */
  11430. constructor(
  11431. /** defines the manager's name */
  11432. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11433. /**
  11434. * Returns the string "SpriteManager"
  11435. * @returns "SpriteManager"
  11436. */
  11437. getClassName(): string;
  11438. private _makePacked;
  11439. private _appendSpriteVertex;
  11440. private _checkTextureAlpha;
  11441. /**
  11442. * Intersects the sprites with a ray
  11443. * @param ray defines the ray to intersect with
  11444. * @param camera defines the current active camera
  11445. * @param predicate defines a predicate used to select candidate sprites
  11446. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11447. * @returns null if no hit or a PickingInfo
  11448. */
  11449. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11450. /**
  11451. * Intersects the sprites with a ray
  11452. * @param ray defines the ray to intersect with
  11453. * @param camera defines the current active camera
  11454. * @param predicate defines a predicate used to select candidate sprites
  11455. * @returns null if no hit or a PickingInfo array
  11456. */
  11457. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11458. /**
  11459. * Render all child sprites
  11460. */
  11461. render(): void;
  11462. /**
  11463. * Release associated resources
  11464. */
  11465. dispose(): void;
  11466. /**
  11467. * Serializes the sprite manager to a JSON object
  11468. * @param serializeTexture defines if the texture must be serialized as well
  11469. * @returns the JSON object
  11470. */
  11471. serialize(serializeTexture?: boolean): any;
  11472. /**
  11473. * Parses a JSON object to create a new sprite manager.
  11474. * @param parsedManager The JSON object to parse
  11475. * @param scene The scene to create the sprite managerin
  11476. * @param rootUrl The root url to use to load external dependencies like texture
  11477. * @returns the new sprite manager
  11478. */
  11479. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11480. /**
  11481. * Creates a sprite manager from a snippet saved in a remote file
  11482. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11483. * @param url defines the url to load from
  11484. * @param scene defines the hosting scene
  11485. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11486. * @returns a promise that will resolve to the new sprite manager
  11487. */
  11488. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11489. /**
  11490. * Creates a sprite manager from a snippet saved by the sprite editor
  11491. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11492. * @param scene defines the hosting scene
  11493. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11494. * @returns a promise that will resolve to the new sprite manager
  11495. */
  11496. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11497. }
  11498. }
  11499. declare module "babylonjs/Misc/gradients" {
  11500. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11501. /** Interface used by value gradients (color, factor, ...) */
  11502. export interface IValueGradient {
  11503. /**
  11504. * Gets or sets the gradient value (between 0 and 1)
  11505. */
  11506. gradient: number;
  11507. }
  11508. /** Class used to store color4 gradient */
  11509. export class ColorGradient implements IValueGradient {
  11510. /**
  11511. * Gets or sets the gradient value (between 0 and 1)
  11512. */
  11513. gradient: number;
  11514. /**
  11515. * Gets or sets first associated color
  11516. */
  11517. color1: Color4;
  11518. /**
  11519. * Gets or sets second associated color
  11520. */
  11521. color2?: Color4 | undefined;
  11522. /**
  11523. * Creates a new color4 gradient
  11524. * @param gradient gets or sets the gradient value (between 0 and 1)
  11525. * @param color1 gets or sets first associated color
  11526. * @param color2 gets or sets first second color
  11527. */
  11528. constructor(
  11529. /**
  11530. * Gets or sets the gradient value (between 0 and 1)
  11531. */
  11532. gradient: number,
  11533. /**
  11534. * Gets or sets first associated color
  11535. */
  11536. color1: Color4,
  11537. /**
  11538. * Gets or sets second associated color
  11539. */
  11540. color2?: Color4 | undefined);
  11541. /**
  11542. * Will get a color picked randomly between color1 and color2.
  11543. * If color2 is undefined then color1 will be used
  11544. * @param result defines the target Color4 to store the result in
  11545. */
  11546. getColorToRef(result: Color4): void;
  11547. }
  11548. /** Class used to store color 3 gradient */
  11549. export class Color3Gradient implements IValueGradient {
  11550. /**
  11551. * Gets or sets the gradient value (between 0 and 1)
  11552. */
  11553. gradient: number;
  11554. /**
  11555. * Gets or sets the associated color
  11556. */
  11557. color: Color3;
  11558. /**
  11559. * Creates a new color3 gradient
  11560. * @param gradient gets or sets the gradient value (between 0 and 1)
  11561. * @param color gets or sets associated color
  11562. */
  11563. constructor(
  11564. /**
  11565. * Gets or sets the gradient value (between 0 and 1)
  11566. */
  11567. gradient: number,
  11568. /**
  11569. * Gets or sets the associated color
  11570. */
  11571. color: Color3);
  11572. }
  11573. /** Class used to store factor gradient */
  11574. export class FactorGradient implements IValueGradient {
  11575. /**
  11576. * Gets or sets the gradient value (between 0 and 1)
  11577. */
  11578. gradient: number;
  11579. /**
  11580. * Gets or sets first associated factor
  11581. */
  11582. factor1: number;
  11583. /**
  11584. * Gets or sets second associated factor
  11585. */
  11586. factor2?: number | undefined;
  11587. /**
  11588. * Creates a new factor gradient
  11589. * @param gradient gets or sets the gradient value (between 0 and 1)
  11590. * @param factor1 gets or sets first associated factor
  11591. * @param factor2 gets or sets second associated factor
  11592. */
  11593. constructor(
  11594. /**
  11595. * Gets or sets the gradient value (between 0 and 1)
  11596. */
  11597. gradient: number,
  11598. /**
  11599. * Gets or sets first associated factor
  11600. */
  11601. factor1: number,
  11602. /**
  11603. * Gets or sets second associated factor
  11604. */
  11605. factor2?: number | undefined);
  11606. /**
  11607. * Will get a number picked randomly between factor1 and factor2.
  11608. * If factor2 is undefined then factor1 will be used
  11609. * @returns the picked number
  11610. */
  11611. getFactor(): number;
  11612. }
  11613. /**
  11614. * Helper used to simplify some generic gradient tasks
  11615. */
  11616. export class GradientHelper {
  11617. /**
  11618. * Gets the current gradient from an array of IValueGradient
  11619. * @param ratio defines the current ratio to get
  11620. * @param gradients defines the array of IValueGradient
  11621. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11622. */
  11623. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11624. }
  11625. }
  11626. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11627. import { Nullable } from "babylonjs/types";
  11628. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11629. import { Scene } from "babylonjs/scene";
  11630. module "babylonjs/Engines/thinEngine" {
  11631. interface ThinEngine {
  11632. /**
  11633. * Creates a raw texture
  11634. * @param data defines the data to store in the texture
  11635. * @param width defines the width of the texture
  11636. * @param height defines the height of the texture
  11637. * @param format defines the format of the data
  11638. * @param generateMipMaps defines if the engine should generate the mip levels
  11639. * @param invertY defines if data must be stored with Y axis inverted
  11640. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11641. * @param compression defines the compression used (null by default)
  11642. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11643. * @returns the raw texture inside an InternalTexture
  11644. */
  11645. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11646. /**
  11647. * Update a raw texture
  11648. * @param texture defines the texture to update
  11649. * @param data defines the data to store in the texture
  11650. * @param format defines the format of the data
  11651. * @param invertY defines if data must be stored with Y axis inverted
  11652. */
  11653. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11654. /**
  11655. * Update a raw texture
  11656. * @param texture defines the texture to update
  11657. * @param data defines the data to store in the texture
  11658. * @param format defines the format of the data
  11659. * @param invertY defines if data must be stored with Y axis inverted
  11660. * @param compression defines the compression used (null by default)
  11661. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11662. */
  11663. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11664. /**
  11665. * Creates a new raw cube texture
  11666. * @param data defines the array of data to use to create each face
  11667. * @param size defines the size of the textures
  11668. * @param format defines the format of the data
  11669. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11670. * @param generateMipMaps defines if the engine should generate the mip levels
  11671. * @param invertY defines if data must be stored with Y axis inverted
  11672. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11673. * @param compression defines the compression used (null by default)
  11674. * @returns the cube texture as an InternalTexture
  11675. */
  11676. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11677. /**
  11678. * Update a raw cube texture
  11679. * @param texture defines the texture to udpdate
  11680. * @param data defines the data to store
  11681. * @param format defines the data format
  11682. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11683. * @param invertY defines if data must be stored with Y axis inverted
  11684. */
  11685. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11686. /**
  11687. * Update a raw cube texture
  11688. * @param texture defines the texture to udpdate
  11689. * @param data defines the data to store
  11690. * @param format defines the data format
  11691. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11692. * @param invertY defines if data must be stored with Y axis inverted
  11693. * @param compression defines the compression used (null by default)
  11694. */
  11695. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11696. /**
  11697. * Update a raw cube texture
  11698. * @param texture defines the texture to udpdate
  11699. * @param data defines the data to store
  11700. * @param format defines the data format
  11701. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11702. * @param invertY defines if data must be stored with Y axis inverted
  11703. * @param compression defines the compression used (null by default)
  11704. * @param level defines which level of the texture to update
  11705. */
  11706. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11707. /**
  11708. * Creates a new raw cube texture from a specified url
  11709. * @param url defines the url where the data is located
  11710. * @param scene defines the current scene
  11711. * @param size defines the size of the textures
  11712. * @param format defines the format of the data
  11713. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11714. * @param noMipmap defines if the engine should avoid generating the mip levels
  11715. * @param callback defines a callback used to extract texture data from loaded data
  11716. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11717. * @param onLoad defines a callback called when texture is loaded
  11718. * @param onError defines a callback called if there is an error
  11719. * @returns the cube texture as an InternalTexture
  11720. */
  11721. 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;
  11722. /**
  11723. * Creates a new raw cube texture from a specified url
  11724. * @param url defines the url where the data is located
  11725. * @param scene defines the current scene
  11726. * @param size defines the size of the textures
  11727. * @param format defines the format of the data
  11728. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11729. * @param noMipmap defines if the engine should avoid generating the mip levels
  11730. * @param callback defines a callback used to extract texture data from loaded data
  11731. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11732. * @param onLoad defines a callback called when texture is loaded
  11733. * @param onError defines a callback called if there is an error
  11734. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11735. * @param invertY defines if data must be stored with Y axis inverted
  11736. * @returns the cube texture as an InternalTexture
  11737. */
  11738. 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;
  11739. /**
  11740. * Creates a new raw 3D texture
  11741. * @param data defines the data used to create the texture
  11742. * @param width defines the width of the texture
  11743. * @param height defines the height of the texture
  11744. * @param depth defines the depth of the texture
  11745. * @param format defines the format of the texture
  11746. * @param generateMipMaps defines if the engine must generate mip levels
  11747. * @param invertY defines if data must be stored with Y axis inverted
  11748. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11749. * @param compression defines the compressed used (can be null)
  11750. * @param textureType defines the compressed used (can be null)
  11751. * @returns a new raw 3D texture (stored in an InternalTexture)
  11752. */
  11753. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11754. /**
  11755. * Update a raw 3D texture
  11756. * @param texture defines the texture to update
  11757. * @param data defines the data to store
  11758. * @param format defines the data format
  11759. * @param invertY defines if data must be stored with Y axis inverted
  11760. */
  11761. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11762. /**
  11763. * Update a raw 3D texture
  11764. * @param texture defines the texture to update
  11765. * @param data defines the data to store
  11766. * @param format defines the data format
  11767. * @param invertY defines if data must be stored with Y axis inverted
  11768. * @param compression defines the used compression (can be null)
  11769. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11770. */
  11771. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11772. /**
  11773. * Creates a new raw 2D array texture
  11774. * @param data defines the data used to create the texture
  11775. * @param width defines the width of the texture
  11776. * @param height defines the height of the texture
  11777. * @param depth defines the number of layers of the texture
  11778. * @param format defines the format of the texture
  11779. * @param generateMipMaps defines if the engine must generate mip levels
  11780. * @param invertY defines if data must be stored with Y axis inverted
  11781. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11782. * @param compression defines the compressed used (can be null)
  11783. * @param textureType defines the compressed used (can be null)
  11784. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11785. */
  11786. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11787. /**
  11788. * Update a raw 2D array texture
  11789. * @param texture defines the texture to update
  11790. * @param data defines the data to store
  11791. * @param format defines the data format
  11792. * @param invertY defines if data must be stored with Y axis inverted
  11793. */
  11794. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11795. /**
  11796. * Update a raw 2D array texture
  11797. * @param texture defines the texture to update
  11798. * @param data defines the data to store
  11799. * @param format defines the data format
  11800. * @param invertY defines if data must be stored with Y axis inverted
  11801. * @param compression defines the used compression (can be null)
  11802. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11803. */
  11804. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11805. }
  11806. }
  11807. }
  11808. declare module "babylonjs/Materials/Textures/rawTexture" {
  11809. import { Texture } from "babylonjs/Materials/Textures/texture";
  11810. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11811. import { Nullable } from "babylonjs/types";
  11812. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11813. import { Scene } from "babylonjs/scene";
  11814. /**
  11815. * Raw texture can help creating a texture directly from an array of data.
  11816. * This can be super useful if you either get the data from an uncompressed source or
  11817. * if you wish to create your texture pixel by pixel.
  11818. */
  11819. export class RawTexture extends Texture {
  11820. /**
  11821. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11822. */
  11823. format: number;
  11824. /**
  11825. * Instantiates a new RawTexture.
  11826. * Raw texture can help creating a texture directly from an array of data.
  11827. * This can be super useful if you either get the data from an uncompressed source or
  11828. * if you wish to create your texture pixel by pixel.
  11829. * @param data define the array of data to use to create the texture
  11830. * @param width define the width of the texture
  11831. * @param height define the height of the texture
  11832. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11833. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11834. * @param generateMipMaps define whether mip maps should be generated or not
  11835. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11836. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11837. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11838. */
  11839. constructor(data: ArrayBufferView, width: number, height: number,
  11840. /**
  11841. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11842. */
  11843. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11844. /**
  11845. * Updates the texture underlying data.
  11846. * @param data Define the new data of the texture
  11847. */
  11848. update(data: ArrayBufferView): void;
  11849. /**
  11850. * Creates a luminance texture from some data.
  11851. * @param data Define the texture data
  11852. * @param width Define the width of the texture
  11853. * @param height Define the height of the texture
  11854. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11855. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11856. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11857. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11858. * @returns the luminance texture
  11859. */
  11860. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11861. /**
  11862. * Creates a luminance alpha texture from some data.
  11863. * @param data Define the texture data
  11864. * @param width Define the width of the texture
  11865. * @param height Define the height of the texture
  11866. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11867. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11868. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11869. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11870. * @returns the luminance alpha texture
  11871. */
  11872. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11873. /**
  11874. * Creates an alpha texture from some data.
  11875. * @param data Define the texture data
  11876. * @param width Define the width of the texture
  11877. * @param height Define the height of the texture
  11878. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11879. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11880. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11881. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11882. * @returns the alpha texture
  11883. */
  11884. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11885. /**
  11886. * Creates a RGB texture from some data.
  11887. * @param data Define the texture data
  11888. * @param width Define the width of the texture
  11889. * @param height Define the height of the texture
  11890. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11891. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11892. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11893. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11894. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11895. * @returns the RGB alpha texture
  11896. */
  11897. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11898. /**
  11899. * Creates a RGBA texture from some data.
  11900. * @param data Define the texture data
  11901. * @param width Define the width of the texture
  11902. * @param height Define the height of the texture
  11903. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11904. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11905. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11906. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11907. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11908. * @returns the RGBA texture
  11909. */
  11910. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11911. /**
  11912. * Creates a R texture from some data.
  11913. * @param data Define the texture data
  11914. * @param width Define the width of the texture
  11915. * @param height Define the height of the texture
  11916. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11917. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11918. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11919. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11920. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11921. * @returns the R texture
  11922. */
  11923. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11924. }
  11925. }
  11926. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11927. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11928. import { IndicesArray, DataArray } from "babylonjs/types";
  11929. module "babylonjs/Engines/thinEngine" {
  11930. interface ThinEngine {
  11931. /**
  11932. * Update a dynamic index buffer
  11933. * @param indexBuffer defines the target index buffer
  11934. * @param indices defines the data to update
  11935. * @param offset defines the offset in the target index buffer where update should start
  11936. */
  11937. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11938. /**
  11939. * Updates a dynamic vertex buffer.
  11940. * @param vertexBuffer the vertex buffer to update
  11941. * @param data the data used to update the vertex buffer
  11942. * @param byteOffset the byte offset of the data
  11943. * @param byteLength the byte length of the data
  11944. */
  11945. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11946. }
  11947. }
  11948. }
  11949. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11950. import { Scene } from "babylonjs/scene";
  11951. import { ISceneComponent } from "babylonjs/sceneComponent";
  11952. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11953. module "babylonjs/abstractScene" {
  11954. interface AbstractScene {
  11955. /**
  11956. * The list of procedural textures added to the scene
  11957. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11958. */
  11959. proceduralTextures: Array<ProceduralTexture>;
  11960. }
  11961. }
  11962. /**
  11963. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11964. * in a given scene.
  11965. */
  11966. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11967. /**
  11968. * The component name helpfull to identify the component in the list of scene components.
  11969. */
  11970. readonly name: string;
  11971. /**
  11972. * The scene the component belongs to.
  11973. */
  11974. scene: Scene;
  11975. /**
  11976. * Creates a new instance of the component for the given scene
  11977. * @param scene Defines the scene to register the component in
  11978. */
  11979. constructor(scene: Scene);
  11980. /**
  11981. * Registers the component in a given scene
  11982. */
  11983. register(): void;
  11984. /**
  11985. * Rebuilds the elements related to this component in case of
  11986. * context lost for instance.
  11987. */
  11988. rebuild(): void;
  11989. /**
  11990. * Disposes the component and the associated ressources.
  11991. */
  11992. dispose(): void;
  11993. private _beforeClear;
  11994. }
  11995. }
  11996. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11997. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11998. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11999. module "babylonjs/Engines/thinEngine" {
  12000. interface ThinEngine {
  12001. /**
  12002. * Creates a new render target cube texture
  12003. * @param size defines the size of the texture
  12004. * @param options defines the options used to create the texture
  12005. * @returns a new render target cube texture stored in an InternalTexture
  12006. */
  12007. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  12008. }
  12009. }
  12010. }
  12011. declare module "babylonjs/Shaders/procedural.vertex" {
  12012. /** @hidden */
  12013. export var proceduralVertexShader: {
  12014. name: string;
  12015. shader: string;
  12016. };
  12017. }
  12018. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  12019. import { Observable } from "babylonjs/Misc/observable";
  12020. import { Nullable } from "babylonjs/types";
  12021. import { Scene } from "babylonjs/scene";
  12022. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12023. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12024. import { Effect } from "babylonjs/Materials/effect";
  12025. import { Texture } from "babylonjs/Materials/Textures/texture";
  12026. import "babylonjs/Engines/Extensions/engine.renderTarget";
  12027. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  12028. import "babylonjs/Shaders/procedural.vertex";
  12029. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12030. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  12031. /**
  12032. * 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.
  12033. * This is the base class of any Procedural texture and contains most of the shareable code.
  12034. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12035. */
  12036. export class ProceduralTexture extends Texture {
  12037. /**
  12038. * Define if the texture is enabled or not (disabled texture will not render)
  12039. */
  12040. isEnabled: boolean;
  12041. /**
  12042. * Define if the texture must be cleared before rendering (default is true)
  12043. */
  12044. autoClear: boolean;
  12045. /**
  12046. * Callback called when the texture is generated
  12047. */
  12048. onGenerated: () => void;
  12049. /**
  12050. * Event raised when the texture is generated
  12051. */
  12052. onGeneratedObservable: Observable<ProceduralTexture>;
  12053. /**
  12054. * Event raised before the texture is generated
  12055. */
  12056. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12057. /**
  12058. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12059. */
  12060. nodeMaterialSource: Nullable<NodeMaterial>;
  12061. /** @hidden */
  12062. _generateMipMaps: boolean;
  12063. /** @hidden **/
  12064. _effect: Effect;
  12065. /** @hidden */
  12066. _textures: {
  12067. [key: string]: Texture;
  12068. };
  12069. /** @hidden */
  12070. protected _fallbackTexture: Nullable<Texture>;
  12071. private _size;
  12072. private _currentRefreshId;
  12073. private _frameId;
  12074. private _refreshRate;
  12075. private _vertexBuffers;
  12076. private _indexBuffer;
  12077. private _uniforms;
  12078. private _samplers;
  12079. private _fragment;
  12080. private _floats;
  12081. private _ints;
  12082. private _floatsArrays;
  12083. private _colors3;
  12084. private _colors4;
  12085. private _vectors2;
  12086. private _vectors3;
  12087. private _matrices;
  12088. private _fallbackTextureUsed;
  12089. private _fullEngine;
  12090. private _cachedDefines;
  12091. private _contentUpdateId;
  12092. private _contentData;
  12093. /**
  12094. * Instantiates a new procedural texture.
  12095. * 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.
  12096. * This is the base class of any Procedural texture and contains most of the shareable code.
  12097. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12098. * @param name Define the name of the texture
  12099. * @param size Define the size of the texture to create
  12100. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12101. * @param scene Define the scene the texture belongs to
  12102. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12103. * @param generateMipMaps Define if the texture should creates mip maps or not
  12104. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12105. * @param textureType The FBO internal texture type
  12106. */
  12107. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  12108. /**
  12109. * The effect that is created when initializing the post process.
  12110. * @returns The created effect corresponding the the postprocess.
  12111. */
  12112. getEffect(): Effect;
  12113. /**
  12114. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12115. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12116. */
  12117. getContent(): Nullable<ArrayBufferView>;
  12118. private _createIndexBuffer;
  12119. /** @hidden */
  12120. _rebuild(): void;
  12121. /**
  12122. * Resets the texture in order to recreate its associated resources.
  12123. * This can be called in case of context loss
  12124. */
  12125. reset(): void;
  12126. protected _getDefines(): string;
  12127. /**
  12128. * Is the texture ready to be used ? (rendered at least once)
  12129. * @returns true if ready, otherwise, false.
  12130. */
  12131. isReady(): boolean;
  12132. /**
  12133. * Resets the refresh counter of the texture and start bak from scratch.
  12134. * Could be useful to regenerate the texture if it is setup to render only once.
  12135. */
  12136. resetRefreshCounter(): void;
  12137. /**
  12138. * Set the fragment shader to use in order to render the texture.
  12139. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12140. */
  12141. setFragment(fragment: any): void;
  12142. /**
  12143. * Define the refresh rate of the texture or the rendering frequency.
  12144. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12145. */
  12146. get refreshRate(): number;
  12147. set refreshRate(value: number);
  12148. /** @hidden */
  12149. _shouldRender(): boolean;
  12150. /**
  12151. * Get the size the texture is rendering at.
  12152. * @returns the size (on cube texture it is always squared)
  12153. */
  12154. getRenderSize(): RenderTargetTextureSize;
  12155. /**
  12156. * Resize the texture to new value.
  12157. * @param size Define the new size the texture should have
  12158. * @param generateMipMaps Define whether the new texture should create mip maps
  12159. */
  12160. resize(size: number, generateMipMaps: boolean): void;
  12161. private _checkUniform;
  12162. /**
  12163. * Set a texture in the shader program used to render.
  12164. * @param name Define the name of the uniform samplers as defined in the shader
  12165. * @param texture Define the texture to bind to this sampler
  12166. * @return the texture itself allowing "fluent" like uniform updates
  12167. */
  12168. setTexture(name: string, texture: Texture): ProceduralTexture;
  12169. /**
  12170. * Set a float in the shader.
  12171. * @param name Define the name of the uniform as defined in the shader
  12172. * @param value Define the value to give to the uniform
  12173. * @return the texture itself allowing "fluent" like uniform updates
  12174. */
  12175. setFloat(name: string, value: number): ProceduralTexture;
  12176. /**
  12177. * Set a int in the shader.
  12178. * @param name Define the name of the uniform as defined in the shader
  12179. * @param value Define the value to give to the uniform
  12180. * @return the texture itself allowing "fluent" like uniform updates
  12181. */
  12182. setInt(name: string, value: number): ProceduralTexture;
  12183. /**
  12184. * Set an array of floats in the shader.
  12185. * @param name Define the name of the uniform as defined in the shader
  12186. * @param value Define the value to give to the uniform
  12187. * @return the texture itself allowing "fluent" like uniform updates
  12188. */
  12189. setFloats(name: string, value: number[]): ProceduralTexture;
  12190. /**
  12191. * Set a vec3 in the shader from a Color3.
  12192. * @param name Define the name of the uniform as defined in the shader
  12193. * @param value Define the value to give to the uniform
  12194. * @return the texture itself allowing "fluent" like uniform updates
  12195. */
  12196. setColor3(name: string, value: Color3): ProceduralTexture;
  12197. /**
  12198. * Set a vec4 in the shader from a Color4.
  12199. * @param name Define the name of the uniform as defined in the shader
  12200. * @param value Define the value to give to the uniform
  12201. * @return the texture itself allowing "fluent" like uniform updates
  12202. */
  12203. setColor4(name: string, value: Color4): ProceduralTexture;
  12204. /**
  12205. * Set a vec2 in the shader from a Vector2.
  12206. * @param name Define the name of the uniform as defined in the shader
  12207. * @param value Define the value to give to the uniform
  12208. * @return the texture itself allowing "fluent" like uniform updates
  12209. */
  12210. setVector2(name: string, value: Vector2): ProceduralTexture;
  12211. /**
  12212. * Set a vec3 in the shader from a Vector3.
  12213. * @param name Define the name of the uniform as defined in the shader
  12214. * @param value Define the value to give to the uniform
  12215. * @return the texture itself allowing "fluent" like uniform updates
  12216. */
  12217. setVector3(name: string, value: Vector3): ProceduralTexture;
  12218. /**
  12219. * Set a mat4 in the shader from a MAtrix.
  12220. * @param name Define the name of the uniform as defined in the shader
  12221. * @param value Define the value to give to the uniform
  12222. * @return the texture itself allowing "fluent" like uniform updates
  12223. */
  12224. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12225. /**
  12226. * Render the texture to its associated render target.
  12227. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12228. */
  12229. render(useCameraPostProcess?: boolean): void;
  12230. /**
  12231. * Clone the texture.
  12232. * @returns the cloned texture
  12233. */
  12234. clone(): ProceduralTexture;
  12235. /**
  12236. * Dispose the texture and release its asoociated resources.
  12237. */
  12238. dispose(): void;
  12239. }
  12240. }
  12241. declare module "babylonjs/Particles/baseParticleSystem" {
  12242. import { Nullable } from "babylonjs/types";
  12243. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12245. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12246. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12247. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12248. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12249. import { Color4 } from "babylonjs/Maths/math.color";
  12250. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12251. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12252. import { Animation } from "babylonjs/Animations/animation";
  12253. import { Scene } from "babylonjs/scene";
  12254. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12255. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12256. /**
  12257. * This represents the base class for particle system in Babylon.
  12258. * 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.
  12259. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12260. * @example https://doc.babylonjs.com/babylon101/particles
  12261. */
  12262. export class BaseParticleSystem {
  12263. /**
  12264. * Source color is added to the destination color without alpha affecting the result
  12265. */
  12266. static BLENDMODE_ONEONE: number;
  12267. /**
  12268. * Blend current color and particle color using particle’s alpha
  12269. */
  12270. static BLENDMODE_STANDARD: number;
  12271. /**
  12272. * Add current color and particle color multiplied by particle’s alpha
  12273. */
  12274. static BLENDMODE_ADD: number;
  12275. /**
  12276. * Multiply current color with particle color
  12277. */
  12278. static BLENDMODE_MULTIPLY: number;
  12279. /**
  12280. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12281. */
  12282. static BLENDMODE_MULTIPLYADD: number;
  12283. /**
  12284. * List of animations used by the particle system.
  12285. */
  12286. animations: Animation[];
  12287. /**
  12288. * Gets or sets the unique id of the particle system
  12289. */
  12290. uniqueId: number;
  12291. /**
  12292. * The id of the Particle system.
  12293. */
  12294. id: string;
  12295. /**
  12296. * The friendly name of the Particle system.
  12297. */
  12298. name: string;
  12299. /**
  12300. * Snippet ID if the particle system was created from the snippet server
  12301. */
  12302. snippetId: string;
  12303. /**
  12304. * The rendering group used by the Particle system to chose when to render.
  12305. */
  12306. renderingGroupId: number;
  12307. /**
  12308. * The emitter represents the Mesh or position we are attaching the particle system to.
  12309. */
  12310. emitter: Nullable<AbstractMesh | Vector3>;
  12311. /**
  12312. * The maximum number of particles to emit per frame
  12313. */
  12314. emitRate: number;
  12315. /**
  12316. * If you want to launch only a few particles at once, that can be done, as well.
  12317. */
  12318. manualEmitCount: number;
  12319. /**
  12320. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12321. */
  12322. updateSpeed: number;
  12323. /**
  12324. * The amount of time the particle system is running (depends of the overall update speed).
  12325. */
  12326. targetStopDuration: number;
  12327. /**
  12328. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12329. */
  12330. disposeOnStop: boolean;
  12331. /**
  12332. * Minimum power of emitting particles.
  12333. */
  12334. minEmitPower: number;
  12335. /**
  12336. * Maximum power of emitting particles.
  12337. */
  12338. maxEmitPower: number;
  12339. /**
  12340. * Minimum life time of emitting particles.
  12341. */
  12342. minLifeTime: number;
  12343. /**
  12344. * Maximum life time of emitting particles.
  12345. */
  12346. maxLifeTime: number;
  12347. /**
  12348. * Minimum Size of emitting particles.
  12349. */
  12350. minSize: number;
  12351. /**
  12352. * Maximum Size of emitting particles.
  12353. */
  12354. maxSize: number;
  12355. /**
  12356. * Minimum scale of emitting particles on X axis.
  12357. */
  12358. minScaleX: number;
  12359. /**
  12360. * Maximum scale of emitting particles on X axis.
  12361. */
  12362. maxScaleX: number;
  12363. /**
  12364. * Minimum scale of emitting particles on Y axis.
  12365. */
  12366. minScaleY: number;
  12367. /**
  12368. * Maximum scale of emitting particles on Y axis.
  12369. */
  12370. maxScaleY: number;
  12371. /**
  12372. * Gets or sets the minimal initial rotation in radians.
  12373. */
  12374. minInitialRotation: number;
  12375. /**
  12376. * Gets or sets the maximal initial rotation in radians.
  12377. */
  12378. maxInitialRotation: number;
  12379. /**
  12380. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12381. */
  12382. minAngularSpeed: number;
  12383. /**
  12384. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12385. */
  12386. maxAngularSpeed: number;
  12387. /**
  12388. * The texture used to render each particle. (this can be a spritesheet)
  12389. */
  12390. particleTexture: Nullable<BaseTexture>;
  12391. /**
  12392. * The layer mask we are rendering the particles through.
  12393. */
  12394. layerMask: number;
  12395. /**
  12396. * This can help using your own shader to render the particle system.
  12397. * The according effect will be created
  12398. */
  12399. customShader: any;
  12400. /**
  12401. * By default particle system starts as soon as they are created. This prevents the
  12402. * automatic start to happen and let you decide when to start emitting particles.
  12403. */
  12404. preventAutoStart: boolean;
  12405. private _noiseTexture;
  12406. /**
  12407. * Gets or sets a texture used to add random noise to particle positions
  12408. */
  12409. get noiseTexture(): Nullable<ProceduralTexture>;
  12410. set noiseTexture(value: Nullable<ProceduralTexture>);
  12411. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12412. noiseStrength: Vector3;
  12413. /**
  12414. * Callback triggered when the particle animation is ending.
  12415. */
  12416. onAnimationEnd: Nullable<() => void>;
  12417. /**
  12418. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12419. */
  12420. blendMode: number;
  12421. /**
  12422. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12423. * to override the particles.
  12424. */
  12425. forceDepthWrite: boolean;
  12426. /** 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 */
  12427. preWarmCycles: number;
  12428. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12429. preWarmStepOffset: number;
  12430. /**
  12431. * 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)
  12432. */
  12433. spriteCellChangeSpeed: number;
  12434. /**
  12435. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12436. */
  12437. startSpriteCellID: number;
  12438. /**
  12439. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12440. */
  12441. endSpriteCellID: number;
  12442. /**
  12443. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12444. */
  12445. spriteCellWidth: number;
  12446. /**
  12447. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12448. */
  12449. spriteCellHeight: number;
  12450. /**
  12451. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12452. */
  12453. spriteRandomStartCell: boolean;
  12454. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12455. translationPivot: Vector2;
  12456. /** @hidden */
  12457. protected _isAnimationSheetEnabled: boolean;
  12458. /**
  12459. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12460. */
  12461. beginAnimationOnStart: boolean;
  12462. /**
  12463. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12464. */
  12465. beginAnimationFrom: number;
  12466. /**
  12467. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12468. */
  12469. beginAnimationTo: number;
  12470. /**
  12471. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12472. */
  12473. beginAnimationLoop: boolean;
  12474. /**
  12475. * Gets or sets a world offset applied to all particles
  12476. */
  12477. worldOffset: Vector3;
  12478. /**
  12479. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12480. */
  12481. get isAnimationSheetEnabled(): boolean;
  12482. set isAnimationSheetEnabled(value: boolean);
  12483. /**
  12484. * Get hosting scene
  12485. * @returns the scene
  12486. */
  12487. getScene(): Nullable<Scene>;
  12488. /**
  12489. * You can use gravity if you want to give an orientation to your particles.
  12490. */
  12491. gravity: Vector3;
  12492. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12493. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12494. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12495. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12496. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12497. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12498. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12499. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12500. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12501. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12502. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12503. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12504. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12505. /**
  12506. * Defines the delay in milliseconds before starting the system (0 by default)
  12507. */
  12508. startDelay: number;
  12509. /**
  12510. * Gets the current list of drag gradients.
  12511. * You must use addDragGradient and removeDragGradient to udpate this list
  12512. * @returns the list of drag gradients
  12513. */
  12514. getDragGradients(): Nullable<Array<FactorGradient>>;
  12515. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12516. limitVelocityDamping: number;
  12517. /**
  12518. * Gets the current list of limit velocity gradients.
  12519. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12520. * @returns the list of limit velocity gradients
  12521. */
  12522. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12523. /**
  12524. * Gets the current list of color gradients.
  12525. * You must use addColorGradient and removeColorGradient to udpate this list
  12526. * @returns the list of color gradients
  12527. */
  12528. getColorGradients(): Nullable<Array<ColorGradient>>;
  12529. /**
  12530. * Gets the current list of size gradients.
  12531. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12532. * @returns the list of size gradients
  12533. */
  12534. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12535. /**
  12536. * Gets the current list of color remap gradients.
  12537. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12538. * @returns the list of color remap gradients
  12539. */
  12540. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12541. /**
  12542. * Gets the current list of alpha remap gradients.
  12543. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12544. * @returns the list of alpha remap gradients
  12545. */
  12546. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12547. /**
  12548. * Gets the current list of life time gradients.
  12549. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12550. * @returns the list of life time gradients
  12551. */
  12552. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12553. /**
  12554. * Gets the current list of angular speed gradients.
  12555. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12556. * @returns the list of angular speed gradients
  12557. */
  12558. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12559. /**
  12560. * Gets the current list of velocity gradients.
  12561. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12562. * @returns the list of velocity gradients
  12563. */
  12564. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12565. /**
  12566. * Gets the current list of start size gradients.
  12567. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12568. * @returns the list of start size gradients
  12569. */
  12570. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12571. /**
  12572. * Gets the current list of emit rate gradients.
  12573. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12574. * @returns the list of emit rate gradients
  12575. */
  12576. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12577. /**
  12578. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12579. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12580. */
  12581. get direction1(): Vector3;
  12582. set direction1(value: Vector3);
  12583. /**
  12584. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12585. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12586. */
  12587. get direction2(): Vector3;
  12588. set direction2(value: Vector3);
  12589. /**
  12590. * 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.
  12591. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12592. */
  12593. get minEmitBox(): Vector3;
  12594. set minEmitBox(value: Vector3);
  12595. /**
  12596. * 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.
  12597. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12598. */
  12599. get maxEmitBox(): Vector3;
  12600. set maxEmitBox(value: Vector3);
  12601. /**
  12602. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12603. */
  12604. color1: Color4;
  12605. /**
  12606. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12607. */
  12608. color2: Color4;
  12609. /**
  12610. * Color the particle will have at the end of its lifetime
  12611. */
  12612. colorDead: Color4;
  12613. /**
  12614. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12615. */
  12616. textureMask: Color4;
  12617. /**
  12618. * The particle emitter type defines the emitter used by the particle system.
  12619. * It can be for example box, sphere, or cone...
  12620. */
  12621. particleEmitterType: IParticleEmitterType;
  12622. /** @hidden */
  12623. _isSubEmitter: boolean;
  12624. /**
  12625. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12626. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12627. */
  12628. billboardMode: number;
  12629. protected _isBillboardBased: boolean;
  12630. /**
  12631. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12632. */
  12633. get isBillboardBased(): boolean;
  12634. set isBillboardBased(value: boolean);
  12635. /**
  12636. * The scene the particle system belongs to.
  12637. */
  12638. protected _scene: Nullable<Scene>;
  12639. /**
  12640. * The engine the particle system belongs to.
  12641. */
  12642. protected _engine: ThinEngine;
  12643. /**
  12644. * Local cache of defines for image processing.
  12645. */
  12646. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12647. /**
  12648. * Default configuration related to image processing available in the standard Material.
  12649. */
  12650. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12651. /**
  12652. * Gets the image processing configuration used either in this material.
  12653. */
  12654. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12655. /**
  12656. * Sets the Default image processing configuration used either in the this material.
  12657. *
  12658. * If sets to null, the scene one is in use.
  12659. */
  12660. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12661. /**
  12662. * Attaches a new image processing configuration to the Standard Material.
  12663. * @param configuration
  12664. */
  12665. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12666. /** @hidden */
  12667. protected _reset(): void;
  12668. /** @hidden */
  12669. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12670. /**
  12671. * Instantiates a particle system.
  12672. * 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.
  12673. * @param name The name of the particle system
  12674. */
  12675. constructor(name: string);
  12676. /**
  12677. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12678. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12679. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12680. * @returns the emitter
  12681. */
  12682. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12683. /**
  12684. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12685. * @param radius The radius of the hemisphere to emit from
  12686. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12687. * @returns the emitter
  12688. */
  12689. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12690. /**
  12691. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12692. * @param radius The radius of the sphere to emit from
  12693. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12694. * @returns the emitter
  12695. */
  12696. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12697. /**
  12698. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12699. * @param radius The radius of the sphere to emit from
  12700. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12701. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12702. * @returns the emitter
  12703. */
  12704. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12705. /**
  12706. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12707. * @param radius The radius of the emission cylinder
  12708. * @param height The height of the emission cylinder
  12709. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12710. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12711. * @returns the emitter
  12712. */
  12713. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12714. /**
  12715. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12716. * @param radius The radius of the cylinder to emit from
  12717. * @param height The height of the emission cylinder
  12718. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12719. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12720. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12721. * @returns the emitter
  12722. */
  12723. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12724. /**
  12725. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12726. * @param radius The radius of the cone to emit from
  12727. * @param angle The base angle of the cone
  12728. * @returns the emitter
  12729. */
  12730. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12731. /**
  12732. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12733. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12734. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12735. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12736. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12737. * @returns the emitter
  12738. */
  12739. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12740. }
  12741. }
  12742. declare module "babylonjs/Particles/subEmitter" {
  12743. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12744. import { Scene } from "babylonjs/scene";
  12745. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12746. /**
  12747. * Type of sub emitter
  12748. */
  12749. export enum SubEmitterType {
  12750. /**
  12751. * Attached to the particle over it's lifetime
  12752. */
  12753. ATTACHED = 0,
  12754. /**
  12755. * Created when the particle dies
  12756. */
  12757. END = 1
  12758. }
  12759. /**
  12760. * Sub emitter class used to emit particles from an existing particle
  12761. */
  12762. export class SubEmitter {
  12763. /**
  12764. * the particle system to be used by the sub emitter
  12765. */
  12766. particleSystem: ParticleSystem;
  12767. /**
  12768. * Type of the submitter (Default: END)
  12769. */
  12770. type: SubEmitterType;
  12771. /**
  12772. * 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)
  12773. * Note: This only is supported when using an emitter of type Mesh
  12774. */
  12775. inheritDirection: boolean;
  12776. /**
  12777. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12778. */
  12779. inheritedVelocityAmount: number;
  12780. /**
  12781. * Creates a sub emitter
  12782. * @param particleSystem the particle system to be used by the sub emitter
  12783. */
  12784. constructor(
  12785. /**
  12786. * the particle system to be used by the sub emitter
  12787. */
  12788. particleSystem: ParticleSystem);
  12789. /**
  12790. * Clones the sub emitter
  12791. * @returns the cloned sub emitter
  12792. */
  12793. clone(): SubEmitter;
  12794. /**
  12795. * Serialize current object to a JSON object
  12796. * @returns the serialized object
  12797. */
  12798. serialize(): any;
  12799. /** @hidden */
  12800. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12801. /**
  12802. * Creates a new SubEmitter from a serialized JSON version
  12803. * @param serializationObject defines the JSON object to read from
  12804. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12805. * @param rootUrl defines the rootUrl for data loading
  12806. * @returns a new SubEmitter
  12807. */
  12808. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12809. /** Release associated resources */
  12810. dispose(): void;
  12811. }
  12812. }
  12813. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12814. /** @hidden */
  12815. export var imageProcessingDeclaration: {
  12816. name: string;
  12817. shader: string;
  12818. };
  12819. }
  12820. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12821. /** @hidden */
  12822. export var imageProcessingFunctions: {
  12823. name: string;
  12824. shader: string;
  12825. };
  12826. }
  12827. declare module "babylonjs/Shaders/particles.fragment" {
  12828. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12829. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12830. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12831. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12832. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12833. /** @hidden */
  12834. export var particlesPixelShader: {
  12835. name: string;
  12836. shader: string;
  12837. };
  12838. }
  12839. declare module "babylonjs/Shaders/particles.vertex" {
  12840. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12841. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12842. /** @hidden */
  12843. export var particlesVertexShader: {
  12844. name: string;
  12845. shader: string;
  12846. };
  12847. }
  12848. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12849. import { Nullable } from "babylonjs/types";
  12850. import { Plane } from "babylonjs/Maths/math";
  12851. /**
  12852. * Interface used to define entities containing multiple clip planes
  12853. */
  12854. export interface IClipPlanesHolder {
  12855. /**
  12856. * Gets or sets the active clipplane 1
  12857. */
  12858. clipPlane: Nullable<Plane>;
  12859. /**
  12860. * Gets or sets the active clipplane 2
  12861. */
  12862. clipPlane2: Nullable<Plane>;
  12863. /**
  12864. * Gets or sets the active clipplane 3
  12865. */
  12866. clipPlane3: Nullable<Plane>;
  12867. /**
  12868. * Gets or sets the active clipplane 4
  12869. */
  12870. clipPlane4: Nullable<Plane>;
  12871. /**
  12872. * Gets or sets the active clipplane 5
  12873. */
  12874. clipPlane5: Nullable<Plane>;
  12875. /**
  12876. * Gets or sets the active clipplane 6
  12877. */
  12878. clipPlane6: Nullable<Plane>;
  12879. }
  12880. }
  12881. declare module "babylonjs/Materials/thinMaterialHelper" {
  12882. import { Effect } from "babylonjs/Materials/effect";
  12883. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12884. /**
  12885. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12886. *
  12887. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12888. *
  12889. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12890. */
  12891. export class ThinMaterialHelper {
  12892. /**
  12893. * Binds the clip plane information from the holder to the effect.
  12894. * @param effect The effect we are binding the data to
  12895. * @param holder The entity containing the clip plane information
  12896. */
  12897. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12898. }
  12899. }
  12900. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12901. module "babylonjs/Engines/thinEngine" {
  12902. interface ThinEngine {
  12903. /**
  12904. * Sets alpha constants used by some alpha blending modes
  12905. * @param r defines the red component
  12906. * @param g defines the green component
  12907. * @param b defines the blue component
  12908. * @param a defines the alpha component
  12909. */
  12910. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12911. /**
  12912. * Sets the current alpha mode
  12913. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12914. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12915. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12916. */
  12917. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12918. /**
  12919. * Gets the current alpha mode
  12920. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12921. * @returns the current alpha mode
  12922. */
  12923. getAlphaMode(): number;
  12924. /**
  12925. * Sets the current alpha equation
  12926. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12927. */
  12928. setAlphaEquation(equation: number): void;
  12929. /**
  12930. * Gets the current alpha equation.
  12931. * @returns the current alpha equation
  12932. */
  12933. getAlphaEquation(): number;
  12934. }
  12935. }
  12936. }
  12937. declare module "babylonjs/Particles/particleSystem" {
  12938. import { Nullable } from "babylonjs/types";
  12939. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12940. import { Observable } from "babylonjs/Misc/observable";
  12941. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12942. import { Effect } from "babylonjs/Materials/effect";
  12943. import { IDisposable } from "babylonjs/scene";
  12944. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12945. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12946. import { Particle } from "babylonjs/Particles/particle";
  12947. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12948. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12949. import "babylonjs/Shaders/particles.fragment";
  12950. import "babylonjs/Shaders/particles.vertex";
  12951. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12952. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12953. import "babylonjs/Engines/Extensions/engine.alpha";
  12954. import { Scene } from "babylonjs/scene";
  12955. /**
  12956. * This represents a particle system in Babylon.
  12957. * 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.
  12958. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12959. * @example https://doc.babylonjs.com/babylon101/particles
  12960. */
  12961. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12962. /**
  12963. * Billboard mode will only apply to Y axis
  12964. */
  12965. static readonly BILLBOARDMODE_Y: number;
  12966. /**
  12967. * Billboard mode will apply to all axes
  12968. */
  12969. static readonly BILLBOARDMODE_ALL: number;
  12970. /**
  12971. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12972. */
  12973. static readonly BILLBOARDMODE_STRETCHED: number;
  12974. /**
  12975. * This function can be defined to provide custom update for active particles.
  12976. * This function will be called instead of regular update (age, position, color, etc.).
  12977. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12978. */
  12979. updateFunction: (particles: Particle[]) => void;
  12980. private _emitterWorldMatrix;
  12981. /**
  12982. * This function can be defined to specify initial direction for every new particle.
  12983. * It by default use the emitterType defined function
  12984. */
  12985. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12986. /**
  12987. * This function can be defined to specify initial position for every new particle.
  12988. * It by default use the emitterType defined function
  12989. */
  12990. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12991. /**
  12992. * @hidden
  12993. */
  12994. _inheritedVelocityOffset: Vector3;
  12995. /**
  12996. * An event triggered when the system is disposed
  12997. */
  12998. onDisposeObservable: Observable<IParticleSystem>;
  12999. /**
  13000. * An event triggered when the system is stopped
  13001. */
  13002. onStoppedObservable: Observable<IParticleSystem>;
  13003. private _onDisposeObserver;
  13004. /**
  13005. * Sets a callback that will be triggered when the system is disposed
  13006. */
  13007. set onDispose(callback: () => void);
  13008. private _particles;
  13009. private _epsilon;
  13010. private _capacity;
  13011. private _stockParticles;
  13012. private _newPartsExcess;
  13013. private _vertexData;
  13014. private _vertexBuffer;
  13015. private _vertexBuffers;
  13016. private _spriteBuffer;
  13017. private _indexBuffer;
  13018. private _effect;
  13019. private _customEffect;
  13020. private _cachedDefines;
  13021. private _scaledColorStep;
  13022. private _colorDiff;
  13023. private _scaledDirection;
  13024. private _scaledGravity;
  13025. private _currentRenderId;
  13026. private _alive;
  13027. private _useInstancing;
  13028. private _vertexArrayObject;
  13029. private _started;
  13030. private _stopped;
  13031. private _actualFrame;
  13032. private _scaledUpdateSpeed;
  13033. private _vertexBufferSize;
  13034. /** @hidden */
  13035. _currentEmitRateGradient: Nullable<FactorGradient>;
  13036. /** @hidden */
  13037. _currentEmitRate1: number;
  13038. /** @hidden */
  13039. _currentEmitRate2: number;
  13040. /** @hidden */
  13041. _currentStartSizeGradient: Nullable<FactorGradient>;
  13042. /** @hidden */
  13043. _currentStartSize1: number;
  13044. /** @hidden */
  13045. _currentStartSize2: number;
  13046. private readonly _rawTextureWidth;
  13047. private _rampGradientsTexture;
  13048. private _useRampGradients;
  13049. /** Gets or sets a matrix to use to compute projection */
  13050. defaultProjectionMatrix: Matrix;
  13051. /** Gets or sets a matrix to use to compute view */
  13052. defaultViewMatrix: Matrix;
  13053. /** Gets or sets a boolean indicating that ramp gradients must be used
  13054. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13055. */
  13056. get useRampGradients(): boolean;
  13057. set useRampGradients(value: boolean);
  13058. /**
  13059. * 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.
  13060. * 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: [])
  13061. */
  13062. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13063. private _subEmitters;
  13064. /**
  13065. * @hidden
  13066. * If the particle systems emitter should be disposed when the particle system is disposed
  13067. */
  13068. _disposeEmitterOnDispose: boolean;
  13069. /**
  13070. * The current active Sub-systems, this property is used by the root particle system only.
  13071. */
  13072. activeSubSystems: Array<ParticleSystem>;
  13073. /**
  13074. * Specifies if the particles are updated in emitter local space or world space
  13075. */
  13076. isLocal: boolean;
  13077. private _rootParticleSystem;
  13078. /**
  13079. * Gets the current list of active particles
  13080. */
  13081. get particles(): Particle[];
  13082. /**
  13083. * Gets the number of particles active at the same time.
  13084. * @returns The number of active particles.
  13085. */
  13086. getActiveCount(): number;
  13087. /**
  13088. * Returns the string "ParticleSystem"
  13089. * @returns a string containing the class name
  13090. */
  13091. getClassName(): string;
  13092. /**
  13093. * Gets a boolean indicating that the system is stopping
  13094. * @returns true if the system is currently stopping
  13095. */
  13096. isStopping(): boolean;
  13097. /**
  13098. * Gets the custom effect used to render the particles
  13099. * @param blendMode Blend mode for which the effect should be retrieved
  13100. * @returns The effect
  13101. */
  13102. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13103. /**
  13104. * Sets the custom effect used to render the particles
  13105. * @param effect The effect to set
  13106. * @param blendMode Blend mode for which the effect should be set
  13107. */
  13108. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13109. /** @hidden */
  13110. private _onBeforeDrawParticlesObservable;
  13111. /**
  13112. * Observable that will be called just before the particles are drawn
  13113. */
  13114. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13115. /**
  13116. * Gets the name of the particle vertex shader
  13117. */
  13118. get vertexShaderName(): string;
  13119. /**
  13120. * Instantiates a particle system.
  13121. * 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.
  13122. * @param name The name of the particle system
  13123. * @param capacity The max number of particles alive at the same time
  13124. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13125. * @param customEffect a custom effect used to change the way particles are rendered by default
  13126. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13127. * @param epsilon Offset used to render the particles
  13128. */
  13129. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13130. private _addFactorGradient;
  13131. private _removeFactorGradient;
  13132. /**
  13133. * Adds a new life time gradient
  13134. * @param gradient defines the gradient to use (between 0 and 1)
  13135. * @param factor defines the life time factor to affect to the specified gradient
  13136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13137. * @returns the current particle system
  13138. */
  13139. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13140. /**
  13141. * Remove a specific life time gradient
  13142. * @param gradient defines the gradient to remove
  13143. * @returns the current particle system
  13144. */
  13145. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13146. /**
  13147. * Adds a new size gradient
  13148. * @param gradient defines the gradient to use (between 0 and 1)
  13149. * @param factor defines the size factor to affect to the specified gradient
  13150. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13151. * @returns the current particle system
  13152. */
  13153. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13154. /**
  13155. * Remove a specific size gradient
  13156. * @param gradient defines the gradient to remove
  13157. * @returns the current particle system
  13158. */
  13159. removeSizeGradient(gradient: number): IParticleSystem;
  13160. /**
  13161. * Adds a new color remap gradient
  13162. * @param gradient defines the gradient to use (between 0 and 1)
  13163. * @param min defines the color remap minimal range
  13164. * @param max defines the color remap maximal range
  13165. * @returns the current particle system
  13166. */
  13167. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13168. /**
  13169. * Remove a specific color remap gradient
  13170. * @param gradient defines the gradient to remove
  13171. * @returns the current particle system
  13172. */
  13173. removeColorRemapGradient(gradient: number): IParticleSystem;
  13174. /**
  13175. * Adds a new alpha remap gradient
  13176. * @param gradient defines the gradient to use (between 0 and 1)
  13177. * @param min defines the alpha remap minimal range
  13178. * @param max defines the alpha remap maximal range
  13179. * @returns the current particle system
  13180. */
  13181. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13182. /**
  13183. * Remove a specific alpha remap gradient
  13184. * @param gradient defines the gradient to remove
  13185. * @returns the current particle system
  13186. */
  13187. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13188. /**
  13189. * Adds a new angular speed gradient
  13190. * @param gradient defines the gradient to use (between 0 and 1)
  13191. * @param factor defines the angular speed to affect to the specified gradient
  13192. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13193. * @returns the current particle system
  13194. */
  13195. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13196. /**
  13197. * Remove a specific angular speed gradient
  13198. * @param gradient defines the gradient to remove
  13199. * @returns the current particle system
  13200. */
  13201. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13202. /**
  13203. * Adds a new velocity gradient
  13204. * @param gradient defines the gradient to use (between 0 and 1)
  13205. * @param factor defines the velocity to affect to the specified gradient
  13206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13207. * @returns the current particle system
  13208. */
  13209. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13210. /**
  13211. * Remove a specific velocity gradient
  13212. * @param gradient defines the gradient to remove
  13213. * @returns the current particle system
  13214. */
  13215. removeVelocityGradient(gradient: number): IParticleSystem;
  13216. /**
  13217. * Adds a new limit velocity gradient
  13218. * @param gradient defines the gradient to use (between 0 and 1)
  13219. * @param factor defines the limit velocity value to affect to the specified gradient
  13220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13221. * @returns the current particle system
  13222. */
  13223. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13224. /**
  13225. * Remove a specific limit velocity gradient
  13226. * @param gradient defines the gradient to remove
  13227. * @returns the current particle system
  13228. */
  13229. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13230. /**
  13231. * Adds a new drag gradient
  13232. * @param gradient defines the gradient to use (between 0 and 1)
  13233. * @param factor defines the drag value to affect to the specified gradient
  13234. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13235. * @returns the current particle system
  13236. */
  13237. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13238. /**
  13239. * Remove a specific drag gradient
  13240. * @param gradient defines the gradient to remove
  13241. * @returns the current particle system
  13242. */
  13243. removeDragGradient(gradient: number): IParticleSystem;
  13244. /**
  13245. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13246. * @param gradient defines the gradient to use (between 0 and 1)
  13247. * @param factor defines the emit rate value to affect to the specified gradient
  13248. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13249. * @returns the current particle system
  13250. */
  13251. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13252. /**
  13253. * Remove a specific emit rate gradient
  13254. * @param gradient defines the gradient to remove
  13255. * @returns the current particle system
  13256. */
  13257. removeEmitRateGradient(gradient: number): IParticleSystem;
  13258. /**
  13259. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13260. * @param gradient defines the gradient to use (between 0 and 1)
  13261. * @param factor defines the start size value to affect to the specified gradient
  13262. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13263. * @returns the current particle system
  13264. */
  13265. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13266. /**
  13267. * Remove a specific start size gradient
  13268. * @param gradient defines the gradient to remove
  13269. * @returns the current particle system
  13270. */
  13271. removeStartSizeGradient(gradient: number): IParticleSystem;
  13272. private _createRampGradientTexture;
  13273. /**
  13274. * Gets the current list of ramp gradients.
  13275. * You must use addRampGradient and removeRampGradient to udpate this list
  13276. * @returns the list of ramp gradients
  13277. */
  13278. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13279. /** Force the system to rebuild all gradients that need to be resync */
  13280. forceRefreshGradients(): void;
  13281. private _syncRampGradientTexture;
  13282. /**
  13283. * Adds a new ramp gradient used to remap particle colors
  13284. * @param gradient defines the gradient to use (between 0 and 1)
  13285. * @param color defines the color to affect to the specified gradient
  13286. * @returns the current particle system
  13287. */
  13288. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13289. /**
  13290. * Remove a specific ramp gradient
  13291. * @param gradient defines the gradient to remove
  13292. * @returns the current particle system
  13293. */
  13294. removeRampGradient(gradient: number): ParticleSystem;
  13295. /**
  13296. * Adds a new color gradient
  13297. * @param gradient defines the gradient to use (between 0 and 1)
  13298. * @param color1 defines the color to affect to the specified gradient
  13299. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13300. * @returns this particle system
  13301. */
  13302. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13303. /**
  13304. * Remove a specific color gradient
  13305. * @param gradient defines the gradient to remove
  13306. * @returns this particle system
  13307. */
  13308. removeColorGradient(gradient: number): IParticleSystem;
  13309. private _fetchR;
  13310. protected _reset(): void;
  13311. private _resetEffect;
  13312. private _createVertexBuffers;
  13313. private _createIndexBuffer;
  13314. /**
  13315. * Gets the maximum number of particles active at the same time.
  13316. * @returns The max number of active particles.
  13317. */
  13318. getCapacity(): number;
  13319. /**
  13320. * Gets whether there are still active particles in the system.
  13321. * @returns True if it is alive, otherwise false.
  13322. */
  13323. isAlive(): boolean;
  13324. /**
  13325. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13326. * @returns True if it has been started, otherwise false.
  13327. */
  13328. isStarted(): boolean;
  13329. private _prepareSubEmitterInternalArray;
  13330. /**
  13331. * Starts the particle system and begins to emit
  13332. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13333. */
  13334. start(delay?: number): void;
  13335. /**
  13336. * Stops the particle system.
  13337. * @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.
  13338. */
  13339. stop(stopSubEmitters?: boolean): void;
  13340. /**
  13341. * Remove all active particles
  13342. */
  13343. reset(): void;
  13344. /**
  13345. * @hidden (for internal use only)
  13346. */
  13347. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13348. /**
  13349. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13350. * Its lifetime will start back at 0.
  13351. */
  13352. recycleParticle: (particle: Particle) => void;
  13353. private _stopSubEmitters;
  13354. private _createParticle;
  13355. private _removeFromRoot;
  13356. private _emitFromParticle;
  13357. private _update;
  13358. /** @hidden */
  13359. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13360. /** @hidden */
  13361. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13362. /**
  13363. * Fill the defines array according to the current settings of the particle system
  13364. * @param defines Array to be updated
  13365. * @param blendMode blend mode to take into account when updating the array
  13366. */
  13367. fillDefines(defines: Array<string>, blendMode: number): void;
  13368. /**
  13369. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13370. * @param uniforms Uniforms array to fill
  13371. * @param attributes Attributes array to fill
  13372. * @param samplers Samplers array to fill
  13373. */
  13374. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13375. /** @hidden */
  13376. private _getEffect;
  13377. /**
  13378. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13379. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13380. */
  13381. animate(preWarmOnly?: boolean): void;
  13382. private _appendParticleVertices;
  13383. /**
  13384. * Rebuilds the particle system.
  13385. */
  13386. rebuild(): void;
  13387. /**
  13388. * Is this system ready to be used/rendered
  13389. * @return true if the system is ready
  13390. */
  13391. isReady(): boolean;
  13392. private _render;
  13393. /**
  13394. * Renders the particle system in its current state.
  13395. * @returns the current number of particles
  13396. */
  13397. render(): number;
  13398. /**
  13399. * Disposes the particle system and free the associated resources
  13400. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13401. */
  13402. dispose(disposeTexture?: boolean): void;
  13403. /**
  13404. * Clones the particle system.
  13405. * @param name The name of the cloned object
  13406. * @param newEmitter The new emitter to use
  13407. * @returns the cloned particle system
  13408. */
  13409. clone(name: string, newEmitter: any): ParticleSystem;
  13410. /**
  13411. * Serializes the particle system to a JSON object
  13412. * @param serializeTexture defines if the texture must be serialized as well
  13413. * @returns the JSON object
  13414. */
  13415. serialize(serializeTexture?: boolean): any;
  13416. /** @hidden */
  13417. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13418. /** @hidden */
  13419. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13420. /**
  13421. * Parses a JSON object to create a particle system.
  13422. * @param parsedParticleSystem The JSON object to parse
  13423. * @param sceneOrEngine The scene or the engine to create the particle system in
  13424. * @param rootUrl The root url to use to load external dependencies like texture
  13425. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13426. * @returns the Parsed particle system
  13427. */
  13428. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13429. }
  13430. }
  13431. declare module "babylonjs/Particles/particle" {
  13432. import { Nullable } from "babylonjs/types";
  13433. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13434. import { Color4 } from "babylonjs/Maths/math.color";
  13435. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13436. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13437. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13438. /**
  13439. * A particle represents one of the element emitted by a particle system.
  13440. * This is mainly define by its coordinates, direction, velocity and age.
  13441. */
  13442. export class Particle {
  13443. /**
  13444. * The particle system the particle belongs to.
  13445. */
  13446. particleSystem: ParticleSystem;
  13447. private static _Count;
  13448. /**
  13449. * Unique ID of the particle
  13450. */
  13451. id: number;
  13452. /**
  13453. * The world position of the particle in the scene.
  13454. */
  13455. position: Vector3;
  13456. /**
  13457. * The world direction of the particle in the scene.
  13458. */
  13459. direction: Vector3;
  13460. /**
  13461. * The color of the particle.
  13462. */
  13463. color: Color4;
  13464. /**
  13465. * The color change of the particle per step.
  13466. */
  13467. colorStep: Color4;
  13468. /**
  13469. * Defines how long will the life of the particle be.
  13470. */
  13471. lifeTime: number;
  13472. /**
  13473. * The current age of the particle.
  13474. */
  13475. age: number;
  13476. /**
  13477. * The current size of the particle.
  13478. */
  13479. size: number;
  13480. /**
  13481. * The current scale of the particle.
  13482. */
  13483. scale: Vector2;
  13484. /**
  13485. * The current angle of the particle.
  13486. */
  13487. angle: number;
  13488. /**
  13489. * Defines how fast is the angle changing.
  13490. */
  13491. angularSpeed: number;
  13492. /**
  13493. * Defines the cell index used by the particle to be rendered from a sprite.
  13494. */
  13495. cellIndex: number;
  13496. /**
  13497. * The information required to support color remapping
  13498. */
  13499. remapData: Vector4;
  13500. /** @hidden */
  13501. _randomCellOffset?: number;
  13502. /** @hidden */
  13503. _initialDirection: Nullable<Vector3>;
  13504. /** @hidden */
  13505. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13506. /** @hidden */
  13507. _initialStartSpriteCellID: number;
  13508. /** @hidden */
  13509. _initialEndSpriteCellID: number;
  13510. /** @hidden */
  13511. _currentColorGradient: Nullable<ColorGradient>;
  13512. /** @hidden */
  13513. _currentColor1: Color4;
  13514. /** @hidden */
  13515. _currentColor2: Color4;
  13516. /** @hidden */
  13517. _currentSizeGradient: Nullable<FactorGradient>;
  13518. /** @hidden */
  13519. _currentSize1: number;
  13520. /** @hidden */
  13521. _currentSize2: number;
  13522. /** @hidden */
  13523. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13524. /** @hidden */
  13525. _currentAngularSpeed1: number;
  13526. /** @hidden */
  13527. _currentAngularSpeed2: number;
  13528. /** @hidden */
  13529. _currentVelocityGradient: Nullable<FactorGradient>;
  13530. /** @hidden */
  13531. _currentVelocity1: number;
  13532. /** @hidden */
  13533. _currentVelocity2: number;
  13534. /** @hidden */
  13535. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13536. /** @hidden */
  13537. _currentLimitVelocity1: number;
  13538. /** @hidden */
  13539. _currentLimitVelocity2: number;
  13540. /** @hidden */
  13541. _currentDragGradient: Nullable<FactorGradient>;
  13542. /** @hidden */
  13543. _currentDrag1: number;
  13544. /** @hidden */
  13545. _currentDrag2: number;
  13546. /** @hidden */
  13547. _randomNoiseCoordinates1: Vector3;
  13548. /** @hidden */
  13549. _randomNoiseCoordinates2: Vector3;
  13550. /** @hidden */
  13551. _localPosition?: Vector3;
  13552. /**
  13553. * Creates a new instance Particle
  13554. * @param particleSystem the particle system the particle belongs to
  13555. */
  13556. constructor(
  13557. /**
  13558. * The particle system the particle belongs to.
  13559. */
  13560. particleSystem: ParticleSystem);
  13561. private updateCellInfoFromSystem;
  13562. /**
  13563. * Defines how the sprite cell index is updated for the particle
  13564. */
  13565. updateCellIndex(): void;
  13566. /** @hidden */
  13567. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13568. /** @hidden */
  13569. _inheritParticleInfoToSubEmitters(): void;
  13570. /** @hidden */
  13571. _reset(): void;
  13572. /**
  13573. * Copy the properties of particle to another one.
  13574. * @param other the particle to copy the information to.
  13575. */
  13576. copyTo(other: Particle): void;
  13577. }
  13578. }
  13579. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13580. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13581. import { Effect } from "babylonjs/Materials/effect";
  13582. import { Particle } from "babylonjs/Particles/particle";
  13583. import { Nullable } from "babylonjs/types";
  13584. import { Scene } from "babylonjs/scene";
  13585. /**
  13586. * Particle emitter represents a volume emitting particles.
  13587. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13588. */
  13589. export interface IParticleEmitterType {
  13590. /**
  13591. * Called by the particle System when the direction is computed for the created particle.
  13592. * @param worldMatrix is the world matrix of the particle system
  13593. * @param directionToUpdate is the direction vector to update with the result
  13594. * @param particle is the particle we are computed the direction for
  13595. * @param isLocal defines if the direction should be set in local space
  13596. */
  13597. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13598. /**
  13599. * Called by the particle System when the position is computed for the created particle.
  13600. * @param worldMatrix is the world matrix of the particle system
  13601. * @param positionToUpdate is the position vector to update with the result
  13602. * @param particle is the particle we are computed the position for
  13603. * @param isLocal defines if the position should be set in local space
  13604. */
  13605. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13606. /**
  13607. * Clones the current emitter and returns a copy of it
  13608. * @returns the new emitter
  13609. */
  13610. clone(): IParticleEmitterType;
  13611. /**
  13612. * Called by the GPUParticleSystem to setup the update shader
  13613. * @param effect defines the update shader
  13614. */
  13615. applyToShader(effect: Effect): void;
  13616. /**
  13617. * Returns a string to use to update the GPU particles update shader
  13618. * @returns the effect defines string
  13619. */
  13620. getEffectDefines(): string;
  13621. /**
  13622. * Returns a string representing the class name
  13623. * @returns a string containing the class name
  13624. */
  13625. getClassName(): string;
  13626. /**
  13627. * Serializes the particle system to a JSON object.
  13628. * @returns the JSON object
  13629. */
  13630. serialize(): any;
  13631. /**
  13632. * Parse properties from a JSON object
  13633. * @param serializationObject defines the JSON object
  13634. * @param scene defines the hosting scene
  13635. */
  13636. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13637. }
  13638. }
  13639. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13640. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13641. import { Effect } from "babylonjs/Materials/effect";
  13642. import { Particle } from "babylonjs/Particles/particle";
  13643. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13644. /**
  13645. * Particle emitter emitting particles from the inside of a box.
  13646. * It emits the particles randomly between 2 given directions.
  13647. */
  13648. export class BoxParticleEmitter implements IParticleEmitterType {
  13649. /**
  13650. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13651. */
  13652. direction1: Vector3;
  13653. /**
  13654. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13655. */
  13656. direction2: Vector3;
  13657. /**
  13658. * 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.
  13659. */
  13660. minEmitBox: Vector3;
  13661. /**
  13662. * 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.
  13663. */
  13664. maxEmitBox: Vector3;
  13665. /**
  13666. * Creates a new instance BoxParticleEmitter
  13667. */
  13668. constructor();
  13669. /**
  13670. * Called by the particle System when the direction is computed for the created particle.
  13671. * @param worldMatrix is the world matrix of the particle system
  13672. * @param directionToUpdate is the direction vector to update with the result
  13673. * @param particle is the particle we are computed the direction for
  13674. * @param isLocal defines if the direction should be set in local space
  13675. */
  13676. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13677. /**
  13678. * Called by the particle System when the position is computed for the created particle.
  13679. * @param worldMatrix is the world matrix of the particle system
  13680. * @param positionToUpdate is the position vector to update with the result
  13681. * @param particle is the particle we are computed the position for
  13682. * @param isLocal defines if the position should be set in local space
  13683. */
  13684. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13685. /**
  13686. * Clones the current emitter and returns a copy of it
  13687. * @returns the new emitter
  13688. */
  13689. clone(): BoxParticleEmitter;
  13690. /**
  13691. * Called by the GPUParticleSystem to setup the update shader
  13692. * @param effect defines the update shader
  13693. */
  13694. applyToShader(effect: Effect): void;
  13695. /**
  13696. * Returns a string to use to update the GPU particles update shader
  13697. * @returns a string containng the defines string
  13698. */
  13699. getEffectDefines(): string;
  13700. /**
  13701. * Returns the string "BoxParticleEmitter"
  13702. * @returns a string containing the class name
  13703. */
  13704. getClassName(): string;
  13705. /**
  13706. * Serializes the particle system to a JSON object.
  13707. * @returns the JSON object
  13708. */
  13709. serialize(): any;
  13710. /**
  13711. * Parse properties from a JSON object
  13712. * @param serializationObject defines the JSON object
  13713. */
  13714. parse(serializationObject: any): void;
  13715. }
  13716. }
  13717. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13718. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13719. import { Effect } from "babylonjs/Materials/effect";
  13720. import { Particle } from "babylonjs/Particles/particle";
  13721. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13722. /**
  13723. * Particle emitter emitting particles from the inside of a cone.
  13724. * It emits the particles alongside the cone volume from the base to the particle.
  13725. * The emission direction might be randomized.
  13726. */
  13727. export class ConeParticleEmitter implements IParticleEmitterType {
  13728. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13729. directionRandomizer: number;
  13730. private _radius;
  13731. private _angle;
  13732. private _height;
  13733. /**
  13734. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13735. */
  13736. radiusRange: number;
  13737. /**
  13738. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13739. */
  13740. heightRange: number;
  13741. /**
  13742. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13743. */
  13744. emitFromSpawnPointOnly: boolean;
  13745. /**
  13746. * Gets or sets the radius of the emission cone
  13747. */
  13748. get radius(): number;
  13749. set radius(value: number);
  13750. /**
  13751. * Gets or sets the angle of the emission cone
  13752. */
  13753. get angle(): number;
  13754. set angle(value: number);
  13755. private _buildHeight;
  13756. /**
  13757. * Creates a new instance ConeParticleEmitter
  13758. * @param radius the radius of the emission cone (1 by default)
  13759. * @param angle the cone base angle (PI by default)
  13760. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13761. */
  13762. constructor(radius?: number, angle?: number,
  13763. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13764. directionRandomizer?: number);
  13765. /**
  13766. * Called by the particle System when the direction is computed for the created particle.
  13767. * @param worldMatrix is the world matrix of the particle system
  13768. * @param directionToUpdate is the direction vector to update with the result
  13769. * @param particle is the particle we are computed the direction for
  13770. * @param isLocal defines if the direction should be set in local space
  13771. */
  13772. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13773. /**
  13774. * Called by the particle System when the position is computed for the created particle.
  13775. * @param worldMatrix is the world matrix of the particle system
  13776. * @param positionToUpdate is the position vector to update with the result
  13777. * @param particle is the particle we are computed the position for
  13778. * @param isLocal defines if the position should be set in local space
  13779. */
  13780. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13781. /**
  13782. * Clones the current emitter and returns a copy of it
  13783. * @returns the new emitter
  13784. */
  13785. clone(): ConeParticleEmitter;
  13786. /**
  13787. * Called by the GPUParticleSystem to setup the update shader
  13788. * @param effect defines the update shader
  13789. */
  13790. applyToShader(effect: Effect): void;
  13791. /**
  13792. * Returns a string to use to update the GPU particles update shader
  13793. * @returns a string containng the defines string
  13794. */
  13795. getEffectDefines(): string;
  13796. /**
  13797. * Returns the string "ConeParticleEmitter"
  13798. * @returns a string containing the class name
  13799. */
  13800. getClassName(): string;
  13801. /**
  13802. * Serializes the particle system to a JSON object.
  13803. * @returns the JSON object
  13804. */
  13805. serialize(): any;
  13806. /**
  13807. * Parse properties from a JSON object
  13808. * @param serializationObject defines the JSON object
  13809. */
  13810. parse(serializationObject: any): void;
  13811. }
  13812. }
  13813. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13814. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13815. import { Effect } from "babylonjs/Materials/effect";
  13816. import { Particle } from "babylonjs/Particles/particle";
  13817. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13818. /**
  13819. * Particle emitter emitting particles from the inside of a cylinder.
  13820. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13821. */
  13822. export class CylinderParticleEmitter implements IParticleEmitterType {
  13823. /**
  13824. * The radius of the emission cylinder.
  13825. */
  13826. radius: number;
  13827. /**
  13828. * The height of the emission cylinder.
  13829. */
  13830. height: number;
  13831. /**
  13832. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13833. */
  13834. radiusRange: number;
  13835. /**
  13836. * How much to randomize the particle direction [0-1].
  13837. */
  13838. directionRandomizer: number;
  13839. /**
  13840. * Creates a new instance CylinderParticleEmitter
  13841. * @param radius the radius of the emission cylinder (1 by default)
  13842. * @param height the height of the emission cylinder (1 by default)
  13843. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13844. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13845. */
  13846. constructor(
  13847. /**
  13848. * The radius of the emission cylinder.
  13849. */
  13850. radius?: number,
  13851. /**
  13852. * The height of the emission cylinder.
  13853. */
  13854. height?: number,
  13855. /**
  13856. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13857. */
  13858. radiusRange?: number,
  13859. /**
  13860. * How much to randomize the particle direction [0-1].
  13861. */
  13862. directionRandomizer?: number);
  13863. /**
  13864. * Called by the particle System when the direction is computed for the created particle.
  13865. * @param worldMatrix is the world matrix of the particle system
  13866. * @param directionToUpdate is the direction vector to update with the result
  13867. * @param particle is the particle we are computed the direction for
  13868. * @param isLocal defines if the direction should be set in local space
  13869. */
  13870. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13871. /**
  13872. * Called by the particle System when the position is computed for the created particle.
  13873. * @param worldMatrix is the world matrix of the particle system
  13874. * @param positionToUpdate is the position vector to update with the result
  13875. * @param particle is the particle we are computed the position for
  13876. * @param isLocal defines if the position should be set in local space
  13877. */
  13878. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13879. /**
  13880. * Clones the current emitter and returns a copy of it
  13881. * @returns the new emitter
  13882. */
  13883. clone(): CylinderParticleEmitter;
  13884. /**
  13885. * Called by the GPUParticleSystem to setup the update shader
  13886. * @param effect defines the update shader
  13887. */
  13888. applyToShader(effect: Effect): void;
  13889. /**
  13890. * Returns a string to use to update the GPU particles update shader
  13891. * @returns a string containng the defines string
  13892. */
  13893. getEffectDefines(): string;
  13894. /**
  13895. * Returns the string "CylinderParticleEmitter"
  13896. * @returns a string containing the class name
  13897. */
  13898. getClassName(): string;
  13899. /**
  13900. * Serializes the particle system to a JSON object.
  13901. * @returns the JSON object
  13902. */
  13903. serialize(): any;
  13904. /**
  13905. * Parse properties from a JSON object
  13906. * @param serializationObject defines the JSON object
  13907. */
  13908. parse(serializationObject: any): void;
  13909. }
  13910. /**
  13911. * Particle emitter emitting particles from the inside of a cylinder.
  13912. * It emits the particles randomly between two vectors.
  13913. */
  13914. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13915. /**
  13916. * The min limit of the emission direction.
  13917. */
  13918. direction1: Vector3;
  13919. /**
  13920. * The max limit of the emission direction.
  13921. */
  13922. direction2: Vector3;
  13923. /**
  13924. * Creates a new instance CylinderDirectedParticleEmitter
  13925. * @param radius the radius of the emission cylinder (1 by default)
  13926. * @param height the height of the emission cylinder (1 by default)
  13927. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13928. * @param direction1 the min limit of the emission direction (up vector by default)
  13929. * @param direction2 the max limit of the emission direction (up vector by default)
  13930. */
  13931. constructor(radius?: number, height?: number, radiusRange?: number,
  13932. /**
  13933. * The min limit of the emission direction.
  13934. */
  13935. direction1?: Vector3,
  13936. /**
  13937. * The max limit of the emission direction.
  13938. */
  13939. direction2?: Vector3);
  13940. /**
  13941. * Called by the particle System when the direction is computed for the created particle.
  13942. * @param worldMatrix is the world matrix of the particle system
  13943. * @param directionToUpdate is the direction vector to update with the result
  13944. * @param particle is the particle we are computed the direction for
  13945. */
  13946. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13947. /**
  13948. * Clones the current emitter and returns a copy of it
  13949. * @returns the new emitter
  13950. */
  13951. clone(): CylinderDirectedParticleEmitter;
  13952. /**
  13953. * Called by the GPUParticleSystem to setup the update shader
  13954. * @param effect defines the update shader
  13955. */
  13956. applyToShader(effect: Effect): void;
  13957. /**
  13958. * Returns a string to use to update the GPU particles update shader
  13959. * @returns a string containng the defines string
  13960. */
  13961. getEffectDefines(): string;
  13962. /**
  13963. * Returns the string "CylinderDirectedParticleEmitter"
  13964. * @returns a string containing the class name
  13965. */
  13966. getClassName(): string;
  13967. /**
  13968. * Serializes the particle system to a JSON object.
  13969. * @returns the JSON object
  13970. */
  13971. serialize(): any;
  13972. /**
  13973. * Parse properties from a JSON object
  13974. * @param serializationObject defines the JSON object
  13975. */
  13976. parse(serializationObject: any): void;
  13977. }
  13978. }
  13979. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13980. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13981. import { Effect } from "babylonjs/Materials/effect";
  13982. import { Particle } from "babylonjs/Particles/particle";
  13983. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13984. /**
  13985. * Particle emitter emitting particles from the inside of a hemisphere.
  13986. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13987. */
  13988. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13989. /**
  13990. * The radius of the emission hemisphere.
  13991. */
  13992. radius: number;
  13993. /**
  13994. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13995. */
  13996. radiusRange: number;
  13997. /**
  13998. * How much to randomize the particle direction [0-1].
  13999. */
  14000. directionRandomizer: number;
  14001. /**
  14002. * Creates a new instance HemisphericParticleEmitter
  14003. * @param radius the radius of the emission hemisphere (1 by default)
  14004. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14005. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14006. */
  14007. constructor(
  14008. /**
  14009. * The radius of the emission hemisphere.
  14010. */
  14011. radius?: number,
  14012. /**
  14013. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14014. */
  14015. radiusRange?: number,
  14016. /**
  14017. * How much to randomize the particle direction [0-1].
  14018. */
  14019. directionRandomizer?: number);
  14020. /**
  14021. * Called by the particle System when the direction is computed for the created particle.
  14022. * @param worldMatrix is the world matrix of the particle system
  14023. * @param directionToUpdate is the direction vector to update with the result
  14024. * @param particle is the particle we are computed the direction for
  14025. * @param isLocal defines if the direction should be set in local space
  14026. */
  14027. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14028. /**
  14029. * Called by the particle System when the position is computed for the created particle.
  14030. * @param worldMatrix is the world matrix of the particle system
  14031. * @param positionToUpdate is the position vector to update with the result
  14032. * @param particle is the particle we are computed the position for
  14033. * @param isLocal defines if the position should be set in local space
  14034. */
  14035. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14036. /**
  14037. * Clones the current emitter and returns a copy of it
  14038. * @returns the new emitter
  14039. */
  14040. clone(): HemisphericParticleEmitter;
  14041. /**
  14042. * Called by the GPUParticleSystem to setup the update shader
  14043. * @param effect defines the update shader
  14044. */
  14045. applyToShader(effect: Effect): void;
  14046. /**
  14047. * Returns a string to use to update the GPU particles update shader
  14048. * @returns a string containng the defines string
  14049. */
  14050. getEffectDefines(): string;
  14051. /**
  14052. * Returns the string "HemisphericParticleEmitter"
  14053. * @returns a string containing the class name
  14054. */
  14055. getClassName(): string;
  14056. /**
  14057. * Serializes the particle system to a JSON object.
  14058. * @returns the JSON object
  14059. */
  14060. serialize(): any;
  14061. /**
  14062. * Parse properties from a JSON object
  14063. * @param serializationObject defines the JSON object
  14064. */
  14065. parse(serializationObject: any): void;
  14066. }
  14067. }
  14068. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14069. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14070. import { Effect } from "babylonjs/Materials/effect";
  14071. import { Particle } from "babylonjs/Particles/particle";
  14072. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14073. /**
  14074. * Particle emitter emitting particles from a point.
  14075. * It emits the particles randomly between 2 given directions.
  14076. */
  14077. export class PointParticleEmitter implements IParticleEmitterType {
  14078. /**
  14079. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14080. */
  14081. direction1: Vector3;
  14082. /**
  14083. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14084. */
  14085. direction2: Vector3;
  14086. /**
  14087. * Creates a new instance PointParticleEmitter
  14088. */
  14089. constructor();
  14090. /**
  14091. * Called by the particle System when the direction is computed for the created particle.
  14092. * @param worldMatrix is the world matrix of the particle system
  14093. * @param directionToUpdate is the direction vector to update with the result
  14094. * @param particle is the particle we are computed the direction for
  14095. * @param isLocal defines if the direction should be set in local space
  14096. */
  14097. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14098. /**
  14099. * Called by the particle System when the position is computed for the created particle.
  14100. * @param worldMatrix is the world matrix of the particle system
  14101. * @param positionToUpdate is the position vector to update with the result
  14102. * @param particle is the particle we are computed the position for
  14103. * @param isLocal defines if the position should be set in local space
  14104. */
  14105. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14106. /**
  14107. * Clones the current emitter and returns a copy of it
  14108. * @returns the new emitter
  14109. */
  14110. clone(): PointParticleEmitter;
  14111. /**
  14112. * Called by the GPUParticleSystem to setup the update shader
  14113. * @param effect defines the update shader
  14114. */
  14115. applyToShader(effect: Effect): void;
  14116. /**
  14117. * Returns a string to use to update the GPU particles update shader
  14118. * @returns a string containng the defines string
  14119. */
  14120. getEffectDefines(): string;
  14121. /**
  14122. * Returns the string "PointParticleEmitter"
  14123. * @returns a string containing the class name
  14124. */
  14125. getClassName(): string;
  14126. /**
  14127. * Serializes the particle system to a JSON object.
  14128. * @returns the JSON object
  14129. */
  14130. serialize(): any;
  14131. /**
  14132. * Parse properties from a JSON object
  14133. * @param serializationObject defines the JSON object
  14134. */
  14135. parse(serializationObject: any): void;
  14136. }
  14137. }
  14138. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14139. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14140. import { Effect } from "babylonjs/Materials/effect";
  14141. import { Particle } from "babylonjs/Particles/particle";
  14142. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14143. /**
  14144. * Particle emitter emitting particles from the inside of a sphere.
  14145. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14146. */
  14147. export class SphereParticleEmitter implements IParticleEmitterType {
  14148. /**
  14149. * The radius of the emission sphere.
  14150. */
  14151. radius: number;
  14152. /**
  14153. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14154. */
  14155. radiusRange: number;
  14156. /**
  14157. * How much to randomize the particle direction [0-1].
  14158. */
  14159. directionRandomizer: number;
  14160. /**
  14161. * Creates a new instance SphereParticleEmitter
  14162. * @param radius the radius of the emission sphere (1 by default)
  14163. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14164. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14165. */
  14166. constructor(
  14167. /**
  14168. * The radius of the emission sphere.
  14169. */
  14170. radius?: number,
  14171. /**
  14172. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14173. */
  14174. radiusRange?: number,
  14175. /**
  14176. * How much to randomize the particle direction [0-1].
  14177. */
  14178. directionRandomizer?: number);
  14179. /**
  14180. * Called by the particle System when the direction is computed for the created particle.
  14181. * @param worldMatrix is the world matrix of the particle system
  14182. * @param directionToUpdate is the direction vector to update with the result
  14183. * @param particle is the particle we are computed the direction for
  14184. * @param isLocal defines if the direction should be set in local space
  14185. */
  14186. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14187. /**
  14188. * Called by the particle System when the position is computed for the created particle.
  14189. * @param worldMatrix is the world matrix of the particle system
  14190. * @param positionToUpdate is the position vector to update with the result
  14191. * @param particle is the particle we are computed the position for
  14192. * @param isLocal defines if the position should be set in local space
  14193. */
  14194. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14195. /**
  14196. * Clones the current emitter and returns a copy of it
  14197. * @returns the new emitter
  14198. */
  14199. clone(): SphereParticleEmitter;
  14200. /**
  14201. * Called by the GPUParticleSystem to setup the update shader
  14202. * @param effect defines the update shader
  14203. */
  14204. applyToShader(effect: Effect): void;
  14205. /**
  14206. * Returns a string to use to update the GPU particles update shader
  14207. * @returns a string containng the defines string
  14208. */
  14209. getEffectDefines(): string;
  14210. /**
  14211. * Returns the string "SphereParticleEmitter"
  14212. * @returns a string containing the class name
  14213. */
  14214. getClassName(): string;
  14215. /**
  14216. * Serializes the particle system to a JSON object.
  14217. * @returns the JSON object
  14218. */
  14219. serialize(): any;
  14220. /**
  14221. * Parse properties from a JSON object
  14222. * @param serializationObject defines the JSON object
  14223. */
  14224. parse(serializationObject: any): void;
  14225. }
  14226. /**
  14227. * Particle emitter emitting particles from the inside of a sphere.
  14228. * It emits the particles randomly between two vectors.
  14229. */
  14230. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14231. /**
  14232. * The min limit of the emission direction.
  14233. */
  14234. direction1: Vector3;
  14235. /**
  14236. * The max limit of the emission direction.
  14237. */
  14238. direction2: Vector3;
  14239. /**
  14240. * Creates a new instance SphereDirectedParticleEmitter
  14241. * @param radius the radius of the emission sphere (1 by default)
  14242. * @param direction1 the min limit of the emission direction (up vector by default)
  14243. * @param direction2 the max limit of the emission direction (up vector by default)
  14244. */
  14245. constructor(radius?: number,
  14246. /**
  14247. * The min limit of the emission direction.
  14248. */
  14249. direction1?: Vector3,
  14250. /**
  14251. * The max limit of the emission direction.
  14252. */
  14253. direction2?: Vector3);
  14254. /**
  14255. * Called by the particle System when the direction is computed for the created particle.
  14256. * @param worldMatrix is the world matrix of the particle system
  14257. * @param directionToUpdate is the direction vector to update with the result
  14258. * @param particle is the particle we are computed the direction for
  14259. */
  14260. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14261. /**
  14262. * Clones the current emitter and returns a copy of it
  14263. * @returns the new emitter
  14264. */
  14265. clone(): SphereDirectedParticleEmitter;
  14266. /**
  14267. * Called by the GPUParticleSystem to setup the update shader
  14268. * @param effect defines the update shader
  14269. */
  14270. applyToShader(effect: Effect): void;
  14271. /**
  14272. * Returns a string to use to update the GPU particles update shader
  14273. * @returns a string containng the defines string
  14274. */
  14275. getEffectDefines(): string;
  14276. /**
  14277. * Returns the string "SphereDirectedParticleEmitter"
  14278. * @returns a string containing the class name
  14279. */
  14280. getClassName(): string;
  14281. /**
  14282. * Serializes the particle system to a JSON object.
  14283. * @returns the JSON object
  14284. */
  14285. serialize(): any;
  14286. /**
  14287. * Parse properties from a JSON object
  14288. * @param serializationObject defines the JSON object
  14289. */
  14290. parse(serializationObject: any): void;
  14291. }
  14292. }
  14293. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14294. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14295. import { Effect } from "babylonjs/Materials/effect";
  14296. import { Particle } from "babylonjs/Particles/particle";
  14297. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14298. import { Nullable } from "babylonjs/types";
  14299. /**
  14300. * Particle emitter emitting particles from a custom list of positions.
  14301. */
  14302. export class CustomParticleEmitter implements IParticleEmitterType {
  14303. /**
  14304. * Gets or sets the position generator that will create the inital position of each particle.
  14305. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14306. */
  14307. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14308. /**
  14309. * Gets or sets the destination generator that will create the final destination of each particle.
  14310. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14311. */
  14312. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14313. /**
  14314. * Creates a new instance CustomParticleEmitter
  14315. */
  14316. constructor();
  14317. /**
  14318. * Called by the particle System when the direction is computed for the created particle.
  14319. * @param worldMatrix is the world matrix of the particle system
  14320. * @param directionToUpdate is the direction vector to update with the result
  14321. * @param particle is the particle we are computed the direction for
  14322. * @param isLocal defines if the direction should be set in local space
  14323. */
  14324. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14325. /**
  14326. * Called by the particle System when the position is computed for the created particle.
  14327. * @param worldMatrix is the world matrix of the particle system
  14328. * @param positionToUpdate is the position vector to update with the result
  14329. * @param particle is the particle we are computed the position for
  14330. * @param isLocal defines if the position should be set in local space
  14331. */
  14332. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14333. /**
  14334. * Clones the current emitter and returns a copy of it
  14335. * @returns the new emitter
  14336. */
  14337. clone(): CustomParticleEmitter;
  14338. /**
  14339. * Called by the GPUParticleSystem to setup the update shader
  14340. * @param effect defines the update shader
  14341. */
  14342. applyToShader(effect: Effect): void;
  14343. /**
  14344. * Returns a string to use to update the GPU particles update shader
  14345. * @returns a string containng the defines string
  14346. */
  14347. getEffectDefines(): string;
  14348. /**
  14349. * Returns the string "PointParticleEmitter"
  14350. * @returns a string containing the class name
  14351. */
  14352. getClassName(): string;
  14353. /**
  14354. * Serializes the particle system to a JSON object.
  14355. * @returns the JSON object
  14356. */
  14357. serialize(): any;
  14358. /**
  14359. * Parse properties from a JSON object
  14360. * @param serializationObject defines the JSON object
  14361. */
  14362. parse(serializationObject: any): void;
  14363. }
  14364. }
  14365. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14366. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14367. import { Effect } from "babylonjs/Materials/effect";
  14368. import { Particle } from "babylonjs/Particles/particle";
  14369. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14370. import { Nullable } from "babylonjs/types";
  14371. import { Scene } from "babylonjs/scene";
  14372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14373. /**
  14374. * Particle emitter emitting particles from the inside of a box.
  14375. * It emits the particles randomly between 2 given directions.
  14376. */
  14377. export class MeshParticleEmitter implements IParticleEmitterType {
  14378. private _indices;
  14379. private _positions;
  14380. private _normals;
  14381. private _storedNormal;
  14382. private _mesh;
  14383. /**
  14384. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14385. */
  14386. direction1: Vector3;
  14387. /**
  14388. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14389. */
  14390. direction2: Vector3;
  14391. /**
  14392. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14393. */
  14394. useMeshNormalsForDirection: boolean;
  14395. /** Defines the mesh to use as source */
  14396. get mesh(): Nullable<AbstractMesh>;
  14397. set mesh(value: Nullable<AbstractMesh>);
  14398. /**
  14399. * Creates a new instance MeshParticleEmitter
  14400. * @param mesh defines the mesh to use as source
  14401. */
  14402. constructor(mesh?: Nullable<AbstractMesh>);
  14403. /**
  14404. * Called by the particle System when the direction is computed for the created particle.
  14405. * @param worldMatrix is the world matrix of the particle system
  14406. * @param directionToUpdate is the direction vector to update with the result
  14407. * @param particle is the particle we are computed the direction for
  14408. * @param isLocal defines if the direction should be set in local space
  14409. */
  14410. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14411. /**
  14412. * Called by the particle System when the position is computed for the created particle.
  14413. * @param worldMatrix is the world matrix of the particle system
  14414. * @param positionToUpdate is the position vector to update with the result
  14415. * @param particle is the particle we are computed the position for
  14416. * @param isLocal defines if the position should be set in local space
  14417. */
  14418. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14419. /**
  14420. * Clones the current emitter and returns a copy of it
  14421. * @returns the new emitter
  14422. */
  14423. clone(): MeshParticleEmitter;
  14424. /**
  14425. * Called by the GPUParticleSystem to setup the update shader
  14426. * @param effect defines the update shader
  14427. */
  14428. applyToShader(effect: Effect): void;
  14429. /**
  14430. * Returns a string to use to update the GPU particles update shader
  14431. * @returns a string containng the defines string
  14432. */
  14433. getEffectDefines(): string;
  14434. /**
  14435. * Returns the string "BoxParticleEmitter"
  14436. * @returns a string containing the class name
  14437. */
  14438. getClassName(): string;
  14439. /**
  14440. * Serializes the particle system to a JSON object.
  14441. * @returns the JSON object
  14442. */
  14443. serialize(): any;
  14444. /**
  14445. * Parse properties from a JSON object
  14446. * @param serializationObject defines the JSON object
  14447. * @param scene defines the hosting scene
  14448. */
  14449. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14450. }
  14451. }
  14452. declare module "babylonjs/Particles/EmitterTypes/index" {
  14453. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14454. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14455. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14456. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14457. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14458. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14459. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14460. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14461. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14462. }
  14463. declare module "babylonjs/Particles/IParticleSystem" {
  14464. import { Nullable } from "babylonjs/types";
  14465. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14466. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14467. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14468. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14469. import { Scene } from "babylonjs/scene";
  14470. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14471. import { Effect } from "babylonjs/Materials/effect";
  14472. import { Observable } from "babylonjs/Misc/observable";
  14473. import { Animation } from "babylonjs/Animations/animation";
  14474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14475. /**
  14476. * Interface representing a particle system in Babylon.js.
  14477. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14478. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14479. */
  14480. export interface IParticleSystem {
  14481. /**
  14482. * List of animations used by the particle system.
  14483. */
  14484. animations: Animation[];
  14485. /**
  14486. * The id of the Particle system.
  14487. */
  14488. id: string;
  14489. /**
  14490. * The name of the Particle system.
  14491. */
  14492. name: string;
  14493. /**
  14494. * The emitter represents the Mesh or position we are attaching the particle system to.
  14495. */
  14496. emitter: Nullable<AbstractMesh | Vector3>;
  14497. /**
  14498. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14499. */
  14500. isBillboardBased: boolean;
  14501. /**
  14502. * The rendering group used by the Particle system to chose when to render.
  14503. */
  14504. renderingGroupId: number;
  14505. /**
  14506. * The layer mask we are rendering the particles through.
  14507. */
  14508. layerMask: number;
  14509. /**
  14510. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14511. */
  14512. updateSpeed: number;
  14513. /**
  14514. * The amount of time the particle system is running (depends of the overall update speed).
  14515. */
  14516. targetStopDuration: number;
  14517. /**
  14518. * The texture used to render each particle. (this can be a spritesheet)
  14519. */
  14520. particleTexture: Nullable<BaseTexture>;
  14521. /**
  14522. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14523. */
  14524. blendMode: number;
  14525. /**
  14526. * Minimum life time of emitting particles.
  14527. */
  14528. minLifeTime: number;
  14529. /**
  14530. * Maximum life time of emitting particles.
  14531. */
  14532. maxLifeTime: number;
  14533. /**
  14534. * Minimum Size of emitting particles.
  14535. */
  14536. minSize: number;
  14537. /**
  14538. * Maximum Size of emitting particles.
  14539. */
  14540. maxSize: number;
  14541. /**
  14542. * Minimum scale of emitting particles on X axis.
  14543. */
  14544. minScaleX: number;
  14545. /**
  14546. * Maximum scale of emitting particles on X axis.
  14547. */
  14548. maxScaleX: number;
  14549. /**
  14550. * Minimum scale of emitting particles on Y axis.
  14551. */
  14552. minScaleY: number;
  14553. /**
  14554. * Maximum scale of emitting particles on Y axis.
  14555. */
  14556. maxScaleY: number;
  14557. /**
  14558. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14559. */
  14560. color1: Color4;
  14561. /**
  14562. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14563. */
  14564. color2: Color4;
  14565. /**
  14566. * Color the particle will have at the end of its lifetime.
  14567. */
  14568. colorDead: Color4;
  14569. /**
  14570. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14571. */
  14572. emitRate: number;
  14573. /**
  14574. * You can use gravity if you want to give an orientation to your particles.
  14575. */
  14576. gravity: Vector3;
  14577. /**
  14578. * Minimum power of emitting particles.
  14579. */
  14580. minEmitPower: number;
  14581. /**
  14582. * Maximum power of emitting particles.
  14583. */
  14584. maxEmitPower: number;
  14585. /**
  14586. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14587. */
  14588. minAngularSpeed: number;
  14589. /**
  14590. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14591. */
  14592. maxAngularSpeed: number;
  14593. /**
  14594. * Gets or sets the minimal initial rotation in radians.
  14595. */
  14596. minInitialRotation: number;
  14597. /**
  14598. * Gets or sets the maximal initial rotation in radians.
  14599. */
  14600. maxInitialRotation: number;
  14601. /**
  14602. * The particle emitter type defines the emitter used by the particle system.
  14603. * It can be for example box, sphere, or cone...
  14604. */
  14605. particleEmitterType: Nullable<IParticleEmitterType>;
  14606. /**
  14607. * Defines the delay in milliseconds before starting the system (0 by default)
  14608. */
  14609. startDelay: number;
  14610. /**
  14611. * 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
  14612. */
  14613. preWarmCycles: number;
  14614. /**
  14615. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14616. */
  14617. preWarmStepOffset: number;
  14618. /**
  14619. * 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)
  14620. */
  14621. spriteCellChangeSpeed: number;
  14622. /**
  14623. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14624. */
  14625. startSpriteCellID: number;
  14626. /**
  14627. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14628. */
  14629. endSpriteCellID: number;
  14630. /**
  14631. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14632. */
  14633. spriteCellWidth: number;
  14634. /**
  14635. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14636. */
  14637. spriteCellHeight: number;
  14638. /**
  14639. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14640. */
  14641. spriteRandomStartCell: boolean;
  14642. /**
  14643. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14644. */
  14645. isAnimationSheetEnabled: boolean;
  14646. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14647. translationPivot: Vector2;
  14648. /**
  14649. * Gets or sets a texture used to add random noise to particle positions
  14650. */
  14651. noiseTexture: Nullable<BaseTexture>;
  14652. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14653. noiseStrength: Vector3;
  14654. /**
  14655. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14656. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14657. */
  14658. billboardMode: number;
  14659. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14660. limitVelocityDamping: number;
  14661. /**
  14662. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14663. */
  14664. beginAnimationOnStart: boolean;
  14665. /**
  14666. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14667. */
  14668. beginAnimationFrom: number;
  14669. /**
  14670. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14671. */
  14672. beginAnimationTo: number;
  14673. /**
  14674. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14675. */
  14676. beginAnimationLoop: boolean;
  14677. /**
  14678. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14679. */
  14680. disposeOnStop: boolean;
  14681. /**
  14682. * Specifies if the particles are updated in emitter local space or world space
  14683. */
  14684. isLocal: boolean;
  14685. /** Snippet ID if the particle system was created from the snippet server */
  14686. snippetId: string;
  14687. /** Gets or sets a matrix to use to compute projection */
  14688. defaultProjectionMatrix: Matrix;
  14689. /**
  14690. * Gets the maximum number of particles active at the same time.
  14691. * @returns The max number of active particles.
  14692. */
  14693. getCapacity(): number;
  14694. /**
  14695. * Gets the number of particles active at the same time.
  14696. * @returns The number of active particles.
  14697. */
  14698. getActiveCount(): number;
  14699. /**
  14700. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14701. * @returns True if it has been started, otherwise false.
  14702. */
  14703. isStarted(): boolean;
  14704. /**
  14705. * Animates the particle system for this frame.
  14706. */
  14707. animate(): void;
  14708. /**
  14709. * Renders the particle system in its current state.
  14710. * @returns the current number of particles
  14711. */
  14712. render(): number;
  14713. /**
  14714. * Dispose the particle system and frees its associated resources.
  14715. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14716. */
  14717. dispose(disposeTexture?: boolean): void;
  14718. /**
  14719. * An event triggered when the system is disposed
  14720. */
  14721. onDisposeObservable: Observable<IParticleSystem>;
  14722. /**
  14723. * An event triggered when the system is stopped
  14724. */
  14725. onStoppedObservable: Observable<IParticleSystem>;
  14726. /**
  14727. * Clones the particle system.
  14728. * @param name The name of the cloned object
  14729. * @param newEmitter The new emitter to use
  14730. * @returns the cloned particle system
  14731. */
  14732. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14733. /**
  14734. * Serializes the particle system to a JSON object
  14735. * @param serializeTexture defines if the texture must be serialized as well
  14736. * @returns the JSON object
  14737. */
  14738. serialize(serializeTexture: boolean): any;
  14739. /**
  14740. * Rebuild the particle system
  14741. */
  14742. rebuild(): void;
  14743. /** Force the system to rebuild all gradients that need to be resync */
  14744. forceRefreshGradients(): void;
  14745. /**
  14746. * Starts the particle system and begins to emit
  14747. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14748. */
  14749. start(delay?: number): void;
  14750. /**
  14751. * Stops the particle system.
  14752. */
  14753. stop(): void;
  14754. /**
  14755. * Remove all active particles
  14756. */
  14757. reset(): void;
  14758. /**
  14759. * Gets a boolean indicating that the system is stopping
  14760. * @returns true if the system is currently stopping
  14761. */
  14762. isStopping(): boolean;
  14763. /**
  14764. * Is this system ready to be used/rendered
  14765. * @return true if the system is ready
  14766. */
  14767. isReady(): boolean;
  14768. /**
  14769. * Returns the string "ParticleSystem"
  14770. * @returns a string containing the class name
  14771. */
  14772. getClassName(): string;
  14773. /**
  14774. * Gets the custom effect used to render the particles
  14775. * @param blendMode Blend mode for which the effect should be retrieved
  14776. * @returns The effect
  14777. */
  14778. getCustomEffect(blendMode: number): Nullable<Effect>;
  14779. /**
  14780. * Sets the custom effect used to render the particles
  14781. * @param effect The effect to set
  14782. * @param blendMode Blend mode for which the effect should be set
  14783. */
  14784. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14785. /**
  14786. * Fill the defines array according to the current settings of the particle system
  14787. * @param defines Array to be updated
  14788. * @param blendMode blend mode to take into account when updating the array
  14789. */
  14790. fillDefines(defines: Array<string>, blendMode: number): void;
  14791. /**
  14792. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14793. * @param uniforms Uniforms array to fill
  14794. * @param attributes Attributes array to fill
  14795. * @param samplers Samplers array to fill
  14796. */
  14797. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14798. /**
  14799. * Observable that will be called just before the particles are drawn
  14800. */
  14801. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14802. /**
  14803. * Gets the name of the particle vertex shader
  14804. */
  14805. vertexShaderName: string;
  14806. /**
  14807. * Adds a new color gradient
  14808. * @param gradient defines the gradient to use (between 0 and 1)
  14809. * @param color1 defines the color to affect to the specified gradient
  14810. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14811. * @returns the current particle system
  14812. */
  14813. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14814. /**
  14815. * Remove a specific color gradient
  14816. * @param gradient defines the gradient to remove
  14817. * @returns the current particle system
  14818. */
  14819. removeColorGradient(gradient: number): IParticleSystem;
  14820. /**
  14821. * Adds a new size gradient
  14822. * @param gradient defines the gradient to use (between 0 and 1)
  14823. * @param factor defines the size factor to affect to the specified gradient
  14824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14825. * @returns the current particle system
  14826. */
  14827. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14828. /**
  14829. * Remove a specific size gradient
  14830. * @param gradient defines the gradient to remove
  14831. * @returns the current particle system
  14832. */
  14833. removeSizeGradient(gradient: number): IParticleSystem;
  14834. /**
  14835. * Gets the current list of color gradients.
  14836. * You must use addColorGradient and removeColorGradient to udpate this list
  14837. * @returns the list of color gradients
  14838. */
  14839. getColorGradients(): Nullable<Array<ColorGradient>>;
  14840. /**
  14841. * Gets the current list of size gradients.
  14842. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14843. * @returns the list of size gradients
  14844. */
  14845. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14846. /**
  14847. * Gets the current list of angular speed gradients.
  14848. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14849. * @returns the list of angular speed gradients
  14850. */
  14851. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14852. /**
  14853. * Adds a new angular speed gradient
  14854. * @param gradient defines the gradient to use (between 0 and 1)
  14855. * @param factor defines the angular speed to affect to the specified gradient
  14856. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14857. * @returns the current particle system
  14858. */
  14859. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14860. /**
  14861. * Remove a specific angular speed gradient
  14862. * @param gradient defines the gradient to remove
  14863. * @returns the current particle system
  14864. */
  14865. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14866. /**
  14867. * Gets the current list of velocity gradients.
  14868. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14869. * @returns the list of velocity gradients
  14870. */
  14871. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14872. /**
  14873. * Adds a new velocity gradient
  14874. * @param gradient defines the gradient to use (between 0 and 1)
  14875. * @param factor defines the velocity to affect to the specified gradient
  14876. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14877. * @returns the current particle system
  14878. */
  14879. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14880. /**
  14881. * Remove a specific velocity gradient
  14882. * @param gradient defines the gradient to remove
  14883. * @returns the current particle system
  14884. */
  14885. removeVelocityGradient(gradient: number): IParticleSystem;
  14886. /**
  14887. * Gets the current list of limit velocity gradients.
  14888. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14889. * @returns the list of limit velocity gradients
  14890. */
  14891. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14892. /**
  14893. * Adds a new limit velocity gradient
  14894. * @param gradient defines the gradient to use (between 0 and 1)
  14895. * @param factor defines the limit velocity to affect to the specified gradient
  14896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14897. * @returns the current particle system
  14898. */
  14899. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14900. /**
  14901. * Remove a specific limit velocity gradient
  14902. * @param gradient defines the gradient to remove
  14903. * @returns the current particle system
  14904. */
  14905. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14906. /**
  14907. * Adds a new drag gradient
  14908. * @param gradient defines the gradient to use (between 0 and 1)
  14909. * @param factor defines the drag to affect to the specified gradient
  14910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14911. * @returns the current particle system
  14912. */
  14913. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14914. /**
  14915. * Remove a specific drag gradient
  14916. * @param gradient defines the gradient to remove
  14917. * @returns the current particle system
  14918. */
  14919. removeDragGradient(gradient: number): IParticleSystem;
  14920. /**
  14921. * Gets the current list of drag gradients.
  14922. * You must use addDragGradient and removeDragGradient to udpate this list
  14923. * @returns the list of drag gradients
  14924. */
  14925. getDragGradients(): Nullable<Array<FactorGradient>>;
  14926. /**
  14927. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14928. * @param gradient defines the gradient to use (between 0 and 1)
  14929. * @param factor defines the emit rate to affect to the specified gradient
  14930. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14931. * @returns the current particle system
  14932. */
  14933. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14934. /**
  14935. * Remove a specific emit rate gradient
  14936. * @param gradient defines the gradient to remove
  14937. * @returns the current particle system
  14938. */
  14939. removeEmitRateGradient(gradient: number): IParticleSystem;
  14940. /**
  14941. * Gets the current list of emit rate gradients.
  14942. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14943. * @returns the list of emit rate gradients
  14944. */
  14945. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14946. /**
  14947. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14948. * @param gradient defines the gradient to use (between 0 and 1)
  14949. * @param factor defines the start size to affect to the specified gradient
  14950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14951. * @returns the current particle system
  14952. */
  14953. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14954. /**
  14955. * Remove a specific start size gradient
  14956. * @param gradient defines the gradient to remove
  14957. * @returns the current particle system
  14958. */
  14959. removeStartSizeGradient(gradient: number): IParticleSystem;
  14960. /**
  14961. * Gets the current list of start size gradients.
  14962. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14963. * @returns the list of start size gradients
  14964. */
  14965. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14966. /**
  14967. * Adds a new life time gradient
  14968. * @param gradient defines the gradient to use (between 0 and 1)
  14969. * @param factor defines the life time factor to affect to the specified gradient
  14970. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14971. * @returns the current particle system
  14972. */
  14973. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14974. /**
  14975. * Remove a specific life time gradient
  14976. * @param gradient defines the gradient to remove
  14977. * @returns the current particle system
  14978. */
  14979. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14980. /**
  14981. * Gets the current list of life time gradients.
  14982. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14983. * @returns the list of life time gradients
  14984. */
  14985. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14986. /**
  14987. * Gets the current list of color gradients.
  14988. * You must use addColorGradient and removeColorGradient to udpate this list
  14989. * @returns the list of color gradients
  14990. */
  14991. getColorGradients(): Nullable<Array<ColorGradient>>;
  14992. /**
  14993. * Adds a new ramp gradient used to remap particle colors
  14994. * @param gradient defines the gradient to use (between 0 and 1)
  14995. * @param color defines the color to affect to the specified gradient
  14996. * @returns the current particle system
  14997. */
  14998. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14999. /**
  15000. * Gets the current list of ramp gradients.
  15001. * You must use addRampGradient and removeRampGradient to udpate this list
  15002. * @returns the list of ramp gradients
  15003. */
  15004. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15005. /** Gets or sets a boolean indicating that ramp gradients must be used
  15006. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15007. */
  15008. useRampGradients: boolean;
  15009. /**
  15010. * Adds a new color remap gradient
  15011. * @param gradient defines the gradient to use (between 0 and 1)
  15012. * @param min defines the color remap minimal range
  15013. * @param max defines the color remap maximal range
  15014. * @returns the current particle system
  15015. */
  15016. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15017. /**
  15018. * Gets the current list of color remap gradients.
  15019. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15020. * @returns the list of color remap gradients
  15021. */
  15022. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15023. /**
  15024. * Adds a new alpha remap gradient
  15025. * @param gradient defines the gradient to use (between 0 and 1)
  15026. * @param min defines the alpha remap minimal range
  15027. * @param max defines the alpha remap maximal range
  15028. * @returns the current particle system
  15029. */
  15030. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15031. /**
  15032. * Gets the current list of alpha remap gradients.
  15033. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15034. * @returns the list of alpha remap gradients
  15035. */
  15036. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15037. /**
  15038. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15039. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15040. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15041. * @returns the emitter
  15042. */
  15043. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15044. /**
  15045. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15046. * @param radius The radius of the hemisphere to emit from
  15047. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15048. * @returns the emitter
  15049. */
  15050. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15051. /**
  15052. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15053. * @param radius The radius of the sphere to emit from
  15054. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15055. * @returns the emitter
  15056. */
  15057. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15058. /**
  15059. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15060. * @param radius The radius of the sphere to emit from
  15061. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15062. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15063. * @returns the emitter
  15064. */
  15065. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15066. /**
  15067. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15068. * @param radius The radius of the emission cylinder
  15069. * @param height The height of the emission cylinder
  15070. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15071. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15072. * @returns the emitter
  15073. */
  15074. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15075. /**
  15076. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15077. * @param radius The radius of the cylinder to emit from
  15078. * @param height The height of the emission cylinder
  15079. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15080. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15081. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15082. * @returns the emitter
  15083. */
  15084. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15085. /**
  15086. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15087. * @param radius The radius of the cone to emit from
  15088. * @param angle The base angle of the cone
  15089. * @returns the emitter
  15090. */
  15091. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15092. /**
  15093. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15094. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15095. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15096. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15097. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15098. * @returns the emitter
  15099. */
  15100. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15101. /**
  15102. * Get hosting scene
  15103. * @returns the scene
  15104. */
  15105. getScene(): Nullable<Scene>;
  15106. }
  15107. }
  15108. declare module "babylonjs/Meshes/transformNode" {
  15109. import { DeepImmutable } from "babylonjs/types";
  15110. import { Observable } from "babylonjs/Misc/observable";
  15111. import { Nullable } from "babylonjs/types";
  15112. import { Camera } from "babylonjs/Cameras/camera";
  15113. import { Scene } from "babylonjs/scene";
  15114. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15115. import { Node } from "babylonjs/node";
  15116. import { Bone } from "babylonjs/Bones/bone";
  15117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15118. import { Space } from "babylonjs/Maths/math.axis";
  15119. /**
  15120. * 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.
  15121. * @see https://doc.babylonjs.com/how_to/transformnode
  15122. */
  15123. export class TransformNode extends Node {
  15124. /**
  15125. * Object will not rotate to face the camera
  15126. */
  15127. static BILLBOARDMODE_NONE: number;
  15128. /**
  15129. * Object will rotate to face the camera but only on the x axis
  15130. */
  15131. static BILLBOARDMODE_X: number;
  15132. /**
  15133. * Object will rotate to face the camera but only on the y axis
  15134. */
  15135. static BILLBOARDMODE_Y: number;
  15136. /**
  15137. * Object will rotate to face the camera but only on the z axis
  15138. */
  15139. static BILLBOARDMODE_Z: number;
  15140. /**
  15141. * Object will rotate to face the camera
  15142. */
  15143. static BILLBOARDMODE_ALL: number;
  15144. /**
  15145. * Object will rotate to face the camera's position instead of orientation
  15146. */
  15147. static BILLBOARDMODE_USE_POSITION: number;
  15148. private static _TmpRotation;
  15149. private static _TmpScaling;
  15150. private static _TmpTranslation;
  15151. private _forward;
  15152. private _forwardInverted;
  15153. private _up;
  15154. private _right;
  15155. private _rightInverted;
  15156. private _position;
  15157. private _rotation;
  15158. private _rotationQuaternion;
  15159. protected _scaling: Vector3;
  15160. protected _isDirty: boolean;
  15161. private _transformToBoneReferal;
  15162. private _isAbsoluteSynced;
  15163. private _billboardMode;
  15164. /**
  15165. * Gets or sets the billboard mode. Default is 0.
  15166. *
  15167. * | Value | Type | Description |
  15168. * | --- | --- | --- |
  15169. * | 0 | BILLBOARDMODE_NONE | |
  15170. * | 1 | BILLBOARDMODE_X | |
  15171. * | 2 | BILLBOARDMODE_Y | |
  15172. * | 4 | BILLBOARDMODE_Z | |
  15173. * | 7 | BILLBOARDMODE_ALL | |
  15174. *
  15175. */
  15176. get billboardMode(): number;
  15177. set billboardMode(value: number);
  15178. private _preserveParentRotationForBillboard;
  15179. /**
  15180. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15181. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15182. */
  15183. get preserveParentRotationForBillboard(): boolean;
  15184. set preserveParentRotationForBillboard(value: boolean);
  15185. /**
  15186. * 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
  15187. */
  15188. scalingDeterminant: number;
  15189. private _infiniteDistance;
  15190. /**
  15191. * Gets or sets the distance of the object to max, often used by skybox
  15192. */
  15193. get infiniteDistance(): boolean;
  15194. set infiniteDistance(value: boolean);
  15195. /**
  15196. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15197. * By default the system will update normals to compensate
  15198. */
  15199. ignoreNonUniformScaling: boolean;
  15200. /**
  15201. * 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
  15202. */
  15203. reIntegrateRotationIntoRotationQuaternion: boolean;
  15204. /** @hidden */
  15205. _poseMatrix: Nullable<Matrix>;
  15206. /** @hidden */
  15207. _localMatrix: Matrix;
  15208. private _usePivotMatrix;
  15209. private _absolutePosition;
  15210. private _absoluteScaling;
  15211. private _absoluteRotationQuaternion;
  15212. private _pivotMatrix;
  15213. private _pivotMatrixInverse;
  15214. /** @hidden */
  15215. _postMultiplyPivotMatrix: boolean;
  15216. protected _isWorldMatrixFrozen: boolean;
  15217. /** @hidden */
  15218. _indexInSceneTransformNodesArray: number;
  15219. /**
  15220. * An event triggered after the world matrix is updated
  15221. */
  15222. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15223. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15224. /**
  15225. * Gets a string identifying the name of the class
  15226. * @returns "TransformNode" string
  15227. */
  15228. getClassName(): string;
  15229. /**
  15230. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15231. */
  15232. get position(): Vector3;
  15233. set position(newPosition: Vector3);
  15234. /**
  15235. * 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)).
  15236. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15237. */
  15238. get rotation(): Vector3;
  15239. set rotation(newRotation: Vector3);
  15240. /**
  15241. * 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)).
  15242. */
  15243. get scaling(): Vector3;
  15244. set scaling(newScaling: Vector3);
  15245. /**
  15246. * 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).
  15247. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15248. */
  15249. get rotationQuaternion(): Nullable<Quaternion>;
  15250. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15251. /**
  15252. * The forward direction of that transform in world space.
  15253. */
  15254. get forward(): Vector3;
  15255. /**
  15256. * The up direction of that transform in world space.
  15257. */
  15258. get up(): Vector3;
  15259. /**
  15260. * The right direction of that transform in world space.
  15261. */
  15262. get right(): Vector3;
  15263. /**
  15264. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15265. * @param matrix the matrix to copy the pose from
  15266. * @returns this TransformNode.
  15267. */
  15268. updatePoseMatrix(matrix: Matrix): TransformNode;
  15269. /**
  15270. * Returns the mesh Pose matrix.
  15271. * @returns the pose matrix
  15272. */
  15273. getPoseMatrix(): Matrix;
  15274. /** @hidden */
  15275. _isSynchronized(): boolean;
  15276. /** @hidden */
  15277. _initCache(): void;
  15278. /**
  15279. * Flag the transform node as dirty (Forcing it to update everything)
  15280. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15281. * @returns this transform node
  15282. */
  15283. markAsDirty(property: string): TransformNode;
  15284. /**
  15285. * Returns the current mesh absolute position.
  15286. * Returns a Vector3.
  15287. */
  15288. get absolutePosition(): Vector3;
  15289. /**
  15290. * Returns the current mesh absolute scaling.
  15291. * Returns a Vector3.
  15292. */
  15293. get absoluteScaling(): Vector3;
  15294. /**
  15295. * Returns the current mesh absolute rotation.
  15296. * Returns a Quaternion.
  15297. */
  15298. get absoluteRotationQuaternion(): Quaternion;
  15299. /**
  15300. * Sets a new matrix to apply before all other transformation
  15301. * @param matrix defines the transform matrix
  15302. * @returns the current TransformNode
  15303. */
  15304. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15305. /**
  15306. * Sets a new pivot matrix to the current node
  15307. * @param matrix defines the new pivot matrix to use
  15308. * @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
  15309. * @returns the current TransformNode
  15310. */
  15311. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15312. /**
  15313. * Returns the mesh pivot matrix.
  15314. * Default : Identity.
  15315. * @returns the matrix
  15316. */
  15317. getPivotMatrix(): Matrix;
  15318. /**
  15319. * Instantiate (when possible) or clone that node with its hierarchy
  15320. * @param newParent defines the new parent to use for the instance (or clone)
  15321. * @param options defines options to configure how copy is done
  15322. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15323. * @returns an instance (or a clone) of the current node with its hiearchy
  15324. */
  15325. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15326. doNotInstantiate: boolean;
  15327. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15328. /**
  15329. * Prevents the World matrix to be computed any longer
  15330. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15331. * @returns the TransformNode.
  15332. */
  15333. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15334. /**
  15335. * Allows back the World matrix computation.
  15336. * @returns the TransformNode.
  15337. */
  15338. unfreezeWorldMatrix(): this;
  15339. /**
  15340. * True if the World matrix has been frozen.
  15341. */
  15342. get isWorldMatrixFrozen(): boolean;
  15343. /**
  15344. * Retuns the mesh absolute position in the World.
  15345. * @returns a Vector3.
  15346. */
  15347. getAbsolutePosition(): Vector3;
  15348. /**
  15349. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15350. * @param absolutePosition the absolute position to set
  15351. * @returns the TransformNode.
  15352. */
  15353. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15354. /**
  15355. * Sets the mesh position in its local space.
  15356. * @param vector3 the position to set in localspace
  15357. * @returns the TransformNode.
  15358. */
  15359. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15360. /**
  15361. * Returns the mesh position in the local space from the current World matrix values.
  15362. * @returns a new Vector3.
  15363. */
  15364. getPositionExpressedInLocalSpace(): Vector3;
  15365. /**
  15366. * Translates the mesh along the passed Vector3 in its local space.
  15367. * @param vector3 the distance to translate in localspace
  15368. * @returns the TransformNode.
  15369. */
  15370. locallyTranslate(vector3: Vector3): TransformNode;
  15371. private static _lookAtVectorCache;
  15372. /**
  15373. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15374. * @param targetPoint the position (must be in same space as current mesh) to look at
  15375. * @param yawCor optional yaw (y-axis) correction in radians
  15376. * @param pitchCor optional pitch (x-axis) correction in radians
  15377. * @param rollCor optional roll (z-axis) correction in radians
  15378. * @param space the choosen space of the target
  15379. * @returns the TransformNode.
  15380. */
  15381. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15382. /**
  15383. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15384. * This Vector3 is expressed in the World space.
  15385. * @param localAxis axis to rotate
  15386. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15387. */
  15388. getDirection(localAxis: Vector3): Vector3;
  15389. /**
  15390. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15391. * localAxis is expressed in the mesh local space.
  15392. * result is computed in the Wordl space from the mesh World matrix.
  15393. * @param localAxis axis to rotate
  15394. * @param result the resulting transformnode
  15395. * @returns this TransformNode.
  15396. */
  15397. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15398. /**
  15399. * Sets this transform node rotation to the given local axis.
  15400. * @param localAxis the axis in local space
  15401. * @param yawCor optional yaw (y-axis) correction in radians
  15402. * @param pitchCor optional pitch (x-axis) correction in radians
  15403. * @param rollCor optional roll (z-axis) correction in radians
  15404. * @returns this TransformNode
  15405. */
  15406. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15407. /**
  15408. * Sets a new pivot point to the current node
  15409. * @param point defines the new pivot point to use
  15410. * @param space defines if the point is in world or local space (local by default)
  15411. * @returns the current TransformNode
  15412. */
  15413. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15414. /**
  15415. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15416. * @returns the pivot point
  15417. */
  15418. getPivotPoint(): Vector3;
  15419. /**
  15420. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15421. * @param result the vector3 to store the result
  15422. * @returns this TransformNode.
  15423. */
  15424. getPivotPointToRef(result: Vector3): TransformNode;
  15425. /**
  15426. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15427. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15428. */
  15429. getAbsolutePivotPoint(): Vector3;
  15430. /**
  15431. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15432. * @param result vector3 to store the result
  15433. * @returns this TransformNode.
  15434. */
  15435. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15436. /**
  15437. * Defines the passed node as the parent of the current node.
  15438. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15439. * @see https://doc.babylonjs.com/how_to/parenting
  15440. * @param node the node ot set as the parent
  15441. * @returns this TransformNode.
  15442. */
  15443. setParent(node: Nullable<Node>): TransformNode;
  15444. private _nonUniformScaling;
  15445. /**
  15446. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15447. */
  15448. get nonUniformScaling(): boolean;
  15449. /** @hidden */
  15450. _updateNonUniformScalingState(value: boolean): boolean;
  15451. /**
  15452. * Attach the current TransformNode to another TransformNode associated with a bone
  15453. * @param bone Bone affecting the TransformNode
  15454. * @param affectedTransformNode TransformNode associated with the bone
  15455. * @returns this object
  15456. */
  15457. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15458. /**
  15459. * Detach the transform node if its associated with a bone
  15460. * @returns this object
  15461. */
  15462. detachFromBone(): TransformNode;
  15463. private static _rotationAxisCache;
  15464. /**
  15465. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15466. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15467. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15468. * The passed axis is also normalized.
  15469. * @param axis the axis to rotate around
  15470. * @param amount the amount to rotate in radians
  15471. * @param space Space to rotate in (Default: local)
  15472. * @returns the TransformNode.
  15473. */
  15474. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15475. /**
  15476. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15477. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15478. * The passed axis is also normalized. .
  15479. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15480. * @param point the point to rotate around
  15481. * @param axis the axis to rotate around
  15482. * @param amount the amount to rotate in radians
  15483. * @returns the TransformNode
  15484. */
  15485. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15486. /**
  15487. * Translates the mesh along the axis vector for the passed distance in the given space.
  15488. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15489. * @param axis the axis to translate in
  15490. * @param distance the distance to translate
  15491. * @param space Space to rotate in (Default: local)
  15492. * @returns the TransformNode.
  15493. */
  15494. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15495. /**
  15496. * Adds a rotation step to the mesh current rotation.
  15497. * x, y, z are Euler angles expressed in radians.
  15498. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15499. * This means this rotation is made in the mesh local space only.
  15500. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15501. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15502. * ```javascript
  15503. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15504. * ```
  15505. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15506. * 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.
  15507. * @param x Rotation to add
  15508. * @param y Rotation to add
  15509. * @param z Rotation to add
  15510. * @returns the TransformNode.
  15511. */
  15512. addRotation(x: number, y: number, z: number): TransformNode;
  15513. /**
  15514. * @hidden
  15515. */
  15516. protected _getEffectiveParent(): Nullable<Node>;
  15517. /**
  15518. * Computes the world matrix of the node
  15519. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15520. * @returns the world matrix
  15521. */
  15522. computeWorldMatrix(force?: boolean): Matrix;
  15523. /**
  15524. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15525. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15526. */
  15527. resetLocalMatrix(independentOfChildren?: boolean): void;
  15528. protected _afterComputeWorldMatrix(): void;
  15529. /**
  15530. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15531. * @param func callback function to add
  15532. *
  15533. * @returns the TransformNode.
  15534. */
  15535. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15536. /**
  15537. * Removes a registered callback function.
  15538. * @param func callback function to remove
  15539. * @returns the TransformNode.
  15540. */
  15541. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15542. /**
  15543. * Gets the position of the current mesh in camera space
  15544. * @param camera defines the camera to use
  15545. * @returns a position
  15546. */
  15547. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15548. /**
  15549. * Returns the distance from the mesh to the active camera
  15550. * @param camera defines the camera to use
  15551. * @returns the distance
  15552. */
  15553. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15554. /**
  15555. * Clone the current transform node
  15556. * @param name Name of the new clone
  15557. * @param newParent New parent for the clone
  15558. * @param doNotCloneChildren Do not clone children hierarchy
  15559. * @returns the new transform node
  15560. */
  15561. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15562. /**
  15563. * Serializes the objects information.
  15564. * @param currentSerializationObject defines the object to serialize in
  15565. * @returns the serialized object
  15566. */
  15567. serialize(currentSerializationObject?: any): any;
  15568. /**
  15569. * Returns a new TransformNode object parsed from the source provided.
  15570. * @param parsedTransformNode is the source.
  15571. * @param scene the scne the object belongs to
  15572. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15573. * @returns a new TransformNode object parsed from the source provided.
  15574. */
  15575. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15576. /**
  15577. * Get all child-transformNodes of this node
  15578. * @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
  15579. * @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
  15580. * @returns an array of TransformNode
  15581. */
  15582. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15583. /**
  15584. * Releases resources associated with this transform node.
  15585. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15586. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15587. */
  15588. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15589. /**
  15590. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15591. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15592. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15593. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15594. * @returns the current mesh
  15595. */
  15596. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15597. private _syncAbsoluteScalingAndRotation;
  15598. }
  15599. }
  15600. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15601. /**
  15602. * Class used to override all child animations of a given target
  15603. */
  15604. export class AnimationPropertiesOverride {
  15605. /**
  15606. * Gets or sets a value indicating if animation blending must be used
  15607. */
  15608. enableBlending: boolean;
  15609. /**
  15610. * Gets or sets the blending speed to use when enableBlending is true
  15611. */
  15612. blendingSpeed: number;
  15613. /**
  15614. * Gets or sets the default loop mode to use
  15615. */
  15616. loopMode: number;
  15617. }
  15618. }
  15619. declare module "babylonjs/Bones/bone" {
  15620. import { Skeleton } from "babylonjs/Bones/skeleton";
  15621. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15622. import { Nullable } from "babylonjs/types";
  15623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15624. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15625. import { Node } from "babylonjs/node";
  15626. import { Space } from "babylonjs/Maths/math.axis";
  15627. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15628. /**
  15629. * Class used to store bone information
  15630. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15631. */
  15632. export class Bone extends Node {
  15633. /**
  15634. * defines the bone name
  15635. */
  15636. name: string;
  15637. private static _tmpVecs;
  15638. private static _tmpQuat;
  15639. private static _tmpMats;
  15640. /**
  15641. * Gets the list of child bones
  15642. */
  15643. children: Bone[];
  15644. /** Gets the animations associated with this bone */
  15645. animations: import("babylonjs/Animations/animation").Animation[];
  15646. /**
  15647. * Gets or sets bone length
  15648. */
  15649. length: number;
  15650. /**
  15651. * @hidden Internal only
  15652. * Set this value to map this bone to a different index in the transform matrices
  15653. * Set this value to -1 to exclude the bone from the transform matrices
  15654. */
  15655. _index: Nullable<number>;
  15656. private _skeleton;
  15657. private _localMatrix;
  15658. private _restPose;
  15659. private _bindPose;
  15660. private _baseMatrix;
  15661. private _absoluteTransform;
  15662. private _invertedAbsoluteTransform;
  15663. private _parent;
  15664. private _scalingDeterminant;
  15665. private _worldTransform;
  15666. private _localScaling;
  15667. private _localRotation;
  15668. private _localPosition;
  15669. private _needToDecompose;
  15670. private _needToCompose;
  15671. /** @hidden */
  15672. _linkedTransformNode: Nullable<TransformNode>;
  15673. /** @hidden */
  15674. _waitingTransformNodeId: Nullable<string>;
  15675. /** @hidden */
  15676. get _matrix(): Matrix;
  15677. /** @hidden */
  15678. set _matrix(value: Matrix);
  15679. /**
  15680. * Create a new bone
  15681. * @param name defines the bone name
  15682. * @param skeleton defines the parent skeleton
  15683. * @param parentBone defines the parent (can be null if the bone is the root)
  15684. * @param localMatrix defines the local matrix
  15685. * @param restPose defines the rest pose matrix
  15686. * @param baseMatrix defines the base matrix
  15687. * @param index defines index of the bone in the hiearchy
  15688. */
  15689. constructor(
  15690. /**
  15691. * defines the bone name
  15692. */
  15693. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15694. /**
  15695. * Gets the current object class name.
  15696. * @return the class name
  15697. */
  15698. getClassName(): string;
  15699. /**
  15700. * Gets the parent skeleton
  15701. * @returns a skeleton
  15702. */
  15703. getSkeleton(): Skeleton;
  15704. /**
  15705. * Gets parent bone
  15706. * @returns a bone or null if the bone is the root of the bone hierarchy
  15707. */
  15708. getParent(): Nullable<Bone>;
  15709. /**
  15710. * Returns an array containing the root bones
  15711. * @returns an array containing the root bones
  15712. */
  15713. getChildren(): Array<Bone>;
  15714. /**
  15715. * Gets the node index in matrix array generated for rendering
  15716. * @returns the node index
  15717. */
  15718. getIndex(): number;
  15719. /**
  15720. * Sets the parent bone
  15721. * @param parent defines the parent (can be null if the bone is the root)
  15722. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15723. */
  15724. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15725. /**
  15726. * Gets the local matrix
  15727. * @returns a matrix
  15728. */
  15729. getLocalMatrix(): Matrix;
  15730. /**
  15731. * Gets the base matrix (initial matrix which remains unchanged)
  15732. * @returns a matrix
  15733. */
  15734. getBaseMatrix(): Matrix;
  15735. /**
  15736. * Gets the rest pose matrix
  15737. * @returns a matrix
  15738. */
  15739. getRestPose(): Matrix;
  15740. /**
  15741. * Sets the rest pose matrix
  15742. * @param matrix the local-space rest pose to set for this bone
  15743. */
  15744. setRestPose(matrix: Matrix): void;
  15745. /**
  15746. * Gets the bind pose matrix
  15747. * @returns the bind pose matrix
  15748. */
  15749. getBindPose(): Matrix;
  15750. /**
  15751. * Sets the bind pose matrix
  15752. * @param matrix the local-space bind pose to set for this bone
  15753. */
  15754. setBindPose(matrix: Matrix): void;
  15755. /**
  15756. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15757. */
  15758. getWorldMatrix(): Matrix;
  15759. /**
  15760. * Sets the local matrix to rest pose matrix
  15761. */
  15762. returnToRest(): void;
  15763. /**
  15764. * Gets the inverse of the absolute transform matrix.
  15765. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15766. * @returns a matrix
  15767. */
  15768. getInvertedAbsoluteTransform(): Matrix;
  15769. /**
  15770. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15771. * @returns a matrix
  15772. */
  15773. getAbsoluteTransform(): Matrix;
  15774. /**
  15775. * Links with the given transform node.
  15776. * The local matrix of this bone is copied from the transform node every frame.
  15777. * @param transformNode defines the transform node to link to
  15778. */
  15779. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15780. /**
  15781. * Gets the node used to drive the bone's transformation
  15782. * @returns a transform node or null
  15783. */
  15784. getTransformNode(): Nullable<TransformNode>;
  15785. /** Gets or sets current position (in local space) */
  15786. get position(): Vector3;
  15787. set position(newPosition: Vector3);
  15788. /** Gets or sets current rotation (in local space) */
  15789. get rotation(): Vector3;
  15790. set rotation(newRotation: Vector3);
  15791. /** Gets or sets current rotation quaternion (in local space) */
  15792. get rotationQuaternion(): Quaternion;
  15793. set rotationQuaternion(newRotation: Quaternion);
  15794. /** Gets or sets current scaling (in local space) */
  15795. get scaling(): Vector3;
  15796. set scaling(newScaling: Vector3);
  15797. /**
  15798. * Gets the animation properties override
  15799. */
  15800. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15801. private _decompose;
  15802. private _compose;
  15803. /**
  15804. * Update the base and local matrices
  15805. * @param matrix defines the new base or local matrix
  15806. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15807. * @param updateLocalMatrix defines if the local matrix should be updated
  15808. */
  15809. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15810. /** @hidden */
  15811. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15812. /**
  15813. * Flag the bone as dirty (Forcing it to update everything)
  15814. */
  15815. markAsDirty(): void;
  15816. /** @hidden */
  15817. _markAsDirtyAndCompose(): void;
  15818. private _markAsDirtyAndDecompose;
  15819. /**
  15820. * Translate the bone in local or world space
  15821. * @param vec The amount to translate the bone
  15822. * @param space The space that the translation is in
  15823. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15824. */
  15825. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15826. /**
  15827. * Set the postion of the bone in local or world space
  15828. * @param position The position to set the bone
  15829. * @param space The space that the position is in
  15830. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15831. */
  15832. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15833. /**
  15834. * Set the absolute position of the bone (world space)
  15835. * @param position The position to set the bone
  15836. * @param mesh The mesh that this bone is attached to
  15837. */
  15838. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15839. /**
  15840. * Scale the bone on the x, y and z axes (in local space)
  15841. * @param x The amount to scale the bone on the x axis
  15842. * @param y The amount to scale the bone on the y axis
  15843. * @param z The amount to scale the bone on the z axis
  15844. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15845. */
  15846. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15847. /**
  15848. * Set the bone scaling in local space
  15849. * @param scale defines the scaling vector
  15850. */
  15851. setScale(scale: Vector3): void;
  15852. /**
  15853. * Gets the current scaling in local space
  15854. * @returns the current scaling vector
  15855. */
  15856. getScale(): Vector3;
  15857. /**
  15858. * Gets the current scaling in local space and stores it in a target vector
  15859. * @param result defines the target vector
  15860. */
  15861. getScaleToRef(result: Vector3): void;
  15862. /**
  15863. * Set the yaw, pitch, and roll of the bone in local or world space
  15864. * @param yaw The rotation of the bone on the y axis
  15865. * @param pitch The rotation of the bone on the x axis
  15866. * @param roll The rotation of the bone on the z axis
  15867. * @param space The space that the axes of rotation are in
  15868. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15869. */
  15870. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15871. /**
  15872. * Add a rotation to the bone on an axis in local or world space
  15873. * @param axis The axis to rotate the bone on
  15874. * @param amount The amount to rotate the bone
  15875. * @param space The space that the axis is in
  15876. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15877. */
  15878. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15879. /**
  15880. * Set the rotation of the bone to a particular axis angle in local or world space
  15881. * @param axis The axis to rotate the bone on
  15882. * @param angle The angle that the bone should be rotated to
  15883. * @param space The space that the axis is in
  15884. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15885. */
  15886. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15887. /**
  15888. * Set the euler rotation of the bone in local or world space
  15889. * @param rotation The euler rotation that the bone should be set to
  15890. * @param space The space that the rotation is in
  15891. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15892. */
  15893. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15894. /**
  15895. * Set the quaternion rotation of the bone in local or world space
  15896. * @param quat The quaternion rotation that the bone should be set to
  15897. * @param space The space that the rotation is in
  15898. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15899. */
  15900. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15901. /**
  15902. * Set the rotation matrix of the bone in local or world space
  15903. * @param rotMat The rotation matrix that the bone should be set to
  15904. * @param space The space that the rotation is in
  15905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15906. */
  15907. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15908. private _rotateWithMatrix;
  15909. private _getNegativeRotationToRef;
  15910. /**
  15911. * Get the position of the bone in local or world space
  15912. * @param space The space that the returned position is in
  15913. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15914. * @returns The position of the bone
  15915. */
  15916. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15917. /**
  15918. * Copy the position of the bone to a vector3 in local or world space
  15919. * @param space The space that the returned position is in
  15920. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15921. * @param result The vector3 to copy the position to
  15922. */
  15923. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15924. /**
  15925. * Get the absolute position of the bone (world space)
  15926. * @param mesh The mesh that this bone is attached to
  15927. * @returns The absolute position of the bone
  15928. */
  15929. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15930. /**
  15931. * Copy the absolute position of the bone (world space) to the result param
  15932. * @param mesh The mesh that this bone is attached to
  15933. * @param result The vector3 to copy the absolute position to
  15934. */
  15935. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15936. /**
  15937. * Compute the absolute transforms of this bone and its children
  15938. */
  15939. computeAbsoluteTransforms(): void;
  15940. /**
  15941. * Get the world direction from an axis that is in the local space of the bone
  15942. * @param localAxis The local direction that is used to compute the world direction
  15943. * @param mesh The mesh that this bone is attached to
  15944. * @returns The world direction
  15945. */
  15946. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15947. /**
  15948. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15949. * @param localAxis The local direction that is used to compute the world direction
  15950. * @param mesh The mesh that this bone is attached to
  15951. * @param result The vector3 that the world direction will be copied to
  15952. */
  15953. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15954. /**
  15955. * Get the euler rotation of the bone in local or world space
  15956. * @param space The space that the rotation should be in
  15957. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15958. * @returns The euler rotation
  15959. */
  15960. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15961. /**
  15962. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15963. * @param space The space that the rotation should be in
  15964. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15965. * @param result The vector3 that the rotation should be copied to
  15966. */
  15967. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15968. /**
  15969. * Get the quaternion rotation of the bone in either local or world space
  15970. * @param space The space that the rotation should be in
  15971. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15972. * @returns The quaternion rotation
  15973. */
  15974. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15975. /**
  15976. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15977. * @param space The space that the rotation should be in
  15978. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15979. * @param result The quaternion that the rotation should be copied to
  15980. */
  15981. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15982. /**
  15983. * Get the rotation matrix of the bone in local or world space
  15984. * @param space The space that the rotation should be in
  15985. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15986. * @returns The rotation matrix
  15987. */
  15988. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15989. /**
  15990. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15991. * @param space The space that the rotation should be in
  15992. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15993. * @param result The quaternion that the rotation should be copied to
  15994. */
  15995. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15996. /**
  15997. * Get the world position of a point that is in the local space of the bone
  15998. * @param position The local position
  15999. * @param mesh The mesh that this bone is attached to
  16000. * @returns The world position
  16001. */
  16002. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  16003. /**
  16004. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  16005. * @param position The local position
  16006. * @param mesh The mesh that this bone is attached to
  16007. * @param result The vector3 that the world position should be copied to
  16008. */
  16009. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  16010. /**
  16011. * Get the local position of a point that is in world space
  16012. * @param position The world position
  16013. * @param mesh The mesh that this bone is attached to
  16014. * @returns The local position
  16015. */
  16016. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  16017. /**
  16018. * Get the local position of a point that is in world space and copy it to the result param
  16019. * @param position The world position
  16020. * @param mesh The mesh that this bone is attached to
  16021. * @param result The vector3 that the local position should be copied to
  16022. */
  16023. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  16024. /**
  16025. * Set the current local matrix as the restPose for this bone.
  16026. */
  16027. setCurrentPoseAsRest(): void;
  16028. }
  16029. }
  16030. declare module "babylonjs/Animations/runtimeAnimation" {
  16031. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  16032. import { Animatable } from "babylonjs/Animations/animatable";
  16033. import { Scene } from "babylonjs/scene";
  16034. /**
  16035. * Defines a runtime animation
  16036. */
  16037. export class RuntimeAnimation {
  16038. private _events;
  16039. /**
  16040. * The current frame of the runtime animation
  16041. */
  16042. private _currentFrame;
  16043. /**
  16044. * The animation used by the runtime animation
  16045. */
  16046. private _animation;
  16047. /**
  16048. * The target of the runtime animation
  16049. */
  16050. private _target;
  16051. /**
  16052. * The initiating animatable
  16053. */
  16054. private _host;
  16055. /**
  16056. * The original value of the runtime animation
  16057. */
  16058. private _originalValue;
  16059. /**
  16060. * The original blend value of the runtime animation
  16061. */
  16062. private _originalBlendValue;
  16063. /**
  16064. * The offsets cache of the runtime animation
  16065. */
  16066. private _offsetsCache;
  16067. /**
  16068. * The high limits cache of the runtime animation
  16069. */
  16070. private _highLimitsCache;
  16071. /**
  16072. * Specifies if the runtime animation has been stopped
  16073. */
  16074. private _stopped;
  16075. /**
  16076. * The blending factor of the runtime animation
  16077. */
  16078. private _blendingFactor;
  16079. /**
  16080. * The BabylonJS scene
  16081. */
  16082. private _scene;
  16083. /**
  16084. * The current value of the runtime animation
  16085. */
  16086. private _currentValue;
  16087. /** @hidden */
  16088. _animationState: _IAnimationState;
  16089. /**
  16090. * The active target of the runtime animation
  16091. */
  16092. private _activeTargets;
  16093. private _currentActiveTarget;
  16094. private _directTarget;
  16095. /**
  16096. * The target path of the runtime animation
  16097. */
  16098. private _targetPath;
  16099. /**
  16100. * The weight of the runtime animation
  16101. */
  16102. private _weight;
  16103. /**
  16104. * The ratio offset of the runtime animation
  16105. */
  16106. private _ratioOffset;
  16107. /**
  16108. * The previous delay of the runtime animation
  16109. */
  16110. private _previousDelay;
  16111. /**
  16112. * The previous ratio of the runtime animation
  16113. */
  16114. private _previousRatio;
  16115. private _enableBlending;
  16116. private _keys;
  16117. private _minFrame;
  16118. private _maxFrame;
  16119. private _minValue;
  16120. private _maxValue;
  16121. private _targetIsArray;
  16122. /**
  16123. * Gets the current frame of the runtime animation
  16124. */
  16125. get currentFrame(): number;
  16126. /**
  16127. * Gets the weight of the runtime animation
  16128. */
  16129. get weight(): number;
  16130. /**
  16131. * Gets the current value of the runtime animation
  16132. */
  16133. get currentValue(): any;
  16134. /**
  16135. * Gets the target path of the runtime animation
  16136. */
  16137. get targetPath(): string;
  16138. /**
  16139. * Gets the actual target of the runtime animation
  16140. */
  16141. get target(): any;
  16142. /**
  16143. * Gets the additive state of the runtime animation
  16144. */
  16145. get isAdditive(): boolean;
  16146. /** @hidden */
  16147. _onLoop: () => void;
  16148. /**
  16149. * Create a new RuntimeAnimation object
  16150. * @param target defines the target of the animation
  16151. * @param animation defines the source animation object
  16152. * @param scene defines the hosting scene
  16153. * @param host defines the initiating Animatable
  16154. */
  16155. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16156. private _preparePath;
  16157. /**
  16158. * Gets the animation from the runtime animation
  16159. */
  16160. get animation(): Animation;
  16161. /**
  16162. * Resets the runtime animation to the beginning
  16163. * @param restoreOriginal defines whether to restore the target property to the original value
  16164. */
  16165. reset(restoreOriginal?: boolean): void;
  16166. /**
  16167. * Specifies if the runtime animation is stopped
  16168. * @returns Boolean specifying if the runtime animation is stopped
  16169. */
  16170. isStopped(): boolean;
  16171. /**
  16172. * Disposes of the runtime animation
  16173. */
  16174. dispose(): void;
  16175. /**
  16176. * Apply the interpolated value to the target
  16177. * @param currentValue defines the value computed by the animation
  16178. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16179. */
  16180. setValue(currentValue: any, weight: number): void;
  16181. private _getOriginalValues;
  16182. private _setValue;
  16183. /**
  16184. * Gets the loop pmode of the runtime animation
  16185. * @returns Loop Mode
  16186. */
  16187. private _getCorrectLoopMode;
  16188. /**
  16189. * Move the current animation to a given frame
  16190. * @param frame defines the frame to move to
  16191. */
  16192. goToFrame(frame: number): void;
  16193. /**
  16194. * @hidden Internal use only
  16195. */
  16196. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16197. /**
  16198. * Execute the current animation
  16199. * @param delay defines the delay to add to the current frame
  16200. * @param from defines the lower bound of the animation range
  16201. * @param to defines the upper bound of the animation range
  16202. * @param loop defines if the current animation must loop
  16203. * @param speedRatio defines the current speed ratio
  16204. * @param weight defines the weight of the animation (default is -1 so no weight)
  16205. * @param onLoop optional callback called when animation loops
  16206. * @returns a boolean indicating if the animation is running
  16207. */
  16208. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16209. }
  16210. }
  16211. declare module "babylonjs/Animations/animatable" {
  16212. import { Animation } from "babylonjs/Animations/animation";
  16213. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16214. import { Nullable } from "babylonjs/types";
  16215. import { Observable } from "babylonjs/Misc/observable";
  16216. import { Scene } from "babylonjs/scene";
  16217. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16218. import { Node } from "babylonjs/node";
  16219. /**
  16220. * Class used to store an actual running animation
  16221. */
  16222. export class Animatable {
  16223. /** defines the target object */
  16224. target: any;
  16225. /** defines the starting frame number (default is 0) */
  16226. fromFrame: number;
  16227. /** defines the ending frame number (default is 100) */
  16228. toFrame: number;
  16229. /** defines if the animation must loop (default is false) */
  16230. loopAnimation: boolean;
  16231. /** defines a callback to call when animation ends if it is not looping */
  16232. onAnimationEnd?: (() => void) | null | undefined;
  16233. /** defines a callback to call when animation loops */
  16234. onAnimationLoop?: (() => void) | null | undefined;
  16235. /** defines whether the animation should be evaluated additively */
  16236. isAdditive: boolean;
  16237. private _localDelayOffset;
  16238. private _pausedDelay;
  16239. private _runtimeAnimations;
  16240. private _paused;
  16241. private _scene;
  16242. private _speedRatio;
  16243. private _weight;
  16244. private _syncRoot;
  16245. /**
  16246. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16247. * This will only apply for non looping animation (default is true)
  16248. */
  16249. disposeOnEnd: boolean;
  16250. /**
  16251. * Gets a boolean indicating if the animation has started
  16252. */
  16253. animationStarted: boolean;
  16254. /**
  16255. * Observer raised when the animation ends
  16256. */
  16257. onAnimationEndObservable: Observable<Animatable>;
  16258. /**
  16259. * Observer raised when the animation loops
  16260. */
  16261. onAnimationLoopObservable: Observable<Animatable>;
  16262. /**
  16263. * Gets the root Animatable used to synchronize and normalize animations
  16264. */
  16265. get syncRoot(): Nullable<Animatable>;
  16266. /**
  16267. * Gets the current frame of the first RuntimeAnimation
  16268. * Used to synchronize Animatables
  16269. */
  16270. get masterFrame(): number;
  16271. /**
  16272. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16273. */
  16274. get weight(): number;
  16275. set weight(value: number);
  16276. /**
  16277. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16278. */
  16279. get speedRatio(): number;
  16280. set speedRatio(value: number);
  16281. /**
  16282. * Creates a new Animatable
  16283. * @param scene defines the hosting scene
  16284. * @param target defines the target object
  16285. * @param fromFrame defines the starting frame number (default is 0)
  16286. * @param toFrame defines the ending frame number (default is 100)
  16287. * @param loopAnimation defines if the animation must loop (default is false)
  16288. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16289. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16290. * @param animations defines a group of animation to add to the new Animatable
  16291. * @param onAnimationLoop defines a callback to call when animation loops
  16292. * @param isAdditive defines whether the animation should be evaluated additively
  16293. */
  16294. constructor(scene: Scene,
  16295. /** defines the target object */
  16296. target: any,
  16297. /** defines the starting frame number (default is 0) */
  16298. fromFrame?: number,
  16299. /** defines the ending frame number (default is 100) */
  16300. toFrame?: number,
  16301. /** defines if the animation must loop (default is false) */
  16302. loopAnimation?: boolean, speedRatio?: number,
  16303. /** defines a callback to call when animation ends if it is not looping */
  16304. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16305. /** defines a callback to call when animation loops */
  16306. onAnimationLoop?: (() => void) | null | undefined,
  16307. /** defines whether the animation should be evaluated additively */
  16308. isAdditive?: boolean);
  16309. /**
  16310. * Synchronize and normalize current Animatable with a source Animatable
  16311. * This is useful when using animation weights and when animations are not of the same length
  16312. * @param root defines the root Animatable to synchronize with
  16313. * @returns the current Animatable
  16314. */
  16315. syncWith(root: Animatable): Animatable;
  16316. /**
  16317. * Gets the list of runtime animations
  16318. * @returns an array of RuntimeAnimation
  16319. */
  16320. getAnimations(): RuntimeAnimation[];
  16321. /**
  16322. * Adds more animations to the current animatable
  16323. * @param target defines the target of the animations
  16324. * @param animations defines the new animations to add
  16325. */
  16326. appendAnimations(target: any, animations: Animation[]): void;
  16327. /**
  16328. * Gets the source animation for a specific property
  16329. * @param property defines the propertyu to look for
  16330. * @returns null or the source animation for the given property
  16331. */
  16332. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16333. /**
  16334. * Gets the runtime animation for a specific property
  16335. * @param property defines the propertyu to look for
  16336. * @returns null or the runtime animation for the given property
  16337. */
  16338. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16339. /**
  16340. * Resets the animatable to its original state
  16341. */
  16342. reset(): void;
  16343. /**
  16344. * Allows the animatable to blend with current running animations
  16345. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16346. * @param blendingSpeed defines the blending speed to use
  16347. */
  16348. enableBlending(blendingSpeed: number): void;
  16349. /**
  16350. * Disable animation blending
  16351. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16352. */
  16353. disableBlending(): void;
  16354. /**
  16355. * Jump directly to a given frame
  16356. * @param frame defines the frame to jump to
  16357. */
  16358. goToFrame(frame: number): void;
  16359. /**
  16360. * Pause the animation
  16361. */
  16362. pause(): void;
  16363. /**
  16364. * Restart the animation
  16365. */
  16366. restart(): void;
  16367. private _raiseOnAnimationEnd;
  16368. /**
  16369. * Stop and delete the current animation
  16370. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16371. * @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)
  16372. */
  16373. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16374. /**
  16375. * Wait asynchronously for the animation to end
  16376. * @returns a promise which will be fullfilled when the animation ends
  16377. */
  16378. waitAsync(): Promise<Animatable>;
  16379. /** @hidden */
  16380. _animate(delay: number): boolean;
  16381. }
  16382. module "babylonjs/scene" {
  16383. interface Scene {
  16384. /** @hidden */
  16385. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16386. /** @hidden */
  16387. _processLateAnimationBindingsForMatrices(holder: {
  16388. totalWeight: number;
  16389. totalAdditiveWeight: number;
  16390. animations: RuntimeAnimation[];
  16391. additiveAnimations: RuntimeAnimation[];
  16392. originalValue: Matrix;
  16393. }): any;
  16394. /** @hidden */
  16395. _processLateAnimationBindingsForQuaternions(holder: {
  16396. totalWeight: number;
  16397. totalAdditiveWeight: number;
  16398. animations: RuntimeAnimation[];
  16399. additiveAnimations: RuntimeAnimation[];
  16400. originalValue: Quaternion;
  16401. }, refQuaternion: Quaternion): Quaternion;
  16402. /** @hidden */
  16403. _processLateAnimationBindings(): void;
  16404. /**
  16405. * Will start the animation sequence of a given target
  16406. * @param target defines the target
  16407. * @param from defines from which frame should animation start
  16408. * @param to defines until which frame should animation run.
  16409. * @param weight defines the weight to apply to the animation (1.0 by default)
  16410. * @param loop defines if the animation loops
  16411. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16412. * @param onAnimationEnd defines the function to be executed when the animation ends
  16413. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16414. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16415. * @param onAnimationLoop defines the callback to call when an animation loops
  16416. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16417. * @returns the animatable object created for this animation
  16418. */
  16419. 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;
  16420. /**
  16421. * Will start the animation sequence of a given target
  16422. * @param target defines the target
  16423. * @param from defines from which frame should animation start
  16424. * @param to defines until which frame should animation run.
  16425. * @param loop defines if the animation loops
  16426. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16427. * @param onAnimationEnd defines the function to be executed when the animation ends
  16428. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16429. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16430. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16431. * @param onAnimationLoop defines the callback to call when an animation loops
  16432. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16433. * @returns the animatable object created for this animation
  16434. */
  16435. 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;
  16436. /**
  16437. * Will start the animation sequence of a given target and its hierarchy
  16438. * @param target defines the target
  16439. * @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.
  16440. * @param from defines from which frame should animation start
  16441. * @param to defines until which frame should animation run.
  16442. * @param loop defines if the animation loops
  16443. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16444. * @param onAnimationEnd defines the function to be executed when the animation ends
  16445. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16446. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16447. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16448. * @param onAnimationLoop defines the callback to call when an animation loops
  16449. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16450. * @returns the list of created animatables
  16451. */
  16452. 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[];
  16453. /**
  16454. * Begin a new animation on a given node
  16455. * @param target defines the target where the animation will take place
  16456. * @param animations defines the list of animations to start
  16457. * @param from defines the initial value
  16458. * @param to defines the final value
  16459. * @param loop defines if you want animation to loop (off by default)
  16460. * @param speedRatio defines the speed ratio to apply to all animations
  16461. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16462. * @param onAnimationLoop defines the callback to call when an animation loops
  16463. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16464. * @returns the list of created animatables
  16465. */
  16466. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16467. /**
  16468. * Begin a new animation on a given node and its hierarchy
  16469. * @param target defines the root node where the animation will take place
  16470. * @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.
  16471. * @param animations defines the list of animations to start
  16472. * @param from defines the initial value
  16473. * @param to defines the final value
  16474. * @param loop defines if you want animation to loop (off by default)
  16475. * @param speedRatio defines the speed ratio to apply to all animations
  16476. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16477. * @param onAnimationLoop defines the callback to call when an animation loops
  16478. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16479. * @returns the list of animatables created for all nodes
  16480. */
  16481. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16482. /**
  16483. * Gets the animatable associated with a specific target
  16484. * @param target defines the target of the animatable
  16485. * @returns the required animatable if found
  16486. */
  16487. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16488. /**
  16489. * Gets all animatables associated with a given target
  16490. * @param target defines the target to look animatables for
  16491. * @returns an array of Animatables
  16492. */
  16493. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16494. /**
  16495. * Stops and removes all animations that have been applied to the scene
  16496. */
  16497. stopAllAnimations(): void;
  16498. /**
  16499. * Gets the current delta time used by animation engine
  16500. */
  16501. deltaTime: number;
  16502. }
  16503. }
  16504. module "babylonjs/Bones/bone" {
  16505. interface Bone {
  16506. /**
  16507. * Copy an animation range from another bone
  16508. * @param source defines the source bone
  16509. * @param rangeName defines the range name to copy
  16510. * @param frameOffset defines the frame offset
  16511. * @param rescaleAsRequired defines if rescaling must be applied if required
  16512. * @param skelDimensionsRatio defines the scaling ratio
  16513. * @returns true if operation was successful
  16514. */
  16515. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16516. }
  16517. }
  16518. }
  16519. declare module "babylonjs/Bones/skeleton" {
  16520. import { Bone } from "babylonjs/Bones/bone";
  16521. import { Observable } from "babylonjs/Misc/observable";
  16522. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16523. import { Scene } from "babylonjs/scene";
  16524. import { Nullable } from "babylonjs/types";
  16525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16526. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16527. import { Animatable } from "babylonjs/Animations/animatable";
  16528. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16529. import { Animation } from "babylonjs/Animations/animation";
  16530. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16531. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16532. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16533. /**
  16534. * Class used to handle skinning animations
  16535. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16536. */
  16537. export class Skeleton implements IAnimatable {
  16538. /** defines the skeleton name */
  16539. name: string;
  16540. /** defines the skeleton Id */
  16541. id: string;
  16542. /**
  16543. * Defines the list of child bones
  16544. */
  16545. bones: Bone[];
  16546. /**
  16547. * Defines an estimate of the dimension of the skeleton at rest
  16548. */
  16549. dimensionsAtRest: Vector3;
  16550. /**
  16551. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16552. */
  16553. needInitialSkinMatrix: boolean;
  16554. /**
  16555. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16556. */
  16557. overrideMesh: Nullable<AbstractMesh>;
  16558. /**
  16559. * Gets the list of animations attached to this skeleton
  16560. */
  16561. animations: Array<Animation>;
  16562. private _scene;
  16563. private _isDirty;
  16564. private _transformMatrices;
  16565. private _transformMatrixTexture;
  16566. private _meshesWithPoseMatrix;
  16567. private _animatables;
  16568. private _identity;
  16569. private _synchronizedWithMesh;
  16570. private _ranges;
  16571. private _lastAbsoluteTransformsUpdateId;
  16572. private _canUseTextureForBones;
  16573. private _uniqueId;
  16574. /** @hidden */
  16575. _numBonesWithLinkedTransformNode: number;
  16576. /** @hidden */
  16577. _hasWaitingData: Nullable<boolean>;
  16578. /** @hidden */
  16579. _waitingOverrideMeshId: Nullable<string>;
  16580. /**
  16581. * Specifies if the skeleton should be serialized
  16582. */
  16583. doNotSerialize: boolean;
  16584. private _useTextureToStoreBoneMatrices;
  16585. /**
  16586. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16587. * Please note that this option is not available if the hardware does not support it
  16588. */
  16589. get useTextureToStoreBoneMatrices(): boolean;
  16590. set useTextureToStoreBoneMatrices(value: boolean);
  16591. private _animationPropertiesOverride;
  16592. /**
  16593. * Gets or sets the animation properties override
  16594. */
  16595. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16596. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16597. /**
  16598. * List of inspectable custom properties (used by the Inspector)
  16599. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16600. */
  16601. inspectableCustomProperties: IInspectable[];
  16602. /**
  16603. * An observable triggered before computing the skeleton's matrices
  16604. */
  16605. onBeforeComputeObservable: Observable<Skeleton>;
  16606. /**
  16607. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16608. */
  16609. get isUsingTextureForMatrices(): boolean;
  16610. /**
  16611. * Gets the unique ID of this skeleton
  16612. */
  16613. get uniqueId(): number;
  16614. /**
  16615. * Creates a new skeleton
  16616. * @param name defines the skeleton name
  16617. * @param id defines the skeleton Id
  16618. * @param scene defines the hosting scene
  16619. */
  16620. constructor(
  16621. /** defines the skeleton name */
  16622. name: string,
  16623. /** defines the skeleton Id */
  16624. id: string, scene: Scene);
  16625. /**
  16626. * Gets the current object class name.
  16627. * @return the class name
  16628. */
  16629. getClassName(): string;
  16630. /**
  16631. * Returns an array containing the root bones
  16632. * @returns an array containing the root bones
  16633. */
  16634. getChildren(): Array<Bone>;
  16635. /**
  16636. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16637. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16638. * @returns a Float32Array containing matrices data
  16639. */
  16640. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16641. /**
  16642. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16643. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16644. * @returns a raw texture containing the data
  16645. */
  16646. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16647. /**
  16648. * Gets the current hosting scene
  16649. * @returns a scene object
  16650. */
  16651. getScene(): Scene;
  16652. /**
  16653. * Gets a string representing the current skeleton data
  16654. * @param fullDetails defines a boolean indicating if we want a verbose version
  16655. * @returns a string representing the current skeleton data
  16656. */
  16657. toString(fullDetails?: boolean): string;
  16658. /**
  16659. * Get bone's index searching by name
  16660. * @param name defines bone's name to search for
  16661. * @return the indice of the bone. Returns -1 if not found
  16662. */
  16663. getBoneIndexByName(name: string): number;
  16664. /**
  16665. * Creater a new animation range
  16666. * @param name defines the name of the range
  16667. * @param from defines the start key
  16668. * @param to defines the end key
  16669. */
  16670. createAnimationRange(name: string, from: number, to: number): void;
  16671. /**
  16672. * Delete a specific animation range
  16673. * @param name defines the name of the range
  16674. * @param deleteFrames defines if frames must be removed as well
  16675. */
  16676. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16677. /**
  16678. * Gets a specific animation range
  16679. * @param name defines the name of the range to look for
  16680. * @returns the requested animation range or null if not found
  16681. */
  16682. getAnimationRange(name: string): Nullable<AnimationRange>;
  16683. /**
  16684. * Gets the list of all animation ranges defined on this skeleton
  16685. * @returns an array
  16686. */
  16687. getAnimationRanges(): Nullable<AnimationRange>[];
  16688. /**
  16689. * Copy animation range from a source skeleton.
  16690. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16691. * @param source defines the source skeleton
  16692. * @param name defines the name of the range to copy
  16693. * @param rescaleAsRequired defines if rescaling must be applied if required
  16694. * @returns true if operation was successful
  16695. */
  16696. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16697. /**
  16698. * Forces the skeleton to go to rest pose
  16699. */
  16700. returnToRest(): void;
  16701. private _getHighestAnimationFrame;
  16702. /**
  16703. * Begin a specific animation range
  16704. * @param name defines the name of the range to start
  16705. * @param loop defines if looping must be turned on (false by default)
  16706. * @param speedRatio defines the speed ratio to apply (1 by default)
  16707. * @param onAnimationEnd defines a callback which will be called when animation will end
  16708. * @returns a new animatable
  16709. */
  16710. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16711. /**
  16712. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16713. * @param skeleton defines the Skeleton containing the animation range to convert
  16714. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16715. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16716. * @returns the original skeleton
  16717. */
  16718. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16719. /** @hidden */
  16720. _markAsDirty(): void;
  16721. /** @hidden */
  16722. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16723. /** @hidden */
  16724. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16725. private _computeTransformMatrices;
  16726. /**
  16727. * Build all resources required to render a skeleton
  16728. */
  16729. prepare(): void;
  16730. /**
  16731. * Gets the list of animatables currently running for this skeleton
  16732. * @returns an array of animatables
  16733. */
  16734. getAnimatables(): IAnimatable[];
  16735. /**
  16736. * Clone the current skeleton
  16737. * @param name defines the name of the new skeleton
  16738. * @param id defines the id of the new skeleton
  16739. * @returns the new skeleton
  16740. */
  16741. clone(name: string, id?: string): Skeleton;
  16742. /**
  16743. * Enable animation blending for this skeleton
  16744. * @param blendingSpeed defines the blending speed to apply
  16745. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16746. */
  16747. enableBlending(blendingSpeed?: number): void;
  16748. /**
  16749. * Releases all resources associated with the current skeleton
  16750. */
  16751. dispose(): void;
  16752. /**
  16753. * Serialize the skeleton in a JSON object
  16754. * @returns a JSON object
  16755. */
  16756. serialize(): any;
  16757. /**
  16758. * Creates a new skeleton from serialized data
  16759. * @param parsedSkeleton defines the serialized data
  16760. * @param scene defines the hosting scene
  16761. * @returns a new skeleton
  16762. */
  16763. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16764. /**
  16765. * Compute all node absolute transforms
  16766. * @param forceUpdate defines if computation must be done even if cache is up to date
  16767. */
  16768. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16769. /**
  16770. * Gets the root pose matrix
  16771. * @returns a matrix
  16772. */
  16773. getPoseMatrix(): Nullable<Matrix>;
  16774. /**
  16775. * Sorts bones per internal index
  16776. */
  16777. sortBones(): void;
  16778. private _sortBones;
  16779. /**
  16780. * Set the current local matrix as the restPose for all bones in the skeleton.
  16781. */
  16782. setCurrentPoseAsRest(): void;
  16783. }
  16784. }
  16785. declare module "babylonjs/Meshes/instancedMesh" {
  16786. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16787. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16788. import { Camera } from "babylonjs/Cameras/camera";
  16789. import { Node } from "babylonjs/node";
  16790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16791. import { Mesh } from "babylonjs/Meshes/mesh";
  16792. import { Material } from "babylonjs/Materials/material";
  16793. import { Skeleton } from "babylonjs/Bones/skeleton";
  16794. import { Light } from "babylonjs/Lights/light";
  16795. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16796. /**
  16797. * Creates an instance based on a source mesh.
  16798. */
  16799. export class InstancedMesh extends AbstractMesh {
  16800. private _sourceMesh;
  16801. private _currentLOD;
  16802. /** @hidden */
  16803. _indexInSourceMeshInstanceArray: number;
  16804. constructor(name: string, source: Mesh);
  16805. /**
  16806. * Returns the string "InstancedMesh".
  16807. */
  16808. getClassName(): string;
  16809. /** Gets the list of lights affecting that mesh */
  16810. get lightSources(): Light[];
  16811. _resyncLightSources(): void;
  16812. _resyncLightSource(light: Light): void;
  16813. _removeLightSource(light: Light, dispose: boolean): void;
  16814. /**
  16815. * If the source mesh receives shadows
  16816. */
  16817. get receiveShadows(): boolean;
  16818. /**
  16819. * The material of the source mesh
  16820. */
  16821. get material(): Nullable<Material>;
  16822. /**
  16823. * Visibility of the source mesh
  16824. */
  16825. get visibility(): number;
  16826. /**
  16827. * Skeleton of the source mesh
  16828. */
  16829. get skeleton(): Nullable<Skeleton>;
  16830. /**
  16831. * Rendering ground id of the source mesh
  16832. */
  16833. get renderingGroupId(): number;
  16834. set renderingGroupId(value: number);
  16835. /**
  16836. * Returns the total number of vertices (integer).
  16837. */
  16838. getTotalVertices(): number;
  16839. /**
  16840. * Returns a positive integer : the total number of indices in this mesh geometry.
  16841. * @returns the numner of indices or zero if the mesh has no geometry.
  16842. */
  16843. getTotalIndices(): number;
  16844. /**
  16845. * The source mesh of the instance
  16846. */
  16847. get sourceMesh(): Mesh;
  16848. /**
  16849. * Creates a new InstancedMesh object from the mesh model.
  16850. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16851. * @param name defines the name of the new instance
  16852. * @returns a new InstancedMesh
  16853. */
  16854. createInstance(name: string): InstancedMesh;
  16855. /**
  16856. * Is this node ready to be used/rendered
  16857. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16858. * @return {boolean} is it ready
  16859. */
  16860. isReady(completeCheck?: boolean): boolean;
  16861. /**
  16862. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16863. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16864. * @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.
  16865. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16866. */
  16867. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16868. /**
  16869. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16870. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16871. * The `data` are either a numeric array either a Float32Array.
  16872. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16873. * 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).
  16874. * Note that a new underlying VertexBuffer object is created each call.
  16875. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16876. *
  16877. * Possible `kind` values :
  16878. * - VertexBuffer.PositionKind
  16879. * - VertexBuffer.UVKind
  16880. * - VertexBuffer.UV2Kind
  16881. * - VertexBuffer.UV3Kind
  16882. * - VertexBuffer.UV4Kind
  16883. * - VertexBuffer.UV5Kind
  16884. * - VertexBuffer.UV6Kind
  16885. * - VertexBuffer.ColorKind
  16886. * - VertexBuffer.MatricesIndicesKind
  16887. * - VertexBuffer.MatricesIndicesExtraKind
  16888. * - VertexBuffer.MatricesWeightsKind
  16889. * - VertexBuffer.MatricesWeightsExtraKind
  16890. *
  16891. * Returns the Mesh.
  16892. */
  16893. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16894. /**
  16895. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16896. * If the mesh has no geometry, it is simply returned as it is.
  16897. * The `data` are either a numeric array either a Float32Array.
  16898. * No new underlying VertexBuffer object is created.
  16899. * 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.
  16900. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16901. *
  16902. * Possible `kind` values :
  16903. * - VertexBuffer.PositionKind
  16904. * - VertexBuffer.UVKind
  16905. * - VertexBuffer.UV2Kind
  16906. * - VertexBuffer.UV3Kind
  16907. * - VertexBuffer.UV4Kind
  16908. * - VertexBuffer.UV5Kind
  16909. * - VertexBuffer.UV6Kind
  16910. * - VertexBuffer.ColorKind
  16911. * - VertexBuffer.MatricesIndicesKind
  16912. * - VertexBuffer.MatricesIndicesExtraKind
  16913. * - VertexBuffer.MatricesWeightsKind
  16914. * - VertexBuffer.MatricesWeightsExtraKind
  16915. *
  16916. * Returns the Mesh.
  16917. */
  16918. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16919. /**
  16920. * Sets the mesh indices.
  16921. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16922. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16923. * This method creates a new index buffer each call.
  16924. * Returns the Mesh.
  16925. */
  16926. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16927. /**
  16928. * Boolean : True if the mesh owns the requested kind of data.
  16929. */
  16930. isVerticesDataPresent(kind: string): boolean;
  16931. /**
  16932. * Returns an array of indices (IndicesArray).
  16933. */
  16934. getIndices(): Nullable<IndicesArray>;
  16935. get _positions(): Nullable<Vector3[]>;
  16936. /**
  16937. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16938. * This means the mesh underlying bounding box and sphere are recomputed.
  16939. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16940. * @returns the current mesh
  16941. */
  16942. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16943. /** @hidden */
  16944. _preActivate(): InstancedMesh;
  16945. /** @hidden */
  16946. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16947. /** @hidden */
  16948. _postActivate(): void;
  16949. getWorldMatrix(): Matrix;
  16950. get isAnInstance(): boolean;
  16951. /**
  16952. * Returns the current associated LOD AbstractMesh.
  16953. */
  16954. getLOD(camera: Camera): AbstractMesh;
  16955. /** @hidden */
  16956. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16957. /** @hidden */
  16958. _syncSubMeshes(): InstancedMesh;
  16959. /** @hidden */
  16960. _generatePointsArray(): boolean;
  16961. /** @hidden */
  16962. _updateBoundingInfo(): AbstractMesh;
  16963. /**
  16964. * Creates a new InstancedMesh from the current mesh.
  16965. * - name (string) : the cloned mesh name
  16966. * - newParent (optional Node) : the optional Node to parent the clone to.
  16967. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16968. *
  16969. * Returns the clone.
  16970. */
  16971. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16972. /**
  16973. * Disposes the InstancedMesh.
  16974. * Returns nothing.
  16975. */
  16976. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16977. }
  16978. module "babylonjs/Meshes/mesh" {
  16979. interface Mesh {
  16980. /**
  16981. * Register a custom buffer that will be instanced
  16982. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16983. * @param kind defines the buffer kind
  16984. * @param stride defines the stride in floats
  16985. */
  16986. registerInstancedBuffer(kind: string, stride: number): void;
  16987. /**
  16988. * true to use the edge renderer for all instances of this mesh
  16989. */
  16990. edgesShareWithInstances: boolean;
  16991. /** @hidden */
  16992. _userInstancedBuffersStorage: {
  16993. data: {
  16994. [key: string]: Float32Array;
  16995. };
  16996. sizes: {
  16997. [key: string]: number;
  16998. };
  16999. vertexBuffers: {
  17000. [key: string]: Nullable<VertexBuffer>;
  17001. };
  17002. strides: {
  17003. [key: string]: number;
  17004. };
  17005. };
  17006. }
  17007. }
  17008. module "babylonjs/Meshes/abstractMesh" {
  17009. interface AbstractMesh {
  17010. /**
  17011. * Object used to store instanced buffers defined by user
  17012. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  17013. */
  17014. instancedBuffers: {
  17015. [key: string]: any;
  17016. };
  17017. }
  17018. }
  17019. }
  17020. declare module "babylonjs/Materials/shaderMaterial" {
  17021. import { Nullable } from "babylonjs/types";
  17022. import { Scene } from "babylonjs/scene";
  17023. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  17024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17025. import { Mesh } from "babylonjs/Meshes/mesh";
  17026. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17027. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17028. import { Effect } from "babylonjs/Materials/effect";
  17029. import { Material } from "babylonjs/Materials/material";
  17030. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  17031. /**
  17032. * Defines the options associated with the creation of a shader material.
  17033. */
  17034. export interface IShaderMaterialOptions {
  17035. /**
  17036. * Does the material work in alpha blend mode
  17037. */
  17038. needAlphaBlending: boolean;
  17039. /**
  17040. * Does the material work in alpha test mode
  17041. */
  17042. needAlphaTesting: boolean;
  17043. /**
  17044. * The list of attribute names used in the shader
  17045. */
  17046. attributes: string[];
  17047. /**
  17048. * The list of unifrom names used in the shader
  17049. */
  17050. uniforms: string[];
  17051. /**
  17052. * The list of UBO names used in the shader
  17053. */
  17054. uniformBuffers: string[];
  17055. /**
  17056. * The list of sampler names used in the shader
  17057. */
  17058. samplers: string[];
  17059. /**
  17060. * The list of defines used in the shader
  17061. */
  17062. defines: string[];
  17063. }
  17064. /**
  17065. * 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.
  17066. *
  17067. * This returned material effects how the mesh will look based on the code in the shaders.
  17068. *
  17069. * @see https://doc.babylonjs.com/how_to/shader_material
  17070. */
  17071. export class ShaderMaterial extends Material {
  17072. private _shaderPath;
  17073. private _options;
  17074. private _textures;
  17075. private _textureArrays;
  17076. private _floats;
  17077. private _ints;
  17078. private _floatsArrays;
  17079. private _colors3;
  17080. private _colors3Arrays;
  17081. private _colors4;
  17082. private _colors4Arrays;
  17083. private _vectors2;
  17084. private _vectors3;
  17085. private _vectors4;
  17086. private _matrices;
  17087. private _matrixArrays;
  17088. private _matrices3x3;
  17089. private _matrices2x2;
  17090. private _vectors2Arrays;
  17091. private _vectors3Arrays;
  17092. private _vectors4Arrays;
  17093. private _cachedWorldViewMatrix;
  17094. private _cachedWorldViewProjectionMatrix;
  17095. private _renderId;
  17096. private _multiview;
  17097. private _cachedDefines;
  17098. /** Define the Url to load snippets */
  17099. static SnippetUrl: string;
  17100. /** Snippet ID if the material was created from the snippet server */
  17101. snippetId: string;
  17102. /**
  17103. * Instantiate a new shader material.
  17104. * 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.
  17105. * This returned material effects how the mesh will look based on the code in the shaders.
  17106. * @see https://doc.babylonjs.com/how_to/shader_material
  17107. * @param name Define the name of the material in the scene
  17108. * @param scene Define the scene the material belongs to
  17109. * @param shaderPath Defines the route to the shader code in one of three ways:
  17110. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17111. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17112. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17113. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17114. * @param options Define the options used to create the shader
  17115. */
  17116. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17117. /**
  17118. * Gets the shader path used to define the shader code
  17119. * It can be modified to trigger a new compilation
  17120. */
  17121. get shaderPath(): any;
  17122. /**
  17123. * Sets the shader path used to define the shader code
  17124. * It can be modified to trigger a new compilation
  17125. */
  17126. set shaderPath(shaderPath: any);
  17127. /**
  17128. * Gets the options used to compile the shader.
  17129. * They can be modified to trigger a new compilation
  17130. */
  17131. get options(): IShaderMaterialOptions;
  17132. /**
  17133. * Gets the current class name of the material e.g. "ShaderMaterial"
  17134. * Mainly use in serialization.
  17135. * @returns the class name
  17136. */
  17137. getClassName(): string;
  17138. /**
  17139. * Specifies if the material will require alpha blending
  17140. * @returns a boolean specifying if alpha blending is needed
  17141. */
  17142. needAlphaBlending(): boolean;
  17143. /**
  17144. * Specifies if this material should be rendered in alpha test mode
  17145. * @returns a boolean specifying if an alpha test is needed.
  17146. */
  17147. needAlphaTesting(): boolean;
  17148. private _checkUniform;
  17149. /**
  17150. * Set a texture in the shader.
  17151. * @param name Define the name of the uniform samplers as defined in the shader
  17152. * @param texture Define the texture to bind to this sampler
  17153. * @return the material itself allowing "fluent" like uniform updates
  17154. */
  17155. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17156. /**
  17157. * Set a texture array in the shader.
  17158. * @param name Define the name of the uniform sampler array as defined in the shader
  17159. * @param textures Define the list of textures to bind to this sampler
  17160. * @return the material itself allowing "fluent" like uniform updates
  17161. */
  17162. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17163. /**
  17164. * Set a float in the shader.
  17165. * @param name Define the name of the uniform as defined in the shader
  17166. * @param value Define the value to give to the uniform
  17167. * @return the material itself allowing "fluent" like uniform updates
  17168. */
  17169. setFloat(name: string, value: number): ShaderMaterial;
  17170. /**
  17171. * Set a int in the shader.
  17172. * @param name Define the name of the uniform as defined in the shader
  17173. * @param value Define the value to give to the uniform
  17174. * @return the material itself allowing "fluent" like uniform updates
  17175. */
  17176. setInt(name: string, value: number): ShaderMaterial;
  17177. /**
  17178. * Set an array of floats in the shader.
  17179. * @param name Define the name of the uniform as defined in the shader
  17180. * @param value Define the value to give to the uniform
  17181. * @return the material itself allowing "fluent" like uniform updates
  17182. */
  17183. setFloats(name: string, value: number[]): ShaderMaterial;
  17184. /**
  17185. * Set a vec3 in the shader from a Color3.
  17186. * @param name Define the name of the uniform as defined in the shader
  17187. * @param value Define the value to give to the uniform
  17188. * @return the material itself allowing "fluent" like uniform updates
  17189. */
  17190. setColor3(name: string, value: Color3): ShaderMaterial;
  17191. /**
  17192. * Set a vec3 array in the shader from a Color3 array.
  17193. * @param name Define the name of the uniform as defined in the shader
  17194. * @param value Define the value to give to the uniform
  17195. * @return the material itself allowing "fluent" like uniform updates
  17196. */
  17197. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17198. /**
  17199. * Set a vec4 in the shader from a Color4.
  17200. * @param name Define the name of the uniform as defined in the shader
  17201. * @param value Define the value to give to the uniform
  17202. * @return the material itself allowing "fluent" like uniform updates
  17203. */
  17204. setColor4(name: string, value: Color4): ShaderMaterial;
  17205. /**
  17206. * Set a vec4 array in the shader from a Color4 array.
  17207. * @param name Define the name of the uniform as defined in the shader
  17208. * @param value Define the value to give to the uniform
  17209. * @return the material itself allowing "fluent" like uniform updates
  17210. */
  17211. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17212. /**
  17213. * Set a vec2 in the shader from a Vector2.
  17214. * @param name Define the name of the uniform as defined in the shader
  17215. * @param value Define the value to give to the uniform
  17216. * @return the material itself allowing "fluent" like uniform updates
  17217. */
  17218. setVector2(name: string, value: Vector2): ShaderMaterial;
  17219. /**
  17220. * Set a vec3 in the shader from a Vector3.
  17221. * @param name Define the name of the uniform as defined in the shader
  17222. * @param value Define the value to give to the uniform
  17223. * @return the material itself allowing "fluent" like uniform updates
  17224. */
  17225. setVector3(name: string, value: Vector3): ShaderMaterial;
  17226. /**
  17227. * Set a vec4 in the shader from a Vector4.
  17228. * @param name Define the name of the uniform as defined in the shader
  17229. * @param value Define the value to give to the uniform
  17230. * @return the material itself allowing "fluent" like uniform updates
  17231. */
  17232. setVector4(name: string, value: Vector4): ShaderMaterial;
  17233. /**
  17234. * Set a mat4 in the shader from a Matrix.
  17235. * @param name Define the name of the uniform as defined in the shader
  17236. * @param value Define the value to give to the uniform
  17237. * @return the material itself allowing "fluent" like uniform updates
  17238. */
  17239. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17240. /**
  17241. * Set a float32Array in the shader from a matrix array.
  17242. * @param name Define the name of the uniform as defined in the shader
  17243. * @param value Define the value to give to the uniform
  17244. * @return the material itself allowing "fluent" like uniform updates
  17245. */
  17246. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17247. /**
  17248. * Set a mat3 in the shader from a Float32Array.
  17249. * @param name Define the name of the uniform as defined in the shader
  17250. * @param value Define the value to give to the uniform
  17251. * @return the material itself allowing "fluent" like uniform updates
  17252. */
  17253. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17254. /**
  17255. * Set a mat2 in the shader from a Float32Array.
  17256. * @param name Define the name of the uniform as defined in the shader
  17257. * @param value Define the value to give to the uniform
  17258. * @return the material itself allowing "fluent" like uniform updates
  17259. */
  17260. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17261. /**
  17262. * Set a vec2 array in the shader from a number array.
  17263. * @param name Define the name of the uniform as defined in the shader
  17264. * @param value Define the value to give to the uniform
  17265. * @return the material itself allowing "fluent" like uniform updates
  17266. */
  17267. setArray2(name: string, value: number[]): ShaderMaterial;
  17268. /**
  17269. * Set a vec3 array in the shader from a number array.
  17270. * @param name Define the name of the uniform as defined in the shader
  17271. * @param value Define the value to give to the uniform
  17272. * @return the material itself allowing "fluent" like uniform updates
  17273. */
  17274. setArray3(name: string, value: number[]): ShaderMaterial;
  17275. /**
  17276. * Set a vec4 array in the shader from a number array.
  17277. * @param name Define the name of the uniform as defined in the shader
  17278. * @param value Define the value to give to the uniform
  17279. * @return the material itself allowing "fluent" like uniform updates
  17280. */
  17281. setArray4(name: string, value: number[]): ShaderMaterial;
  17282. private _checkCache;
  17283. /**
  17284. * Specifies that the submesh is ready to be used
  17285. * @param mesh defines the mesh to check
  17286. * @param subMesh defines which submesh to check
  17287. * @param useInstances specifies that instances should be used
  17288. * @returns a boolean indicating that the submesh is ready or not
  17289. */
  17290. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17291. /**
  17292. * Checks if the material is ready to render the requested mesh
  17293. * @param mesh Define the mesh to render
  17294. * @param useInstances Define whether or not the material is used with instances
  17295. * @returns true if ready, otherwise false
  17296. */
  17297. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17298. /**
  17299. * Binds the world matrix to the material
  17300. * @param world defines the world transformation matrix
  17301. * @param effectOverride - If provided, use this effect instead of internal effect
  17302. */
  17303. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17304. /**
  17305. * Binds the submesh to this material by preparing the effect and shader to draw
  17306. * @param world defines the world transformation matrix
  17307. * @param mesh defines the mesh containing the submesh
  17308. * @param subMesh defines the submesh to bind the material to
  17309. */
  17310. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17311. /**
  17312. * Binds the material to the mesh
  17313. * @param world defines the world transformation matrix
  17314. * @param mesh defines the mesh to bind the material to
  17315. * @param effectOverride - If provided, use this effect instead of internal effect
  17316. */
  17317. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17318. protected _afterBind(mesh?: Mesh): void;
  17319. /**
  17320. * Gets the active textures from the material
  17321. * @returns an array of textures
  17322. */
  17323. getActiveTextures(): BaseTexture[];
  17324. /**
  17325. * Specifies if the material uses a texture
  17326. * @param texture defines the texture to check against the material
  17327. * @returns a boolean specifying if the material uses the texture
  17328. */
  17329. hasTexture(texture: BaseTexture): boolean;
  17330. /**
  17331. * Makes a duplicate of the material, and gives it a new name
  17332. * @param name defines the new name for the duplicated material
  17333. * @returns the cloned material
  17334. */
  17335. clone(name: string): ShaderMaterial;
  17336. /**
  17337. * Disposes the material
  17338. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17339. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17340. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17341. */
  17342. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17343. /**
  17344. * Serializes this material in a JSON representation
  17345. * @returns the serialized material object
  17346. */
  17347. serialize(): any;
  17348. /**
  17349. * Creates a shader material from parsed shader material data
  17350. * @param source defines the JSON represnetation of the material
  17351. * @param scene defines the hosting scene
  17352. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17353. * @returns a new material
  17354. */
  17355. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17356. /**
  17357. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17358. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17359. * @param url defines the url to load from
  17360. * @param scene defines the hosting scene
  17361. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17362. * @returns a promise that will resolve to the new ShaderMaterial
  17363. */
  17364. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17365. /**
  17366. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17367. * @param snippetId defines the snippet to load
  17368. * @param scene defines the hosting scene
  17369. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17370. * @returns a promise that will resolve to the new ShaderMaterial
  17371. */
  17372. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17373. }
  17374. }
  17375. declare module "babylonjs/Shaders/color.fragment" {
  17376. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17377. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17378. /** @hidden */
  17379. export var colorPixelShader: {
  17380. name: string;
  17381. shader: string;
  17382. };
  17383. }
  17384. declare module "babylonjs/Shaders/color.vertex" {
  17385. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17387. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17388. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17389. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17390. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17391. /** @hidden */
  17392. export var colorVertexShader: {
  17393. name: string;
  17394. shader: string;
  17395. };
  17396. }
  17397. declare module "babylonjs/Meshes/linesMesh" {
  17398. import { Nullable } from "babylonjs/types";
  17399. import { Scene } from "babylonjs/scene";
  17400. import { Color3 } from "babylonjs/Maths/math.color";
  17401. import { Node } from "babylonjs/node";
  17402. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17403. import { Mesh } from "babylonjs/Meshes/mesh";
  17404. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17405. import { Effect } from "babylonjs/Materials/effect";
  17406. import { Material } from "babylonjs/Materials/material";
  17407. import "babylonjs/Shaders/color.fragment";
  17408. import "babylonjs/Shaders/color.vertex";
  17409. /**
  17410. * Line mesh
  17411. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17412. */
  17413. export class LinesMesh extends Mesh {
  17414. /**
  17415. * If vertex color should be applied to the mesh
  17416. */
  17417. readonly useVertexColor?: boolean | undefined;
  17418. /**
  17419. * If vertex alpha should be applied to the mesh
  17420. */
  17421. readonly useVertexAlpha?: boolean | undefined;
  17422. /**
  17423. * Color of the line (Default: White)
  17424. */
  17425. color: Color3;
  17426. /**
  17427. * Alpha of the line (Default: 1)
  17428. */
  17429. alpha: number;
  17430. /**
  17431. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17432. * This margin is expressed in world space coordinates, so its value may vary.
  17433. * Default value is 0.1
  17434. */
  17435. intersectionThreshold: number;
  17436. private _colorShader;
  17437. private color4;
  17438. /**
  17439. * Creates a new LinesMesh
  17440. * @param name defines the name
  17441. * @param scene defines the hosting scene
  17442. * @param parent defines the parent mesh if any
  17443. * @param source defines the optional source LinesMesh used to clone data from
  17444. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17445. * When false, achieved by calling a clone(), also passing False.
  17446. * This will make creation of children, recursive.
  17447. * @param useVertexColor defines if this LinesMesh supports vertex color
  17448. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17449. */
  17450. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17451. /**
  17452. * If vertex color should be applied to the mesh
  17453. */
  17454. useVertexColor?: boolean | undefined,
  17455. /**
  17456. * If vertex alpha should be applied to the mesh
  17457. */
  17458. useVertexAlpha?: boolean | undefined);
  17459. private _addClipPlaneDefine;
  17460. private _removeClipPlaneDefine;
  17461. isReady(): boolean;
  17462. /**
  17463. * Returns the string "LineMesh"
  17464. */
  17465. getClassName(): string;
  17466. /**
  17467. * @hidden
  17468. */
  17469. get material(): Material;
  17470. /**
  17471. * @hidden
  17472. */
  17473. set material(value: Material);
  17474. /**
  17475. * @hidden
  17476. */
  17477. get checkCollisions(): boolean;
  17478. /** @hidden */
  17479. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17480. /** @hidden */
  17481. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17482. /**
  17483. * Disposes of the line mesh
  17484. * @param doNotRecurse If children should be disposed
  17485. */
  17486. dispose(doNotRecurse?: boolean): void;
  17487. /**
  17488. * Returns a new LineMesh object cloned from the current one.
  17489. */
  17490. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17491. /**
  17492. * Creates a new InstancedLinesMesh object from the mesh model.
  17493. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17494. * @param name defines the name of the new instance
  17495. * @returns a new InstancedLinesMesh
  17496. */
  17497. createInstance(name: string): InstancedLinesMesh;
  17498. }
  17499. /**
  17500. * Creates an instance based on a source LinesMesh
  17501. */
  17502. export class InstancedLinesMesh extends InstancedMesh {
  17503. /**
  17504. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17505. * This margin is expressed in world space coordinates, so its value may vary.
  17506. * Initilized with the intersectionThreshold value of the source LinesMesh
  17507. */
  17508. intersectionThreshold: number;
  17509. constructor(name: string, source: LinesMesh);
  17510. /**
  17511. * Returns the string "InstancedLinesMesh".
  17512. */
  17513. getClassName(): string;
  17514. }
  17515. }
  17516. declare module "babylonjs/Shaders/line.fragment" {
  17517. /** @hidden */
  17518. export var linePixelShader: {
  17519. name: string;
  17520. shader: string;
  17521. };
  17522. }
  17523. declare module "babylonjs/Shaders/line.vertex" {
  17524. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17525. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17526. /** @hidden */
  17527. export var lineVertexShader: {
  17528. name: string;
  17529. shader: string;
  17530. };
  17531. }
  17532. declare module "babylonjs/Rendering/edgesRenderer" {
  17533. import { Nullable } from "babylonjs/types";
  17534. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17536. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17537. import { IDisposable } from "babylonjs/scene";
  17538. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17539. import "babylonjs/Shaders/line.fragment";
  17540. import "babylonjs/Shaders/line.vertex";
  17541. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17542. import { SmartArray } from "babylonjs/Misc/smartArray";
  17543. module "babylonjs/scene" {
  17544. interface Scene {
  17545. /** @hidden */
  17546. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17547. }
  17548. }
  17549. module "babylonjs/Meshes/abstractMesh" {
  17550. interface AbstractMesh {
  17551. /**
  17552. * Gets the edgesRenderer associated with the mesh
  17553. */
  17554. edgesRenderer: Nullable<EdgesRenderer>;
  17555. }
  17556. }
  17557. module "babylonjs/Meshes/linesMesh" {
  17558. interface LinesMesh {
  17559. /**
  17560. * Enables the edge rendering mode on the mesh.
  17561. * This mode makes the mesh edges visible
  17562. * @param epsilon defines the maximal distance between two angles to detect a face
  17563. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17564. * @returns the currentAbstractMesh
  17565. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17566. */
  17567. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17568. }
  17569. }
  17570. module "babylonjs/Meshes/linesMesh" {
  17571. interface InstancedLinesMesh {
  17572. /**
  17573. * Enables the edge rendering mode on the mesh.
  17574. * This mode makes the mesh edges visible
  17575. * @param epsilon defines the maximal distance between two angles to detect a face
  17576. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17577. * @returns the current InstancedLinesMesh
  17578. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17579. */
  17580. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17581. }
  17582. }
  17583. /**
  17584. * Defines the minimum contract an Edges renderer should follow.
  17585. */
  17586. export interface IEdgesRenderer extends IDisposable {
  17587. /**
  17588. * Gets or sets a boolean indicating if the edgesRenderer is active
  17589. */
  17590. isEnabled: boolean;
  17591. /**
  17592. * Renders the edges of the attached mesh,
  17593. */
  17594. render(): void;
  17595. /**
  17596. * Checks wether or not the edges renderer is ready to render.
  17597. * @return true if ready, otherwise false.
  17598. */
  17599. isReady(): boolean;
  17600. /**
  17601. * List of instances to render in case the source mesh has instances
  17602. */
  17603. customInstances: SmartArray<Matrix>;
  17604. }
  17605. /**
  17606. * Defines the additional options of the edges renderer
  17607. */
  17608. export interface IEdgesRendererOptions {
  17609. /**
  17610. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17611. * If not defined, the default value is true
  17612. */
  17613. useAlternateEdgeFinder?: boolean;
  17614. /**
  17615. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17616. * If not defined, the default value is true.
  17617. * 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)
  17618. * This option is used only if useAlternateEdgeFinder = true
  17619. */
  17620. useFastVertexMerger?: boolean;
  17621. /**
  17622. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17623. * The default value is 1e-6
  17624. * This option is used only if useAlternateEdgeFinder = true
  17625. */
  17626. epsilonVertexMerge?: number;
  17627. /**
  17628. * 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
  17629. * 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.
  17630. * This option is used only if useAlternateEdgeFinder = true
  17631. */
  17632. applyTessellation?: boolean;
  17633. /**
  17634. * 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
  17635. * The default value is 1e-6
  17636. * This option is used only if useAlternateEdgeFinder = true
  17637. */
  17638. epsilonVertexAligned?: number;
  17639. }
  17640. /**
  17641. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17642. */
  17643. export class EdgesRenderer implements IEdgesRenderer {
  17644. /**
  17645. * Define the size of the edges with an orthographic camera
  17646. */
  17647. edgesWidthScalerForOrthographic: number;
  17648. /**
  17649. * Define the size of the edges with a perspective camera
  17650. */
  17651. edgesWidthScalerForPerspective: number;
  17652. protected _source: AbstractMesh;
  17653. protected _linesPositions: number[];
  17654. protected _linesNormals: number[];
  17655. protected _linesIndices: number[];
  17656. protected _epsilon: number;
  17657. protected _indicesCount: number;
  17658. protected _lineShader: ShaderMaterial;
  17659. protected _ib: DataBuffer;
  17660. protected _buffers: {
  17661. [key: string]: Nullable<VertexBuffer>;
  17662. };
  17663. protected _buffersForInstances: {
  17664. [key: string]: Nullable<VertexBuffer>;
  17665. };
  17666. protected _checkVerticesInsteadOfIndices: boolean;
  17667. protected _options: Nullable<IEdgesRendererOptions>;
  17668. private _meshRebuildObserver;
  17669. private _meshDisposeObserver;
  17670. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17671. isEnabled: boolean;
  17672. /**
  17673. * List of instances to render in case the source mesh has instances
  17674. */
  17675. customInstances: SmartArray<Matrix>;
  17676. private static GetShader;
  17677. /**
  17678. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17679. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17680. * @param source Mesh used to create edges
  17681. * @param epsilon sum of angles in adjacency to check for edge
  17682. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17683. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17684. * @param options The options to apply when generating the edges
  17685. */
  17686. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17687. protected _prepareRessources(): void;
  17688. /** @hidden */
  17689. _rebuild(): void;
  17690. /**
  17691. * Releases the required resources for the edges renderer
  17692. */
  17693. dispose(): void;
  17694. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17695. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17696. /**
  17697. * Checks if the pair of p0 and p1 is en edge
  17698. * @param faceIndex
  17699. * @param edge
  17700. * @param faceNormals
  17701. * @param p0
  17702. * @param p1
  17703. * @private
  17704. */
  17705. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17706. /**
  17707. * push line into the position, normal and index buffer
  17708. * @protected
  17709. */
  17710. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17711. /**
  17712. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17713. */
  17714. private _tessellateTriangle;
  17715. private _generateEdgesLinesAlternate;
  17716. /**
  17717. * Generates lines edges from adjacencjes
  17718. * @private
  17719. */
  17720. _generateEdgesLines(): void;
  17721. /**
  17722. * Checks wether or not the edges renderer is ready to render.
  17723. * @return true if ready, otherwise false.
  17724. */
  17725. isReady(): boolean;
  17726. /**
  17727. * Renders the edges of the attached mesh,
  17728. */
  17729. render(): void;
  17730. }
  17731. /**
  17732. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17733. */
  17734. export class LineEdgesRenderer extends EdgesRenderer {
  17735. /**
  17736. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17737. * @param source LineMesh used to generate edges
  17738. * @param epsilon not important (specified angle for edge detection)
  17739. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17740. */
  17741. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17742. /**
  17743. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17744. */
  17745. _generateEdgesLines(): void;
  17746. }
  17747. }
  17748. declare module "babylonjs/Rendering/renderingGroup" {
  17749. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17750. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17752. import { Nullable } from "babylonjs/types";
  17753. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17754. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17755. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17756. import { Material } from "babylonjs/Materials/material";
  17757. import { Scene } from "babylonjs/scene";
  17758. /**
  17759. * This represents the object necessary to create a rendering group.
  17760. * This is exclusively used and created by the rendering manager.
  17761. * To modify the behavior, you use the available helpers in your scene or meshes.
  17762. * @hidden
  17763. */
  17764. export class RenderingGroup {
  17765. index: number;
  17766. private static _zeroVector;
  17767. private _scene;
  17768. private _opaqueSubMeshes;
  17769. private _transparentSubMeshes;
  17770. private _alphaTestSubMeshes;
  17771. private _depthOnlySubMeshes;
  17772. private _particleSystems;
  17773. private _spriteManagers;
  17774. private _opaqueSortCompareFn;
  17775. private _alphaTestSortCompareFn;
  17776. private _transparentSortCompareFn;
  17777. private _renderOpaque;
  17778. private _renderAlphaTest;
  17779. private _renderTransparent;
  17780. /** @hidden */
  17781. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17782. onBeforeTransparentRendering: () => void;
  17783. /**
  17784. * Set the opaque sort comparison function.
  17785. * If null the sub meshes will be render in the order they were created
  17786. */
  17787. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17788. /**
  17789. * Set the alpha test sort comparison function.
  17790. * If null the sub meshes will be render in the order they were created
  17791. */
  17792. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17793. /**
  17794. * Set the transparent sort comparison function.
  17795. * If null the sub meshes will be render in the order they were created
  17796. */
  17797. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17798. /**
  17799. * Creates a new rendering group.
  17800. * @param index The rendering group index
  17801. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17802. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17803. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17804. */
  17805. 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>);
  17806. /**
  17807. * Render all the sub meshes contained in the group.
  17808. * @param customRenderFunction Used to override the default render behaviour of the group.
  17809. * @returns true if rendered some submeshes.
  17810. */
  17811. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17812. /**
  17813. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17814. * @param subMeshes The submeshes to render
  17815. */
  17816. private renderOpaqueSorted;
  17817. /**
  17818. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17819. * @param subMeshes The submeshes to render
  17820. */
  17821. private renderAlphaTestSorted;
  17822. /**
  17823. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17824. * @param subMeshes The submeshes to render
  17825. */
  17826. private renderTransparentSorted;
  17827. /**
  17828. * Renders the submeshes in a specified order.
  17829. * @param subMeshes The submeshes to sort before render
  17830. * @param sortCompareFn The comparison function use to sort
  17831. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17832. * @param transparent Specifies to activate blending if true
  17833. */
  17834. private static renderSorted;
  17835. /**
  17836. * Renders the submeshes in the order they were dispatched (no sort applied).
  17837. * @param subMeshes The submeshes to render
  17838. */
  17839. private static renderUnsorted;
  17840. /**
  17841. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17842. * are rendered back to front if in the same alpha index.
  17843. *
  17844. * @param a The first submesh
  17845. * @param b The second submesh
  17846. * @returns The result of the comparison
  17847. */
  17848. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17849. /**
  17850. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17851. * are rendered back to front.
  17852. *
  17853. * @param a The first submesh
  17854. * @param b The second submesh
  17855. * @returns The result of the comparison
  17856. */
  17857. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17858. /**
  17859. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17860. * are rendered front to back (prevent overdraw).
  17861. *
  17862. * @param a The first submesh
  17863. * @param b The second submesh
  17864. * @returns The result of the comparison
  17865. */
  17866. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17867. /**
  17868. * Resets the different lists of submeshes to prepare a new frame.
  17869. */
  17870. prepare(): void;
  17871. dispose(): void;
  17872. /**
  17873. * Inserts the submesh in its correct queue depending on its material.
  17874. * @param subMesh The submesh to dispatch
  17875. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17876. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17877. */
  17878. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17879. dispatchSprites(spriteManager: ISpriteManager): void;
  17880. dispatchParticles(particleSystem: IParticleSystem): void;
  17881. private _renderParticles;
  17882. private _renderSprites;
  17883. }
  17884. }
  17885. declare module "babylonjs/Rendering/renderingManager" {
  17886. import { Nullable } from "babylonjs/types";
  17887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17888. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17889. import { SmartArray } from "babylonjs/Misc/smartArray";
  17890. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17891. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17892. import { Material } from "babylonjs/Materials/material";
  17893. import { Scene } from "babylonjs/scene";
  17894. import { Camera } from "babylonjs/Cameras/camera";
  17895. /**
  17896. * Interface describing the different options available in the rendering manager
  17897. * regarding Auto Clear between groups.
  17898. */
  17899. export interface IRenderingManagerAutoClearSetup {
  17900. /**
  17901. * Defines whether or not autoclear is enable.
  17902. */
  17903. autoClear: boolean;
  17904. /**
  17905. * Defines whether or not to autoclear the depth buffer.
  17906. */
  17907. depth: boolean;
  17908. /**
  17909. * Defines whether or not to autoclear the stencil buffer.
  17910. */
  17911. stencil: boolean;
  17912. }
  17913. /**
  17914. * This class is used by the onRenderingGroupObservable
  17915. */
  17916. export class RenderingGroupInfo {
  17917. /**
  17918. * The Scene that being rendered
  17919. */
  17920. scene: Scene;
  17921. /**
  17922. * The camera currently used for the rendering pass
  17923. */
  17924. camera: Nullable<Camera>;
  17925. /**
  17926. * The ID of the renderingGroup being processed
  17927. */
  17928. renderingGroupId: number;
  17929. }
  17930. /**
  17931. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17932. * It is enable to manage the different groups as well as the different necessary sort functions.
  17933. * This should not be used directly aside of the few static configurations
  17934. */
  17935. export class RenderingManager {
  17936. /**
  17937. * The max id used for rendering groups (not included)
  17938. */
  17939. static MAX_RENDERINGGROUPS: number;
  17940. /**
  17941. * The min id used for rendering groups (included)
  17942. */
  17943. static MIN_RENDERINGGROUPS: number;
  17944. /**
  17945. * Used to globally prevent autoclearing scenes.
  17946. */
  17947. static AUTOCLEAR: boolean;
  17948. /**
  17949. * @hidden
  17950. */
  17951. _useSceneAutoClearSetup: boolean;
  17952. private _scene;
  17953. private _renderingGroups;
  17954. private _depthStencilBufferAlreadyCleaned;
  17955. private _autoClearDepthStencil;
  17956. private _customOpaqueSortCompareFn;
  17957. private _customAlphaTestSortCompareFn;
  17958. private _customTransparentSortCompareFn;
  17959. private _renderingGroupInfo;
  17960. /**
  17961. * Instantiates a new rendering group for a particular scene
  17962. * @param scene Defines the scene the groups belongs to
  17963. */
  17964. constructor(scene: Scene);
  17965. private _clearDepthStencilBuffer;
  17966. /**
  17967. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17968. * @hidden
  17969. */
  17970. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17971. /**
  17972. * Resets the different information of the group to prepare a new frame
  17973. * @hidden
  17974. */
  17975. reset(): void;
  17976. /**
  17977. * Dispose and release the group and its associated resources.
  17978. * @hidden
  17979. */
  17980. dispose(): void;
  17981. /**
  17982. * Clear the info related to rendering groups preventing retention points during dispose.
  17983. */
  17984. freeRenderingGroups(): void;
  17985. private _prepareRenderingGroup;
  17986. /**
  17987. * Add a sprite manager to the rendering manager in order to render it this frame.
  17988. * @param spriteManager Define the sprite manager to render
  17989. */
  17990. dispatchSprites(spriteManager: ISpriteManager): void;
  17991. /**
  17992. * Add a particle system to the rendering manager in order to render it this frame.
  17993. * @param particleSystem Define the particle system to render
  17994. */
  17995. dispatchParticles(particleSystem: IParticleSystem): void;
  17996. /**
  17997. * Add a submesh to the manager in order to render it this frame
  17998. * @param subMesh The submesh to dispatch
  17999. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18000. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18001. */
  18002. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18003. /**
  18004. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18005. * This allowed control for front to back rendering or reversly depending of the special needs.
  18006. *
  18007. * @param renderingGroupId The rendering group id corresponding to its index
  18008. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18009. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18010. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18011. */
  18012. 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;
  18013. /**
  18014. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18015. *
  18016. * @param renderingGroupId The rendering group id corresponding to its index
  18017. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18018. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18019. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18020. */
  18021. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18022. /**
  18023. * Gets the current auto clear configuration for one rendering group of the rendering
  18024. * manager.
  18025. * @param index the rendering group index to get the information for
  18026. * @returns The auto clear setup for the requested rendering group
  18027. */
  18028. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18029. }
  18030. }
  18031. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  18032. import { SmartArray } from "babylonjs/Misc/smartArray";
  18033. import { Nullable } from "babylonjs/types";
  18034. import { Scene } from "babylonjs/scene";
  18035. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  18036. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18038. import { Mesh } from "babylonjs/Meshes/mesh";
  18039. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  18040. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  18041. import { Effect } from "babylonjs/Materials/effect";
  18042. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18043. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18044. import "babylonjs/Shaders/shadowMap.fragment";
  18045. import "babylonjs/Shaders/shadowMap.vertex";
  18046. import "babylonjs/Shaders/depthBoxBlur.fragment";
  18047. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  18048. import { Observable } from "babylonjs/Misc/observable";
  18049. /**
  18050. * Defines the options associated with the creation of a custom shader for a shadow generator.
  18051. */
  18052. export interface ICustomShaderOptions {
  18053. /**
  18054. * Gets or sets the custom shader name to use
  18055. */
  18056. shaderName: string;
  18057. /**
  18058. * The list of attribute names used in the shader
  18059. */
  18060. attributes?: string[];
  18061. /**
  18062. * The list of unifrom names used in the shader
  18063. */
  18064. uniforms?: string[];
  18065. /**
  18066. * The list of sampler names used in the shader
  18067. */
  18068. samplers?: string[];
  18069. /**
  18070. * The list of defines used in the shader
  18071. */
  18072. defines?: string[];
  18073. }
  18074. /**
  18075. * Interface to implement to create a shadow generator compatible with BJS.
  18076. */
  18077. export interface IShadowGenerator {
  18078. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18079. id: string;
  18080. /**
  18081. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18082. * @returns The render target texture if present otherwise, null
  18083. */
  18084. getShadowMap(): Nullable<RenderTargetTexture>;
  18085. /**
  18086. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18087. * @param subMesh The submesh we want to render in the shadow map
  18088. * @param useInstances Defines wether will draw in the map using instances
  18089. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18090. * @returns true if ready otherwise, false
  18091. */
  18092. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18093. /**
  18094. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18095. * @param defines Defines of the material we want to update
  18096. * @param lightIndex Index of the light in the enabled light list of the material
  18097. */
  18098. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18099. /**
  18100. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18101. * defined in the generator but impacting the effect).
  18102. * It implies the unifroms available on the materials are the standard BJS ones.
  18103. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18104. * @param effect The effect we are binfing the information for
  18105. */
  18106. bindShadowLight(lightIndex: string, effect: Effect): void;
  18107. /**
  18108. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18109. * (eq to shadow prjection matrix * light transform matrix)
  18110. * @returns The transform matrix used to create the shadow map
  18111. */
  18112. getTransformMatrix(): Matrix;
  18113. /**
  18114. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18115. * Cube and 2D textures for instance.
  18116. */
  18117. recreateShadowMap(): void;
  18118. /**
  18119. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18120. * @param onCompiled Callback triggered at the and of the effects compilation
  18121. * @param options Sets of optional options forcing the compilation with different modes
  18122. */
  18123. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18124. useInstances: boolean;
  18125. }>): void;
  18126. /**
  18127. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18128. * @param options Sets of optional options forcing the compilation with different modes
  18129. * @returns A promise that resolves when the compilation completes
  18130. */
  18131. forceCompilationAsync(options?: Partial<{
  18132. useInstances: boolean;
  18133. }>): Promise<void>;
  18134. /**
  18135. * Serializes the shadow generator setup to a json object.
  18136. * @returns The serialized JSON object
  18137. */
  18138. serialize(): any;
  18139. /**
  18140. * Disposes the Shadow map and related Textures and effects.
  18141. */
  18142. dispose(): void;
  18143. }
  18144. /**
  18145. * Default implementation IShadowGenerator.
  18146. * This is the main object responsible of generating shadows in the framework.
  18147. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18148. */
  18149. export class ShadowGenerator implements IShadowGenerator {
  18150. /**
  18151. * Name of the shadow generator class
  18152. */
  18153. static CLASSNAME: string;
  18154. /**
  18155. * Shadow generator mode None: no filtering applied.
  18156. */
  18157. static readonly FILTER_NONE: number;
  18158. /**
  18159. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18160. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18161. */
  18162. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18163. /**
  18164. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18165. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18166. */
  18167. static readonly FILTER_POISSONSAMPLING: number;
  18168. /**
  18169. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18170. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18171. */
  18172. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18173. /**
  18174. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18175. * edge artifacts on steep falloff.
  18176. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18177. */
  18178. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18179. /**
  18180. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18181. * edge artifacts on steep falloff.
  18182. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18183. */
  18184. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18185. /**
  18186. * Shadow generator mode PCF: Percentage Closer Filtering
  18187. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18188. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18189. */
  18190. static readonly FILTER_PCF: number;
  18191. /**
  18192. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18193. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18194. * Contact Hardening
  18195. */
  18196. static readonly FILTER_PCSS: number;
  18197. /**
  18198. * Reserved for PCF and PCSS
  18199. * Highest Quality.
  18200. *
  18201. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18202. *
  18203. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18204. */
  18205. static readonly QUALITY_HIGH: number;
  18206. /**
  18207. * Reserved for PCF and PCSS
  18208. * Good tradeoff for quality/perf cross devices
  18209. *
  18210. * Execute PCF on a 3*3 kernel.
  18211. *
  18212. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18213. */
  18214. static readonly QUALITY_MEDIUM: number;
  18215. /**
  18216. * Reserved for PCF and PCSS
  18217. * The lowest quality but the fastest.
  18218. *
  18219. * Execute PCF on a 1*1 kernel.
  18220. *
  18221. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18222. */
  18223. static readonly QUALITY_LOW: number;
  18224. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18225. id: string;
  18226. /** Gets or sets the custom shader name to use */
  18227. customShaderOptions: ICustomShaderOptions;
  18228. /**
  18229. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18230. */
  18231. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18232. /**
  18233. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18234. */
  18235. onAfterShadowMapRenderObservable: Observable<Effect>;
  18236. /**
  18237. * Observable triggered before a mesh is rendered in the shadow map.
  18238. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18239. */
  18240. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18241. /**
  18242. * Observable triggered after a mesh is rendered in the shadow map.
  18243. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18244. */
  18245. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18246. protected _bias: number;
  18247. /**
  18248. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18249. */
  18250. get bias(): number;
  18251. /**
  18252. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18253. */
  18254. set bias(bias: number);
  18255. protected _normalBias: number;
  18256. /**
  18257. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18258. */
  18259. get normalBias(): number;
  18260. /**
  18261. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18262. */
  18263. set normalBias(normalBias: number);
  18264. protected _blurBoxOffset: number;
  18265. /**
  18266. * Gets the blur box offset: offset applied during the blur pass.
  18267. * Only useful if useKernelBlur = false
  18268. */
  18269. get blurBoxOffset(): number;
  18270. /**
  18271. * Sets the blur box offset: offset applied during the blur pass.
  18272. * Only useful if useKernelBlur = false
  18273. */
  18274. set blurBoxOffset(value: number);
  18275. protected _blurScale: number;
  18276. /**
  18277. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18278. * 2 means half of the size.
  18279. */
  18280. get blurScale(): number;
  18281. /**
  18282. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18283. * 2 means half of the size.
  18284. */
  18285. set blurScale(value: number);
  18286. protected _blurKernel: number;
  18287. /**
  18288. * Gets the blur kernel: kernel size of the blur pass.
  18289. * Only useful if useKernelBlur = true
  18290. */
  18291. get blurKernel(): number;
  18292. /**
  18293. * Sets the blur kernel: kernel size of the blur pass.
  18294. * Only useful if useKernelBlur = true
  18295. */
  18296. set blurKernel(value: number);
  18297. protected _useKernelBlur: boolean;
  18298. /**
  18299. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18300. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18301. */
  18302. get useKernelBlur(): boolean;
  18303. /**
  18304. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18305. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18306. */
  18307. set useKernelBlur(value: boolean);
  18308. protected _depthScale: number;
  18309. /**
  18310. * Gets the depth scale used in ESM mode.
  18311. */
  18312. get depthScale(): number;
  18313. /**
  18314. * Sets the depth scale used in ESM mode.
  18315. * This can override the scale stored on the light.
  18316. */
  18317. set depthScale(value: number);
  18318. protected _validateFilter(filter: number): number;
  18319. protected _filter: number;
  18320. /**
  18321. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18322. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18323. */
  18324. get filter(): number;
  18325. /**
  18326. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18327. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18328. */
  18329. set filter(value: number);
  18330. /**
  18331. * Gets if the current filter is set to Poisson Sampling.
  18332. */
  18333. get usePoissonSampling(): boolean;
  18334. /**
  18335. * Sets the current filter to Poisson Sampling.
  18336. */
  18337. set usePoissonSampling(value: boolean);
  18338. /**
  18339. * Gets if the current filter is set to ESM.
  18340. */
  18341. get useExponentialShadowMap(): boolean;
  18342. /**
  18343. * Sets the current filter is to ESM.
  18344. */
  18345. set useExponentialShadowMap(value: boolean);
  18346. /**
  18347. * Gets if the current filter is set to filtered ESM.
  18348. */
  18349. get useBlurExponentialShadowMap(): boolean;
  18350. /**
  18351. * Gets if the current filter is set to filtered ESM.
  18352. */
  18353. set useBlurExponentialShadowMap(value: boolean);
  18354. /**
  18355. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18356. * exponential to prevent steep falloff artifacts).
  18357. */
  18358. get useCloseExponentialShadowMap(): boolean;
  18359. /**
  18360. * Sets the current filter to "close ESM" (using the inverse of the
  18361. * exponential to prevent steep falloff artifacts).
  18362. */
  18363. set useCloseExponentialShadowMap(value: boolean);
  18364. /**
  18365. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18366. * exponential to prevent steep falloff artifacts).
  18367. */
  18368. get useBlurCloseExponentialShadowMap(): boolean;
  18369. /**
  18370. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18371. * exponential to prevent steep falloff artifacts).
  18372. */
  18373. set useBlurCloseExponentialShadowMap(value: boolean);
  18374. /**
  18375. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18376. */
  18377. get usePercentageCloserFiltering(): boolean;
  18378. /**
  18379. * Sets the current filter to "PCF" (percentage closer filtering).
  18380. */
  18381. set usePercentageCloserFiltering(value: boolean);
  18382. protected _filteringQuality: number;
  18383. /**
  18384. * Gets the PCF or PCSS Quality.
  18385. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18386. */
  18387. get filteringQuality(): number;
  18388. /**
  18389. * Sets the PCF or PCSS Quality.
  18390. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18391. */
  18392. set filteringQuality(filteringQuality: number);
  18393. /**
  18394. * Gets if the current filter is set to "PCSS" (contact hardening).
  18395. */
  18396. get useContactHardeningShadow(): boolean;
  18397. /**
  18398. * Sets the current filter to "PCSS" (contact hardening).
  18399. */
  18400. set useContactHardeningShadow(value: boolean);
  18401. protected _contactHardeningLightSizeUVRatio: number;
  18402. /**
  18403. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18404. * Using a ratio helps keeping shape stability independently of the map size.
  18405. *
  18406. * It does not account for the light projection as it was having too much
  18407. * instability during the light setup or during light position changes.
  18408. *
  18409. * Only valid if useContactHardeningShadow is true.
  18410. */
  18411. get contactHardeningLightSizeUVRatio(): number;
  18412. /**
  18413. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18414. * Using a ratio helps keeping shape stability independently of the map size.
  18415. *
  18416. * It does not account for the light projection as it was having too much
  18417. * instability during the light setup or during light position changes.
  18418. *
  18419. * Only valid if useContactHardeningShadow is true.
  18420. */
  18421. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18422. protected _darkness: number;
  18423. /** Gets or sets the actual darkness of a shadow */
  18424. get darkness(): number;
  18425. set darkness(value: number);
  18426. /**
  18427. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18428. * 0 means strongest and 1 would means no shadow.
  18429. * @returns the darkness.
  18430. */
  18431. getDarkness(): number;
  18432. /**
  18433. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18434. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18435. * @returns the shadow generator allowing fluent coding.
  18436. */
  18437. setDarkness(darkness: number): ShadowGenerator;
  18438. protected _transparencyShadow: boolean;
  18439. /** Gets or sets the ability to have transparent shadow */
  18440. get transparencyShadow(): boolean;
  18441. set transparencyShadow(value: boolean);
  18442. /**
  18443. * Sets the ability to have transparent shadow (boolean).
  18444. * @param transparent True if transparent else False
  18445. * @returns the shadow generator allowing fluent coding
  18446. */
  18447. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18448. /**
  18449. * Enables or disables shadows with varying strength based on the transparency
  18450. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18451. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18452. * mesh.visibility * alphaTexture.a
  18453. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18454. */
  18455. enableSoftTransparentShadow: boolean;
  18456. protected _shadowMap: Nullable<RenderTargetTexture>;
  18457. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18458. /**
  18459. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18460. * @returns The render target texture if present otherwise, null
  18461. */
  18462. getShadowMap(): Nullable<RenderTargetTexture>;
  18463. /**
  18464. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18465. * @returns The render target texture if the shadow map is present otherwise, null
  18466. */
  18467. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18468. /**
  18469. * Gets the class name of that object
  18470. * @returns "ShadowGenerator"
  18471. */
  18472. getClassName(): string;
  18473. /**
  18474. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18475. * @param mesh Mesh to add
  18476. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18477. * @returns the Shadow Generator itself
  18478. */
  18479. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18480. /**
  18481. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18482. * @param mesh Mesh to remove
  18483. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18484. * @returns the Shadow Generator itself
  18485. */
  18486. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18487. /**
  18488. * Controls the extent to which the shadows fade out at the edge of the frustum
  18489. */
  18490. frustumEdgeFalloff: number;
  18491. protected _light: IShadowLight;
  18492. /**
  18493. * Returns the associated light object.
  18494. * @returns the light generating the shadow
  18495. */
  18496. getLight(): IShadowLight;
  18497. /**
  18498. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18499. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18500. * It might on the other hand introduce peter panning.
  18501. */
  18502. forceBackFacesOnly: boolean;
  18503. protected _scene: Scene;
  18504. protected _lightDirection: Vector3;
  18505. protected _effect: Effect;
  18506. protected _viewMatrix: Matrix;
  18507. protected _projectionMatrix: Matrix;
  18508. protected _transformMatrix: Matrix;
  18509. protected _cachedPosition: Vector3;
  18510. protected _cachedDirection: Vector3;
  18511. protected _cachedDefines: string;
  18512. protected _currentRenderID: number;
  18513. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18514. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18515. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18516. protected _blurPostProcesses: PostProcess[];
  18517. protected _mapSize: number;
  18518. protected _currentFaceIndex: number;
  18519. protected _currentFaceIndexCache: number;
  18520. protected _textureType: number;
  18521. protected _defaultTextureMatrix: Matrix;
  18522. protected _storedUniqueId: Nullable<number>;
  18523. /** @hidden */
  18524. static _SceneComponentInitialization: (scene: Scene) => void;
  18525. /**
  18526. * Gets or sets the size of the texture what stores the shadows
  18527. */
  18528. get mapSize(): number;
  18529. set mapSize(size: number);
  18530. /**
  18531. * Creates a ShadowGenerator object.
  18532. * A ShadowGenerator is the required tool to use the shadows.
  18533. * Each light casting shadows needs to use its own ShadowGenerator.
  18534. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18535. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18536. * @param light The light object generating the shadows.
  18537. * @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.
  18538. */
  18539. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18540. protected _initializeGenerator(): void;
  18541. protected _createTargetRenderTexture(): void;
  18542. protected _initializeShadowMap(): void;
  18543. protected _initializeBlurRTTAndPostProcesses(): void;
  18544. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18545. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18546. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18547. protected _applyFilterValues(): void;
  18548. /**
  18549. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18550. * @param onCompiled Callback triggered at the and of the effects compilation
  18551. * @param options Sets of optional options forcing the compilation with different modes
  18552. */
  18553. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18554. useInstances: boolean;
  18555. }>): void;
  18556. /**
  18557. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18558. * @param options Sets of optional options forcing the compilation with different modes
  18559. * @returns A promise that resolves when the compilation completes
  18560. */
  18561. forceCompilationAsync(options?: Partial<{
  18562. useInstances: boolean;
  18563. }>): Promise<void>;
  18564. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18565. private _prepareShadowDefines;
  18566. /**
  18567. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18568. * @param subMesh The submesh we want to render in the shadow map
  18569. * @param useInstances Defines wether will draw in the map using instances
  18570. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18571. * @returns true if ready otherwise, false
  18572. */
  18573. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18574. /**
  18575. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18576. * @param defines Defines of the material we want to update
  18577. * @param lightIndex Index of the light in the enabled light list of the material
  18578. */
  18579. prepareDefines(defines: any, lightIndex: number): void;
  18580. /**
  18581. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18582. * defined in the generator but impacting the effect).
  18583. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18584. * @param effect The effect we are binfing the information for
  18585. */
  18586. bindShadowLight(lightIndex: string, effect: Effect): void;
  18587. /**
  18588. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18589. * (eq to shadow prjection matrix * light transform matrix)
  18590. * @returns The transform matrix used to create the shadow map
  18591. */
  18592. getTransformMatrix(): Matrix;
  18593. /**
  18594. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18595. * Cube and 2D textures for instance.
  18596. */
  18597. recreateShadowMap(): void;
  18598. protected _disposeBlurPostProcesses(): void;
  18599. protected _disposeRTTandPostProcesses(): void;
  18600. /**
  18601. * Disposes the ShadowGenerator.
  18602. * Returns nothing.
  18603. */
  18604. dispose(): void;
  18605. /**
  18606. * Serializes the shadow generator setup to a json object.
  18607. * @returns The serialized JSON object
  18608. */
  18609. serialize(): any;
  18610. /**
  18611. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18612. * @param parsedShadowGenerator The JSON object to parse
  18613. * @param scene The scene to create the shadow map for
  18614. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18615. * @returns The parsed shadow generator
  18616. */
  18617. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18618. }
  18619. }
  18620. declare module "babylonjs/Lights/light" {
  18621. import { Nullable } from "babylonjs/types";
  18622. import { Scene } from "babylonjs/scene";
  18623. import { Vector3 } from "babylonjs/Maths/math.vector";
  18624. import { Color3 } from "babylonjs/Maths/math.color";
  18625. import { Node } from "babylonjs/node";
  18626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18627. import { Effect } from "babylonjs/Materials/effect";
  18628. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18629. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18630. /**
  18631. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18632. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18633. * 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.
  18634. */
  18635. export abstract class Light extends Node {
  18636. /**
  18637. * Falloff Default: light is falling off following the material specification:
  18638. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18639. */
  18640. static readonly FALLOFF_DEFAULT: number;
  18641. /**
  18642. * Falloff Physical: light is falling off following the inverse squared distance law.
  18643. */
  18644. static readonly FALLOFF_PHYSICAL: number;
  18645. /**
  18646. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18647. * to enhance interoperability with other engines.
  18648. */
  18649. static readonly FALLOFF_GLTF: number;
  18650. /**
  18651. * Falloff Standard: light is falling off like in the standard material
  18652. * to enhance interoperability with other materials.
  18653. */
  18654. static readonly FALLOFF_STANDARD: number;
  18655. /**
  18656. * If every light affecting the material is in this lightmapMode,
  18657. * material.lightmapTexture adds or multiplies
  18658. * (depends on material.useLightmapAsShadowmap)
  18659. * after every other light calculations.
  18660. */
  18661. static readonly LIGHTMAP_DEFAULT: number;
  18662. /**
  18663. * material.lightmapTexture as only diffuse lighting from this light
  18664. * adds only specular lighting from this light
  18665. * adds dynamic shadows
  18666. */
  18667. static readonly LIGHTMAP_SPECULAR: number;
  18668. /**
  18669. * material.lightmapTexture as only lighting
  18670. * no light calculation from this light
  18671. * only adds dynamic shadows from this light
  18672. */
  18673. static readonly LIGHTMAP_SHADOWSONLY: number;
  18674. /**
  18675. * Each light type uses the default quantity according to its type:
  18676. * point/spot lights use luminous intensity
  18677. * directional lights use illuminance
  18678. */
  18679. static readonly INTENSITYMODE_AUTOMATIC: number;
  18680. /**
  18681. * lumen (lm)
  18682. */
  18683. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18684. /**
  18685. * candela (lm/sr)
  18686. */
  18687. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18688. /**
  18689. * lux (lm/m^2)
  18690. */
  18691. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18692. /**
  18693. * nit (cd/m^2)
  18694. */
  18695. static readonly INTENSITYMODE_LUMINANCE: number;
  18696. /**
  18697. * Light type const id of the point light.
  18698. */
  18699. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18700. /**
  18701. * Light type const id of the directional light.
  18702. */
  18703. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18704. /**
  18705. * Light type const id of the spot light.
  18706. */
  18707. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18708. /**
  18709. * Light type const id of the hemispheric light.
  18710. */
  18711. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18712. /**
  18713. * Diffuse gives the basic color to an object.
  18714. */
  18715. diffuse: Color3;
  18716. /**
  18717. * Specular produces a highlight color on an object.
  18718. * Note: This is note affecting PBR materials.
  18719. */
  18720. specular: Color3;
  18721. /**
  18722. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18723. * falling off base on range or angle.
  18724. * This can be set to any values in Light.FALLOFF_x.
  18725. *
  18726. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18727. * other types of materials.
  18728. */
  18729. falloffType: number;
  18730. /**
  18731. * Strength of the light.
  18732. * Note: By default it is define in the framework own unit.
  18733. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18734. */
  18735. intensity: number;
  18736. private _range;
  18737. protected _inverseSquaredRange: number;
  18738. /**
  18739. * Defines how far from the source the light is impacting in scene units.
  18740. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18741. */
  18742. get range(): number;
  18743. /**
  18744. * Defines how far from the source the light is impacting in scene units.
  18745. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18746. */
  18747. set range(value: number);
  18748. /**
  18749. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18750. * of light.
  18751. */
  18752. private _photometricScale;
  18753. private _intensityMode;
  18754. /**
  18755. * Gets the photometric scale used to interpret the intensity.
  18756. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18757. */
  18758. get intensityMode(): number;
  18759. /**
  18760. * Sets the photometric scale used to interpret the intensity.
  18761. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18762. */
  18763. set intensityMode(value: number);
  18764. private _radius;
  18765. /**
  18766. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18767. */
  18768. get radius(): number;
  18769. /**
  18770. * sets the light radius used by PBR Materials to simulate soft area lights.
  18771. */
  18772. set radius(value: number);
  18773. private _renderPriority;
  18774. /**
  18775. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18776. * exceeding the number allowed of the materials.
  18777. */
  18778. renderPriority: number;
  18779. private _shadowEnabled;
  18780. /**
  18781. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18782. * the current shadow generator.
  18783. */
  18784. get shadowEnabled(): boolean;
  18785. /**
  18786. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18787. * the current shadow generator.
  18788. */
  18789. set shadowEnabled(value: boolean);
  18790. private _includedOnlyMeshes;
  18791. /**
  18792. * Gets the only meshes impacted by this light.
  18793. */
  18794. get includedOnlyMeshes(): AbstractMesh[];
  18795. /**
  18796. * Sets the only meshes impacted by this light.
  18797. */
  18798. set includedOnlyMeshes(value: AbstractMesh[]);
  18799. private _excludedMeshes;
  18800. /**
  18801. * Gets the meshes not impacted by this light.
  18802. */
  18803. get excludedMeshes(): AbstractMesh[];
  18804. /**
  18805. * Sets the meshes not impacted by this light.
  18806. */
  18807. set excludedMeshes(value: AbstractMesh[]);
  18808. private _excludeWithLayerMask;
  18809. /**
  18810. * Gets the layer id use to find what meshes are not impacted by the light.
  18811. * Inactive if 0
  18812. */
  18813. get excludeWithLayerMask(): number;
  18814. /**
  18815. * Sets the layer id use to find what meshes are not impacted by the light.
  18816. * Inactive if 0
  18817. */
  18818. set excludeWithLayerMask(value: number);
  18819. private _includeOnlyWithLayerMask;
  18820. /**
  18821. * Gets the layer id use to find what meshes are impacted by the light.
  18822. * Inactive if 0
  18823. */
  18824. get includeOnlyWithLayerMask(): number;
  18825. /**
  18826. * Sets the layer id use to find what meshes are impacted by the light.
  18827. * Inactive if 0
  18828. */
  18829. set includeOnlyWithLayerMask(value: number);
  18830. private _lightmapMode;
  18831. /**
  18832. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18833. */
  18834. get lightmapMode(): number;
  18835. /**
  18836. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18837. */
  18838. set lightmapMode(value: number);
  18839. /**
  18840. * Shadow generator associted to the light.
  18841. * @hidden Internal use only.
  18842. */
  18843. _shadowGenerator: Nullable<IShadowGenerator>;
  18844. /**
  18845. * @hidden Internal use only.
  18846. */
  18847. _excludedMeshesIds: string[];
  18848. /**
  18849. * @hidden Internal use only.
  18850. */
  18851. _includedOnlyMeshesIds: string[];
  18852. /**
  18853. * The current light unifom buffer.
  18854. * @hidden Internal use only.
  18855. */
  18856. _uniformBuffer: UniformBuffer;
  18857. /** @hidden */
  18858. _renderId: number;
  18859. /**
  18860. * Creates a Light object in the scene.
  18861. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18862. * @param name The firendly name of the light
  18863. * @param scene The scene the light belongs too
  18864. */
  18865. constructor(name: string, scene: Scene);
  18866. protected abstract _buildUniformLayout(): void;
  18867. /**
  18868. * Sets the passed Effect "effect" with the Light information.
  18869. * @param effect The effect to update
  18870. * @param lightIndex The index of the light in the effect to update
  18871. * @returns The light
  18872. */
  18873. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18874. /**
  18875. * Sets the passed Effect "effect" with the Light textures.
  18876. * @param effect The effect to update
  18877. * @param lightIndex The index of the light in the effect to update
  18878. * @returns The light
  18879. */
  18880. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18881. /**
  18882. * Binds the lights information from the scene to the effect for the given mesh.
  18883. * @param lightIndex Light index
  18884. * @param scene The scene where the light belongs to
  18885. * @param effect The effect we are binding the data to
  18886. * @param useSpecular Defines if specular is supported
  18887. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18888. */
  18889. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18890. /**
  18891. * Sets the passed Effect "effect" with the Light information.
  18892. * @param effect The effect to update
  18893. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18894. * @returns The light
  18895. */
  18896. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18897. /**
  18898. * Returns the string "Light".
  18899. * @returns the class name
  18900. */
  18901. getClassName(): string;
  18902. /** @hidden */
  18903. readonly _isLight: boolean;
  18904. /**
  18905. * Converts the light information to a readable string for debug purpose.
  18906. * @param fullDetails Supports for multiple levels of logging within scene loading
  18907. * @returns the human readable light info
  18908. */
  18909. toString(fullDetails?: boolean): string;
  18910. /** @hidden */
  18911. protected _syncParentEnabledState(): void;
  18912. /**
  18913. * Set the enabled state of this node.
  18914. * @param value - the new enabled state
  18915. */
  18916. setEnabled(value: boolean): void;
  18917. /**
  18918. * Returns the Light associated shadow generator if any.
  18919. * @return the associated shadow generator.
  18920. */
  18921. getShadowGenerator(): Nullable<IShadowGenerator>;
  18922. /**
  18923. * Returns a Vector3, the absolute light position in the World.
  18924. * @returns the world space position of the light
  18925. */
  18926. getAbsolutePosition(): Vector3;
  18927. /**
  18928. * Specifies if the light will affect the passed mesh.
  18929. * @param mesh The mesh to test against the light
  18930. * @return true the mesh is affected otherwise, false.
  18931. */
  18932. canAffectMesh(mesh: AbstractMesh): boolean;
  18933. /**
  18934. * Sort function to order lights for rendering.
  18935. * @param a First Light object to compare to second.
  18936. * @param b Second Light object to compare first.
  18937. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18938. */
  18939. static CompareLightsPriority(a: Light, b: Light): number;
  18940. /**
  18941. * Releases resources associated with this node.
  18942. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18943. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18944. */
  18945. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18946. /**
  18947. * Returns the light type ID (integer).
  18948. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18949. */
  18950. getTypeID(): number;
  18951. /**
  18952. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18953. * @returns the scaled intensity in intensity mode unit
  18954. */
  18955. getScaledIntensity(): number;
  18956. /**
  18957. * Returns a new Light object, named "name", from the current one.
  18958. * @param name The name of the cloned light
  18959. * @param newParent The parent of this light, if it has one
  18960. * @returns the new created light
  18961. */
  18962. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18963. /**
  18964. * Serializes the current light into a Serialization object.
  18965. * @returns the serialized object.
  18966. */
  18967. serialize(): any;
  18968. /**
  18969. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18970. * This new light is named "name" and added to the passed scene.
  18971. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18972. * @param name The friendly name of the light
  18973. * @param scene The scene the new light will belong to
  18974. * @returns the constructor function
  18975. */
  18976. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18977. /**
  18978. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18979. * @param parsedLight The JSON representation of the light
  18980. * @param scene The scene to create the parsed light in
  18981. * @returns the created light after parsing
  18982. */
  18983. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18984. private _hookArrayForExcluded;
  18985. private _hookArrayForIncludedOnly;
  18986. private _resyncMeshes;
  18987. /**
  18988. * Forces the meshes to update their light related information in their rendering used effects
  18989. * @hidden Internal Use Only
  18990. */
  18991. _markMeshesAsLightDirty(): void;
  18992. /**
  18993. * Recomputes the cached photometric scale if needed.
  18994. */
  18995. private _computePhotometricScale;
  18996. /**
  18997. * Returns the Photometric Scale according to the light type and intensity mode.
  18998. */
  18999. private _getPhotometricScale;
  19000. /**
  19001. * Reorder the light in the scene according to their defined priority.
  19002. * @hidden Internal Use Only
  19003. */
  19004. _reorderLightsInScene(): void;
  19005. /**
  19006. * Prepares the list of defines specific to the light type.
  19007. * @param defines the list of defines
  19008. * @param lightIndex defines the index of the light for the effect
  19009. */
  19010. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19011. }
  19012. }
  19013. declare module "babylonjs/Materials/prePassConfiguration" {
  19014. import { Matrix } from "babylonjs/Maths/math.vector";
  19015. import { Mesh } from "babylonjs/Meshes/mesh";
  19016. import { Scene } from "babylonjs/scene";
  19017. import { Effect } from "babylonjs/Materials/effect";
  19018. /**
  19019. * Configuration needed for prepass-capable materials
  19020. */
  19021. export class PrePassConfiguration {
  19022. /**
  19023. * Previous world matrices of meshes carrying this material
  19024. * Used for computing velocity
  19025. */
  19026. previousWorldMatrices: {
  19027. [index: number]: Matrix;
  19028. };
  19029. /**
  19030. * Previous view project matrix
  19031. * Used for computing velocity
  19032. */
  19033. previousViewProjection: Matrix;
  19034. /**
  19035. * Previous bones of meshes carrying this material
  19036. * Used for computing velocity
  19037. */
  19038. previousBones: {
  19039. [index: number]: Float32Array;
  19040. };
  19041. /**
  19042. * Add the required uniforms to the current list.
  19043. * @param uniforms defines the current uniform list.
  19044. */
  19045. static AddUniforms(uniforms: string[]): void;
  19046. /**
  19047. * Add the required samplers to the current list.
  19048. * @param samplers defines the current sampler list.
  19049. */
  19050. static AddSamplers(samplers: string[]): void;
  19051. /**
  19052. * Binds the material data.
  19053. * @param effect defines the effect to update
  19054. * @param scene defines the scene the material belongs to.
  19055. * @param mesh The mesh
  19056. * @param world World matrix of this mesh
  19057. * @param isFrozen Is the material frozen
  19058. */
  19059. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  19060. }
  19061. }
  19062. declare module "babylonjs/Cameras/targetCamera" {
  19063. import { Nullable } from "babylonjs/types";
  19064. import { Camera } from "babylonjs/Cameras/camera";
  19065. import { Scene } from "babylonjs/scene";
  19066. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  19067. /**
  19068. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  19069. * This is the base of the follow, arc rotate cameras and Free camera
  19070. * @see https://doc.babylonjs.com/features/cameras
  19071. */
  19072. export class TargetCamera extends Camera {
  19073. private static _RigCamTransformMatrix;
  19074. private static _TargetTransformMatrix;
  19075. private static _TargetFocalPoint;
  19076. private _tmpUpVector;
  19077. private _tmpTargetVector;
  19078. /**
  19079. * Define the current direction the camera is moving to
  19080. */
  19081. cameraDirection: Vector3;
  19082. /**
  19083. * Define the current rotation the camera is rotating to
  19084. */
  19085. cameraRotation: Vector2;
  19086. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  19087. ignoreParentScaling: boolean;
  19088. /**
  19089. * When set, the up vector of the camera will be updated by the rotation of the camera
  19090. */
  19091. updateUpVectorFromRotation: boolean;
  19092. private _tmpQuaternion;
  19093. /**
  19094. * Define the current rotation of the camera
  19095. */
  19096. rotation: Vector3;
  19097. /**
  19098. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  19099. */
  19100. rotationQuaternion: Quaternion;
  19101. /**
  19102. * Define the current speed of the camera
  19103. */
  19104. speed: number;
  19105. /**
  19106. * Add constraint to the camera to prevent it to move freely in all directions and
  19107. * around all axis.
  19108. */
  19109. noRotationConstraint: boolean;
  19110. /**
  19111. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  19112. * panning
  19113. */
  19114. invertRotation: boolean;
  19115. /**
  19116. * Speed multiplier for inverse camera panning
  19117. */
  19118. inverseRotationSpeed: number;
  19119. /**
  19120. * Define the current target of the camera as an object or a position.
  19121. */
  19122. lockedTarget: any;
  19123. /** @hidden */
  19124. _currentTarget: Vector3;
  19125. /** @hidden */
  19126. _initialFocalDistance: number;
  19127. /** @hidden */
  19128. _viewMatrix: Matrix;
  19129. /** @hidden */
  19130. _camMatrix: Matrix;
  19131. /** @hidden */
  19132. _cameraTransformMatrix: Matrix;
  19133. /** @hidden */
  19134. _cameraRotationMatrix: Matrix;
  19135. /** @hidden */
  19136. _referencePoint: Vector3;
  19137. /** @hidden */
  19138. _transformedReferencePoint: Vector3;
  19139. /** @hidden */
  19140. _reset: () => void;
  19141. private _defaultUp;
  19142. /**
  19143. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19144. * This is the base of the follow, arc rotate cameras and Free camera
  19145. * @see https://doc.babylonjs.com/features/cameras
  19146. * @param name Defines the name of the camera in the scene
  19147. * @param position Defines the start position of the camera in the scene
  19148. * @param scene Defines the scene the camera belongs to
  19149. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19150. */
  19151. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19152. /**
  19153. * Gets the position in front of the camera at a given distance.
  19154. * @param distance The distance from the camera we want the position to be
  19155. * @returns the position
  19156. */
  19157. getFrontPosition(distance: number): Vector3;
  19158. /** @hidden */
  19159. _getLockedTargetPosition(): Nullable<Vector3>;
  19160. private _storedPosition;
  19161. private _storedRotation;
  19162. private _storedRotationQuaternion;
  19163. /**
  19164. * Store current camera state of the camera (fov, position, rotation, etc..)
  19165. * @returns the camera
  19166. */
  19167. storeState(): Camera;
  19168. /**
  19169. * Restored camera state. You must call storeState() first
  19170. * @returns whether it was successful or not
  19171. * @hidden
  19172. */
  19173. _restoreStateValues(): boolean;
  19174. /** @hidden */
  19175. _initCache(): void;
  19176. /** @hidden */
  19177. _updateCache(ignoreParentClass?: boolean): void;
  19178. /** @hidden */
  19179. _isSynchronizedViewMatrix(): boolean;
  19180. /** @hidden */
  19181. _computeLocalCameraSpeed(): number;
  19182. /**
  19183. * Defines the target the camera should look at.
  19184. * @param target Defines the new target as a Vector or a mesh
  19185. */
  19186. setTarget(target: Vector3): void;
  19187. /**
  19188. * Defines the target point of the camera.
  19189. * The camera looks towards it form the radius distance.
  19190. */
  19191. get target(): Vector3;
  19192. set target(value: Vector3);
  19193. /**
  19194. * Return the current target position of the camera. This value is expressed in local space.
  19195. * @returns the target position
  19196. */
  19197. getTarget(): Vector3;
  19198. /** @hidden */
  19199. _decideIfNeedsToMove(): boolean;
  19200. /** @hidden */
  19201. _updatePosition(): void;
  19202. /** @hidden */
  19203. _checkInputs(): void;
  19204. protected _updateCameraRotationMatrix(): void;
  19205. /**
  19206. * 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)
  19207. * @returns the current camera
  19208. */
  19209. private _rotateUpVectorWithCameraRotationMatrix;
  19210. private _cachedRotationZ;
  19211. private _cachedQuaternionRotationZ;
  19212. /** @hidden */
  19213. _getViewMatrix(): Matrix;
  19214. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19215. /**
  19216. * @hidden
  19217. */
  19218. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19219. /**
  19220. * @hidden
  19221. */
  19222. _updateRigCameras(): void;
  19223. private _getRigCamPositionAndTarget;
  19224. /**
  19225. * Gets the current object class name.
  19226. * @return the class name
  19227. */
  19228. getClassName(): string;
  19229. }
  19230. }
  19231. declare module "babylonjs/Events/keyboardEvents" {
  19232. /**
  19233. * Gather the list of keyboard event types as constants.
  19234. */
  19235. export class KeyboardEventTypes {
  19236. /**
  19237. * The keydown event is fired when a key becomes active (pressed).
  19238. */
  19239. static readonly KEYDOWN: number;
  19240. /**
  19241. * The keyup event is fired when a key has been released.
  19242. */
  19243. static readonly KEYUP: number;
  19244. }
  19245. /**
  19246. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19247. */
  19248. export class KeyboardInfo {
  19249. /**
  19250. * Defines the type of event (KeyboardEventTypes)
  19251. */
  19252. type: number;
  19253. /**
  19254. * Defines the related dom event
  19255. */
  19256. event: KeyboardEvent;
  19257. /**
  19258. * Instantiates a new keyboard info.
  19259. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19260. * @param type Defines the type of event (KeyboardEventTypes)
  19261. * @param event Defines the related dom event
  19262. */
  19263. constructor(
  19264. /**
  19265. * Defines the type of event (KeyboardEventTypes)
  19266. */
  19267. type: number,
  19268. /**
  19269. * Defines the related dom event
  19270. */
  19271. event: KeyboardEvent);
  19272. }
  19273. /**
  19274. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19275. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19276. */
  19277. export class KeyboardInfoPre extends KeyboardInfo {
  19278. /**
  19279. * Defines the type of event (KeyboardEventTypes)
  19280. */
  19281. type: number;
  19282. /**
  19283. * Defines the related dom event
  19284. */
  19285. event: KeyboardEvent;
  19286. /**
  19287. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19288. */
  19289. skipOnPointerObservable: boolean;
  19290. /**
  19291. * Instantiates a new keyboard pre info.
  19292. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19293. * @param type Defines the type of event (KeyboardEventTypes)
  19294. * @param event Defines the related dom event
  19295. */
  19296. constructor(
  19297. /**
  19298. * Defines the type of event (KeyboardEventTypes)
  19299. */
  19300. type: number,
  19301. /**
  19302. * Defines the related dom event
  19303. */
  19304. event: KeyboardEvent);
  19305. }
  19306. }
  19307. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19308. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19309. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19310. /**
  19311. * Manage the keyboard inputs to control the movement of a free camera.
  19312. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19313. */
  19314. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19315. /**
  19316. * Defines the camera the input is attached to.
  19317. */
  19318. camera: FreeCamera;
  19319. /**
  19320. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19321. */
  19322. keysUp: number[];
  19323. /**
  19324. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19325. */
  19326. keysUpward: number[];
  19327. /**
  19328. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19329. */
  19330. keysDown: number[];
  19331. /**
  19332. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19333. */
  19334. keysDownward: number[];
  19335. /**
  19336. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19337. */
  19338. keysLeft: number[];
  19339. /**
  19340. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19341. */
  19342. keysRight: number[];
  19343. private _keys;
  19344. private _onCanvasBlurObserver;
  19345. private _onKeyboardObserver;
  19346. private _engine;
  19347. private _scene;
  19348. /**
  19349. * Attach the input controls to a specific dom element to get the input from.
  19350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19351. */
  19352. attachControl(noPreventDefault?: boolean): void;
  19353. /**
  19354. * Detach the current controls from the specified dom element.
  19355. */
  19356. detachControl(): void;
  19357. /**
  19358. * Update the current camera state depending on the inputs that have been used this frame.
  19359. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19360. */
  19361. checkInputs(): void;
  19362. /**
  19363. * Gets the class name of the current intput.
  19364. * @returns the class name
  19365. */
  19366. getClassName(): string;
  19367. /** @hidden */
  19368. _onLostFocus(): void;
  19369. /**
  19370. * Get the friendly name associated with the input class.
  19371. * @returns the input friendly name
  19372. */
  19373. getSimpleName(): string;
  19374. }
  19375. }
  19376. declare module "babylonjs/Events/pointerEvents" {
  19377. import { Nullable } from "babylonjs/types";
  19378. import { Vector2 } from "babylonjs/Maths/math.vector";
  19379. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19380. import { Ray } from "babylonjs/Culling/ray";
  19381. /**
  19382. * Gather the list of pointer event types as constants.
  19383. */
  19384. export class PointerEventTypes {
  19385. /**
  19386. * 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.
  19387. */
  19388. static readonly POINTERDOWN: number;
  19389. /**
  19390. * The pointerup event is fired when a pointer is no longer active.
  19391. */
  19392. static readonly POINTERUP: number;
  19393. /**
  19394. * The pointermove event is fired when a pointer changes coordinates.
  19395. */
  19396. static readonly POINTERMOVE: number;
  19397. /**
  19398. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19399. */
  19400. static readonly POINTERWHEEL: number;
  19401. /**
  19402. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19403. */
  19404. static readonly POINTERPICK: number;
  19405. /**
  19406. * The pointertap event is fired when a the object has been touched and released without drag.
  19407. */
  19408. static readonly POINTERTAP: number;
  19409. /**
  19410. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19411. */
  19412. static readonly POINTERDOUBLETAP: number;
  19413. }
  19414. /**
  19415. * Base class of pointer info types.
  19416. */
  19417. export class PointerInfoBase {
  19418. /**
  19419. * Defines the type of event (PointerEventTypes)
  19420. */
  19421. type: number;
  19422. /**
  19423. * Defines the related dom event
  19424. */
  19425. event: PointerEvent | MouseWheelEvent;
  19426. /**
  19427. * Instantiates the base class of pointers info.
  19428. * @param type Defines the type of event (PointerEventTypes)
  19429. * @param event Defines the related dom event
  19430. */
  19431. constructor(
  19432. /**
  19433. * Defines the type of event (PointerEventTypes)
  19434. */
  19435. type: number,
  19436. /**
  19437. * Defines the related dom event
  19438. */
  19439. event: PointerEvent | MouseWheelEvent);
  19440. }
  19441. /**
  19442. * This class is used to store pointer related info for the onPrePointerObservable event.
  19443. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19444. */
  19445. export class PointerInfoPre extends PointerInfoBase {
  19446. /**
  19447. * Ray from a pointer if availible (eg. 6dof controller)
  19448. */
  19449. ray: Nullable<Ray>;
  19450. /**
  19451. * Defines the local position of the pointer on the canvas.
  19452. */
  19453. localPosition: Vector2;
  19454. /**
  19455. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19456. */
  19457. skipOnPointerObservable: boolean;
  19458. /**
  19459. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19460. * @param type Defines the type of event (PointerEventTypes)
  19461. * @param event Defines the related dom event
  19462. * @param localX Defines the local x coordinates of the pointer when the event occured
  19463. * @param localY Defines the local y coordinates of the pointer when the event occured
  19464. */
  19465. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19466. }
  19467. /**
  19468. * This type contains all the data related to a pointer event in Babylon.js.
  19469. * 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.
  19470. */
  19471. export class PointerInfo extends PointerInfoBase {
  19472. /**
  19473. * Defines the picking info associated to the info (if any)\
  19474. */
  19475. pickInfo: Nullable<PickingInfo>;
  19476. /**
  19477. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19478. * @param type Defines the type of event (PointerEventTypes)
  19479. * @param event Defines the related dom event
  19480. * @param pickInfo Defines the picking info associated to the info (if any)\
  19481. */
  19482. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19483. /**
  19484. * Defines the picking info associated to the info (if any)\
  19485. */
  19486. pickInfo: Nullable<PickingInfo>);
  19487. }
  19488. /**
  19489. * Data relating to a touch event on the screen.
  19490. */
  19491. export interface PointerTouch {
  19492. /**
  19493. * X coordinate of touch.
  19494. */
  19495. x: number;
  19496. /**
  19497. * Y coordinate of touch.
  19498. */
  19499. y: number;
  19500. /**
  19501. * Id of touch. Unique for each finger.
  19502. */
  19503. pointerId: number;
  19504. /**
  19505. * Event type passed from DOM.
  19506. */
  19507. type: any;
  19508. }
  19509. }
  19510. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19511. import { Observable } from "babylonjs/Misc/observable";
  19512. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19513. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19514. /**
  19515. * Manage the mouse inputs to control the movement of a free camera.
  19516. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19517. */
  19518. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19519. /**
  19520. * Define if touch is enabled in the mouse input
  19521. */
  19522. touchEnabled: boolean;
  19523. /**
  19524. * Defines the camera the input is attached to.
  19525. */
  19526. camera: FreeCamera;
  19527. /**
  19528. * Defines the buttons associated with the input to handle camera move.
  19529. */
  19530. buttons: number[];
  19531. /**
  19532. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19533. */
  19534. angularSensibility: number;
  19535. private _pointerInput;
  19536. private _onMouseMove;
  19537. private _observer;
  19538. private previousPosition;
  19539. /**
  19540. * Observable for when a pointer move event occurs containing the move offset
  19541. */
  19542. onPointerMovedObservable: Observable<{
  19543. offsetX: number;
  19544. offsetY: number;
  19545. }>;
  19546. /**
  19547. * @hidden
  19548. * If the camera should be rotated automatically based on pointer movement
  19549. */
  19550. _allowCameraRotation: boolean;
  19551. /**
  19552. * Manage the mouse inputs to control the movement of a free camera.
  19553. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19554. * @param touchEnabled Defines if touch is enabled or not
  19555. */
  19556. constructor(
  19557. /**
  19558. * Define if touch is enabled in the mouse input
  19559. */
  19560. touchEnabled?: boolean);
  19561. /**
  19562. * Attach the input controls to a specific dom element to get the input from.
  19563. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19564. */
  19565. attachControl(noPreventDefault?: boolean): void;
  19566. /**
  19567. * Called on JS contextmenu event.
  19568. * Override this method to provide functionality.
  19569. */
  19570. protected onContextMenu(evt: PointerEvent): void;
  19571. /**
  19572. * Detach the current controls from the specified dom element.
  19573. */
  19574. detachControl(): void;
  19575. /**
  19576. * Gets the class name of the current intput.
  19577. * @returns the class name
  19578. */
  19579. getClassName(): string;
  19580. /**
  19581. * Get the friendly name associated with the input class.
  19582. * @returns the input friendly name
  19583. */
  19584. getSimpleName(): string;
  19585. }
  19586. }
  19587. declare module "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput" {
  19588. import { Observable } from "babylonjs/Misc/observable";
  19589. import { Camera } from "babylonjs/Cameras/camera";
  19590. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19591. /**
  19592. * Base class for mouse wheel input..
  19593. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  19594. * for example usage.
  19595. */
  19596. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  19597. /**
  19598. * Defines the camera the input is attached to.
  19599. */
  19600. abstract camera: Camera;
  19601. /**
  19602. * How fast is the camera moves in relation to X axis mouseWheel events.
  19603. * Use negative value to reverse direction.
  19604. */
  19605. wheelPrecisionX: number;
  19606. /**
  19607. * How fast is the camera moves in relation to Y axis mouseWheel events.
  19608. * Use negative value to reverse direction.
  19609. */
  19610. wheelPrecisionY: number;
  19611. /**
  19612. * How fast is the camera moves in relation to Z axis mouseWheel events.
  19613. * Use negative value to reverse direction.
  19614. */
  19615. wheelPrecisionZ: number;
  19616. /**
  19617. * Observable for when a mouse wheel move event occurs.
  19618. */
  19619. onChangedObservable: Observable<{
  19620. wheelDeltaX: number;
  19621. wheelDeltaY: number;
  19622. wheelDeltaZ: number;
  19623. }>;
  19624. private _wheel;
  19625. private _observer;
  19626. /**
  19627. * Attach the input controls to a specific dom element to get the input from.
  19628. * @param noPreventDefault Defines whether event caught by the controls
  19629. * should call preventdefault().
  19630. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19631. */
  19632. attachControl(noPreventDefault?: boolean): void;
  19633. /**
  19634. * Detach the current controls from the specified dom element.
  19635. */
  19636. detachControl(): void;
  19637. /**
  19638. * Called for each rendered frame.
  19639. */
  19640. checkInputs(): void;
  19641. /**
  19642. * Gets the class name of the current intput.
  19643. * @returns the class name
  19644. */
  19645. getClassName(): string;
  19646. /**
  19647. * Get the friendly name associated with the input class.
  19648. * @returns the input friendly name
  19649. */
  19650. getSimpleName(): string;
  19651. /**
  19652. * Incremental value of multiple mouse wheel movements of the X axis.
  19653. * Should be zero-ed when read.
  19654. */
  19655. protected _wheelDeltaX: number;
  19656. /**
  19657. * Incremental value of multiple mouse wheel movements of the Y axis.
  19658. * Should be zero-ed when read.
  19659. */
  19660. protected _wheelDeltaY: number;
  19661. /**
  19662. * Incremental value of multiple mouse wheel movements of the Z axis.
  19663. * Should be zero-ed when read.
  19664. */
  19665. protected _wheelDeltaZ: number;
  19666. /**
  19667. * Firefox uses a different scheme to report scroll distances to other
  19668. * browsers. Rather than use complicated methods to calculate the exact
  19669. * multiple we need to apply, let's just cheat and use a constant.
  19670. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  19671. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  19672. */
  19673. private readonly _ffMultiplier;
  19674. /**
  19675. * Different event attributes for wheel data fall into a few set ranges.
  19676. * Some relevant but dated date here:
  19677. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  19678. */
  19679. private readonly _normalize;
  19680. }
  19681. }
  19682. declare module "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput" {
  19683. import { Nullable } from "babylonjs/types";
  19684. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19685. import { BaseCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  19686. import { Coordinate } from "babylonjs/Maths/math.axis";
  19687. /**
  19688. * Manage the mouse wheel inputs to control a free camera.
  19689. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19690. */
  19691. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  19692. /**
  19693. * Defines the camera the input is attached to.
  19694. */
  19695. camera: FreeCamera;
  19696. /**
  19697. * Gets the class name of the current input.
  19698. * @returns the class name
  19699. */
  19700. getClassName(): string;
  19701. /**
  19702. * Set which movement axis (relative to camera's orientation) the mouse
  19703. * wheel's X axis controls.
  19704. * @param axis The axis to be moved. Set null to clear.
  19705. */
  19706. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  19707. /**
  19708. * Get the configured movement axis (relative to camera's orientation) the
  19709. * mouse wheel's X axis controls.
  19710. * @returns The configured axis or null if none.
  19711. */
  19712. get wheelXMoveRelative(): Nullable<Coordinate>;
  19713. /**
  19714. * Set which movement axis (relative to camera's orientation) the mouse
  19715. * wheel's Y axis controls.
  19716. * @param axis The axis to be moved. Set null to clear.
  19717. */
  19718. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  19719. /**
  19720. * Get the configured movement axis (relative to camera's orientation) the
  19721. * mouse wheel's Y axis controls.
  19722. * @returns The configured axis or null if none.
  19723. */
  19724. get wheelYMoveRelative(): Nullable<Coordinate>;
  19725. /**
  19726. * Set which movement axis (relative to camera's orientation) the mouse
  19727. * wheel's Z axis controls.
  19728. * @param axis The axis to be moved. Set null to clear.
  19729. */
  19730. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  19731. /**
  19732. * Get the configured movement axis (relative to camera's orientation) the
  19733. * mouse wheel's Z axis controls.
  19734. * @returns The configured axis or null if none.
  19735. */
  19736. get wheelZMoveRelative(): Nullable<Coordinate>;
  19737. /**
  19738. * Set which rotation axis (relative to camera's orientation) the mouse
  19739. * wheel's X axis controls.
  19740. * @param axis The axis to be moved. Set null to clear.
  19741. */
  19742. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  19743. /**
  19744. * Get the configured rotation axis (relative to camera's orientation) the
  19745. * mouse wheel's X axis controls.
  19746. * @returns The configured axis or null if none.
  19747. */
  19748. get wheelXRotateRelative(): Nullable<Coordinate>;
  19749. /**
  19750. * Set which rotation axis (relative to camera's orientation) the mouse
  19751. * wheel's Y axis controls.
  19752. * @param axis The axis to be moved. Set null to clear.
  19753. */
  19754. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  19755. /**
  19756. * Get the configured rotation axis (relative to camera's orientation) the
  19757. * mouse wheel's Y axis controls.
  19758. * @returns The configured axis or null if none.
  19759. */
  19760. get wheelYRotateRelative(): Nullable<Coordinate>;
  19761. /**
  19762. * Set which rotation axis (relative to camera's orientation) the mouse
  19763. * wheel's Z axis controls.
  19764. * @param axis The axis to be moved. Set null to clear.
  19765. */
  19766. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  19767. /**
  19768. * Get the configured rotation axis (relative to camera's orientation) the
  19769. * mouse wheel's Z axis controls.
  19770. * @returns The configured axis or null if none.
  19771. */
  19772. get wheelZRotateRelative(): Nullable<Coordinate>;
  19773. /**
  19774. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  19775. * controls.
  19776. * @param axis The axis to be moved. Set null to clear.
  19777. */
  19778. set wheelXMoveScene(axis: Nullable<Coordinate>);
  19779. /**
  19780. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19781. * X axis controls.
  19782. * @returns The configured axis or null if none.
  19783. */
  19784. get wheelXMoveScene(): Nullable<Coordinate>;
  19785. /**
  19786. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  19787. * controls.
  19788. * @param axis The axis to be moved. Set null to clear.
  19789. */
  19790. set wheelYMoveScene(axis: Nullable<Coordinate>);
  19791. /**
  19792. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19793. * Y axis controls.
  19794. * @returns The configured axis or null if none.
  19795. */
  19796. get wheelYMoveScene(): Nullable<Coordinate>;
  19797. /**
  19798. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  19799. * controls.
  19800. * @param axis The axis to be moved. Set null to clear.
  19801. */
  19802. set wheelZMoveScene(axis: Nullable<Coordinate>);
  19803. /**
  19804. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19805. * Z axis controls.
  19806. * @returns The configured axis or null if none.
  19807. */
  19808. get wheelZMoveScene(): Nullable<Coordinate>;
  19809. /**
  19810. * Called for each rendered frame.
  19811. */
  19812. checkInputs(): void;
  19813. private _moveRelative;
  19814. private _rotateRelative;
  19815. private _moveScene;
  19816. /**
  19817. * These are set to the desired default behaviour.
  19818. */
  19819. private _wheelXAction;
  19820. private _wheelXActionCoordinate;
  19821. private _wheelYAction;
  19822. private _wheelYActionCoordinate;
  19823. private _wheelZAction;
  19824. private _wheelZActionCoordinate;
  19825. /**
  19826. * Update the camera according to any configured properties for the 3
  19827. * mouse-wheel axis.
  19828. */
  19829. private _updateCamera;
  19830. }
  19831. }
  19832. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19833. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19834. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19835. /**
  19836. * Manage the touch inputs to control the movement of a free camera.
  19837. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19838. */
  19839. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19840. /**
  19841. * Define if mouse events can be treated as touch events
  19842. */
  19843. allowMouse: boolean;
  19844. /**
  19845. * Defines the camera the input is attached to.
  19846. */
  19847. camera: FreeCamera;
  19848. /**
  19849. * Defines the touch sensibility for rotation.
  19850. * The higher the faster.
  19851. */
  19852. touchAngularSensibility: number;
  19853. /**
  19854. * Defines the touch sensibility for move.
  19855. * The higher the faster.
  19856. */
  19857. touchMoveSensibility: number;
  19858. private _offsetX;
  19859. private _offsetY;
  19860. private _pointerPressed;
  19861. private _pointerInput?;
  19862. private _observer;
  19863. private _onLostFocus;
  19864. /**
  19865. * Manage the touch inputs to control the movement of a free camera.
  19866. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19867. * @param allowMouse Defines if mouse events can be treated as touch events
  19868. */
  19869. constructor(
  19870. /**
  19871. * Define if mouse events can be treated as touch events
  19872. */
  19873. allowMouse?: boolean);
  19874. /**
  19875. * Attach the input controls to a specific dom element to get the input from.
  19876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19877. */
  19878. attachControl(noPreventDefault?: boolean): void;
  19879. /**
  19880. * Detach the current controls from the specified dom element.
  19881. * @param element Defines the element to stop listening the inputs from
  19882. */
  19883. detachControl(): void;
  19884. /**
  19885. * Update the current camera state depending on the inputs that have been used this frame.
  19886. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19887. */
  19888. checkInputs(): void;
  19889. /**
  19890. * Gets the class name of the current intput.
  19891. * @returns the class name
  19892. */
  19893. getClassName(): string;
  19894. /**
  19895. * Get the friendly name associated with the input class.
  19896. * @returns the input friendly name
  19897. */
  19898. getSimpleName(): string;
  19899. }
  19900. }
  19901. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19902. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19903. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19904. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19905. import { FreeCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  19906. import { Nullable } from "babylonjs/types";
  19907. /**
  19908. * Default Inputs manager for the FreeCamera.
  19909. * It groups all the default supported inputs for ease of use.
  19910. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19911. */
  19912. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19913. /**
  19914. * @hidden
  19915. */
  19916. _mouseInput: Nullable<FreeCameraMouseInput>;
  19917. /**
  19918. * @hidden
  19919. */
  19920. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  19921. /**
  19922. * Instantiates a new FreeCameraInputsManager.
  19923. * @param camera Defines the camera the inputs belong to
  19924. */
  19925. constructor(camera: FreeCamera);
  19926. /**
  19927. * Add keyboard input support to the input manager.
  19928. * @returns the current input manager
  19929. */
  19930. addKeyboard(): FreeCameraInputsManager;
  19931. /**
  19932. * Add mouse input support to the input manager.
  19933. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19934. * @returns the current input manager
  19935. */
  19936. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19937. /**
  19938. * Removes the mouse input support from the manager
  19939. * @returns the current input manager
  19940. */
  19941. removeMouse(): FreeCameraInputsManager;
  19942. /**
  19943. * Add mouse wheel input support to the input manager.
  19944. * @returns the current input manager
  19945. */
  19946. addMouseWheel(): FreeCameraInputsManager;
  19947. /**
  19948. * Removes the mouse wheel input support from the manager
  19949. * @returns the current input manager
  19950. */
  19951. removeMouseWheel(): FreeCameraInputsManager;
  19952. /**
  19953. * Add touch input support to the input manager.
  19954. * @returns the current input manager
  19955. */
  19956. addTouch(): FreeCameraInputsManager;
  19957. /**
  19958. * Remove all attached input methods from a camera
  19959. */
  19960. clear(): void;
  19961. }
  19962. }
  19963. declare module "babylonjs/Cameras/freeCamera" {
  19964. import { Vector3 } from "babylonjs/Maths/math.vector";
  19965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19966. import { Scene } from "babylonjs/scene";
  19967. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19968. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19969. /**
  19970. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19971. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19972. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19973. */
  19974. export class FreeCamera extends TargetCamera {
  19975. /**
  19976. * Define the collision ellipsoid of the camera.
  19977. * This is helpful to simulate a camera body like the player body around the camera
  19978. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19979. */
  19980. ellipsoid: Vector3;
  19981. /**
  19982. * Define an offset for the position of the ellipsoid around the camera.
  19983. * This can be helpful to determine the center of the body near the gravity center of the body
  19984. * instead of its head.
  19985. */
  19986. ellipsoidOffset: Vector3;
  19987. /**
  19988. * Enable or disable collisions of the camera with the rest of the scene objects.
  19989. */
  19990. checkCollisions: boolean;
  19991. /**
  19992. * Enable or disable gravity on the camera.
  19993. */
  19994. applyGravity: boolean;
  19995. /**
  19996. * Define the input manager associated to the camera.
  19997. */
  19998. inputs: FreeCameraInputsManager;
  19999. /**
  20000. * Gets the input sensibility for a mouse input. (default is 2000.0)
  20001. * Higher values reduce sensitivity.
  20002. */
  20003. get angularSensibility(): number;
  20004. /**
  20005. * Sets the input sensibility for a mouse input. (default is 2000.0)
  20006. * Higher values reduce sensitivity.
  20007. */
  20008. set angularSensibility(value: number);
  20009. /**
  20010. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  20011. */
  20012. get keysUp(): number[];
  20013. set keysUp(value: number[]);
  20014. /**
  20015. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  20016. */
  20017. get keysUpward(): number[];
  20018. set keysUpward(value: number[]);
  20019. /**
  20020. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  20021. */
  20022. get keysDown(): number[];
  20023. set keysDown(value: number[]);
  20024. /**
  20025. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  20026. */
  20027. get keysDownward(): number[];
  20028. set keysDownward(value: number[]);
  20029. /**
  20030. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  20031. */
  20032. get keysLeft(): number[];
  20033. set keysLeft(value: number[]);
  20034. /**
  20035. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  20036. */
  20037. get keysRight(): number[];
  20038. set keysRight(value: number[]);
  20039. /**
  20040. * Event raised when the camera collide with a mesh in the scene.
  20041. */
  20042. onCollide: (collidedMesh: AbstractMesh) => void;
  20043. private _collider;
  20044. private _needMoveForGravity;
  20045. private _oldPosition;
  20046. private _diffPosition;
  20047. private _newPosition;
  20048. /** @hidden */
  20049. _localDirection: Vector3;
  20050. /** @hidden */
  20051. _transformedDirection: Vector3;
  20052. /**
  20053. * Instantiates a Free Camera.
  20054. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  20055. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  20056. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  20057. * @param name Define the name of the camera in the scene
  20058. * @param position Define the start position of the camera in the scene
  20059. * @param scene Define the scene the camera belongs to
  20060. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  20061. */
  20062. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  20063. /**
  20064. * Attached controls to the current camera.
  20065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20066. */
  20067. attachControl(noPreventDefault?: boolean): void;
  20068. /**
  20069. * Detach the current controls from the camera.
  20070. * The camera will stop reacting to inputs.
  20071. */
  20072. detachControl(): void;
  20073. private _collisionMask;
  20074. /**
  20075. * Define a collision mask to limit the list of object the camera can collide with
  20076. */
  20077. get collisionMask(): number;
  20078. set collisionMask(mask: number);
  20079. /** @hidden */
  20080. _collideWithWorld(displacement: Vector3): void;
  20081. private _onCollisionPositionChange;
  20082. /** @hidden */
  20083. _checkInputs(): void;
  20084. /** @hidden */
  20085. _decideIfNeedsToMove(): boolean;
  20086. /** @hidden */
  20087. _updatePosition(): void;
  20088. /**
  20089. * Destroy the camera and release the current resources hold by it.
  20090. */
  20091. dispose(): void;
  20092. /**
  20093. * Gets the current object class name.
  20094. * @return the class name
  20095. */
  20096. getClassName(): string;
  20097. }
  20098. }
  20099. declare module "babylonjs/Gamepads/gamepad" {
  20100. import { Observable } from "babylonjs/Misc/observable";
  20101. /**
  20102. * Represents a gamepad control stick position
  20103. */
  20104. export class StickValues {
  20105. /**
  20106. * The x component of the control stick
  20107. */
  20108. x: number;
  20109. /**
  20110. * The y component of the control stick
  20111. */
  20112. y: number;
  20113. /**
  20114. * Initializes the gamepad x and y control stick values
  20115. * @param x The x component of the gamepad control stick value
  20116. * @param y The y component of the gamepad control stick value
  20117. */
  20118. constructor(
  20119. /**
  20120. * The x component of the control stick
  20121. */
  20122. x: number,
  20123. /**
  20124. * The y component of the control stick
  20125. */
  20126. y: number);
  20127. }
  20128. /**
  20129. * An interface which manages callbacks for gamepad button changes
  20130. */
  20131. export interface GamepadButtonChanges {
  20132. /**
  20133. * Called when a gamepad has been changed
  20134. */
  20135. changed: boolean;
  20136. /**
  20137. * Called when a gamepad press event has been triggered
  20138. */
  20139. pressChanged: boolean;
  20140. /**
  20141. * Called when a touch event has been triggered
  20142. */
  20143. touchChanged: boolean;
  20144. /**
  20145. * Called when a value has changed
  20146. */
  20147. valueChanged: boolean;
  20148. }
  20149. /**
  20150. * Represents a gamepad
  20151. */
  20152. export class Gamepad {
  20153. /**
  20154. * The id of the gamepad
  20155. */
  20156. id: string;
  20157. /**
  20158. * The index of the gamepad
  20159. */
  20160. index: number;
  20161. /**
  20162. * The browser gamepad
  20163. */
  20164. browserGamepad: any;
  20165. /**
  20166. * Specifies what type of gamepad this represents
  20167. */
  20168. type: number;
  20169. private _leftStick;
  20170. private _rightStick;
  20171. /** @hidden */
  20172. _isConnected: boolean;
  20173. private _leftStickAxisX;
  20174. private _leftStickAxisY;
  20175. private _rightStickAxisX;
  20176. private _rightStickAxisY;
  20177. /**
  20178. * Triggered when the left control stick has been changed
  20179. */
  20180. private _onleftstickchanged;
  20181. /**
  20182. * Triggered when the right control stick has been changed
  20183. */
  20184. private _onrightstickchanged;
  20185. /**
  20186. * Represents a gamepad controller
  20187. */
  20188. static GAMEPAD: number;
  20189. /**
  20190. * Represents a generic controller
  20191. */
  20192. static GENERIC: number;
  20193. /**
  20194. * Represents an XBox controller
  20195. */
  20196. static XBOX: number;
  20197. /**
  20198. * Represents a pose-enabled controller
  20199. */
  20200. static POSE_ENABLED: number;
  20201. /**
  20202. * Represents an Dual Shock controller
  20203. */
  20204. static DUALSHOCK: number;
  20205. /**
  20206. * Specifies whether the left control stick should be Y-inverted
  20207. */
  20208. protected _invertLeftStickY: boolean;
  20209. /**
  20210. * Specifies if the gamepad has been connected
  20211. */
  20212. get isConnected(): boolean;
  20213. /**
  20214. * Initializes the gamepad
  20215. * @param id The id of the gamepad
  20216. * @param index The index of the gamepad
  20217. * @param browserGamepad The browser gamepad
  20218. * @param leftStickX The x component of the left joystick
  20219. * @param leftStickY The y component of the left joystick
  20220. * @param rightStickX The x component of the right joystick
  20221. * @param rightStickY The y component of the right joystick
  20222. */
  20223. constructor(
  20224. /**
  20225. * The id of the gamepad
  20226. */
  20227. id: string,
  20228. /**
  20229. * The index of the gamepad
  20230. */
  20231. index: number,
  20232. /**
  20233. * The browser gamepad
  20234. */
  20235. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  20236. /**
  20237. * Callback triggered when the left joystick has changed
  20238. * @param callback
  20239. */
  20240. onleftstickchanged(callback: (values: StickValues) => void): void;
  20241. /**
  20242. * Callback triggered when the right joystick has changed
  20243. * @param callback
  20244. */
  20245. onrightstickchanged(callback: (values: StickValues) => void): void;
  20246. /**
  20247. * Gets the left joystick
  20248. */
  20249. get leftStick(): StickValues;
  20250. /**
  20251. * Sets the left joystick values
  20252. */
  20253. set leftStick(newValues: StickValues);
  20254. /**
  20255. * Gets the right joystick
  20256. */
  20257. get rightStick(): StickValues;
  20258. /**
  20259. * Sets the right joystick value
  20260. */
  20261. set rightStick(newValues: StickValues);
  20262. /**
  20263. * Updates the gamepad joystick positions
  20264. */
  20265. update(): void;
  20266. /**
  20267. * Disposes the gamepad
  20268. */
  20269. dispose(): void;
  20270. }
  20271. /**
  20272. * Represents a generic gamepad
  20273. */
  20274. export class GenericPad extends Gamepad {
  20275. private _buttons;
  20276. private _onbuttondown;
  20277. private _onbuttonup;
  20278. /**
  20279. * Observable triggered when a button has been pressed
  20280. */
  20281. onButtonDownObservable: Observable<number>;
  20282. /**
  20283. * Observable triggered when a button has been released
  20284. */
  20285. onButtonUpObservable: Observable<number>;
  20286. /**
  20287. * Callback triggered when a button has been pressed
  20288. * @param callback Called when a button has been pressed
  20289. */
  20290. onbuttondown(callback: (buttonPressed: number) => void): void;
  20291. /**
  20292. * Callback triggered when a button has been released
  20293. * @param callback Called when a button has been released
  20294. */
  20295. onbuttonup(callback: (buttonReleased: number) => void): void;
  20296. /**
  20297. * Initializes the generic gamepad
  20298. * @param id The id of the generic gamepad
  20299. * @param index The index of the generic gamepad
  20300. * @param browserGamepad The browser gamepad
  20301. */
  20302. constructor(id: string, index: number, browserGamepad: any);
  20303. private _setButtonValue;
  20304. /**
  20305. * Updates the generic gamepad
  20306. */
  20307. update(): void;
  20308. /**
  20309. * Disposes the generic gamepad
  20310. */
  20311. dispose(): void;
  20312. }
  20313. }
  20314. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  20315. import { Observable } from "babylonjs/Misc/observable";
  20316. import { Nullable } from "babylonjs/types";
  20317. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20318. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20320. import { Ray } from "babylonjs/Culling/ray";
  20321. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  20322. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  20323. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  20324. /**
  20325. * Defines the types of pose enabled controllers that are supported
  20326. */
  20327. export enum PoseEnabledControllerType {
  20328. /**
  20329. * HTC Vive
  20330. */
  20331. VIVE = 0,
  20332. /**
  20333. * Oculus Rift
  20334. */
  20335. OCULUS = 1,
  20336. /**
  20337. * Windows mixed reality
  20338. */
  20339. WINDOWS = 2,
  20340. /**
  20341. * Samsung gear VR
  20342. */
  20343. GEAR_VR = 3,
  20344. /**
  20345. * Google Daydream
  20346. */
  20347. DAYDREAM = 4,
  20348. /**
  20349. * Generic
  20350. */
  20351. GENERIC = 5
  20352. }
  20353. /**
  20354. * Defines the MutableGamepadButton interface for the state of a gamepad button
  20355. */
  20356. export interface MutableGamepadButton {
  20357. /**
  20358. * Value of the button/trigger
  20359. */
  20360. value: number;
  20361. /**
  20362. * If the button/trigger is currently touched
  20363. */
  20364. touched: boolean;
  20365. /**
  20366. * If the button/trigger is currently pressed
  20367. */
  20368. pressed: boolean;
  20369. }
  20370. /**
  20371. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20372. * @hidden
  20373. */
  20374. export interface ExtendedGamepadButton extends GamepadButton {
  20375. /**
  20376. * If the button/trigger is currently pressed
  20377. */
  20378. readonly pressed: boolean;
  20379. /**
  20380. * If the button/trigger is currently touched
  20381. */
  20382. readonly touched: boolean;
  20383. /**
  20384. * Value of the button/trigger
  20385. */
  20386. readonly value: number;
  20387. }
  20388. /** @hidden */
  20389. export interface _GamePadFactory {
  20390. /**
  20391. * Returns whether or not the current gamepad can be created for this type of controller.
  20392. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20393. * @returns true if it can be created, otherwise false
  20394. */
  20395. canCreate(gamepadInfo: any): boolean;
  20396. /**
  20397. * Creates a new instance of the Gamepad.
  20398. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20399. * @returns the new gamepad instance
  20400. */
  20401. create(gamepadInfo: any): Gamepad;
  20402. }
  20403. /**
  20404. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20405. */
  20406. export class PoseEnabledControllerHelper {
  20407. /** @hidden */
  20408. static _ControllerFactories: _GamePadFactory[];
  20409. /** @hidden */
  20410. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20411. /**
  20412. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20413. * @param vrGamepad the gamepad to initialized
  20414. * @returns a vr controller of the type the gamepad identified as
  20415. */
  20416. static InitiateController(vrGamepad: any): Gamepad;
  20417. }
  20418. /**
  20419. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20420. */
  20421. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20422. /**
  20423. * If the controller is used in a webXR session
  20424. */
  20425. isXR: boolean;
  20426. private _deviceRoomPosition;
  20427. private _deviceRoomRotationQuaternion;
  20428. /**
  20429. * The device position in babylon space
  20430. */
  20431. devicePosition: Vector3;
  20432. /**
  20433. * The device rotation in babylon space
  20434. */
  20435. deviceRotationQuaternion: Quaternion;
  20436. /**
  20437. * The scale factor of the device in babylon space
  20438. */
  20439. deviceScaleFactor: number;
  20440. /**
  20441. * (Likely devicePosition should be used instead) The device position in its room space
  20442. */
  20443. position: Vector3;
  20444. /**
  20445. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20446. */
  20447. rotationQuaternion: Quaternion;
  20448. /**
  20449. * The type of controller (Eg. Windows mixed reality)
  20450. */
  20451. controllerType: PoseEnabledControllerType;
  20452. protected _calculatedPosition: Vector3;
  20453. private _calculatedRotation;
  20454. /**
  20455. * The raw pose from the device
  20456. */
  20457. rawPose: DevicePose;
  20458. private _trackPosition;
  20459. private _maxRotationDistFromHeadset;
  20460. private _draggedRoomRotation;
  20461. /**
  20462. * @hidden
  20463. */
  20464. _disableTrackPosition(fixedPosition: Vector3): void;
  20465. /**
  20466. * Internal, the mesh attached to the controller
  20467. * @hidden
  20468. */
  20469. _mesh: Nullable<AbstractMesh>;
  20470. private _poseControlledCamera;
  20471. private _leftHandSystemQuaternion;
  20472. /**
  20473. * Internal, matrix used to convert room space to babylon space
  20474. * @hidden
  20475. */
  20476. _deviceToWorld: Matrix;
  20477. /**
  20478. * Node to be used when casting a ray from the controller
  20479. * @hidden
  20480. */
  20481. _pointingPoseNode: Nullable<TransformNode>;
  20482. /**
  20483. * Name of the child mesh that can be used to cast a ray from the controller
  20484. */
  20485. static readonly POINTING_POSE: string;
  20486. /**
  20487. * Creates a new PoseEnabledController from a gamepad
  20488. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20489. */
  20490. constructor(browserGamepad: any);
  20491. private _workingMatrix;
  20492. /**
  20493. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20494. */
  20495. update(): void;
  20496. /**
  20497. * Updates only the pose device and mesh without doing any button event checking
  20498. */
  20499. protected _updatePoseAndMesh(): void;
  20500. /**
  20501. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20502. * @param poseData raw pose fromthe device
  20503. */
  20504. updateFromDevice(poseData: DevicePose): void;
  20505. /**
  20506. * @hidden
  20507. */
  20508. _meshAttachedObservable: Observable<AbstractMesh>;
  20509. /**
  20510. * Attaches a mesh to the controller
  20511. * @param mesh the mesh to be attached
  20512. */
  20513. attachToMesh(mesh: AbstractMesh): void;
  20514. /**
  20515. * Attaches the controllers mesh to a camera
  20516. * @param camera the camera the mesh should be attached to
  20517. */
  20518. attachToPoseControlledCamera(camera: TargetCamera): void;
  20519. /**
  20520. * Disposes of the controller
  20521. */
  20522. dispose(): void;
  20523. /**
  20524. * The mesh that is attached to the controller
  20525. */
  20526. get mesh(): Nullable<AbstractMesh>;
  20527. /**
  20528. * Gets the ray of the controller in the direction the controller is pointing
  20529. * @param length the length the resulting ray should be
  20530. * @returns a ray in the direction the controller is pointing
  20531. */
  20532. getForwardRay(length?: number): Ray;
  20533. }
  20534. }
  20535. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20536. import { Observable } from "babylonjs/Misc/observable";
  20537. import { Scene } from "babylonjs/scene";
  20538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20539. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20540. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20541. import { Nullable } from "babylonjs/types";
  20542. /**
  20543. * Defines the WebVRController object that represents controllers tracked in 3D space
  20544. */
  20545. export abstract class WebVRController extends PoseEnabledController {
  20546. /**
  20547. * Internal, the default controller model for the controller
  20548. */
  20549. protected _defaultModel: Nullable<AbstractMesh>;
  20550. /**
  20551. * Fired when the trigger state has changed
  20552. */
  20553. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20554. /**
  20555. * Fired when the main button state has changed
  20556. */
  20557. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20558. /**
  20559. * Fired when the secondary button state has changed
  20560. */
  20561. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20562. /**
  20563. * Fired when the pad state has changed
  20564. */
  20565. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20566. /**
  20567. * Fired when controllers stick values have changed
  20568. */
  20569. onPadValuesChangedObservable: Observable<StickValues>;
  20570. /**
  20571. * Array of button availible on the controller
  20572. */
  20573. protected _buttons: Array<MutableGamepadButton>;
  20574. private _onButtonStateChange;
  20575. /**
  20576. * Fired when a controller button's state has changed
  20577. * @param callback the callback containing the button that was modified
  20578. */
  20579. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20580. /**
  20581. * X and Y axis corresponding to the controllers joystick
  20582. */
  20583. pad: StickValues;
  20584. /**
  20585. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20586. */
  20587. hand: string;
  20588. /**
  20589. * The default controller model for the controller
  20590. */
  20591. get defaultModel(): Nullable<AbstractMesh>;
  20592. /**
  20593. * Creates a new WebVRController from a gamepad
  20594. * @param vrGamepad the gamepad that the WebVRController should be created from
  20595. */
  20596. constructor(vrGamepad: any);
  20597. /**
  20598. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20599. */
  20600. update(): void;
  20601. /**
  20602. * Function to be called when a button is modified
  20603. */
  20604. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20605. /**
  20606. * Loads a mesh and attaches it to the controller
  20607. * @param scene the scene the mesh should be added to
  20608. * @param meshLoaded callback for when the mesh has been loaded
  20609. */
  20610. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20611. private _setButtonValue;
  20612. private _changes;
  20613. private _checkChanges;
  20614. /**
  20615. * Disposes of th webVRCOntroller
  20616. */
  20617. dispose(): void;
  20618. }
  20619. }
  20620. declare module "babylonjs/Lights/hemisphericLight" {
  20621. import { Nullable } from "babylonjs/types";
  20622. import { Scene } from "babylonjs/scene";
  20623. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20624. import { Color3 } from "babylonjs/Maths/math.color";
  20625. import { Effect } from "babylonjs/Materials/effect";
  20626. import { Light } from "babylonjs/Lights/light";
  20627. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20628. /**
  20629. * The HemisphericLight simulates the ambient environment light,
  20630. * so the passed direction is the light reflection direction, not the incoming direction.
  20631. */
  20632. export class HemisphericLight extends Light {
  20633. /**
  20634. * The groundColor is the light in the opposite direction to the one specified during creation.
  20635. * 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.
  20636. */
  20637. groundColor: Color3;
  20638. /**
  20639. * The light reflection direction, not the incoming direction.
  20640. */
  20641. direction: Vector3;
  20642. /**
  20643. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20644. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20645. * The HemisphericLight can't cast shadows.
  20646. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20647. * @param name The friendly name of the light
  20648. * @param direction The direction of the light reflection
  20649. * @param scene The scene the light belongs to
  20650. */
  20651. constructor(name: string, direction: Vector3, scene: Scene);
  20652. protected _buildUniformLayout(): void;
  20653. /**
  20654. * Returns the string "HemisphericLight".
  20655. * @return The class name
  20656. */
  20657. getClassName(): string;
  20658. /**
  20659. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20660. * Returns the updated direction.
  20661. * @param target The target the direction should point to
  20662. * @return The computed direction
  20663. */
  20664. setDirectionToTarget(target: Vector3): Vector3;
  20665. /**
  20666. * Returns the shadow generator associated to the light.
  20667. * @returns Always null for hemispheric lights because it does not support shadows.
  20668. */
  20669. getShadowGenerator(): Nullable<IShadowGenerator>;
  20670. /**
  20671. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20672. * @param effect The effect to update
  20673. * @param lightIndex The index of the light in the effect to update
  20674. * @returns The hemispheric light
  20675. */
  20676. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20677. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20678. /**
  20679. * Computes the world matrix of the node
  20680. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20681. * @param useWasUpdatedFlag defines a reserved property
  20682. * @returns the world matrix
  20683. */
  20684. computeWorldMatrix(): Matrix;
  20685. /**
  20686. * Returns the integer 3.
  20687. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20688. */
  20689. getTypeID(): number;
  20690. /**
  20691. * Prepares the list of defines specific to the light type.
  20692. * @param defines the list of defines
  20693. * @param lightIndex defines the index of the light for the effect
  20694. */
  20695. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20696. }
  20697. }
  20698. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20699. /** @hidden */
  20700. export var vrMultiviewToSingleviewPixelShader: {
  20701. name: string;
  20702. shader: string;
  20703. };
  20704. }
  20705. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20706. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20707. import { Scene } from "babylonjs/scene";
  20708. /**
  20709. * Renders to multiple views with a single draw call
  20710. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20711. */
  20712. export class MultiviewRenderTarget extends RenderTargetTexture {
  20713. /**
  20714. * Creates a multiview render target
  20715. * @param scene scene used with the render target
  20716. * @param size the size of the render target (used for each view)
  20717. */
  20718. constructor(scene: Scene, size?: number | {
  20719. width: number;
  20720. height: number;
  20721. } | {
  20722. ratio: number;
  20723. });
  20724. /**
  20725. * @hidden
  20726. * @param faceIndex the face index, if its a cube texture
  20727. */
  20728. _bindFrameBuffer(faceIndex?: number): void;
  20729. /**
  20730. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20731. * @returns the view count
  20732. */
  20733. getViewCount(): number;
  20734. }
  20735. }
  20736. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20737. import { Camera } from "babylonjs/Cameras/camera";
  20738. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20739. import { Nullable } from "babylonjs/types";
  20740. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20741. import { Matrix } from "babylonjs/Maths/math.vector";
  20742. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20743. module "babylonjs/Engines/engine" {
  20744. interface Engine {
  20745. /**
  20746. * Creates a new multiview render target
  20747. * @param width defines the width of the texture
  20748. * @param height defines the height of the texture
  20749. * @returns the created multiview texture
  20750. */
  20751. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20752. /**
  20753. * Binds a multiview framebuffer to be drawn to
  20754. * @param multiviewTexture texture to bind
  20755. */
  20756. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20757. }
  20758. }
  20759. module "babylonjs/Cameras/camera" {
  20760. interface Camera {
  20761. /**
  20762. * @hidden
  20763. * 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)
  20764. */
  20765. _useMultiviewToSingleView: boolean;
  20766. /**
  20767. * @hidden
  20768. * 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)
  20769. */
  20770. _multiviewTexture: Nullable<RenderTargetTexture>;
  20771. /**
  20772. * @hidden
  20773. * ensures the multiview texture of the camera exists and has the specified width/height
  20774. * @param width height to set on the multiview texture
  20775. * @param height width to set on the multiview texture
  20776. */
  20777. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20778. }
  20779. }
  20780. module "babylonjs/scene" {
  20781. interface Scene {
  20782. /** @hidden */
  20783. _transformMatrixR: Matrix;
  20784. /** @hidden */
  20785. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20786. /** @hidden */
  20787. _createMultiviewUbo(): void;
  20788. /** @hidden */
  20789. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20790. /** @hidden */
  20791. _renderMultiviewToSingleView(camera: Camera): void;
  20792. }
  20793. }
  20794. }
  20795. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20796. import { Camera } from "babylonjs/Cameras/camera";
  20797. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20798. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20799. import "babylonjs/Engines/Extensions/engine.multiview";
  20800. /**
  20801. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20802. * This will not be used for webXR as it supports displaying texture arrays directly
  20803. */
  20804. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20805. /**
  20806. * Gets a string identifying the name of the class
  20807. * @returns "VRMultiviewToSingleviewPostProcess" string
  20808. */
  20809. getClassName(): string;
  20810. /**
  20811. * Initializes a VRMultiviewToSingleview
  20812. * @param name name of the post process
  20813. * @param camera camera to be applied to
  20814. * @param scaleFactor scaling factor to the size of the output texture
  20815. */
  20816. constructor(name: string, camera: Camera, scaleFactor: number);
  20817. }
  20818. }
  20819. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20820. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20821. import { Nullable } from "babylonjs/types";
  20822. import { Size } from "babylonjs/Maths/math.size";
  20823. import { Observable } from "babylonjs/Misc/observable";
  20824. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20825. /**
  20826. * Interface used to define additional presentation attributes
  20827. */
  20828. export interface IVRPresentationAttributes {
  20829. /**
  20830. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20831. */
  20832. highRefreshRate: boolean;
  20833. /**
  20834. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20835. */
  20836. foveationLevel: number;
  20837. }
  20838. module "babylonjs/Engines/engine" {
  20839. interface Engine {
  20840. /** @hidden */
  20841. _vrDisplay: any;
  20842. /** @hidden */
  20843. _vrSupported: boolean;
  20844. /** @hidden */
  20845. _oldSize: Size;
  20846. /** @hidden */
  20847. _oldHardwareScaleFactor: number;
  20848. /** @hidden */
  20849. _vrExclusivePointerMode: boolean;
  20850. /** @hidden */
  20851. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20852. /** @hidden */
  20853. _onVRDisplayPointerRestricted: () => void;
  20854. /** @hidden */
  20855. _onVRDisplayPointerUnrestricted: () => void;
  20856. /** @hidden */
  20857. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20858. /** @hidden */
  20859. _onVrDisplayDisconnect: Nullable<() => void>;
  20860. /** @hidden */
  20861. _onVrDisplayPresentChange: Nullable<() => void>;
  20862. /**
  20863. * Observable signaled when VR display mode changes
  20864. */
  20865. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20866. /**
  20867. * Observable signaled when VR request present is complete
  20868. */
  20869. onVRRequestPresentComplete: Observable<boolean>;
  20870. /**
  20871. * Observable signaled when VR request present starts
  20872. */
  20873. onVRRequestPresentStart: Observable<Engine>;
  20874. /**
  20875. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20876. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20877. */
  20878. isInVRExclusivePointerMode: boolean;
  20879. /**
  20880. * Gets a boolean indicating if a webVR device was detected
  20881. * @returns true if a webVR device was detected
  20882. */
  20883. isVRDevicePresent(): boolean;
  20884. /**
  20885. * Gets the current webVR device
  20886. * @returns the current webVR device (or null)
  20887. */
  20888. getVRDevice(): any;
  20889. /**
  20890. * Initializes a webVR display and starts listening to display change events
  20891. * The onVRDisplayChangedObservable will be notified upon these changes
  20892. * @returns A promise containing a VRDisplay and if vr is supported
  20893. */
  20894. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20895. /** @hidden */
  20896. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20897. /**
  20898. * Gets or sets the presentation attributes used to configure VR rendering
  20899. */
  20900. vrPresentationAttributes?: IVRPresentationAttributes;
  20901. /**
  20902. * Call this function to switch to webVR mode
  20903. * Will do nothing if webVR is not supported or if there is no webVR device
  20904. * @param options the webvr options provided to the camera. mainly used for multiview
  20905. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20906. */
  20907. enableVR(options: WebVROptions): void;
  20908. /** @hidden */
  20909. _onVRFullScreenTriggered(): void;
  20910. }
  20911. }
  20912. }
  20913. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20914. import { Nullable } from "babylonjs/types";
  20915. import { Observable } from "babylonjs/Misc/observable";
  20916. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20917. import { Scene } from "babylonjs/scene";
  20918. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20919. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20920. import { Node } from "babylonjs/node";
  20921. import { Ray } from "babylonjs/Culling/ray";
  20922. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20923. import "babylonjs/Engines/Extensions/engine.webVR";
  20924. /**
  20925. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20926. * IMPORTANT!! The data is right-hand data.
  20927. * @export
  20928. * @interface DevicePose
  20929. */
  20930. export interface DevicePose {
  20931. /**
  20932. * The position of the device, values in array are [x,y,z].
  20933. */
  20934. readonly position: Nullable<Float32Array>;
  20935. /**
  20936. * The linearVelocity of the device, values in array are [x,y,z].
  20937. */
  20938. readonly linearVelocity: Nullable<Float32Array>;
  20939. /**
  20940. * The linearAcceleration of the device, values in array are [x,y,z].
  20941. */
  20942. readonly linearAcceleration: Nullable<Float32Array>;
  20943. /**
  20944. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20945. */
  20946. readonly orientation: Nullable<Float32Array>;
  20947. /**
  20948. * The angularVelocity of the device, values in array are [x,y,z].
  20949. */
  20950. readonly angularVelocity: Nullable<Float32Array>;
  20951. /**
  20952. * The angularAcceleration of the device, values in array are [x,y,z].
  20953. */
  20954. readonly angularAcceleration: Nullable<Float32Array>;
  20955. }
  20956. /**
  20957. * Interface representing a pose controlled object in Babylon.
  20958. * A pose controlled object has both regular pose values as well as pose values
  20959. * from an external device such as a VR head mounted display
  20960. */
  20961. export interface PoseControlled {
  20962. /**
  20963. * The position of the object in babylon space.
  20964. */
  20965. position: Vector3;
  20966. /**
  20967. * The rotation quaternion of the object in babylon space.
  20968. */
  20969. rotationQuaternion: Quaternion;
  20970. /**
  20971. * The position of the device in babylon space.
  20972. */
  20973. devicePosition?: Vector3;
  20974. /**
  20975. * The rotation quaternion of the device in babylon space.
  20976. */
  20977. deviceRotationQuaternion: Quaternion;
  20978. /**
  20979. * The raw pose coming from the device.
  20980. */
  20981. rawPose: Nullable<DevicePose>;
  20982. /**
  20983. * The scale of the device to be used when translating from device space to babylon space.
  20984. */
  20985. deviceScaleFactor: number;
  20986. /**
  20987. * Updates the poseControlled values based on the input device pose.
  20988. * @param poseData the pose data to update the object with
  20989. */
  20990. updateFromDevice(poseData: DevicePose): void;
  20991. }
  20992. /**
  20993. * Set of options to customize the webVRCamera
  20994. */
  20995. export interface WebVROptions {
  20996. /**
  20997. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20998. */
  20999. trackPosition?: boolean;
  21000. /**
  21001. * Sets the scale of the vrDevice in babylon space. (default: 1)
  21002. */
  21003. positionScale?: number;
  21004. /**
  21005. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  21006. */
  21007. displayName?: string;
  21008. /**
  21009. * Should the native controller meshes be initialized. (default: true)
  21010. */
  21011. controllerMeshes?: boolean;
  21012. /**
  21013. * Creating a default HemiLight only on controllers. (default: true)
  21014. */
  21015. defaultLightingOnControllers?: boolean;
  21016. /**
  21017. * If you don't want to use the default VR button of the helper. (default: false)
  21018. */
  21019. useCustomVRButton?: boolean;
  21020. /**
  21021. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  21022. */
  21023. customVRButton?: HTMLButtonElement;
  21024. /**
  21025. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  21026. */
  21027. rayLength?: number;
  21028. /**
  21029. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  21030. */
  21031. defaultHeight?: number;
  21032. /**
  21033. * If multiview should be used if availible (default: false)
  21034. */
  21035. useMultiview?: boolean;
  21036. }
  21037. /**
  21038. * This represents a WebVR camera.
  21039. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  21040. * @example https://doc.babylonjs.com/how_to/webvr_camera
  21041. */
  21042. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  21043. private webVROptions;
  21044. /**
  21045. * @hidden
  21046. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  21047. */
  21048. _vrDevice: any;
  21049. /**
  21050. * The rawPose of the vrDevice.
  21051. */
  21052. rawPose: Nullable<DevicePose>;
  21053. private _onVREnabled;
  21054. private _specsVersion;
  21055. private _attached;
  21056. private _frameData;
  21057. protected _descendants: Array<Node>;
  21058. private _deviceRoomPosition;
  21059. /** @hidden */
  21060. _deviceRoomRotationQuaternion: Quaternion;
  21061. private _standingMatrix;
  21062. /**
  21063. * Represents device position in babylon space.
  21064. */
  21065. devicePosition: Vector3;
  21066. /**
  21067. * Represents device rotation in babylon space.
  21068. */
  21069. deviceRotationQuaternion: Quaternion;
  21070. /**
  21071. * The scale of the device to be used when translating from device space to babylon space.
  21072. */
  21073. deviceScaleFactor: number;
  21074. private _deviceToWorld;
  21075. private _worldToDevice;
  21076. /**
  21077. * References to the webVR controllers for the vrDevice.
  21078. */
  21079. controllers: Array<WebVRController>;
  21080. /**
  21081. * Emits an event when a controller is attached.
  21082. */
  21083. onControllersAttachedObservable: Observable<WebVRController[]>;
  21084. /**
  21085. * Emits an event when a controller's mesh has been loaded;
  21086. */
  21087. onControllerMeshLoadedObservable: Observable<WebVRController>;
  21088. /**
  21089. * Emits an event when the HMD's pose has been updated.
  21090. */
  21091. onPoseUpdatedFromDeviceObservable: Observable<any>;
  21092. private _poseSet;
  21093. /**
  21094. * If the rig cameras be used as parent instead of this camera.
  21095. */
  21096. rigParenting: boolean;
  21097. private _lightOnControllers;
  21098. private _defaultHeight?;
  21099. /**
  21100. * Instantiates a WebVRFreeCamera.
  21101. * @param name The name of the WebVRFreeCamera
  21102. * @param position The starting anchor position for the camera
  21103. * @param scene The scene the camera belongs to
  21104. * @param webVROptions a set of customizable options for the webVRCamera
  21105. */
  21106. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  21107. /**
  21108. * Gets the device distance from the ground in meters.
  21109. * @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.
  21110. */
  21111. deviceDistanceToRoomGround(): number;
  21112. /**
  21113. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  21114. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  21115. */
  21116. useStandingMatrix(callback?: (bool: boolean) => void): void;
  21117. /**
  21118. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  21119. * @returns A promise with a boolean set to if the standing matrix is supported.
  21120. */
  21121. useStandingMatrixAsync(): Promise<boolean>;
  21122. /**
  21123. * Disposes the camera
  21124. */
  21125. dispose(): void;
  21126. /**
  21127. * Gets a vrController by name.
  21128. * @param name The name of the controller to retreive
  21129. * @returns the controller matching the name specified or null if not found
  21130. */
  21131. getControllerByName(name: string): Nullable<WebVRController>;
  21132. private _leftController;
  21133. /**
  21134. * The controller corresponding to the users left hand.
  21135. */
  21136. get leftController(): Nullable<WebVRController>;
  21137. private _rightController;
  21138. /**
  21139. * The controller corresponding to the users right hand.
  21140. */
  21141. get rightController(): Nullable<WebVRController>;
  21142. /**
  21143. * Casts a ray forward from the vrCamera's gaze.
  21144. * @param length Length of the ray (default: 100)
  21145. * @returns the ray corresponding to the gaze
  21146. */
  21147. getForwardRay(length?: number): Ray;
  21148. /**
  21149. * @hidden
  21150. * Updates the camera based on device's frame data
  21151. */
  21152. _checkInputs(): void;
  21153. /**
  21154. * Updates the poseControlled values based on the input device pose.
  21155. * @param poseData Pose coming from the device
  21156. */
  21157. updateFromDevice(poseData: DevicePose): void;
  21158. private _detachIfAttached;
  21159. /**
  21160. * WebVR's attach control will start broadcasting frames to the device.
  21161. * Note that in certain browsers (chrome for example) this function must be called
  21162. * within a user-interaction callback. Example:
  21163. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  21164. *
  21165. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  21166. */
  21167. attachControl(noPreventDefault?: boolean): void;
  21168. /**
  21169. * Detaches the camera from the html element and disables VR
  21170. */
  21171. detachControl(): void;
  21172. /**
  21173. * @returns the name of this class
  21174. */
  21175. getClassName(): string;
  21176. /**
  21177. * Calls resetPose on the vrDisplay
  21178. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  21179. */
  21180. resetToCurrentRotation(): void;
  21181. /**
  21182. * @hidden
  21183. * Updates the rig cameras (left and right eye)
  21184. */
  21185. _updateRigCameras(): void;
  21186. private _workingVector;
  21187. private _oneVector;
  21188. private _workingMatrix;
  21189. private updateCacheCalled;
  21190. private _correctPositionIfNotTrackPosition;
  21191. /**
  21192. * @hidden
  21193. * Updates the cached values of the camera
  21194. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  21195. */
  21196. _updateCache(ignoreParentClass?: boolean): void;
  21197. /**
  21198. * @hidden
  21199. * Get current device position in babylon world
  21200. */
  21201. _computeDevicePosition(): void;
  21202. /**
  21203. * Updates the current device position and rotation in the babylon world
  21204. */
  21205. update(): void;
  21206. /**
  21207. * @hidden
  21208. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  21209. * @returns an identity matrix
  21210. */
  21211. _getViewMatrix(): Matrix;
  21212. private _tmpMatrix;
  21213. /**
  21214. * This function is called by the two RIG cameras.
  21215. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  21216. * @hidden
  21217. */
  21218. _getWebVRViewMatrix(): Matrix;
  21219. /** @hidden */
  21220. _getWebVRProjectionMatrix(): Matrix;
  21221. private _onGamepadConnectedObserver;
  21222. private _onGamepadDisconnectedObserver;
  21223. private _updateCacheWhenTrackingDisabledObserver;
  21224. /**
  21225. * Initializes the controllers and their meshes
  21226. */
  21227. initControllers(): void;
  21228. }
  21229. }
  21230. declare module "babylonjs/Materials/materialHelper" {
  21231. import { Nullable } from "babylonjs/types";
  21232. import { Scene } from "babylonjs/scene";
  21233. import { Engine } from "babylonjs/Engines/engine";
  21234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21235. import { Light } from "babylonjs/Lights/light";
  21236. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  21237. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21238. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  21239. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21240. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21241. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21242. /**
  21243. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  21244. *
  21245. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  21246. *
  21247. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  21248. */
  21249. export class MaterialHelper {
  21250. /**
  21251. * Bind the current view position to an effect.
  21252. * @param effect The effect to be bound
  21253. * @param scene The scene the eyes position is used from
  21254. * @param variableName name of the shader variable that will hold the eye position
  21255. */
  21256. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  21257. /**
  21258. * Helps preparing the defines values about the UVs in used in the effect.
  21259. * UVs are shared as much as we can accross channels in the shaders.
  21260. * @param texture The texture we are preparing the UVs for
  21261. * @param defines The defines to update
  21262. * @param key The channel key "diffuse", "specular"... used in the shader
  21263. */
  21264. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  21265. /**
  21266. * Binds a texture matrix value to its corrsponding uniform
  21267. * @param texture The texture to bind the matrix for
  21268. * @param uniformBuffer The uniform buffer receivin the data
  21269. * @param key The channel key "diffuse", "specular"... used in the shader
  21270. */
  21271. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  21272. /**
  21273. * Gets the current status of the fog (should it be enabled?)
  21274. * @param mesh defines the mesh to evaluate for fog support
  21275. * @param scene defines the hosting scene
  21276. * @returns true if fog must be enabled
  21277. */
  21278. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  21279. /**
  21280. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  21281. * @param mesh defines the current mesh
  21282. * @param scene defines the current scene
  21283. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  21284. * @param pointsCloud defines if point cloud rendering has to be turned on
  21285. * @param fogEnabled defines if fog has to be turned on
  21286. * @param alphaTest defines if alpha testing has to be turned on
  21287. * @param defines defines the current list of defines
  21288. */
  21289. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  21290. /**
  21291. * Helper used to prepare the list of defines associated with frame values for shader compilation
  21292. * @param scene defines the current scene
  21293. * @param engine defines the current engine
  21294. * @param defines specifies the list of active defines
  21295. * @param useInstances defines if instances have to be turned on
  21296. * @param useClipPlane defines if clip plane have to be turned on
  21297. * @param useInstances defines if instances have to be turned on
  21298. * @param useThinInstances defines if thin instances have to be turned on
  21299. */
  21300. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  21301. /**
  21302. * Prepares the defines for bones
  21303. * @param mesh The mesh containing the geometry data we will draw
  21304. * @param defines The defines to update
  21305. */
  21306. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  21307. /**
  21308. * Prepares the defines for morph targets
  21309. * @param mesh The mesh containing the geometry data we will draw
  21310. * @param defines The defines to update
  21311. */
  21312. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  21313. /**
  21314. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  21315. * @param mesh The mesh containing the geometry data we will draw
  21316. * @param defines The defines to update
  21317. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  21318. * @param useBones Precise whether bones should be used or not (override mesh info)
  21319. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  21320. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  21321. * @returns false if defines are considered not dirty and have not been checked
  21322. */
  21323. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  21324. /**
  21325. * Prepares the defines related to multiview
  21326. * @param scene The scene we are intending to draw
  21327. * @param defines The defines to update
  21328. */
  21329. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  21330. /**
  21331. * Prepares the defines related to the prepass
  21332. * @param scene The scene we are intending to draw
  21333. * @param defines The defines to update
  21334. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  21335. */
  21336. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  21337. /**
  21338. * Prepares the defines related to the light information passed in parameter
  21339. * @param scene The scene we are intending to draw
  21340. * @param mesh The mesh the effect is compiling for
  21341. * @param light The light the effect is compiling for
  21342. * @param lightIndex The index of the light
  21343. * @param defines The defines to update
  21344. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21345. * @param state Defines the current state regarding what is needed (normals, etc...)
  21346. */
  21347. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  21348. needNormals: boolean;
  21349. needRebuild: boolean;
  21350. shadowEnabled: boolean;
  21351. specularEnabled: boolean;
  21352. lightmapMode: boolean;
  21353. }): void;
  21354. /**
  21355. * Prepares the defines related to the light information passed in parameter
  21356. * @param scene The scene we are intending to draw
  21357. * @param mesh The mesh the effect is compiling for
  21358. * @param defines The defines to update
  21359. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21360. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21361. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21362. * @returns true if normals will be required for the rest of the effect
  21363. */
  21364. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21365. /**
  21366. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21367. * @param lightIndex defines the light index
  21368. * @param uniformsList The uniform list
  21369. * @param samplersList The sampler list
  21370. * @param projectedLightTexture defines if projected texture must be used
  21371. * @param uniformBuffersList defines an optional list of uniform buffers
  21372. */
  21373. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21374. /**
  21375. * Prepares the uniforms and samplers list to be used in the effect
  21376. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21377. * @param samplersList The sampler list
  21378. * @param defines The defines helping in the list generation
  21379. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21380. */
  21381. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21382. /**
  21383. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21384. * @param defines The defines to update while falling back
  21385. * @param fallbacks The authorized effect fallbacks
  21386. * @param maxSimultaneousLights The maximum number of lights allowed
  21387. * @param rank the current rank of the Effect
  21388. * @returns The newly affected rank
  21389. */
  21390. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21391. private static _TmpMorphInfluencers;
  21392. /**
  21393. * Prepares the list of attributes required for morph targets according to the effect defines.
  21394. * @param attribs The current list of supported attribs
  21395. * @param mesh The mesh to prepare the morph targets attributes for
  21396. * @param influencers The number of influencers
  21397. */
  21398. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21399. /**
  21400. * Prepares the list of attributes required for morph targets according to the effect defines.
  21401. * @param attribs The current list of supported attribs
  21402. * @param mesh The mesh to prepare the morph targets attributes for
  21403. * @param defines The current Defines of the effect
  21404. */
  21405. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21406. /**
  21407. * Prepares the list of attributes required for bones according to the effect defines.
  21408. * @param attribs The current list of supported attribs
  21409. * @param mesh The mesh to prepare the bones attributes for
  21410. * @param defines The current Defines of the effect
  21411. * @param fallbacks The current efffect fallback strategy
  21412. */
  21413. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21414. /**
  21415. * Check and prepare the list of attributes required for instances according to the effect defines.
  21416. * @param attribs The current list of supported attribs
  21417. * @param defines The current MaterialDefines of the effect
  21418. */
  21419. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21420. /**
  21421. * Add the list of attributes required for instances to the attribs array.
  21422. * @param attribs The current list of supported attribs
  21423. */
  21424. static PushAttributesForInstances(attribs: string[]): void;
  21425. /**
  21426. * Binds the light information to the effect.
  21427. * @param light The light containing the generator
  21428. * @param effect The effect we are binding the data to
  21429. * @param lightIndex The light index in the effect used to render
  21430. */
  21431. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21432. /**
  21433. * Binds the lights information from the scene to the effect for the given mesh.
  21434. * @param light Light to bind
  21435. * @param lightIndex Light index
  21436. * @param scene The scene where the light belongs to
  21437. * @param effect The effect we are binding the data to
  21438. * @param useSpecular Defines if specular is supported
  21439. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21440. */
  21441. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21442. /**
  21443. * Binds the lights information from the scene to the effect for the given mesh.
  21444. * @param scene The scene the lights belongs to
  21445. * @param mesh The mesh we are binding the information to render
  21446. * @param effect The effect we are binding the data to
  21447. * @param defines The generated defines for the effect
  21448. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21449. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21450. */
  21451. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21452. private static _tempFogColor;
  21453. /**
  21454. * Binds the fog information from the scene to the effect for the given mesh.
  21455. * @param scene The scene the lights belongs to
  21456. * @param mesh The mesh we are binding the information to render
  21457. * @param effect The effect we are binding the data to
  21458. * @param linearSpace Defines if the fog effect is applied in linear space
  21459. */
  21460. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21461. /**
  21462. * Binds the bones information from the mesh to the effect.
  21463. * @param mesh The mesh we are binding the information to render
  21464. * @param effect The effect we are binding the data to
  21465. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  21466. */
  21467. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  21468. private static _CopyBonesTransformationMatrices;
  21469. /**
  21470. * Binds the morph targets information from the mesh to the effect.
  21471. * @param abstractMesh The mesh we are binding the information to render
  21472. * @param effect The effect we are binding the data to
  21473. */
  21474. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21475. /**
  21476. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21477. * @param defines The generated defines used in the effect
  21478. * @param effect The effect we are binding the data to
  21479. * @param scene The scene we are willing to render with logarithmic scale for
  21480. */
  21481. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21482. /**
  21483. * Binds the clip plane information from the scene to the effect.
  21484. * @param scene The scene the clip plane information are extracted from
  21485. * @param effect The effect we are binding the data to
  21486. */
  21487. static BindClipPlane(effect: Effect, scene: Scene): void;
  21488. }
  21489. }
  21490. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21492. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21493. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21494. import { Nullable } from "babylonjs/types";
  21495. import { Effect } from "babylonjs/Materials/effect";
  21496. import { Matrix } from "babylonjs/Maths/math.vector";
  21497. import { Scene } from "babylonjs/scene";
  21498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21499. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21500. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21501. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21502. import { Observable } from "babylonjs/Misc/observable";
  21503. /**
  21504. * Block used to expose an input value
  21505. */
  21506. export class InputBlock extends NodeMaterialBlock {
  21507. private _mode;
  21508. private _associatedVariableName;
  21509. private _storedValue;
  21510. private _valueCallback;
  21511. private _type;
  21512. private _animationType;
  21513. /** Gets or set a value used to limit the range of float values */
  21514. min: number;
  21515. /** Gets or set a value used to limit the range of float values */
  21516. max: number;
  21517. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21518. isBoolean: boolean;
  21519. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21520. matrixMode: number;
  21521. /** @hidden */
  21522. _systemValue: Nullable<NodeMaterialSystemValues>;
  21523. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21524. isConstant: boolean;
  21525. /** Gets or sets the group to use to display this block in the Inspector */
  21526. groupInInspector: string;
  21527. /** Gets an observable raised when the value is changed */
  21528. onValueChangedObservable: Observable<InputBlock>;
  21529. /**
  21530. * Gets or sets the connection point type (default is float)
  21531. */
  21532. get type(): NodeMaterialBlockConnectionPointTypes;
  21533. /**
  21534. * Creates a new InputBlock
  21535. * @param name defines the block name
  21536. * @param target defines the target of that block (Vertex by default)
  21537. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21538. */
  21539. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21540. /**
  21541. * Validates if a name is a reserve word.
  21542. * @param newName the new name to be given to the node.
  21543. * @returns false if the name is a reserve word, else true.
  21544. */
  21545. validateBlockName(newName: string): boolean;
  21546. /**
  21547. * Gets the output component
  21548. */
  21549. get output(): NodeMaterialConnectionPoint;
  21550. /**
  21551. * Set the source of this connection point to a vertex attribute
  21552. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21553. * @returns the current connection point
  21554. */
  21555. setAsAttribute(attributeName?: string): InputBlock;
  21556. /**
  21557. * Set the source of this connection point to a system value
  21558. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21559. * @returns the current connection point
  21560. */
  21561. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21562. /**
  21563. * Gets or sets the value of that point.
  21564. * Please note that this value will be ignored if valueCallback is defined
  21565. */
  21566. get value(): any;
  21567. set value(value: any);
  21568. /**
  21569. * Gets or sets a callback used to get the value of that point.
  21570. * Please note that setting this value will force the connection point to ignore the value property
  21571. */
  21572. get valueCallback(): () => any;
  21573. set valueCallback(value: () => any);
  21574. /**
  21575. * Gets or sets the associated variable name in the shader
  21576. */
  21577. get associatedVariableName(): string;
  21578. set associatedVariableName(value: string);
  21579. /** Gets or sets the type of animation applied to the input */
  21580. get animationType(): AnimatedInputBlockTypes;
  21581. set animationType(value: AnimatedInputBlockTypes);
  21582. /**
  21583. * Gets a boolean indicating that this connection point not defined yet
  21584. */
  21585. get isUndefined(): boolean;
  21586. /**
  21587. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21588. * In this case the connection point name must be the name of the uniform to use.
  21589. * Can only be set on inputs
  21590. */
  21591. get isUniform(): boolean;
  21592. set isUniform(value: boolean);
  21593. /**
  21594. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21595. * In this case the connection point name must be the name of the attribute to use
  21596. * Can only be set on inputs
  21597. */
  21598. get isAttribute(): boolean;
  21599. set isAttribute(value: boolean);
  21600. /**
  21601. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21602. * Can only be set on exit points
  21603. */
  21604. get isVarying(): boolean;
  21605. set isVarying(value: boolean);
  21606. /**
  21607. * Gets a boolean indicating that the current connection point is a system value
  21608. */
  21609. get isSystemValue(): boolean;
  21610. /**
  21611. * Gets or sets the current well known value or null if not defined as a system value
  21612. */
  21613. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21614. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21615. /**
  21616. * Gets the current class name
  21617. * @returns the class name
  21618. */
  21619. getClassName(): string;
  21620. /**
  21621. * Animate the input if animationType !== None
  21622. * @param scene defines the rendering scene
  21623. */
  21624. animate(scene: Scene): void;
  21625. private _emitDefine;
  21626. initialize(state: NodeMaterialBuildState): void;
  21627. /**
  21628. * Set the input block to its default value (based on its type)
  21629. */
  21630. setDefaultValue(): void;
  21631. private _emitConstant;
  21632. /** @hidden */
  21633. get _noContextSwitch(): boolean;
  21634. private _emit;
  21635. /** @hidden */
  21636. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21637. /** @hidden */
  21638. _transmit(effect: Effect, scene: Scene): void;
  21639. protected _buildBlock(state: NodeMaterialBuildState): void;
  21640. protected _dumpPropertiesCode(): string;
  21641. dispose(): void;
  21642. serialize(): any;
  21643. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21644. }
  21645. }
  21646. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21647. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21648. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21649. import { Nullable } from "babylonjs/types";
  21650. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21651. import { Observable } from "babylonjs/Misc/observable";
  21652. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21653. /**
  21654. * Enum used to define the compatibility state between two connection points
  21655. */
  21656. export enum NodeMaterialConnectionPointCompatibilityStates {
  21657. /** Points are compatibles */
  21658. Compatible = 0,
  21659. /** Points are incompatible because of their types */
  21660. TypeIncompatible = 1,
  21661. /** Points are incompatible because of their targets (vertex vs fragment) */
  21662. TargetIncompatible = 2
  21663. }
  21664. /**
  21665. * Defines the direction of a connection point
  21666. */
  21667. export enum NodeMaterialConnectionPointDirection {
  21668. /** Input */
  21669. Input = 0,
  21670. /** Output */
  21671. Output = 1
  21672. }
  21673. /**
  21674. * Defines a connection point for a block
  21675. */
  21676. export class NodeMaterialConnectionPoint {
  21677. /** @hidden */
  21678. _ownerBlock: NodeMaterialBlock;
  21679. /** @hidden */
  21680. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21681. private _endpoints;
  21682. private _associatedVariableName;
  21683. private _direction;
  21684. /** @hidden */
  21685. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21686. /** @hidden */
  21687. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21688. private _type;
  21689. /** @hidden */
  21690. _enforceAssociatedVariableName: boolean;
  21691. /** Gets the direction of the point */
  21692. get direction(): NodeMaterialConnectionPointDirection;
  21693. /** Indicates that this connection point needs dual validation before being connected to another point */
  21694. needDualDirectionValidation: boolean;
  21695. /**
  21696. * Gets or sets the additional types supported by this connection point
  21697. */
  21698. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21699. /**
  21700. * Gets or sets the additional types excluded by this connection point
  21701. */
  21702. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21703. /**
  21704. * Observable triggered when this point is connected
  21705. */
  21706. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21707. /**
  21708. * Gets or sets the associated variable name in the shader
  21709. */
  21710. get associatedVariableName(): string;
  21711. set associatedVariableName(value: string);
  21712. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21713. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21714. /**
  21715. * Gets or sets the connection point type (default is float)
  21716. */
  21717. get type(): NodeMaterialBlockConnectionPointTypes;
  21718. set type(value: NodeMaterialBlockConnectionPointTypes);
  21719. /**
  21720. * Gets or sets the connection point name
  21721. */
  21722. name: string;
  21723. /**
  21724. * Gets or sets the connection point name
  21725. */
  21726. displayName: string;
  21727. /**
  21728. * Gets or sets a boolean indicating that this connection point can be omitted
  21729. */
  21730. isOptional: boolean;
  21731. /**
  21732. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21733. */
  21734. isExposedOnFrame: boolean;
  21735. /**
  21736. * Gets or sets number indicating the position that the port is exposed to on a frame
  21737. */
  21738. exposedPortPosition: number;
  21739. /**
  21740. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21741. */
  21742. define: string;
  21743. /** @hidden */
  21744. _prioritizeVertex: boolean;
  21745. private _target;
  21746. /** Gets or sets the target of that connection point */
  21747. get target(): NodeMaterialBlockTargets;
  21748. set target(value: NodeMaterialBlockTargets);
  21749. /**
  21750. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21751. */
  21752. get isConnected(): boolean;
  21753. /**
  21754. * Gets a boolean indicating that the current point is connected to an input block
  21755. */
  21756. get isConnectedToInputBlock(): boolean;
  21757. /**
  21758. * Gets a the connected input block (if any)
  21759. */
  21760. get connectInputBlock(): Nullable<InputBlock>;
  21761. /** Get the other side of the connection (if any) */
  21762. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21763. /** Get the block that owns this connection point */
  21764. get ownerBlock(): NodeMaterialBlock;
  21765. /** Get the block connected on the other side of this connection (if any) */
  21766. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21767. /** Get the block connected on the endpoints of this connection (if any) */
  21768. get connectedBlocks(): Array<NodeMaterialBlock>;
  21769. /** Gets the list of connected endpoints */
  21770. get endpoints(): NodeMaterialConnectionPoint[];
  21771. /** Gets a boolean indicating if that output point is connected to at least one input */
  21772. get hasEndpoints(): boolean;
  21773. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21774. get isConnectedInVertexShader(): boolean;
  21775. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21776. get isConnectedInFragmentShader(): boolean;
  21777. /**
  21778. * Creates a block suitable to be used as an input for this input point.
  21779. * If null is returned, a block based on the point type will be created.
  21780. * @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
  21781. */
  21782. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21783. /**
  21784. * Creates a new connection point
  21785. * @param name defines the connection point name
  21786. * @param ownerBlock defines the block hosting this connection point
  21787. * @param direction defines the direction of the connection point
  21788. */
  21789. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21790. /**
  21791. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21792. * @returns the class name
  21793. */
  21794. getClassName(): string;
  21795. /**
  21796. * Gets a boolean indicating if the current point can be connected to another point
  21797. * @param connectionPoint defines the other connection point
  21798. * @returns a boolean
  21799. */
  21800. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21801. /**
  21802. * Gets a number indicating if the current point can be connected to another point
  21803. * @param connectionPoint defines the other connection point
  21804. * @returns a number defining the compatibility state
  21805. */
  21806. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21807. /**
  21808. * Connect this point to another connection point
  21809. * @param connectionPoint defines the other connection point
  21810. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21811. * @returns the current connection point
  21812. */
  21813. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21814. /**
  21815. * Disconnect this point from one of his endpoint
  21816. * @param endpoint defines the other connection point
  21817. * @returns the current connection point
  21818. */
  21819. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21820. /**
  21821. * Serializes this point in a JSON representation
  21822. * @param isInput defines if the connection point is an input (default is true)
  21823. * @returns the serialized point object
  21824. */
  21825. serialize(isInput?: boolean): any;
  21826. /**
  21827. * Release resources
  21828. */
  21829. dispose(): void;
  21830. }
  21831. }
  21832. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21833. /**
  21834. * Enum used to define the material modes
  21835. */
  21836. export enum NodeMaterialModes {
  21837. /** Regular material */
  21838. Material = 0,
  21839. /** For post process */
  21840. PostProcess = 1,
  21841. /** For particle system */
  21842. Particle = 2,
  21843. /** For procedural texture */
  21844. ProceduralTexture = 3
  21845. }
  21846. }
  21847. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21848. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21849. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21850. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21851. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21853. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21854. import { Effect } from "babylonjs/Materials/effect";
  21855. import { Mesh } from "babylonjs/Meshes/mesh";
  21856. import { Nullable } from "babylonjs/types";
  21857. import { Texture } from "babylonjs/Materials/Textures/texture";
  21858. import { Scene } from "babylonjs/scene";
  21859. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21860. /**
  21861. * Block used to read a texture from a sampler
  21862. */
  21863. export class TextureBlock extends NodeMaterialBlock {
  21864. private _defineName;
  21865. private _linearDefineName;
  21866. private _gammaDefineName;
  21867. private _tempTextureRead;
  21868. private _samplerName;
  21869. private _transformedUVName;
  21870. private _textureTransformName;
  21871. private _textureInfoName;
  21872. private _mainUVName;
  21873. private _mainUVDefineName;
  21874. private _fragmentOnly;
  21875. /**
  21876. * Gets or sets the texture associated with the node
  21877. */
  21878. texture: Nullable<Texture>;
  21879. /**
  21880. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21881. */
  21882. convertToGammaSpace: boolean;
  21883. /**
  21884. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21885. */
  21886. convertToLinearSpace: boolean;
  21887. /**
  21888. * Create a new TextureBlock
  21889. * @param name defines the block name
  21890. */
  21891. constructor(name: string, fragmentOnly?: boolean);
  21892. /**
  21893. * Gets the current class name
  21894. * @returns the class name
  21895. */
  21896. getClassName(): string;
  21897. /**
  21898. * Gets the uv input component
  21899. */
  21900. get uv(): NodeMaterialConnectionPoint;
  21901. /**
  21902. * Gets the rgba output component
  21903. */
  21904. get rgba(): NodeMaterialConnectionPoint;
  21905. /**
  21906. * Gets the rgb output component
  21907. */
  21908. get rgb(): NodeMaterialConnectionPoint;
  21909. /**
  21910. * Gets the r output component
  21911. */
  21912. get r(): NodeMaterialConnectionPoint;
  21913. /**
  21914. * Gets the g output component
  21915. */
  21916. get g(): NodeMaterialConnectionPoint;
  21917. /**
  21918. * Gets the b output component
  21919. */
  21920. get b(): NodeMaterialConnectionPoint;
  21921. /**
  21922. * Gets the a output component
  21923. */
  21924. get a(): NodeMaterialConnectionPoint;
  21925. get target(): NodeMaterialBlockTargets;
  21926. autoConfigure(material: NodeMaterial): void;
  21927. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21928. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21929. isReady(): boolean;
  21930. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21931. private get _isMixed();
  21932. private _injectVertexCode;
  21933. private _writeTextureRead;
  21934. private _writeOutput;
  21935. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21936. protected _dumpPropertiesCode(): string;
  21937. serialize(): any;
  21938. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21939. }
  21940. }
  21941. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21942. /** @hidden */
  21943. export var reflectionFunction: {
  21944. name: string;
  21945. shader: string;
  21946. };
  21947. }
  21948. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21949. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21950. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21951. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21952. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21954. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21955. import { Effect } from "babylonjs/Materials/effect";
  21956. import { Mesh } from "babylonjs/Meshes/mesh";
  21957. import { Nullable } from "babylonjs/types";
  21958. import { Scene } from "babylonjs/scene";
  21959. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21960. /**
  21961. * Base block used to read a reflection texture from a sampler
  21962. */
  21963. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21964. /** @hidden */
  21965. _define3DName: string;
  21966. /** @hidden */
  21967. _defineCubicName: string;
  21968. /** @hidden */
  21969. _defineExplicitName: string;
  21970. /** @hidden */
  21971. _defineProjectionName: string;
  21972. /** @hidden */
  21973. _defineLocalCubicName: string;
  21974. /** @hidden */
  21975. _defineSphericalName: string;
  21976. /** @hidden */
  21977. _definePlanarName: string;
  21978. /** @hidden */
  21979. _defineEquirectangularName: string;
  21980. /** @hidden */
  21981. _defineMirroredEquirectangularFixedName: string;
  21982. /** @hidden */
  21983. _defineEquirectangularFixedName: string;
  21984. /** @hidden */
  21985. _defineSkyboxName: string;
  21986. /** @hidden */
  21987. _defineOppositeZ: string;
  21988. /** @hidden */
  21989. _cubeSamplerName: string;
  21990. /** @hidden */
  21991. _2DSamplerName: string;
  21992. protected _positionUVWName: string;
  21993. protected _directionWName: string;
  21994. protected _reflectionVectorName: string;
  21995. /** @hidden */
  21996. _reflectionCoordsName: string;
  21997. /** @hidden */
  21998. _reflectionMatrixName: string;
  21999. protected _reflectionColorName: string;
  22000. /**
  22001. * Gets or sets the texture associated with the node
  22002. */
  22003. texture: Nullable<BaseTexture>;
  22004. /**
  22005. * Create a new ReflectionTextureBaseBlock
  22006. * @param name defines the block name
  22007. */
  22008. constructor(name: string);
  22009. /**
  22010. * Gets the current class name
  22011. * @returns the class name
  22012. */
  22013. getClassName(): string;
  22014. /**
  22015. * Gets the world position input component
  22016. */
  22017. abstract get position(): NodeMaterialConnectionPoint;
  22018. /**
  22019. * Gets the world position input component
  22020. */
  22021. abstract get worldPosition(): NodeMaterialConnectionPoint;
  22022. /**
  22023. * Gets the world normal input component
  22024. */
  22025. abstract get worldNormal(): NodeMaterialConnectionPoint;
  22026. /**
  22027. * Gets the world input component
  22028. */
  22029. abstract get world(): NodeMaterialConnectionPoint;
  22030. /**
  22031. * Gets the camera (or eye) position component
  22032. */
  22033. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  22034. /**
  22035. * Gets the view input component
  22036. */
  22037. abstract get view(): NodeMaterialConnectionPoint;
  22038. protected _getTexture(): Nullable<BaseTexture>;
  22039. autoConfigure(material: NodeMaterial): void;
  22040. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22041. isReady(): boolean;
  22042. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  22043. /**
  22044. * Gets the code to inject in the vertex shader
  22045. * @param state current state of the node material building
  22046. * @returns the shader code
  22047. */
  22048. handleVertexSide(state: NodeMaterialBuildState): string;
  22049. /**
  22050. * Handles the inits for the fragment code path
  22051. * @param state node material build state
  22052. */
  22053. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  22054. /**
  22055. * Generates the reflection coords code for the fragment code path
  22056. * @param worldNormalVarName name of the world normal variable
  22057. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  22058. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  22059. * @returns the shader code
  22060. */
  22061. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  22062. /**
  22063. * Generates the reflection color code for the fragment code path
  22064. * @param lodVarName name of the lod variable
  22065. * @param swizzleLookupTexture swizzle to use for the final color variable
  22066. * @returns the shader code
  22067. */
  22068. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  22069. /**
  22070. * Generates the code corresponding to the connected output points
  22071. * @param state node material build state
  22072. * @param varName name of the variable to output
  22073. * @returns the shader code
  22074. */
  22075. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  22076. protected _buildBlock(state: NodeMaterialBuildState): this;
  22077. protected _dumpPropertiesCode(): string;
  22078. serialize(): any;
  22079. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22080. }
  22081. }
  22082. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  22083. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22084. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22085. import { Nullable } from "babylonjs/types";
  22086. /**
  22087. * Defines a connection point to be used for points with a custom object type
  22088. */
  22089. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  22090. private _blockType;
  22091. private _blockName;
  22092. private _nameForCheking?;
  22093. /**
  22094. * Creates a new connection point
  22095. * @param name defines the connection point name
  22096. * @param ownerBlock defines the block hosting this connection point
  22097. * @param direction defines the direction of the connection point
  22098. */
  22099. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  22100. /**
  22101. * Gets a number indicating if the current point can be connected to another point
  22102. * @param connectionPoint defines the other connection point
  22103. * @returns a number defining the compatibility state
  22104. */
  22105. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  22106. /**
  22107. * Creates a block suitable to be used as an input for this input point.
  22108. * If null is returned, a block based on the point type will be created.
  22109. * @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
  22110. */
  22111. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  22112. }
  22113. }
  22114. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  22115. /**
  22116. * Enum defining the type of properties that can be edited in the property pages in the NME
  22117. */
  22118. export enum PropertyTypeForEdition {
  22119. /** property is a boolean */
  22120. Boolean = 0,
  22121. /** property is a float */
  22122. Float = 1,
  22123. /** property is a Vector2 */
  22124. Vector2 = 2,
  22125. /** property is a list of values */
  22126. List = 3
  22127. }
  22128. /**
  22129. * Interface that defines an option in a variable of type list
  22130. */
  22131. export interface IEditablePropertyListOption {
  22132. /** label of the option */
  22133. "label": string;
  22134. /** value of the option */
  22135. "value": number;
  22136. }
  22137. /**
  22138. * Interface that defines the options available for an editable property
  22139. */
  22140. export interface IEditablePropertyOption {
  22141. /** min value */
  22142. "min"?: number;
  22143. /** max value */
  22144. "max"?: number;
  22145. /** notifiers: indicates which actions to take when the property is changed */
  22146. "notifiers"?: {
  22147. /** the material should be rebuilt */
  22148. "rebuild"?: boolean;
  22149. /** the preview should be updated */
  22150. "update"?: boolean;
  22151. };
  22152. /** list of the options for a variable of type list */
  22153. "options"?: IEditablePropertyListOption[];
  22154. }
  22155. /**
  22156. * Interface that describes an editable property
  22157. */
  22158. export interface IPropertyDescriptionForEdition {
  22159. /** name of the property */
  22160. "propertyName": string;
  22161. /** display name of the property */
  22162. "displayName": string;
  22163. /** type of the property */
  22164. "type": PropertyTypeForEdition;
  22165. /** group of the property - all properties with the same group value will be displayed in a specific section */
  22166. "groupName": string;
  22167. /** options for the property */
  22168. "options": IEditablePropertyOption;
  22169. }
  22170. /**
  22171. * Decorator that flags a property in a node material block as being editable
  22172. */
  22173. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  22174. }
  22175. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  22176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22178. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22180. import { Nullable } from "babylonjs/types";
  22181. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22182. import { Mesh } from "babylonjs/Meshes/mesh";
  22183. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22184. import { Effect } from "babylonjs/Materials/effect";
  22185. import { Scene } from "babylonjs/scene";
  22186. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22187. /**
  22188. * Block used to implement the refraction part of the sub surface module of the PBR material
  22189. */
  22190. export class RefractionBlock extends NodeMaterialBlock {
  22191. /** @hidden */
  22192. _define3DName: string;
  22193. /** @hidden */
  22194. _refractionMatrixName: string;
  22195. /** @hidden */
  22196. _defineLODRefractionAlpha: string;
  22197. /** @hidden */
  22198. _defineLinearSpecularRefraction: string;
  22199. /** @hidden */
  22200. _defineOppositeZ: string;
  22201. /** @hidden */
  22202. _cubeSamplerName: string;
  22203. /** @hidden */
  22204. _2DSamplerName: string;
  22205. /** @hidden */
  22206. _vRefractionMicrosurfaceInfosName: string;
  22207. /** @hidden */
  22208. _vRefractionInfosName: string;
  22209. private _scene;
  22210. /**
  22211. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22212. * Materials half opaque for instance using refraction could benefit from this control.
  22213. */
  22214. linkRefractionWithTransparency: boolean;
  22215. /**
  22216. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22217. */
  22218. invertRefractionY: boolean;
  22219. /**
  22220. * Gets or sets the texture associated with the node
  22221. */
  22222. texture: Nullable<BaseTexture>;
  22223. /**
  22224. * Create a new RefractionBlock
  22225. * @param name defines the block name
  22226. */
  22227. constructor(name: string);
  22228. /**
  22229. * Gets the current class name
  22230. * @returns the class name
  22231. */
  22232. getClassName(): string;
  22233. /**
  22234. * Gets the intensity input component
  22235. */
  22236. get intensity(): NodeMaterialConnectionPoint;
  22237. /**
  22238. * Gets the index of refraction input component
  22239. */
  22240. get indexOfRefraction(): NodeMaterialConnectionPoint;
  22241. /**
  22242. * Gets the tint at distance input component
  22243. */
  22244. get tintAtDistance(): NodeMaterialConnectionPoint;
  22245. /**
  22246. * Gets the view input component
  22247. */
  22248. get view(): NodeMaterialConnectionPoint;
  22249. /**
  22250. * Gets the refraction object output component
  22251. */
  22252. get refraction(): NodeMaterialConnectionPoint;
  22253. /**
  22254. * Returns true if the block has a texture
  22255. */
  22256. get hasTexture(): boolean;
  22257. protected _getTexture(): Nullable<BaseTexture>;
  22258. autoConfigure(material: NodeMaterial): void;
  22259. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22260. isReady(): boolean;
  22261. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22262. /**
  22263. * Gets the main code of the block (fragment side)
  22264. * @param state current state of the node material building
  22265. * @returns the shader code
  22266. */
  22267. getCode(state: NodeMaterialBuildState): string;
  22268. protected _buildBlock(state: NodeMaterialBuildState): this;
  22269. protected _dumpPropertiesCode(): string;
  22270. serialize(): any;
  22271. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22272. }
  22273. }
  22274. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  22275. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22276. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22277. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22278. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22280. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22281. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22282. import { Nullable } from "babylonjs/types";
  22283. import { Scene } from "babylonjs/scene";
  22284. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22285. /**
  22286. * Base block used as input for post process
  22287. */
  22288. export class CurrentScreenBlock extends NodeMaterialBlock {
  22289. private _samplerName;
  22290. private _linearDefineName;
  22291. private _gammaDefineName;
  22292. private _mainUVName;
  22293. private _tempTextureRead;
  22294. /**
  22295. * Gets or sets the texture associated with the node
  22296. */
  22297. texture: Nullable<BaseTexture>;
  22298. /**
  22299. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22300. */
  22301. convertToGammaSpace: boolean;
  22302. /**
  22303. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22304. */
  22305. convertToLinearSpace: boolean;
  22306. /**
  22307. * Create a new CurrentScreenBlock
  22308. * @param name defines the block name
  22309. */
  22310. constructor(name: string);
  22311. /**
  22312. * Gets the current class name
  22313. * @returns the class name
  22314. */
  22315. getClassName(): string;
  22316. /**
  22317. * Gets the uv input component
  22318. */
  22319. get uv(): NodeMaterialConnectionPoint;
  22320. /**
  22321. * Gets the rgba output component
  22322. */
  22323. get rgba(): NodeMaterialConnectionPoint;
  22324. /**
  22325. * Gets the rgb output component
  22326. */
  22327. get rgb(): NodeMaterialConnectionPoint;
  22328. /**
  22329. * Gets the r output component
  22330. */
  22331. get r(): NodeMaterialConnectionPoint;
  22332. /**
  22333. * Gets the g output component
  22334. */
  22335. get g(): NodeMaterialConnectionPoint;
  22336. /**
  22337. * Gets the b output component
  22338. */
  22339. get b(): NodeMaterialConnectionPoint;
  22340. /**
  22341. * Gets the a output component
  22342. */
  22343. get a(): NodeMaterialConnectionPoint;
  22344. /**
  22345. * Initialize the block and prepare the context for build
  22346. * @param state defines the state that will be used for the build
  22347. */
  22348. initialize(state: NodeMaterialBuildState): void;
  22349. get target(): NodeMaterialBlockTargets;
  22350. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22351. isReady(): boolean;
  22352. private _injectVertexCode;
  22353. private _writeTextureRead;
  22354. private _writeOutput;
  22355. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22356. serialize(): any;
  22357. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22358. }
  22359. }
  22360. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  22361. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22362. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22363. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22365. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22366. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22367. import { Nullable } from "babylonjs/types";
  22368. import { Scene } from "babylonjs/scene";
  22369. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22370. /**
  22371. * Base block used for the particle texture
  22372. */
  22373. export class ParticleTextureBlock extends NodeMaterialBlock {
  22374. private _samplerName;
  22375. private _linearDefineName;
  22376. private _gammaDefineName;
  22377. private _tempTextureRead;
  22378. /**
  22379. * Gets or sets the texture associated with the node
  22380. */
  22381. texture: Nullable<BaseTexture>;
  22382. /**
  22383. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22384. */
  22385. convertToGammaSpace: boolean;
  22386. /**
  22387. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22388. */
  22389. convertToLinearSpace: boolean;
  22390. /**
  22391. * Create a new ParticleTextureBlock
  22392. * @param name defines the block name
  22393. */
  22394. constructor(name: string);
  22395. /**
  22396. * Gets the current class name
  22397. * @returns the class name
  22398. */
  22399. getClassName(): string;
  22400. /**
  22401. * Gets the uv input component
  22402. */
  22403. get uv(): NodeMaterialConnectionPoint;
  22404. /**
  22405. * Gets the rgba output component
  22406. */
  22407. get rgba(): NodeMaterialConnectionPoint;
  22408. /**
  22409. * Gets the rgb output component
  22410. */
  22411. get rgb(): NodeMaterialConnectionPoint;
  22412. /**
  22413. * Gets the r output component
  22414. */
  22415. get r(): NodeMaterialConnectionPoint;
  22416. /**
  22417. * Gets the g output component
  22418. */
  22419. get g(): NodeMaterialConnectionPoint;
  22420. /**
  22421. * Gets the b output component
  22422. */
  22423. get b(): NodeMaterialConnectionPoint;
  22424. /**
  22425. * Gets the a output component
  22426. */
  22427. get a(): NodeMaterialConnectionPoint;
  22428. /**
  22429. * Initialize the block and prepare the context for build
  22430. * @param state defines the state that will be used for the build
  22431. */
  22432. initialize(state: NodeMaterialBuildState): void;
  22433. autoConfigure(material: NodeMaterial): void;
  22434. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22435. isReady(): boolean;
  22436. private _writeOutput;
  22437. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22438. serialize(): any;
  22439. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22440. }
  22441. }
  22442. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22443. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22445. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22446. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22447. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22448. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22449. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22450. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22451. import { Scene } from "babylonjs/scene";
  22452. /**
  22453. * Class used to store shared data between 2 NodeMaterialBuildState
  22454. */
  22455. export class NodeMaterialBuildStateSharedData {
  22456. /**
  22457. * Gets the list of emitted varyings
  22458. */
  22459. temps: string[];
  22460. /**
  22461. * Gets the list of emitted varyings
  22462. */
  22463. varyings: string[];
  22464. /**
  22465. * Gets the varying declaration string
  22466. */
  22467. varyingDeclaration: string;
  22468. /**
  22469. * Input blocks
  22470. */
  22471. inputBlocks: InputBlock[];
  22472. /**
  22473. * Input blocks
  22474. */
  22475. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22476. /**
  22477. * Bindable blocks (Blocks that need to set data to the effect)
  22478. */
  22479. bindableBlocks: NodeMaterialBlock[];
  22480. /**
  22481. * List of blocks that can provide a compilation fallback
  22482. */
  22483. blocksWithFallbacks: NodeMaterialBlock[];
  22484. /**
  22485. * List of blocks that can provide a define update
  22486. */
  22487. blocksWithDefines: NodeMaterialBlock[];
  22488. /**
  22489. * List of blocks that can provide a repeatable content
  22490. */
  22491. repeatableContentBlocks: NodeMaterialBlock[];
  22492. /**
  22493. * List of blocks that can provide a dynamic list of uniforms
  22494. */
  22495. dynamicUniformBlocks: NodeMaterialBlock[];
  22496. /**
  22497. * List of blocks that can block the isReady function for the material
  22498. */
  22499. blockingBlocks: NodeMaterialBlock[];
  22500. /**
  22501. * Gets the list of animated inputs
  22502. */
  22503. animatedInputs: InputBlock[];
  22504. /**
  22505. * Build Id used to avoid multiple recompilations
  22506. */
  22507. buildId: number;
  22508. /** List of emitted variables */
  22509. variableNames: {
  22510. [key: string]: number;
  22511. };
  22512. /** List of emitted defines */
  22513. defineNames: {
  22514. [key: string]: number;
  22515. };
  22516. /** Should emit comments? */
  22517. emitComments: boolean;
  22518. /** Emit build activity */
  22519. verbose: boolean;
  22520. /** Gets or sets the hosting scene */
  22521. scene: Scene;
  22522. /**
  22523. * Gets the compilation hints emitted at compilation time
  22524. */
  22525. hints: {
  22526. needWorldViewMatrix: boolean;
  22527. needWorldViewProjectionMatrix: boolean;
  22528. needAlphaBlending: boolean;
  22529. needAlphaTesting: boolean;
  22530. };
  22531. /**
  22532. * List of compilation checks
  22533. */
  22534. checks: {
  22535. emitVertex: boolean;
  22536. emitFragment: boolean;
  22537. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22538. };
  22539. /**
  22540. * Is vertex program allowed to be empty?
  22541. */
  22542. allowEmptyVertexProgram: boolean;
  22543. /** Creates a new shared data */
  22544. constructor();
  22545. /**
  22546. * Emits console errors and exceptions if there is a failing check
  22547. */
  22548. emitErrors(): void;
  22549. }
  22550. }
  22551. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22552. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22553. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22554. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22555. /**
  22556. * Class used to store node based material build state
  22557. */
  22558. export class NodeMaterialBuildState {
  22559. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22560. supportUniformBuffers: boolean;
  22561. /**
  22562. * Gets the list of emitted attributes
  22563. */
  22564. attributes: string[];
  22565. /**
  22566. * Gets the list of emitted uniforms
  22567. */
  22568. uniforms: string[];
  22569. /**
  22570. * Gets the list of emitted constants
  22571. */
  22572. constants: string[];
  22573. /**
  22574. * Gets the list of emitted samplers
  22575. */
  22576. samplers: string[];
  22577. /**
  22578. * Gets the list of emitted functions
  22579. */
  22580. functions: {
  22581. [key: string]: string;
  22582. };
  22583. /**
  22584. * Gets the list of emitted extensions
  22585. */
  22586. extensions: {
  22587. [key: string]: string;
  22588. };
  22589. /**
  22590. * Gets the target of the compilation state
  22591. */
  22592. target: NodeMaterialBlockTargets;
  22593. /**
  22594. * Gets the list of emitted counters
  22595. */
  22596. counters: {
  22597. [key: string]: number;
  22598. };
  22599. /**
  22600. * Shared data between multiple NodeMaterialBuildState instances
  22601. */
  22602. sharedData: NodeMaterialBuildStateSharedData;
  22603. /** @hidden */
  22604. _vertexState: NodeMaterialBuildState;
  22605. /** @hidden */
  22606. _attributeDeclaration: string;
  22607. /** @hidden */
  22608. _uniformDeclaration: string;
  22609. /** @hidden */
  22610. _constantDeclaration: string;
  22611. /** @hidden */
  22612. _samplerDeclaration: string;
  22613. /** @hidden */
  22614. _varyingTransfer: string;
  22615. /** @hidden */
  22616. _injectAtEnd: string;
  22617. private _repeatableContentAnchorIndex;
  22618. /** @hidden */
  22619. _builtCompilationString: string;
  22620. /**
  22621. * Gets the emitted compilation strings
  22622. */
  22623. compilationString: string;
  22624. /**
  22625. * Finalize the compilation strings
  22626. * @param state defines the current compilation state
  22627. */
  22628. finalize(state: NodeMaterialBuildState): void;
  22629. /** @hidden */
  22630. get _repeatableContentAnchor(): string;
  22631. /** @hidden */
  22632. _getFreeVariableName(prefix: string): string;
  22633. /** @hidden */
  22634. _getFreeDefineName(prefix: string): string;
  22635. /** @hidden */
  22636. _excludeVariableName(name: string): void;
  22637. /** @hidden */
  22638. _emit2DSampler(name: string): void;
  22639. /** @hidden */
  22640. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22641. /** @hidden */
  22642. _emitExtension(name: string, extension: string, define?: string): void;
  22643. /** @hidden */
  22644. _emitFunction(name: string, code: string, comments: string): void;
  22645. /** @hidden */
  22646. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22647. replaceStrings?: {
  22648. search: RegExp;
  22649. replace: string;
  22650. }[];
  22651. repeatKey?: string;
  22652. }): string;
  22653. /** @hidden */
  22654. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22655. repeatKey?: string;
  22656. removeAttributes?: boolean;
  22657. removeUniforms?: boolean;
  22658. removeVaryings?: boolean;
  22659. removeIfDef?: boolean;
  22660. replaceStrings?: {
  22661. search: RegExp;
  22662. replace: string;
  22663. }[];
  22664. }, storeKey?: string): void;
  22665. /** @hidden */
  22666. _registerTempVariable(name: string): boolean;
  22667. /** @hidden */
  22668. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22669. /** @hidden */
  22670. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22671. /** @hidden */
  22672. _emitFloat(value: number): string;
  22673. }
  22674. }
  22675. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22676. /**
  22677. * Helper class used to generate session unique ID
  22678. */
  22679. export class UniqueIdGenerator {
  22680. private static _UniqueIdCounter;
  22681. /**
  22682. * Gets an unique (relatively to the current scene) Id
  22683. */
  22684. static get UniqueId(): number;
  22685. }
  22686. }
  22687. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22688. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22689. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22690. import { Nullable } from "babylonjs/types";
  22691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22692. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22693. import { Effect } from "babylonjs/Materials/effect";
  22694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22695. import { Mesh } from "babylonjs/Meshes/mesh";
  22696. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22697. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22698. import { Scene } from "babylonjs/scene";
  22699. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22700. /**
  22701. * Defines a block that can be used inside a node based material
  22702. */
  22703. export class NodeMaterialBlock {
  22704. private _buildId;
  22705. private _buildTarget;
  22706. private _target;
  22707. private _isFinalMerger;
  22708. private _isInput;
  22709. private _name;
  22710. protected _isUnique: boolean;
  22711. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22712. inputsAreExclusive: boolean;
  22713. /** @hidden */
  22714. _codeVariableName: string;
  22715. /** @hidden */
  22716. _inputs: NodeMaterialConnectionPoint[];
  22717. /** @hidden */
  22718. _outputs: NodeMaterialConnectionPoint[];
  22719. /** @hidden */
  22720. _preparationId: number;
  22721. /**
  22722. * Gets the name of the block
  22723. */
  22724. get name(): string;
  22725. /**
  22726. * Sets the name of the block. Will check if the name is valid.
  22727. */
  22728. set name(newName: string);
  22729. /**
  22730. * Gets or sets the unique id of the node
  22731. */
  22732. uniqueId: number;
  22733. /**
  22734. * Gets or sets the comments associated with this block
  22735. */
  22736. comments: string;
  22737. /**
  22738. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22739. */
  22740. get isUnique(): boolean;
  22741. /**
  22742. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22743. */
  22744. get isFinalMerger(): boolean;
  22745. /**
  22746. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22747. */
  22748. get isInput(): boolean;
  22749. /**
  22750. * Gets or sets the build Id
  22751. */
  22752. get buildId(): number;
  22753. set buildId(value: number);
  22754. /**
  22755. * Gets or sets the target of the block
  22756. */
  22757. get target(): NodeMaterialBlockTargets;
  22758. set target(value: NodeMaterialBlockTargets);
  22759. /**
  22760. * Gets the list of input points
  22761. */
  22762. get inputs(): NodeMaterialConnectionPoint[];
  22763. /** Gets the list of output points */
  22764. get outputs(): NodeMaterialConnectionPoint[];
  22765. /**
  22766. * Find an input by its name
  22767. * @param name defines the name of the input to look for
  22768. * @returns the input or null if not found
  22769. */
  22770. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22771. /**
  22772. * Find an output by its name
  22773. * @param name defines the name of the outputto look for
  22774. * @returns the output or null if not found
  22775. */
  22776. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22777. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22778. visibleInInspector: boolean;
  22779. /**
  22780. * Creates a new NodeMaterialBlock
  22781. * @param name defines the block name
  22782. * @param target defines the target of that block (Vertex by default)
  22783. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22784. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22785. */
  22786. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22787. /**
  22788. * Initialize the block and prepare the context for build
  22789. * @param state defines the state that will be used for the build
  22790. */
  22791. initialize(state: NodeMaterialBuildState): void;
  22792. /**
  22793. * Bind data to effect. Will only be called for blocks with isBindable === true
  22794. * @param effect defines the effect to bind data to
  22795. * @param nodeMaterial defines the hosting NodeMaterial
  22796. * @param mesh defines the mesh that will be rendered
  22797. * @param subMesh defines the submesh that will be rendered
  22798. */
  22799. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22800. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22801. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22802. protected _writeFloat(value: number): string;
  22803. /**
  22804. * Gets the current class name e.g. "NodeMaterialBlock"
  22805. * @returns the class name
  22806. */
  22807. getClassName(): string;
  22808. /**
  22809. * Register a new input. Must be called inside a block constructor
  22810. * @param name defines the connection point name
  22811. * @param type defines the connection point type
  22812. * @param isOptional defines a boolean indicating that this input can be omitted
  22813. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22814. * @param point an already created connection point. If not provided, create a new one
  22815. * @returns the current block
  22816. */
  22817. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22818. /**
  22819. * Register a new output. Must be called inside a block constructor
  22820. * @param name defines the connection point name
  22821. * @param type defines the connection point type
  22822. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22823. * @param point an already created connection point. If not provided, create a new one
  22824. * @returns the current block
  22825. */
  22826. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22827. /**
  22828. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22829. * @param forOutput defines an optional connection point to check compatibility with
  22830. * @returns the first available input or null
  22831. */
  22832. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22833. /**
  22834. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22835. * @param forBlock defines an optional block to check compatibility with
  22836. * @returns the first available input or null
  22837. */
  22838. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22839. /**
  22840. * Gets the sibling of the given output
  22841. * @param current defines the current output
  22842. * @returns the next output in the list or null
  22843. */
  22844. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22845. /**
  22846. * Connect current block with another block
  22847. * @param other defines the block to connect with
  22848. * @param options define the various options to help pick the right connections
  22849. * @returns the current block
  22850. */
  22851. connectTo(other: NodeMaterialBlock, options?: {
  22852. input?: string;
  22853. output?: string;
  22854. outputSwizzle?: string;
  22855. }): this | undefined;
  22856. protected _buildBlock(state: NodeMaterialBuildState): void;
  22857. /**
  22858. * Add uniforms, samplers and uniform buffers at compilation time
  22859. * @param state defines the state to update
  22860. * @param nodeMaterial defines the node material requesting the update
  22861. * @param defines defines the material defines to update
  22862. * @param uniformBuffers defines the list of uniform buffer names
  22863. */
  22864. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22865. /**
  22866. * Add potential fallbacks if shader compilation fails
  22867. * @param mesh defines the mesh to be rendered
  22868. * @param fallbacks defines the current prioritized list of fallbacks
  22869. */
  22870. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22871. /**
  22872. * Initialize defines for shader compilation
  22873. * @param mesh defines the mesh to be rendered
  22874. * @param nodeMaterial defines the node material requesting the update
  22875. * @param defines defines the material defines to update
  22876. * @param useInstances specifies that instances should be used
  22877. */
  22878. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22879. /**
  22880. * Update defines for shader compilation
  22881. * @param mesh defines the mesh to be rendered
  22882. * @param nodeMaterial defines the node material requesting the update
  22883. * @param defines defines the material defines to update
  22884. * @param useInstances specifies that instances should be used
  22885. * @param subMesh defines which submesh to render
  22886. */
  22887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22888. /**
  22889. * Lets the block try to connect some inputs automatically
  22890. * @param material defines the hosting NodeMaterial
  22891. */
  22892. autoConfigure(material: NodeMaterial): void;
  22893. /**
  22894. * Function called when a block is declared as repeatable content generator
  22895. * @param vertexShaderState defines the current compilation state for the vertex shader
  22896. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22897. * @param mesh defines the mesh to be rendered
  22898. * @param defines defines the material defines to update
  22899. */
  22900. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22901. /**
  22902. * Checks if the block is ready
  22903. * @param mesh defines the mesh to be rendered
  22904. * @param nodeMaterial defines the node material requesting the update
  22905. * @param defines defines the material defines to update
  22906. * @param useInstances specifies that instances should be used
  22907. * @returns true if the block is ready
  22908. */
  22909. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22910. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22911. private _processBuild;
  22912. /**
  22913. * Validates the new name for the block node.
  22914. * @param newName the new name to be given to the node.
  22915. * @returns false if the name is a reserve word, else true.
  22916. */
  22917. validateBlockName(newName: string): boolean;
  22918. /**
  22919. * Compile the current node and generate the shader code
  22920. * @param state defines the current compilation state (uniforms, samplers, current string)
  22921. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22922. * @returns true if already built
  22923. */
  22924. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22925. protected _inputRename(name: string): string;
  22926. protected _outputRename(name: string): string;
  22927. protected _dumpPropertiesCode(): string;
  22928. /** @hidden */
  22929. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22930. /** @hidden */
  22931. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22932. /**
  22933. * Clone the current block to a new identical block
  22934. * @param scene defines the hosting scene
  22935. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22936. * @returns a copy of the current block
  22937. */
  22938. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22939. /**
  22940. * Serializes this block in a JSON representation
  22941. * @returns the serialized block object
  22942. */
  22943. serialize(): any;
  22944. /** @hidden */
  22945. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22946. private _deserializePortDisplayNamesAndExposedOnFrame;
  22947. /**
  22948. * Release resources
  22949. */
  22950. dispose(): void;
  22951. }
  22952. }
  22953. declare module "babylonjs/Materials/pushMaterial" {
  22954. import { Nullable } from "babylonjs/types";
  22955. import { Scene } from "babylonjs/scene";
  22956. import { Matrix } from "babylonjs/Maths/math.vector";
  22957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22958. import { Mesh } from "babylonjs/Meshes/mesh";
  22959. import { Material } from "babylonjs/Materials/material";
  22960. import { Effect } from "babylonjs/Materials/effect";
  22961. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22962. /**
  22963. * Base class of materials working in push mode in babylon JS
  22964. * @hidden
  22965. */
  22966. export class PushMaterial extends Material {
  22967. protected _activeEffect: Effect;
  22968. protected _normalMatrix: Matrix;
  22969. constructor(name: string, scene: Scene);
  22970. getEffect(): Effect;
  22971. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22972. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22973. /**
  22974. * Binds the given world matrix to the active effect
  22975. *
  22976. * @param world the matrix to bind
  22977. */
  22978. bindOnlyWorldMatrix(world: Matrix): void;
  22979. /**
  22980. * Binds the given normal matrix to the active effect
  22981. *
  22982. * @param normalMatrix the matrix to bind
  22983. */
  22984. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22985. bind(world: Matrix, mesh?: Mesh): void;
  22986. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22987. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22988. }
  22989. }
  22990. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22992. /**
  22993. * Root class for all node material optimizers
  22994. */
  22995. export class NodeMaterialOptimizer {
  22996. /**
  22997. * Function used to optimize a NodeMaterial graph
  22998. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22999. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  23000. */
  23001. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  23002. }
  23003. }
  23004. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  23005. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23006. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23007. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23008. import { Scene } from "babylonjs/scene";
  23009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23010. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  23011. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23012. /**
  23013. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  23014. */
  23015. export class TransformBlock extends NodeMaterialBlock {
  23016. /**
  23017. * Defines the value to use to complement W value to transform it to a Vector4
  23018. */
  23019. complementW: number;
  23020. /**
  23021. * Defines the value to use to complement z value to transform it to a Vector4
  23022. */
  23023. complementZ: number;
  23024. /**
  23025. * Creates a new TransformBlock
  23026. * @param name defines the block name
  23027. */
  23028. constructor(name: string);
  23029. /**
  23030. * Gets the current class name
  23031. * @returns the class name
  23032. */
  23033. getClassName(): string;
  23034. /**
  23035. * Gets the vector input
  23036. */
  23037. get vector(): NodeMaterialConnectionPoint;
  23038. /**
  23039. * Gets the output component
  23040. */
  23041. get output(): NodeMaterialConnectionPoint;
  23042. /**
  23043. * Gets the xyz output component
  23044. */
  23045. get xyz(): NodeMaterialConnectionPoint;
  23046. /**
  23047. * Gets the matrix transform input
  23048. */
  23049. get transform(): NodeMaterialConnectionPoint;
  23050. protected _buildBlock(state: NodeMaterialBuildState): this;
  23051. /**
  23052. * Update defines for shader compilation
  23053. * @param mesh defines the mesh to be rendered
  23054. * @param nodeMaterial defines the node material requesting the update
  23055. * @param defines defines the material defines to update
  23056. * @param useInstances specifies that instances should be used
  23057. * @param subMesh defines which submesh to render
  23058. */
  23059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  23060. serialize(): any;
  23061. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23062. protected _dumpPropertiesCode(): string;
  23063. }
  23064. }
  23065. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  23066. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23067. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23068. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23069. /**
  23070. * Block used to output the vertex position
  23071. */
  23072. export class VertexOutputBlock extends NodeMaterialBlock {
  23073. /**
  23074. * Creates a new VertexOutputBlock
  23075. * @param name defines the block name
  23076. */
  23077. constructor(name: string);
  23078. /**
  23079. * Gets the current class name
  23080. * @returns the class name
  23081. */
  23082. getClassName(): string;
  23083. /**
  23084. * Gets the vector input component
  23085. */
  23086. get vector(): NodeMaterialConnectionPoint;
  23087. protected _buildBlock(state: NodeMaterialBuildState): this;
  23088. }
  23089. }
  23090. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  23091. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23092. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23093. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23094. /**
  23095. * Block used to output the final color
  23096. */
  23097. export class FragmentOutputBlock extends NodeMaterialBlock {
  23098. /**
  23099. * Create a new FragmentOutputBlock
  23100. * @param name defines the block name
  23101. */
  23102. constructor(name: string);
  23103. /**
  23104. * Gets the current class name
  23105. * @returns the class name
  23106. */
  23107. getClassName(): string;
  23108. /**
  23109. * Gets the rgba input component
  23110. */
  23111. get rgba(): NodeMaterialConnectionPoint;
  23112. /**
  23113. * Gets the rgb input component
  23114. */
  23115. get rgb(): NodeMaterialConnectionPoint;
  23116. /**
  23117. * Gets the a input component
  23118. */
  23119. get a(): NodeMaterialConnectionPoint;
  23120. protected _buildBlock(state: NodeMaterialBuildState): this;
  23121. }
  23122. }
  23123. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  23124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23125. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23126. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23127. /**
  23128. * Block used for the particle ramp gradient section
  23129. */
  23130. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  23131. /**
  23132. * Create a new ParticleRampGradientBlock
  23133. * @param name defines the block name
  23134. */
  23135. constructor(name: string);
  23136. /**
  23137. * Gets the current class name
  23138. * @returns the class name
  23139. */
  23140. getClassName(): string;
  23141. /**
  23142. * Gets the color input component
  23143. */
  23144. get color(): NodeMaterialConnectionPoint;
  23145. /**
  23146. * Gets the rampColor output component
  23147. */
  23148. get rampColor(): NodeMaterialConnectionPoint;
  23149. /**
  23150. * Initialize the block and prepare the context for build
  23151. * @param state defines the state that will be used for the build
  23152. */
  23153. initialize(state: NodeMaterialBuildState): void;
  23154. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23155. }
  23156. }
  23157. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  23158. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23159. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23160. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23161. /**
  23162. * Block used for the particle blend multiply section
  23163. */
  23164. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  23165. /**
  23166. * Create a new ParticleBlendMultiplyBlock
  23167. * @param name defines the block name
  23168. */
  23169. constructor(name: string);
  23170. /**
  23171. * Gets the current class name
  23172. * @returns the class name
  23173. */
  23174. getClassName(): string;
  23175. /**
  23176. * Gets the color input component
  23177. */
  23178. get color(): NodeMaterialConnectionPoint;
  23179. /**
  23180. * Gets the alphaTexture input component
  23181. */
  23182. get alphaTexture(): NodeMaterialConnectionPoint;
  23183. /**
  23184. * Gets the alphaColor input component
  23185. */
  23186. get alphaColor(): NodeMaterialConnectionPoint;
  23187. /**
  23188. * Gets the blendColor output component
  23189. */
  23190. get blendColor(): NodeMaterialConnectionPoint;
  23191. /**
  23192. * Initialize the block and prepare the context for build
  23193. * @param state defines the state that will be used for the build
  23194. */
  23195. initialize(state: NodeMaterialBuildState): void;
  23196. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23197. }
  23198. }
  23199. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  23200. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23201. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23202. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23203. /**
  23204. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  23205. */
  23206. export class VectorMergerBlock extends NodeMaterialBlock {
  23207. /**
  23208. * Create a new VectorMergerBlock
  23209. * @param name defines the block name
  23210. */
  23211. constructor(name: string);
  23212. /**
  23213. * Gets the current class name
  23214. * @returns the class name
  23215. */
  23216. getClassName(): string;
  23217. /**
  23218. * Gets the xyz component (input)
  23219. */
  23220. get xyzIn(): NodeMaterialConnectionPoint;
  23221. /**
  23222. * Gets the xy component (input)
  23223. */
  23224. get xyIn(): NodeMaterialConnectionPoint;
  23225. /**
  23226. * Gets the x component (input)
  23227. */
  23228. get x(): NodeMaterialConnectionPoint;
  23229. /**
  23230. * Gets the y component (input)
  23231. */
  23232. get y(): NodeMaterialConnectionPoint;
  23233. /**
  23234. * Gets the z component (input)
  23235. */
  23236. get z(): NodeMaterialConnectionPoint;
  23237. /**
  23238. * Gets the w component (input)
  23239. */
  23240. get w(): NodeMaterialConnectionPoint;
  23241. /**
  23242. * Gets the xyzw component (output)
  23243. */
  23244. get xyzw(): NodeMaterialConnectionPoint;
  23245. /**
  23246. * Gets the xyz component (output)
  23247. */
  23248. get xyzOut(): NodeMaterialConnectionPoint;
  23249. /**
  23250. * Gets the xy component (output)
  23251. */
  23252. get xyOut(): NodeMaterialConnectionPoint;
  23253. /**
  23254. * Gets the xy component (output)
  23255. * @deprecated Please use xyOut instead.
  23256. */
  23257. get xy(): NodeMaterialConnectionPoint;
  23258. /**
  23259. * Gets the xyz component (output)
  23260. * @deprecated Please use xyzOut instead.
  23261. */
  23262. get xyz(): NodeMaterialConnectionPoint;
  23263. protected _buildBlock(state: NodeMaterialBuildState): this;
  23264. }
  23265. }
  23266. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  23267. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23268. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23269. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23270. import { Vector2 } from "babylonjs/Maths/math.vector";
  23271. import { Scene } from "babylonjs/scene";
  23272. /**
  23273. * Block used to remap a float from a range to a new one
  23274. */
  23275. export class RemapBlock extends NodeMaterialBlock {
  23276. /**
  23277. * Gets or sets the source range
  23278. */
  23279. sourceRange: Vector2;
  23280. /**
  23281. * Gets or sets the target range
  23282. */
  23283. targetRange: Vector2;
  23284. /**
  23285. * Creates a new RemapBlock
  23286. * @param name defines the block name
  23287. */
  23288. constructor(name: string);
  23289. /**
  23290. * Gets the current class name
  23291. * @returns the class name
  23292. */
  23293. getClassName(): string;
  23294. /**
  23295. * Gets the input component
  23296. */
  23297. get input(): NodeMaterialConnectionPoint;
  23298. /**
  23299. * Gets the source min input component
  23300. */
  23301. get sourceMin(): NodeMaterialConnectionPoint;
  23302. /**
  23303. * Gets the source max input component
  23304. */
  23305. get sourceMax(): NodeMaterialConnectionPoint;
  23306. /**
  23307. * Gets the target min input component
  23308. */
  23309. get targetMin(): NodeMaterialConnectionPoint;
  23310. /**
  23311. * Gets the target max input component
  23312. */
  23313. get targetMax(): NodeMaterialConnectionPoint;
  23314. /**
  23315. * Gets the output component
  23316. */
  23317. get output(): NodeMaterialConnectionPoint;
  23318. protected _buildBlock(state: NodeMaterialBuildState): this;
  23319. protected _dumpPropertiesCode(): string;
  23320. serialize(): any;
  23321. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23322. }
  23323. }
  23324. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  23325. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23326. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23327. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23328. /**
  23329. * Block used to multiply 2 values
  23330. */
  23331. export class MultiplyBlock extends NodeMaterialBlock {
  23332. /**
  23333. * Creates a new MultiplyBlock
  23334. * @param name defines the block name
  23335. */
  23336. constructor(name: string);
  23337. /**
  23338. * Gets the current class name
  23339. * @returns the class name
  23340. */
  23341. getClassName(): string;
  23342. /**
  23343. * Gets the left operand input component
  23344. */
  23345. get left(): NodeMaterialConnectionPoint;
  23346. /**
  23347. * Gets the right operand input component
  23348. */
  23349. get right(): NodeMaterialConnectionPoint;
  23350. /**
  23351. * Gets the output component
  23352. */
  23353. get output(): NodeMaterialConnectionPoint;
  23354. protected _buildBlock(state: NodeMaterialBuildState): this;
  23355. }
  23356. }
  23357. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  23358. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23359. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23360. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23361. /**
  23362. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23363. */
  23364. export class ColorSplitterBlock extends NodeMaterialBlock {
  23365. /**
  23366. * Create a new ColorSplitterBlock
  23367. * @param name defines the block name
  23368. */
  23369. constructor(name: string);
  23370. /**
  23371. * Gets the current class name
  23372. * @returns the class name
  23373. */
  23374. getClassName(): string;
  23375. /**
  23376. * Gets the rgba component (input)
  23377. */
  23378. get rgba(): NodeMaterialConnectionPoint;
  23379. /**
  23380. * Gets the rgb component (input)
  23381. */
  23382. get rgbIn(): NodeMaterialConnectionPoint;
  23383. /**
  23384. * Gets the rgb component (output)
  23385. */
  23386. get rgbOut(): NodeMaterialConnectionPoint;
  23387. /**
  23388. * Gets the r component (output)
  23389. */
  23390. get r(): NodeMaterialConnectionPoint;
  23391. /**
  23392. * Gets the g component (output)
  23393. */
  23394. get g(): NodeMaterialConnectionPoint;
  23395. /**
  23396. * Gets the b component (output)
  23397. */
  23398. get b(): NodeMaterialConnectionPoint;
  23399. /**
  23400. * Gets the a component (output)
  23401. */
  23402. get a(): NodeMaterialConnectionPoint;
  23403. protected _inputRename(name: string): string;
  23404. protected _outputRename(name: string): string;
  23405. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23406. }
  23407. }
  23408. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23409. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23410. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23411. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23412. import { Scene } from "babylonjs/scene";
  23413. /**
  23414. * Operations supported by the Trigonometry block
  23415. */
  23416. export enum TrigonometryBlockOperations {
  23417. /** Cos */
  23418. Cos = 0,
  23419. /** Sin */
  23420. Sin = 1,
  23421. /** Abs */
  23422. Abs = 2,
  23423. /** Exp */
  23424. Exp = 3,
  23425. /** Exp2 */
  23426. Exp2 = 4,
  23427. /** Round */
  23428. Round = 5,
  23429. /** Floor */
  23430. Floor = 6,
  23431. /** Ceiling */
  23432. Ceiling = 7,
  23433. /** Square root */
  23434. Sqrt = 8,
  23435. /** Log */
  23436. Log = 9,
  23437. /** Tangent */
  23438. Tan = 10,
  23439. /** Arc tangent */
  23440. ArcTan = 11,
  23441. /** Arc cosinus */
  23442. ArcCos = 12,
  23443. /** Arc sinus */
  23444. ArcSin = 13,
  23445. /** Fraction */
  23446. Fract = 14,
  23447. /** Sign */
  23448. Sign = 15,
  23449. /** To radians (from degrees) */
  23450. Radians = 16,
  23451. /** To degrees (from radians) */
  23452. Degrees = 17
  23453. }
  23454. /**
  23455. * Block used to apply trigonometry operation to floats
  23456. */
  23457. export class TrigonometryBlock extends NodeMaterialBlock {
  23458. /**
  23459. * Gets or sets the operation applied by the block
  23460. */
  23461. operation: TrigonometryBlockOperations;
  23462. /**
  23463. * Creates a new TrigonometryBlock
  23464. * @param name defines the block name
  23465. */
  23466. constructor(name: string);
  23467. /**
  23468. * Gets the current class name
  23469. * @returns the class name
  23470. */
  23471. getClassName(): string;
  23472. /**
  23473. * Gets the input component
  23474. */
  23475. get input(): NodeMaterialConnectionPoint;
  23476. /**
  23477. * Gets the output component
  23478. */
  23479. get output(): NodeMaterialConnectionPoint;
  23480. protected _buildBlock(state: NodeMaterialBuildState): this;
  23481. serialize(): any;
  23482. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23483. protected _dumpPropertiesCode(): string;
  23484. }
  23485. }
  23486. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23487. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23488. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23489. import { Scene } from "babylonjs/scene";
  23490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23491. import { Matrix } from "babylonjs/Maths/math.vector";
  23492. import { Mesh } from "babylonjs/Meshes/mesh";
  23493. import { Engine } from "babylonjs/Engines/engine";
  23494. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23495. import { Observable } from "babylonjs/Misc/observable";
  23496. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23497. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23498. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23499. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23500. import { Nullable } from "babylonjs/types";
  23501. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23502. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23503. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23504. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23505. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23506. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23507. import { Effect } from "babylonjs/Materials/effect";
  23508. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23509. import { Camera } from "babylonjs/Cameras/camera";
  23510. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23511. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23512. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23513. /**
  23514. * Interface used to configure the node material editor
  23515. */
  23516. export interface INodeMaterialEditorOptions {
  23517. /** Define the URl to load node editor script */
  23518. editorURL?: string;
  23519. }
  23520. /** @hidden */
  23521. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23522. NORMAL: boolean;
  23523. TANGENT: boolean;
  23524. UV1: boolean;
  23525. /** BONES */
  23526. NUM_BONE_INFLUENCERS: number;
  23527. BonesPerMesh: number;
  23528. BONETEXTURE: boolean;
  23529. /** MORPH TARGETS */
  23530. MORPHTARGETS: boolean;
  23531. MORPHTARGETS_NORMAL: boolean;
  23532. MORPHTARGETS_TANGENT: boolean;
  23533. MORPHTARGETS_UV: boolean;
  23534. NUM_MORPH_INFLUENCERS: number;
  23535. /** IMAGE PROCESSING */
  23536. IMAGEPROCESSING: boolean;
  23537. VIGNETTE: boolean;
  23538. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23539. VIGNETTEBLENDMODEOPAQUE: boolean;
  23540. TONEMAPPING: boolean;
  23541. TONEMAPPING_ACES: boolean;
  23542. CONTRAST: boolean;
  23543. EXPOSURE: boolean;
  23544. COLORCURVES: boolean;
  23545. COLORGRADING: boolean;
  23546. COLORGRADING3D: boolean;
  23547. SAMPLER3DGREENDEPTH: boolean;
  23548. SAMPLER3DBGRMAP: boolean;
  23549. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23550. /** MISC. */
  23551. BUMPDIRECTUV: number;
  23552. constructor();
  23553. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23554. }
  23555. /**
  23556. * Class used to configure NodeMaterial
  23557. */
  23558. export interface INodeMaterialOptions {
  23559. /**
  23560. * Defines if blocks should emit comments
  23561. */
  23562. emitComments: boolean;
  23563. }
  23564. /**
  23565. * Class used to create a node based material built by assembling shader blocks
  23566. */
  23567. export class NodeMaterial extends PushMaterial {
  23568. private static _BuildIdGenerator;
  23569. private _options;
  23570. private _vertexCompilationState;
  23571. private _fragmentCompilationState;
  23572. private _sharedData;
  23573. private _buildId;
  23574. private _buildWasSuccessful;
  23575. private _cachedWorldViewMatrix;
  23576. private _cachedWorldViewProjectionMatrix;
  23577. private _optimizers;
  23578. private _animationFrame;
  23579. /** Define the Url to load node editor script */
  23580. static EditorURL: string;
  23581. /** Define the Url to load snippets */
  23582. static SnippetUrl: string;
  23583. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23584. static IgnoreTexturesAtLoadTime: boolean;
  23585. private BJSNODEMATERIALEDITOR;
  23586. /** Get the inspector from bundle or global */
  23587. private _getGlobalNodeMaterialEditor;
  23588. /**
  23589. * Snippet ID if the material was created from the snippet server
  23590. */
  23591. snippetId: string;
  23592. /**
  23593. * Gets or sets data used by visual editor
  23594. * @see https://nme.babylonjs.com
  23595. */
  23596. editorData: any;
  23597. /**
  23598. * 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)
  23599. */
  23600. ignoreAlpha: boolean;
  23601. /**
  23602. * Defines the maximum number of lights that can be used in the material
  23603. */
  23604. maxSimultaneousLights: number;
  23605. /**
  23606. * Observable raised when the material is built
  23607. */
  23608. onBuildObservable: Observable<NodeMaterial>;
  23609. /**
  23610. * Gets or sets the root nodes of the material vertex shader
  23611. */
  23612. _vertexOutputNodes: NodeMaterialBlock[];
  23613. /**
  23614. * Gets or sets the root nodes of the material fragment (pixel) shader
  23615. */
  23616. _fragmentOutputNodes: NodeMaterialBlock[];
  23617. /** Gets or sets options to control the node material overall behavior */
  23618. get options(): INodeMaterialOptions;
  23619. set options(options: INodeMaterialOptions);
  23620. /**
  23621. * Default configuration related to image processing available in the standard Material.
  23622. */
  23623. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23624. /**
  23625. * Gets the image processing configuration used either in this material.
  23626. */
  23627. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23628. /**
  23629. * Sets the Default image processing configuration used either in the this material.
  23630. *
  23631. * If sets to null, the scene one is in use.
  23632. */
  23633. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23634. /**
  23635. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23636. */
  23637. attachedBlocks: NodeMaterialBlock[];
  23638. /**
  23639. * Specifies the mode of the node material
  23640. * @hidden
  23641. */
  23642. _mode: NodeMaterialModes;
  23643. /**
  23644. * Gets the mode property
  23645. */
  23646. get mode(): NodeMaterialModes;
  23647. /**
  23648. * A free comment about the material
  23649. */
  23650. comment: string;
  23651. /**
  23652. * Create a new node based material
  23653. * @param name defines the material name
  23654. * @param scene defines the hosting scene
  23655. * @param options defines creation option
  23656. */
  23657. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23658. /**
  23659. * Gets the current class name of the material e.g. "NodeMaterial"
  23660. * @returns the class name
  23661. */
  23662. getClassName(): string;
  23663. /**
  23664. * Keep track of the image processing observer to allow dispose and replace.
  23665. */
  23666. private _imageProcessingObserver;
  23667. /**
  23668. * Attaches a new image processing configuration to the Standard Material.
  23669. * @param configuration
  23670. */
  23671. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23672. /**
  23673. * Get a block by its name
  23674. * @param name defines the name of the block to retrieve
  23675. * @returns the required block or null if not found
  23676. */
  23677. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23678. /**
  23679. * Get a block by its name
  23680. * @param predicate defines the predicate used to find the good candidate
  23681. * @returns the required block or null if not found
  23682. */
  23683. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23684. /**
  23685. * Get an input block by its name
  23686. * @param predicate defines the predicate used to find the good candidate
  23687. * @returns the required input block or null if not found
  23688. */
  23689. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23690. /**
  23691. * Gets the list of input blocks attached to this material
  23692. * @returns an array of InputBlocks
  23693. */
  23694. getInputBlocks(): InputBlock[];
  23695. /**
  23696. * Adds a new optimizer to the list of optimizers
  23697. * @param optimizer defines the optimizers to add
  23698. * @returns the current material
  23699. */
  23700. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23701. /**
  23702. * Remove an optimizer from the list of optimizers
  23703. * @param optimizer defines the optimizers to remove
  23704. * @returns the current material
  23705. */
  23706. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23707. /**
  23708. * Add a new block to the list of output nodes
  23709. * @param node defines the node to add
  23710. * @returns the current material
  23711. */
  23712. addOutputNode(node: NodeMaterialBlock): this;
  23713. /**
  23714. * Remove a block from the list of root nodes
  23715. * @param node defines the node to remove
  23716. * @returns the current material
  23717. */
  23718. removeOutputNode(node: NodeMaterialBlock): this;
  23719. private _addVertexOutputNode;
  23720. private _removeVertexOutputNode;
  23721. private _addFragmentOutputNode;
  23722. private _removeFragmentOutputNode;
  23723. /**
  23724. * Specifies if the material will require alpha blending
  23725. * @returns a boolean specifying if alpha blending is needed
  23726. */
  23727. needAlphaBlending(): boolean;
  23728. /**
  23729. * Specifies if this material should be rendered in alpha test mode
  23730. * @returns a boolean specifying if an alpha test is needed.
  23731. */
  23732. needAlphaTesting(): boolean;
  23733. private _initializeBlock;
  23734. private _resetDualBlocks;
  23735. /**
  23736. * Remove a block from the current node material
  23737. * @param block defines the block to remove
  23738. */
  23739. removeBlock(block: NodeMaterialBlock): void;
  23740. /**
  23741. * Build the material and generates the inner effect
  23742. * @param verbose defines if the build should log activity
  23743. */
  23744. build(verbose?: boolean): void;
  23745. /**
  23746. * Runs an otpimization phase to try to improve the shader code
  23747. */
  23748. optimize(): void;
  23749. private _prepareDefinesForAttributes;
  23750. /**
  23751. * Create a post process from the material
  23752. * @param camera The camera to apply the render pass to.
  23753. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23754. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23755. * @param engine The engine which the post process will be applied. (default: current engine)
  23756. * @param reusable If the post process can be reused on the same frame. (default: false)
  23757. * @param textureType Type of textures used when performing the post process. (default: 0)
  23758. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23759. * @returns the post process created
  23760. */
  23761. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23762. /**
  23763. * Create the post process effect from the material
  23764. * @param postProcess The post process to create the effect for
  23765. */
  23766. createEffectForPostProcess(postProcess: PostProcess): void;
  23767. private _createEffectForPostProcess;
  23768. /**
  23769. * Create a new procedural texture based on this node material
  23770. * @param size defines the size of the texture
  23771. * @param scene defines the hosting scene
  23772. * @returns the new procedural texture attached to this node material
  23773. */
  23774. createProceduralTexture(size: number | {
  23775. width: number;
  23776. height: number;
  23777. layers?: number;
  23778. }, scene: Scene): Nullable<ProceduralTexture>;
  23779. private _createEffectForParticles;
  23780. private _checkInternals;
  23781. /**
  23782. * Create the effect to be used as the custom effect for a particle system
  23783. * @param particleSystem Particle system to create the effect for
  23784. * @param onCompiled defines a function to call when the effect creation is successful
  23785. * @param onError defines a function to call when the effect creation has failed
  23786. */
  23787. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23788. private _processDefines;
  23789. /**
  23790. * Get if the submesh is ready to be used and all its information available.
  23791. * Child classes can use it to update shaders
  23792. * @param mesh defines the mesh to check
  23793. * @param subMesh defines which submesh to check
  23794. * @param useInstances specifies that instances should be used
  23795. * @returns a boolean indicating that the submesh is ready or not
  23796. */
  23797. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23798. /**
  23799. * Get a string representing the shaders built by the current node graph
  23800. */
  23801. get compiledShaders(): string;
  23802. /**
  23803. * Binds the world matrix to the material
  23804. * @param world defines the world transformation matrix
  23805. */
  23806. bindOnlyWorldMatrix(world: Matrix): void;
  23807. /**
  23808. * Binds the submesh to this material by preparing the effect and shader to draw
  23809. * @param world defines the world transformation matrix
  23810. * @param mesh defines the mesh containing the submesh
  23811. * @param subMesh defines the submesh to bind the material to
  23812. */
  23813. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23814. /**
  23815. * Gets the active textures from the material
  23816. * @returns an array of textures
  23817. */
  23818. getActiveTextures(): BaseTexture[];
  23819. /**
  23820. * Gets the list of texture blocks
  23821. * @returns an array of texture blocks
  23822. */
  23823. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23824. /**
  23825. * Specifies if the material uses a texture
  23826. * @param texture defines the texture to check against the material
  23827. * @returns a boolean specifying if the material uses the texture
  23828. */
  23829. hasTexture(texture: BaseTexture): boolean;
  23830. /**
  23831. * Disposes the material
  23832. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23833. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23834. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23835. */
  23836. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23837. /** Creates the node editor window. */
  23838. private _createNodeEditor;
  23839. /**
  23840. * Launch the node material editor
  23841. * @param config Define the configuration of the editor
  23842. * @return a promise fulfilled when the node editor is visible
  23843. */
  23844. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23845. /**
  23846. * Clear the current material
  23847. */
  23848. clear(): void;
  23849. /**
  23850. * Clear the current material and set it to a default state
  23851. */
  23852. setToDefault(): void;
  23853. /**
  23854. * Clear the current material and set it to a default state for post process
  23855. */
  23856. setToDefaultPostProcess(): void;
  23857. /**
  23858. * Clear the current material and set it to a default state for procedural texture
  23859. */
  23860. setToDefaultProceduralTexture(): void;
  23861. /**
  23862. * Clear the current material and set it to a default state for particle
  23863. */
  23864. setToDefaultParticle(): void;
  23865. /**
  23866. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23867. * @param url defines the url to load from
  23868. * @returns a promise that will fullfil when the material is fully loaded
  23869. */
  23870. loadAsync(url: string): Promise<void>;
  23871. private _gatherBlocks;
  23872. /**
  23873. * Generate a string containing the code declaration required to create an equivalent of this material
  23874. * @returns a string
  23875. */
  23876. generateCode(): string;
  23877. /**
  23878. * Serializes this material in a JSON representation
  23879. * @returns the serialized material object
  23880. */
  23881. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23882. private _restoreConnections;
  23883. /**
  23884. * Clear the current graph and load a new one from a serialization object
  23885. * @param source defines the JSON representation of the material
  23886. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23887. * @param merge defines whether or not the source must be merged or replace the current content
  23888. */
  23889. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23890. /**
  23891. * Makes a duplicate of the current material.
  23892. * @param name - name to use for the new material.
  23893. */
  23894. clone(name: string): NodeMaterial;
  23895. /**
  23896. * Creates a node material from parsed material data
  23897. * @param source defines the JSON representation of the material
  23898. * @param scene defines the hosting scene
  23899. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23900. * @returns a new node material
  23901. */
  23902. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23903. /**
  23904. * Creates a node material from a snippet saved in a remote file
  23905. * @param name defines the name of the material to create
  23906. * @param url defines the url to load from
  23907. * @param scene defines the hosting scene
  23908. * @returns a promise that will resolve to the new node material
  23909. */
  23910. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23911. /**
  23912. * Creates a node material from a snippet saved by the node material editor
  23913. * @param snippetId defines the snippet to load
  23914. * @param scene defines the hosting scene
  23915. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23916. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23917. * @returns a promise that will resolve to the new node material
  23918. */
  23919. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23920. /**
  23921. * Creates a new node material set to default basic configuration
  23922. * @param name defines the name of the material
  23923. * @param scene defines the hosting scene
  23924. * @returns a new NodeMaterial
  23925. */
  23926. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23927. }
  23928. }
  23929. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  23930. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23931. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  23932. import { Nullable } from "babylonjs/types";
  23933. module "babylonjs/Engines/thinEngine" {
  23934. interface ThinEngine {
  23935. /**
  23936. * Unbind a list of render target textures from the webGL context
  23937. * This is used only when drawBuffer extension or webGL2 are active
  23938. * @param textures defines the render target textures to unbind
  23939. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23940. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23941. */
  23942. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23943. /**
  23944. * Create a multi render target texture
  23945. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23946. * @param size defines the size of the texture
  23947. * @param options defines the creation options
  23948. * @returns the cube texture as an InternalTexture
  23949. */
  23950. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23951. /**
  23952. * Update the sample count for a given multiple render target texture
  23953. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23954. * @param textures defines the textures to update
  23955. * @param samples defines the sample count to set
  23956. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23957. */
  23958. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23959. /**
  23960. * Select a subsets of attachments to draw to.
  23961. * @param attachments gl attachments
  23962. */
  23963. bindAttachments(attachments: number[]): void;
  23964. /**
  23965. * Creates a layout object to draw/clear on specific textures in a MRT
  23966. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23967. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23968. */
  23969. buildTextureLayout(textureStatus: boolean[]): number[];
  23970. /**
  23971. * Restores the webgl state to only draw on the main color attachment
  23972. */
  23973. restoreSingleAttachment(): void;
  23974. }
  23975. }
  23976. }
  23977. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  23978. import { Scene } from "babylonjs/scene";
  23979. import { Engine } from "babylonjs/Engines/engine";
  23980. import { Texture } from "babylonjs/Materials/Textures/texture";
  23981. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23982. import "babylonjs/Engines/Extensions/engine.multiRender";
  23983. /**
  23984. * Creation options of the multi render target texture.
  23985. */
  23986. export interface IMultiRenderTargetOptions {
  23987. /**
  23988. * Define if the texture needs to create mip maps after render.
  23989. */
  23990. generateMipMaps?: boolean;
  23991. /**
  23992. * Define the types of all the draw buffers we want to create
  23993. */
  23994. types?: number[];
  23995. /**
  23996. * Define the sampling modes of all the draw buffers we want to create
  23997. */
  23998. samplingModes?: number[];
  23999. /**
  24000. * Define if a depth buffer is required
  24001. */
  24002. generateDepthBuffer?: boolean;
  24003. /**
  24004. * Define if a stencil buffer is required
  24005. */
  24006. generateStencilBuffer?: boolean;
  24007. /**
  24008. * Define if a depth texture is required instead of a depth buffer
  24009. */
  24010. generateDepthTexture?: boolean;
  24011. /**
  24012. * Define the number of desired draw buffers
  24013. */
  24014. textureCount?: number;
  24015. /**
  24016. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24017. */
  24018. doNotChangeAspectRatio?: boolean;
  24019. /**
  24020. * Define the default type of the buffers we are creating
  24021. */
  24022. defaultType?: number;
  24023. }
  24024. /**
  24025. * A multi render target, like a render target provides the ability to render to a texture.
  24026. * Unlike the render target, it can render to several draw buffers in one draw.
  24027. * This is specially interesting in deferred rendering or for any effects requiring more than
  24028. * just one color from a single pass.
  24029. */
  24030. export class MultiRenderTarget extends RenderTargetTexture {
  24031. private _internalTextures;
  24032. private _textures;
  24033. private _multiRenderTargetOptions;
  24034. private _count;
  24035. /**
  24036. * Get if draw buffers are currently supported by the used hardware and browser.
  24037. */
  24038. get isSupported(): boolean;
  24039. /**
  24040. * Get the list of textures generated by the multi render target.
  24041. */
  24042. get textures(): Texture[];
  24043. /**
  24044. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24045. */
  24046. get count(): number;
  24047. /**
  24048. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24049. */
  24050. get depthTexture(): Texture;
  24051. /**
  24052. * Set the wrapping mode on U of all the textures we are rendering to.
  24053. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24054. */
  24055. set wrapU(wrap: number);
  24056. /**
  24057. * Set the wrapping mode on V of all the textures we are rendering to.
  24058. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24059. */
  24060. set wrapV(wrap: number);
  24061. /**
  24062. * Instantiate a new multi render target texture.
  24063. * A multi render target, like a render target provides the ability to render to a texture.
  24064. * Unlike the render target, it can render to several draw buffers in one draw.
  24065. * This is specially interesting in deferred rendering or for any effects requiring more than
  24066. * just one color from a single pass.
  24067. * @param name Define the name of the texture
  24068. * @param size Define the size of the buffers to render to
  24069. * @param count Define the number of target we are rendering into
  24070. * @param scene Define the scene the texture belongs to
  24071. * @param options Define the options used to create the multi render target
  24072. */
  24073. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24074. private _initTypes;
  24075. /** @hidden */
  24076. _rebuild(forceFullRebuild?: boolean): void;
  24077. private _createInternalTextures;
  24078. private _createTextures;
  24079. /**
  24080. * Replaces a texture within the MRT.
  24081. * @param texture The new texture to insert in the MRT
  24082. * @param index The index of the texture to replace
  24083. */
  24084. replaceTexture(texture: Texture, index: number): void;
  24085. /**
  24086. * Define the number of samples used if MSAA is enabled.
  24087. */
  24088. get samples(): number;
  24089. set samples(value: number);
  24090. /**
  24091. * Resize all the textures in the multi render target.
  24092. * Be careful as it will recreate all the data in the new texture.
  24093. * @param size Define the new size
  24094. */
  24095. resize(size: any): void;
  24096. /**
  24097. * Changes the number of render targets in this MRT
  24098. * Be careful as it will recreate all the data in the new texture.
  24099. * @param count new texture count
  24100. * @param options Specifies texture types and sampling modes for new textures
  24101. */
  24102. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  24103. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24104. /**
  24105. * Dispose the render targets and their associated resources
  24106. */
  24107. dispose(): void;
  24108. /**
  24109. * Release all the underlying texture used as draw buffers.
  24110. */
  24111. releaseInternalTextures(): void;
  24112. }
  24113. }
  24114. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24115. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24116. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24117. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24118. /** @hidden */
  24119. export var imageProcessingPixelShader: {
  24120. name: string;
  24121. shader: string;
  24122. };
  24123. }
  24124. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24125. import { Nullable } from "babylonjs/types";
  24126. import { Color4 } from "babylonjs/Maths/math.color";
  24127. import { Camera } from "babylonjs/Cameras/camera";
  24128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24129. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24130. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24131. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24132. import { Engine } from "babylonjs/Engines/engine";
  24133. import "babylonjs/Shaders/imageProcessing.fragment";
  24134. import "babylonjs/Shaders/postprocess.vertex";
  24135. /**
  24136. * ImageProcessingPostProcess
  24137. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24138. */
  24139. export class ImageProcessingPostProcess extends PostProcess {
  24140. /**
  24141. * Default configuration related to image processing available in the PBR Material.
  24142. */
  24143. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24144. /**
  24145. * Gets the image processing configuration used either in this material.
  24146. */
  24147. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24148. /**
  24149. * Sets the Default image processing configuration used either in the this material.
  24150. *
  24151. * If sets to null, the scene one is in use.
  24152. */
  24153. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24154. /**
  24155. * Keep track of the image processing observer to allow dispose and replace.
  24156. */
  24157. private _imageProcessingObserver;
  24158. /**
  24159. * Attaches a new image processing configuration to the PBR Material.
  24160. * @param configuration
  24161. */
  24162. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24163. /**
  24164. * If the post process is supported.
  24165. */
  24166. get isSupported(): boolean;
  24167. /**
  24168. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24169. */
  24170. get colorCurves(): Nullable<ColorCurves>;
  24171. /**
  24172. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24173. */
  24174. set colorCurves(value: Nullable<ColorCurves>);
  24175. /**
  24176. * Gets wether the color curves effect is enabled.
  24177. */
  24178. get colorCurvesEnabled(): boolean;
  24179. /**
  24180. * Sets wether the color curves effect is enabled.
  24181. */
  24182. set colorCurvesEnabled(value: boolean);
  24183. /**
  24184. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24185. */
  24186. get colorGradingTexture(): Nullable<BaseTexture>;
  24187. /**
  24188. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24189. */
  24190. set colorGradingTexture(value: Nullable<BaseTexture>);
  24191. /**
  24192. * Gets wether the color grading effect is enabled.
  24193. */
  24194. get colorGradingEnabled(): boolean;
  24195. /**
  24196. * Gets wether the color grading effect is enabled.
  24197. */
  24198. set colorGradingEnabled(value: boolean);
  24199. /**
  24200. * Gets exposure used in the effect.
  24201. */
  24202. get exposure(): number;
  24203. /**
  24204. * Sets exposure used in the effect.
  24205. */
  24206. set exposure(value: number);
  24207. /**
  24208. * Gets wether tonemapping is enabled or not.
  24209. */
  24210. get toneMappingEnabled(): boolean;
  24211. /**
  24212. * Sets wether tonemapping is enabled or not
  24213. */
  24214. set toneMappingEnabled(value: boolean);
  24215. /**
  24216. * Gets the type of tone mapping effect.
  24217. */
  24218. get toneMappingType(): number;
  24219. /**
  24220. * Sets the type of tone mapping effect.
  24221. */
  24222. set toneMappingType(value: number);
  24223. /**
  24224. * Gets contrast used in the effect.
  24225. */
  24226. get contrast(): number;
  24227. /**
  24228. * Sets contrast used in the effect.
  24229. */
  24230. set contrast(value: number);
  24231. /**
  24232. * Gets Vignette stretch size.
  24233. */
  24234. get vignetteStretch(): number;
  24235. /**
  24236. * Sets Vignette stretch size.
  24237. */
  24238. set vignetteStretch(value: number);
  24239. /**
  24240. * Gets Vignette centre X Offset.
  24241. */
  24242. get vignetteCentreX(): number;
  24243. /**
  24244. * Sets Vignette centre X Offset.
  24245. */
  24246. set vignetteCentreX(value: number);
  24247. /**
  24248. * Gets Vignette centre Y Offset.
  24249. */
  24250. get vignetteCentreY(): number;
  24251. /**
  24252. * Sets Vignette centre Y Offset.
  24253. */
  24254. set vignetteCentreY(value: number);
  24255. /**
  24256. * Gets Vignette weight or intensity of the vignette effect.
  24257. */
  24258. get vignetteWeight(): number;
  24259. /**
  24260. * Sets Vignette weight or intensity of the vignette effect.
  24261. */
  24262. set vignetteWeight(value: number);
  24263. /**
  24264. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24265. * if vignetteEnabled is set to true.
  24266. */
  24267. get vignetteColor(): Color4;
  24268. /**
  24269. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24270. * if vignetteEnabled is set to true.
  24271. */
  24272. set vignetteColor(value: Color4);
  24273. /**
  24274. * Gets Camera field of view used by the Vignette effect.
  24275. */
  24276. get vignetteCameraFov(): number;
  24277. /**
  24278. * Sets Camera field of view used by the Vignette effect.
  24279. */
  24280. set vignetteCameraFov(value: number);
  24281. /**
  24282. * Gets the vignette blend mode allowing different kind of effect.
  24283. */
  24284. get vignetteBlendMode(): number;
  24285. /**
  24286. * Sets the vignette blend mode allowing different kind of effect.
  24287. */
  24288. set vignetteBlendMode(value: number);
  24289. /**
  24290. * Gets wether the vignette effect is enabled.
  24291. */
  24292. get vignetteEnabled(): boolean;
  24293. /**
  24294. * Sets wether the vignette effect is enabled.
  24295. */
  24296. set vignetteEnabled(value: boolean);
  24297. private _fromLinearSpace;
  24298. /**
  24299. * Gets wether the input of the processing is in Gamma or Linear Space.
  24300. */
  24301. get fromLinearSpace(): boolean;
  24302. /**
  24303. * Sets wether the input of the processing is in Gamma or Linear Space.
  24304. */
  24305. set fromLinearSpace(value: boolean);
  24306. /**
  24307. * Defines cache preventing GC.
  24308. */
  24309. private _defines;
  24310. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24311. /**
  24312. * "ImageProcessingPostProcess"
  24313. * @returns "ImageProcessingPostProcess"
  24314. */
  24315. getClassName(): string;
  24316. /**
  24317. * @hidden
  24318. */
  24319. _updateParameters(): void;
  24320. dispose(camera?: Camera): void;
  24321. }
  24322. }
  24323. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24324. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24325. /**
  24326. * Interface for defining prepass effects in the prepass post-process pipeline
  24327. */
  24328. export interface PrePassEffectConfiguration {
  24329. /**
  24330. * Name of the effect
  24331. */
  24332. name: string;
  24333. /**
  24334. * Post process to attach for this effect
  24335. */
  24336. postProcess?: PostProcess;
  24337. /**
  24338. * Textures required in the MRT
  24339. */
  24340. texturesRequired: number[];
  24341. /**
  24342. * Is the effect enabled
  24343. */
  24344. enabled: boolean;
  24345. /**
  24346. * Disposes the effect configuration
  24347. */
  24348. dispose?: () => void;
  24349. /**
  24350. * Creates the associated post process
  24351. */
  24352. createPostProcess?: () => PostProcess;
  24353. }
  24354. }
  24355. declare module "babylonjs/Materials/fresnelParameters" {
  24356. import { DeepImmutable } from "babylonjs/types";
  24357. import { Color3 } from "babylonjs/Maths/math.color";
  24358. /**
  24359. * Options to be used when creating a FresnelParameters.
  24360. */
  24361. export type IFresnelParametersCreationOptions = {
  24362. /**
  24363. * Define the color used on edges (grazing angle)
  24364. */
  24365. leftColor?: Color3;
  24366. /**
  24367. * Define the color used on center
  24368. */
  24369. rightColor?: Color3;
  24370. /**
  24371. * Define bias applied to computed fresnel term
  24372. */
  24373. bias?: number;
  24374. /**
  24375. * Defined the power exponent applied to fresnel term
  24376. */
  24377. power?: number;
  24378. /**
  24379. * Define if the fresnel effect is enable or not.
  24380. */
  24381. isEnabled?: boolean;
  24382. };
  24383. /**
  24384. * Serialized format for FresnelParameters.
  24385. */
  24386. export type IFresnelParametersSerialized = {
  24387. /**
  24388. * Define the color used on edges (grazing angle) [as an array]
  24389. */
  24390. leftColor: number[];
  24391. /**
  24392. * Define the color used on center [as an array]
  24393. */
  24394. rightColor: number[];
  24395. /**
  24396. * Define bias applied to computed fresnel term
  24397. */
  24398. bias: number;
  24399. /**
  24400. * Defined the power exponent applied to fresnel term
  24401. */
  24402. power?: number;
  24403. /**
  24404. * Define if the fresnel effect is enable or not.
  24405. */
  24406. isEnabled: boolean;
  24407. };
  24408. /**
  24409. * This represents all the required information to add a fresnel effect on a material:
  24410. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24411. */
  24412. export class FresnelParameters {
  24413. private _isEnabled;
  24414. /**
  24415. * Define if the fresnel effect is enable or not.
  24416. */
  24417. get isEnabled(): boolean;
  24418. set isEnabled(value: boolean);
  24419. /**
  24420. * Define the color used on edges (grazing angle)
  24421. */
  24422. leftColor: Color3;
  24423. /**
  24424. * Define the color used on center
  24425. */
  24426. rightColor: Color3;
  24427. /**
  24428. * Define bias applied to computed fresnel term
  24429. */
  24430. bias: number;
  24431. /**
  24432. * Defined the power exponent applied to fresnel term
  24433. */
  24434. power: number;
  24435. /**
  24436. * Creates a new FresnelParameters object.
  24437. *
  24438. * @param options provide your own settings to optionally to override defaults
  24439. */
  24440. constructor(options?: IFresnelParametersCreationOptions);
  24441. /**
  24442. * Clones the current fresnel and its valuues
  24443. * @returns a clone fresnel configuration
  24444. */
  24445. clone(): FresnelParameters;
  24446. /**
  24447. * Determines equality between FresnelParameters objects
  24448. * @param otherFresnelParameters defines the second operand
  24449. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  24450. */
  24451. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  24452. /**
  24453. * Serializes the current fresnel parameters to a JSON representation.
  24454. * @return the JSON serialization
  24455. */
  24456. serialize(): IFresnelParametersSerialized;
  24457. /**
  24458. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  24459. * @param parsedFresnelParameters Define the JSON representation
  24460. * @returns the parsed parameters
  24461. */
  24462. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  24463. }
  24464. }
  24465. declare module "babylonjs/Materials/materialFlags" {
  24466. /**
  24467. * This groups all the flags used to control the materials channel.
  24468. */
  24469. export class MaterialFlags {
  24470. private static _DiffuseTextureEnabled;
  24471. /**
  24472. * Are diffuse textures enabled in the application.
  24473. */
  24474. static get DiffuseTextureEnabled(): boolean;
  24475. static set DiffuseTextureEnabled(value: boolean);
  24476. private static _DetailTextureEnabled;
  24477. /**
  24478. * Are detail textures enabled in the application.
  24479. */
  24480. static get DetailTextureEnabled(): boolean;
  24481. static set DetailTextureEnabled(value: boolean);
  24482. private static _AmbientTextureEnabled;
  24483. /**
  24484. * Are ambient textures enabled in the application.
  24485. */
  24486. static get AmbientTextureEnabled(): boolean;
  24487. static set AmbientTextureEnabled(value: boolean);
  24488. private static _OpacityTextureEnabled;
  24489. /**
  24490. * Are opacity textures enabled in the application.
  24491. */
  24492. static get OpacityTextureEnabled(): boolean;
  24493. static set OpacityTextureEnabled(value: boolean);
  24494. private static _ReflectionTextureEnabled;
  24495. /**
  24496. * Are reflection textures enabled in the application.
  24497. */
  24498. static get ReflectionTextureEnabled(): boolean;
  24499. static set ReflectionTextureEnabled(value: boolean);
  24500. private static _EmissiveTextureEnabled;
  24501. /**
  24502. * Are emissive textures enabled in the application.
  24503. */
  24504. static get EmissiveTextureEnabled(): boolean;
  24505. static set EmissiveTextureEnabled(value: boolean);
  24506. private static _SpecularTextureEnabled;
  24507. /**
  24508. * Are specular textures enabled in the application.
  24509. */
  24510. static get SpecularTextureEnabled(): boolean;
  24511. static set SpecularTextureEnabled(value: boolean);
  24512. private static _BumpTextureEnabled;
  24513. /**
  24514. * Are bump textures enabled in the application.
  24515. */
  24516. static get BumpTextureEnabled(): boolean;
  24517. static set BumpTextureEnabled(value: boolean);
  24518. private static _LightmapTextureEnabled;
  24519. /**
  24520. * Are lightmap textures enabled in the application.
  24521. */
  24522. static get LightmapTextureEnabled(): boolean;
  24523. static set LightmapTextureEnabled(value: boolean);
  24524. private static _RefractionTextureEnabled;
  24525. /**
  24526. * Are refraction textures enabled in the application.
  24527. */
  24528. static get RefractionTextureEnabled(): boolean;
  24529. static set RefractionTextureEnabled(value: boolean);
  24530. private static _ColorGradingTextureEnabled;
  24531. /**
  24532. * Are color grading textures enabled in the application.
  24533. */
  24534. static get ColorGradingTextureEnabled(): boolean;
  24535. static set ColorGradingTextureEnabled(value: boolean);
  24536. private static _FresnelEnabled;
  24537. /**
  24538. * Are fresnels enabled in the application.
  24539. */
  24540. static get FresnelEnabled(): boolean;
  24541. static set FresnelEnabled(value: boolean);
  24542. private static _ClearCoatTextureEnabled;
  24543. /**
  24544. * Are clear coat textures enabled in the application.
  24545. */
  24546. static get ClearCoatTextureEnabled(): boolean;
  24547. static set ClearCoatTextureEnabled(value: boolean);
  24548. private static _ClearCoatBumpTextureEnabled;
  24549. /**
  24550. * Are clear coat bump textures enabled in the application.
  24551. */
  24552. static get ClearCoatBumpTextureEnabled(): boolean;
  24553. static set ClearCoatBumpTextureEnabled(value: boolean);
  24554. private static _ClearCoatTintTextureEnabled;
  24555. /**
  24556. * Are clear coat tint textures enabled in the application.
  24557. */
  24558. static get ClearCoatTintTextureEnabled(): boolean;
  24559. static set ClearCoatTintTextureEnabled(value: boolean);
  24560. private static _SheenTextureEnabled;
  24561. /**
  24562. * Are sheen textures enabled in the application.
  24563. */
  24564. static get SheenTextureEnabled(): boolean;
  24565. static set SheenTextureEnabled(value: boolean);
  24566. private static _AnisotropicTextureEnabled;
  24567. /**
  24568. * Are anisotropic textures enabled in the application.
  24569. */
  24570. static get AnisotropicTextureEnabled(): boolean;
  24571. static set AnisotropicTextureEnabled(value: boolean);
  24572. private static _ThicknessTextureEnabled;
  24573. /**
  24574. * Are thickness textures enabled in the application.
  24575. */
  24576. static get ThicknessTextureEnabled(): boolean;
  24577. static set ThicknessTextureEnabled(value: boolean);
  24578. }
  24579. }
  24580. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  24581. /** @hidden */
  24582. export var defaultFragmentDeclaration: {
  24583. name: string;
  24584. shader: string;
  24585. };
  24586. }
  24587. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  24588. /** @hidden */
  24589. export var defaultUboDeclaration: {
  24590. name: string;
  24591. shader: string;
  24592. };
  24593. }
  24594. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  24595. /** @hidden */
  24596. export var prePassDeclaration: {
  24597. name: string;
  24598. shader: string;
  24599. };
  24600. }
  24601. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  24602. /** @hidden */
  24603. export var lightFragmentDeclaration: {
  24604. name: string;
  24605. shader: string;
  24606. };
  24607. }
  24608. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  24609. /** @hidden */
  24610. export var lightUboDeclaration: {
  24611. name: string;
  24612. shader: string;
  24613. };
  24614. }
  24615. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  24616. /** @hidden */
  24617. export var lightsFragmentFunctions: {
  24618. name: string;
  24619. shader: string;
  24620. };
  24621. }
  24622. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  24623. /** @hidden */
  24624. export var shadowsFragmentFunctions: {
  24625. name: string;
  24626. shader: string;
  24627. };
  24628. }
  24629. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  24630. /** @hidden */
  24631. export var fresnelFunction: {
  24632. name: string;
  24633. shader: string;
  24634. };
  24635. }
  24636. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  24637. /** @hidden */
  24638. export var bumpFragmentMainFunctions: {
  24639. name: string;
  24640. shader: string;
  24641. };
  24642. }
  24643. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  24644. /** @hidden */
  24645. export var bumpFragmentFunctions: {
  24646. name: string;
  24647. shader: string;
  24648. };
  24649. }
  24650. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  24651. /** @hidden */
  24652. export var logDepthDeclaration: {
  24653. name: string;
  24654. shader: string;
  24655. };
  24656. }
  24657. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  24658. /** @hidden */
  24659. export var bumpFragment: {
  24660. name: string;
  24661. shader: string;
  24662. };
  24663. }
  24664. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  24665. /** @hidden */
  24666. export var depthPrePass: {
  24667. name: string;
  24668. shader: string;
  24669. };
  24670. }
  24671. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  24672. /** @hidden */
  24673. export var lightFragment: {
  24674. name: string;
  24675. shader: string;
  24676. };
  24677. }
  24678. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  24679. /** @hidden */
  24680. export var logDepthFragment: {
  24681. name: string;
  24682. shader: string;
  24683. };
  24684. }
  24685. declare module "babylonjs/Shaders/default.fragment" {
  24686. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  24687. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24688. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  24689. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24690. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24691. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24692. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  24693. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  24694. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  24695. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  24696. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24697. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24698. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  24699. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  24700. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  24701. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24702. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24703. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  24704. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  24705. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  24706. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  24707. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  24708. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24709. /** @hidden */
  24710. export var defaultPixelShader: {
  24711. name: string;
  24712. shader: string;
  24713. };
  24714. }
  24715. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  24716. /** @hidden */
  24717. export var defaultVertexDeclaration: {
  24718. name: string;
  24719. shader: string;
  24720. };
  24721. }
  24722. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  24723. /** @hidden */
  24724. export var prePassVertexDeclaration: {
  24725. name: string;
  24726. shader: string;
  24727. };
  24728. }
  24729. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  24730. /** @hidden */
  24731. export var bumpVertexDeclaration: {
  24732. name: string;
  24733. shader: string;
  24734. };
  24735. }
  24736. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  24737. /** @hidden */
  24738. export var prePassVertex: {
  24739. name: string;
  24740. shader: string;
  24741. };
  24742. }
  24743. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  24744. /** @hidden */
  24745. export var bumpVertex: {
  24746. name: string;
  24747. shader: string;
  24748. };
  24749. }
  24750. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  24751. /** @hidden */
  24752. export var fogVertex: {
  24753. name: string;
  24754. shader: string;
  24755. };
  24756. }
  24757. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  24758. /** @hidden */
  24759. export var shadowsVertex: {
  24760. name: string;
  24761. shader: string;
  24762. };
  24763. }
  24764. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  24765. /** @hidden */
  24766. export var pointCloudVertex: {
  24767. name: string;
  24768. shader: string;
  24769. };
  24770. }
  24771. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  24772. /** @hidden */
  24773. export var logDepthVertex: {
  24774. name: string;
  24775. shader: string;
  24776. };
  24777. }
  24778. declare module "babylonjs/Shaders/default.vertex" {
  24779. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  24780. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24781. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24782. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  24783. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  24784. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  24785. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  24786. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  24787. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24788. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24789. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24790. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  24791. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  24792. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24793. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  24794. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  24795. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  24796. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  24797. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  24798. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  24799. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  24800. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  24801. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  24802. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  24803. /** @hidden */
  24804. export var defaultVertexShader: {
  24805. name: string;
  24806. shader: string;
  24807. };
  24808. }
  24809. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  24810. import { Nullable } from "babylonjs/types";
  24811. import { Scene } from "babylonjs/scene";
  24812. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24813. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24814. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24815. /**
  24816. * @hidden
  24817. */
  24818. export interface IMaterialDetailMapDefines {
  24819. DETAIL: boolean;
  24820. DETAILDIRECTUV: number;
  24821. DETAIL_NORMALBLENDMETHOD: number;
  24822. /** @hidden */
  24823. _areTexturesDirty: boolean;
  24824. }
  24825. /**
  24826. * Define the code related to the detail map parameters of a material
  24827. *
  24828. * Inspired from:
  24829. * 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
  24830. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  24831. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  24832. */
  24833. export class DetailMapConfiguration {
  24834. private _texture;
  24835. /**
  24836. * The detail texture of the material.
  24837. */
  24838. texture: Nullable<BaseTexture>;
  24839. /**
  24840. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  24841. * Bigger values mean stronger blending
  24842. */
  24843. diffuseBlendLevel: number;
  24844. /**
  24845. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  24846. * Bigger values mean stronger blending. Only used with PBR materials
  24847. */
  24848. roughnessBlendLevel: number;
  24849. /**
  24850. * Defines how strong the bump effect from the detail map is
  24851. * Bigger values mean stronger effect
  24852. */
  24853. bumpLevel: number;
  24854. private _normalBlendMethod;
  24855. /**
  24856. * The method used to blend the bump and detail normals together
  24857. */
  24858. normalBlendMethod: number;
  24859. private _isEnabled;
  24860. /**
  24861. * Enable or disable the detail map on this material
  24862. */
  24863. isEnabled: boolean;
  24864. /** @hidden */
  24865. private _internalMarkAllSubMeshesAsTexturesDirty;
  24866. /** @hidden */
  24867. _markAllSubMeshesAsTexturesDirty(): void;
  24868. /**
  24869. * Instantiate a new detail map
  24870. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24871. */
  24872. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24873. /**
  24874. * Gets whether the submesh is ready to be used or not.
  24875. * @param defines the list of "defines" to update.
  24876. * @param scene defines the scene the material belongs to.
  24877. * @returns - boolean indicating that the submesh is ready or not.
  24878. */
  24879. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24880. /**
  24881. * Update the defines for detail map usage
  24882. * @param defines the list of "defines" to update.
  24883. * @param scene defines the scene the material belongs to.
  24884. */
  24885. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24886. /**
  24887. * Binds the material data.
  24888. * @param uniformBuffer defines the Uniform buffer to fill in.
  24889. * @param scene defines the scene the material belongs to.
  24890. * @param isFrozen defines whether the material is frozen or not.
  24891. */
  24892. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24893. /**
  24894. * Checks to see if a texture is used in the material.
  24895. * @param texture - Base texture to use.
  24896. * @returns - Boolean specifying if a texture is used in the material.
  24897. */
  24898. hasTexture(texture: BaseTexture): boolean;
  24899. /**
  24900. * Returns an array of the actively used textures.
  24901. * @param activeTextures Array of BaseTextures
  24902. */
  24903. getActiveTextures(activeTextures: BaseTexture[]): void;
  24904. /**
  24905. * Returns the animatable textures.
  24906. * @param animatables Array of animatable textures.
  24907. */
  24908. getAnimatables(animatables: IAnimatable[]): void;
  24909. /**
  24910. * Disposes the resources of the material.
  24911. * @param forceDisposeTextures - Forces the disposal of all textures.
  24912. */
  24913. dispose(forceDisposeTextures?: boolean): void;
  24914. /**
  24915. * Get the current class name useful for serialization or dynamic coding.
  24916. * @returns "DetailMap"
  24917. */
  24918. getClassName(): string;
  24919. /**
  24920. * Add the required uniforms to the current list.
  24921. * @param uniforms defines the current uniform list.
  24922. */
  24923. static AddUniforms(uniforms: string[]): void;
  24924. /**
  24925. * Add the required samplers to the current list.
  24926. * @param samplers defines the current sampler list.
  24927. */
  24928. static AddSamplers(samplers: string[]): void;
  24929. /**
  24930. * Add the required uniforms to the current buffer.
  24931. * @param uniformBuffer defines the current uniform buffer.
  24932. */
  24933. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24934. /**
  24935. * Makes a duplicate of the current instance into another one.
  24936. * @param detailMap define the instance where to copy the info
  24937. */
  24938. copyTo(detailMap: DetailMapConfiguration): void;
  24939. /**
  24940. * Serializes this detail map instance
  24941. * @returns - An object with the serialized instance.
  24942. */
  24943. serialize(): any;
  24944. /**
  24945. * Parses a detail map setting from a serialized object.
  24946. * @param source - Serialized object.
  24947. * @param scene Defines the scene we are parsing for
  24948. * @param rootUrl Defines the rootUrl to load from
  24949. */
  24950. parse(source: any, scene: Scene, rootUrl: string): void;
  24951. }
  24952. }
  24953. declare module "babylonjs/Materials/standardMaterial" {
  24954. import { SmartArray } from "babylonjs/Misc/smartArray";
  24955. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24956. import { Nullable } from "babylonjs/types";
  24957. import { Scene } from "babylonjs/scene";
  24958. import { Matrix } from "babylonjs/Maths/math.vector";
  24959. import { Color3 } from "babylonjs/Maths/math.color";
  24960. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24962. import { Mesh } from "babylonjs/Meshes/mesh";
  24963. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  24964. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  24965. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24966. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  24967. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24968. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  24969. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24970. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24971. import "babylonjs/Shaders/default.fragment";
  24972. import "babylonjs/Shaders/default.vertex";
  24973. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  24974. /** @hidden */
  24975. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24976. MAINUV1: boolean;
  24977. MAINUV2: boolean;
  24978. DIFFUSE: boolean;
  24979. DIFFUSEDIRECTUV: number;
  24980. DETAIL: boolean;
  24981. DETAILDIRECTUV: number;
  24982. DETAIL_NORMALBLENDMETHOD: number;
  24983. AMBIENT: boolean;
  24984. AMBIENTDIRECTUV: number;
  24985. OPACITY: boolean;
  24986. OPACITYDIRECTUV: number;
  24987. OPACITYRGB: boolean;
  24988. REFLECTION: boolean;
  24989. EMISSIVE: boolean;
  24990. EMISSIVEDIRECTUV: number;
  24991. SPECULAR: boolean;
  24992. SPECULARDIRECTUV: number;
  24993. BUMP: boolean;
  24994. BUMPDIRECTUV: number;
  24995. PARALLAX: boolean;
  24996. PARALLAXOCCLUSION: boolean;
  24997. SPECULAROVERALPHA: boolean;
  24998. CLIPPLANE: boolean;
  24999. CLIPPLANE2: boolean;
  25000. CLIPPLANE3: boolean;
  25001. CLIPPLANE4: boolean;
  25002. CLIPPLANE5: boolean;
  25003. CLIPPLANE6: boolean;
  25004. ALPHATEST: boolean;
  25005. DEPTHPREPASS: boolean;
  25006. ALPHAFROMDIFFUSE: boolean;
  25007. POINTSIZE: boolean;
  25008. FOG: boolean;
  25009. SPECULARTERM: boolean;
  25010. DIFFUSEFRESNEL: boolean;
  25011. OPACITYFRESNEL: boolean;
  25012. REFLECTIONFRESNEL: boolean;
  25013. REFRACTIONFRESNEL: boolean;
  25014. EMISSIVEFRESNEL: boolean;
  25015. FRESNEL: boolean;
  25016. NORMAL: boolean;
  25017. UV1: boolean;
  25018. UV2: boolean;
  25019. VERTEXCOLOR: boolean;
  25020. VERTEXALPHA: boolean;
  25021. NUM_BONE_INFLUENCERS: number;
  25022. BonesPerMesh: number;
  25023. BONETEXTURE: boolean;
  25024. BONES_VELOCITY_ENABLED: boolean;
  25025. INSTANCES: boolean;
  25026. THIN_INSTANCES: boolean;
  25027. GLOSSINESS: boolean;
  25028. ROUGHNESS: boolean;
  25029. EMISSIVEASILLUMINATION: boolean;
  25030. LINKEMISSIVEWITHDIFFUSE: boolean;
  25031. REFLECTIONFRESNELFROMSPECULAR: boolean;
  25032. LIGHTMAP: boolean;
  25033. LIGHTMAPDIRECTUV: number;
  25034. OBJECTSPACE_NORMALMAP: boolean;
  25035. USELIGHTMAPASSHADOWMAP: boolean;
  25036. REFLECTIONMAP_3D: boolean;
  25037. REFLECTIONMAP_SPHERICAL: boolean;
  25038. REFLECTIONMAP_PLANAR: boolean;
  25039. REFLECTIONMAP_CUBIC: boolean;
  25040. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  25041. REFLECTIONMAP_PROJECTION: boolean;
  25042. REFLECTIONMAP_SKYBOX: boolean;
  25043. REFLECTIONMAP_EXPLICIT: boolean;
  25044. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  25045. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  25046. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  25047. INVERTCUBICMAP: boolean;
  25048. LOGARITHMICDEPTH: boolean;
  25049. REFRACTION: boolean;
  25050. REFRACTIONMAP_3D: boolean;
  25051. REFLECTIONOVERALPHA: boolean;
  25052. TWOSIDEDLIGHTING: boolean;
  25053. SHADOWFLOAT: boolean;
  25054. MORPHTARGETS: boolean;
  25055. MORPHTARGETS_NORMAL: boolean;
  25056. MORPHTARGETS_TANGENT: boolean;
  25057. MORPHTARGETS_UV: boolean;
  25058. NUM_MORPH_INFLUENCERS: number;
  25059. NONUNIFORMSCALING: boolean;
  25060. PREMULTIPLYALPHA: boolean;
  25061. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  25062. ALPHABLEND: boolean;
  25063. PREPASS: boolean;
  25064. PREPASS_IRRADIANCE: boolean;
  25065. PREPASS_IRRADIANCE_INDEX: number;
  25066. PREPASS_ALBEDO: boolean;
  25067. PREPASS_ALBEDO_INDEX: number;
  25068. PREPASS_DEPTHNORMAL: boolean;
  25069. PREPASS_DEPTHNORMAL_INDEX: number;
  25070. PREPASS_POSITION: boolean;
  25071. PREPASS_POSITION_INDEX: number;
  25072. PREPASS_VELOCITY: boolean;
  25073. PREPASS_VELOCITY_INDEX: number;
  25074. PREPASS_REFLECTIVITY: boolean;
  25075. PREPASS_REFLECTIVITY_INDEX: number;
  25076. SCENE_MRT_COUNT: number;
  25077. RGBDLIGHTMAP: boolean;
  25078. RGBDREFLECTION: boolean;
  25079. RGBDREFRACTION: boolean;
  25080. IMAGEPROCESSING: boolean;
  25081. VIGNETTE: boolean;
  25082. VIGNETTEBLENDMODEMULTIPLY: boolean;
  25083. VIGNETTEBLENDMODEOPAQUE: boolean;
  25084. TONEMAPPING: boolean;
  25085. TONEMAPPING_ACES: boolean;
  25086. CONTRAST: boolean;
  25087. COLORCURVES: boolean;
  25088. COLORGRADING: boolean;
  25089. COLORGRADING3D: boolean;
  25090. SAMPLER3DGREENDEPTH: boolean;
  25091. SAMPLER3DBGRMAP: boolean;
  25092. IMAGEPROCESSINGPOSTPROCESS: boolean;
  25093. MULTIVIEW: boolean;
  25094. /**
  25095. * If the reflection texture on this material is in linear color space
  25096. * @hidden
  25097. */
  25098. IS_REFLECTION_LINEAR: boolean;
  25099. /**
  25100. * If the refraction texture on this material is in linear color space
  25101. * @hidden
  25102. */
  25103. IS_REFRACTION_LINEAR: boolean;
  25104. EXPOSURE: boolean;
  25105. constructor();
  25106. setReflectionMode(modeToEnable: string): void;
  25107. }
  25108. /**
  25109. * This is the default material used in Babylon. It is the best trade off between quality
  25110. * and performances.
  25111. * @see https://doc.babylonjs.com/babylon101/materials
  25112. */
  25113. export class StandardMaterial extends PushMaterial {
  25114. private _diffuseTexture;
  25115. /**
  25116. * The basic texture of the material as viewed under a light.
  25117. */
  25118. diffuseTexture: Nullable<BaseTexture>;
  25119. private _ambientTexture;
  25120. /**
  25121. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  25122. */
  25123. ambientTexture: Nullable<BaseTexture>;
  25124. private _opacityTexture;
  25125. /**
  25126. * Define the transparency of the material from a texture.
  25127. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  25128. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  25129. */
  25130. opacityTexture: Nullable<BaseTexture>;
  25131. private _reflectionTexture;
  25132. /**
  25133. * Define the texture used to display the reflection.
  25134. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25135. */
  25136. reflectionTexture: Nullable<BaseTexture>;
  25137. private _emissiveTexture;
  25138. /**
  25139. * Define texture of the material as if self lit.
  25140. * This will be mixed in the final result even in the absence of light.
  25141. */
  25142. emissiveTexture: Nullable<BaseTexture>;
  25143. private _specularTexture;
  25144. /**
  25145. * Define how the color and intensity of the highlight given by the light in the material.
  25146. */
  25147. specularTexture: Nullable<BaseTexture>;
  25148. private _bumpTexture;
  25149. /**
  25150. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  25151. * 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.
  25152. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  25153. */
  25154. bumpTexture: Nullable<BaseTexture>;
  25155. private _lightmapTexture;
  25156. /**
  25157. * Complex lighting can be computationally expensive to compute at runtime.
  25158. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  25159. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  25160. */
  25161. lightmapTexture: Nullable<BaseTexture>;
  25162. private _refractionTexture;
  25163. /**
  25164. * Define the texture used to display the refraction.
  25165. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25166. */
  25167. refractionTexture: Nullable<BaseTexture>;
  25168. /**
  25169. * The color of the material lit by the environmental background lighting.
  25170. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  25171. */
  25172. ambientColor: Color3;
  25173. /**
  25174. * The basic color of the material as viewed under a light.
  25175. */
  25176. diffuseColor: Color3;
  25177. /**
  25178. * Define how the color and intensity of the highlight given by the light in the material.
  25179. */
  25180. specularColor: Color3;
  25181. /**
  25182. * Define the color of the material as if self lit.
  25183. * This will be mixed in the final result even in the absence of light.
  25184. */
  25185. emissiveColor: Color3;
  25186. /**
  25187. * Defines how sharp are the highlights in the material.
  25188. * The bigger the value the sharper giving a more glossy feeling to the result.
  25189. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  25190. */
  25191. specularPower: number;
  25192. private _useAlphaFromDiffuseTexture;
  25193. /**
  25194. * Does the transparency come from the diffuse texture alpha channel.
  25195. */
  25196. useAlphaFromDiffuseTexture: boolean;
  25197. private _useEmissiveAsIllumination;
  25198. /**
  25199. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  25200. */
  25201. useEmissiveAsIllumination: boolean;
  25202. private _linkEmissiveWithDiffuse;
  25203. /**
  25204. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  25205. * the emissive level when the final color is close to one.
  25206. */
  25207. linkEmissiveWithDiffuse: boolean;
  25208. private _useSpecularOverAlpha;
  25209. /**
  25210. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  25211. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  25212. */
  25213. useSpecularOverAlpha: boolean;
  25214. private _useReflectionOverAlpha;
  25215. /**
  25216. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  25217. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  25218. */
  25219. useReflectionOverAlpha: boolean;
  25220. private _disableLighting;
  25221. /**
  25222. * Does lights from the scene impacts this material.
  25223. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  25224. */
  25225. disableLighting: boolean;
  25226. private _useObjectSpaceNormalMap;
  25227. /**
  25228. * Allows using an object space normal map (instead of tangent space).
  25229. */
  25230. useObjectSpaceNormalMap: boolean;
  25231. private _useParallax;
  25232. /**
  25233. * Is parallax enabled or not.
  25234. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  25235. */
  25236. useParallax: boolean;
  25237. private _useParallaxOcclusion;
  25238. /**
  25239. * Is parallax occlusion enabled or not.
  25240. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  25241. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  25242. */
  25243. useParallaxOcclusion: boolean;
  25244. /**
  25245. * 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.
  25246. */
  25247. parallaxScaleBias: number;
  25248. private _roughness;
  25249. /**
  25250. * Helps to define how blurry the reflections should appears in the material.
  25251. */
  25252. roughness: number;
  25253. /**
  25254. * In case of refraction, define the value of the index of refraction.
  25255. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25256. */
  25257. indexOfRefraction: number;
  25258. /**
  25259. * Invert the refraction texture alongside the y axis.
  25260. * It can be useful with procedural textures or probe for instance.
  25261. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25262. */
  25263. invertRefractionY: boolean;
  25264. /**
  25265. * Defines the alpha limits in alpha test mode.
  25266. */
  25267. alphaCutOff: number;
  25268. private _useLightmapAsShadowmap;
  25269. /**
  25270. * In case of light mapping, define whether the map contains light or shadow informations.
  25271. */
  25272. useLightmapAsShadowmap: boolean;
  25273. private _diffuseFresnelParameters;
  25274. /**
  25275. * Define the diffuse fresnel parameters of the material.
  25276. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25277. */
  25278. diffuseFresnelParameters: FresnelParameters;
  25279. private _opacityFresnelParameters;
  25280. /**
  25281. * Define the opacity fresnel parameters of the material.
  25282. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25283. */
  25284. opacityFresnelParameters: FresnelParameters;
  25285. private _reflectionFresnelParameters;
  25286. /**
  25287. * Define the reflection fresnel parameters of the material.
  25288. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25289. */
  25290. reflectionFresnelParameters: FresnelParameters;
  25291. private _refractionFresnelParameters;
  25292. /**
  25293. * Define the refraction fresnel parameters of the material.
  25294. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25295. */
  25296. refractionFresnelParameters: FresnelParameters;
  25297. private _emissiveFresnelParameters;
  25298. /**
  25299. * Define the emissive fresnel parameters of the material.
  25300. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25301. */
  25302. emissiveFresnelParameters: FresnelParameters;
  25303. private _useReflectionFresnelFromSpecular;
  25304. /**
  25305. * If true automatically deducts the fresnels values from the material specularity.
  25306. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25307. */
  25308. useReflectionFresnelFromSpecular: boolean;
  25309. private _useGlossinessFromSpecularMapAlpha;
  25310. /**
  25311. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  25312. */
  25313. useGlossinessFromSpecularMapAlpha: boolean;
  25314. private _maxSimultaneousLights;
  25315. /**
  25316. * Defines the maximum number of lights that can be used in the material
  25317. */
  25318. maxSimultaneousLights: number;
  25319. private _invertNormalMapX;
  25320. /**
  25321. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25322. */
  25323. invertNormalMapX: boolean;
  25324. private _invertNormalMapY;
  25325. /**
  25326. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25327. */
  25328. invertNormalMapY: boolean;
  25329. private _twoSidedLighting;
  25330. /**
  25331. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25332. */
  25333. twoSidedLighting: boolean;
  25334. /**
  25335. * Default configuration related to image processing available in the standard Material.
  25336. */
  25337. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25338. /**
  25339. * Gets the image processing configuration used either in this material.
  25340. */
  25341. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25342. /**
  25343. * Sets the Default image processing configuration used either in the this material.
  25344. *
  25345. * If sets to null, the scene one is in use.
  25346. */
  25347. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25348. /**
  25349. * Keep track of the image processing observer to allow dispose and replace.
  25350. */
  25351. private _imageProcessingObserver;
  25352. /**
  25353. * Attaches a new image processing configuration to the Standard Material.
  25354. * @param configuration
  25355. */
  25356. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25357. /**
  25358. * Defines additionnal PrePass parameters for the material.
  25359. */
  25360. readonly prePassConfiguration: PrePassConfiguration;
  25361. /**
  25362. * Gets wether the color curves effect is enabled.
  25363. */
  25364. get cameraColorCurvesEnabled(): boolean;
  25365. /**
  25366. * Sets wether the color curves effect is enabled.
  25367. */
  25368. set cameraColorCurvesEnabled(value: boolean);
  25369. /**
  25370. * Gets wether the color grading effect is enabled.
  25371. */
  25372. get cameraColorGradingEnabled(): boolean;
  25373. /**
  25374. * Gets wether the color grading effect is enabled.
  25375. */
  25376. set cameraColorGradingEnabled(value: boolean);
  25377. /**
  25378. * Gets wether tonemapping is enabled or not.
  25379. */
  25380. get cameraToneMappingEnabled(): boolean;
  25381. /**
  25382. * Sets wether tonemapping is enabled or not
  25383. */
  25384. set cameraToneMappingEnabled(value: boolean);
  25385. /**
  25386. * The camera exposure used on this material.
  25387. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25388. * This corresponds to a photographic exposure.
  25389. */
  25390. get cameraExposure(): number;
  25391. /**
  25392. * The camera exposure used on this material.
  25393. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25394. * This corresponds to a photographic exposure.
  25395. */
  25396. set cameraExposure(value: number);
  25397. /**
  25398. * Gets The camera contrast used on this material.
  25399. */
  25400. get cameraContrast(): number;
  25401. /**
  25402. * Sets The camera contrast used on this material.
  25403. */
  25404. set cameraContrast(value: number);
  25405. /**
  25406. * Gets the Color Grading 2D Lookup Texture.
  25407. */
  25408. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  25409. /**
  25410. * Sets the Color Grading 2D Lookup Texture.
  25411. */
  25412. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  25413. /**
  25414. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25415. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25416. * 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;
  25417. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25418. */
  25419. get cameraColorCurves(): Nullable<ColorCurves>;
  25420. /**
  25421. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25422. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25423. * 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;
  25424. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25425. */
  25426. set cameraColorCurves(value: Nullable<ColorCurves>);
  25427. /**
  25428. * Can this material render to several textures at once
  25429. */
  25430. get canRenderToMRT(): boolean;
  25431. /**
  25432. * Defines the detail map parameters for the material.
  25433. */
  25434. readonly detailMap: DetailMapConfiguration;
  25435. protected _renderTargets: SmartArray<RenderTargetTexture>;
  25436. protected _worldViewProjectionMatrix: Matrix;
  25437. protected _globalAmbientColor: Color3;
  25438. protected _useLogarithmicDepth: boolean;
  25439. protected _rebuildInParallel: boolean;
  25440. /**
  25441. * Instantiates a new standard material.
  25442. * This is the default material used in Babylon. It is the best trade off between quality
  25443. * and performances.
  25444. * @see https://doc.babylonjs.com/babylon101/materials
  25445. * @param name Define the name of the material in the scene
  25446. * @param scene Define the scene the material belong to
  25447. */
  25448. constructor(name: string, scene: Scene);
  25449. /**
  25450. * Gets a boolean indicating that current material needs to register RTT
  25451. */
  25452. get hasRenderTargetTextures(): boolean;
  25453. /**
  25454. * Gets the current class name of the material e.g. "StandardMaterial"
  25455. * Mainly use in serialization.
  25456. * @returns the class name
  25457. */
  25458. getClassName(): string;
  25459. /**
  25460. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  25461. * You can try switching to logarithmic depth.
  25462. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  25463. */
  25464. get useLogarithmicDepth(): boolean;
  25465. set useLogarithmicDepth(value: boolean);
  25466. /**
  25467. * Specifies if the material will require alpha blending
  25468. * @returns a boolean specifying if alpha blending is needed
  25469. */
  25470. needAlphaBlending(): boolean;
  25471. /**
  25472. * Specifies if this material should be rendered in alpha test mode
  25473. * @returns a boolean specifying if an alpha test is needed.
  25474. */
  25475. needAlphaTesting(): boolean;
  25476. /**
  25477. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  25478. */
  25479. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  25480. /**
  25481. * Specifies whether or not there is a usable alpha channel for transparency.
  25482. */
  25483. protected _hasAlphaChannel(): boolean;
  25484. /**
  25485. * Get the texture used for alpha test purpose.
  25486. * @returns the diffuse texture in case of the standard material.
  25487. */
  25488. getAlphaTestTexture(): Nullable<BaseTexture>;
  25489. /**
  25490. * Get if the submesh is ready to be used and all its information available.
  25491. * Child classes can use it to update shaders
  25492. * @param mesh defines the mesh to check
  25493. * @param subMesh defines which submesh to check
  25494. * @param useInstances specifies that instances should be used
  25495. * @returns a boolean indicating that the submesh is ready or not
  25496. */
  25497. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25498. /**
  25499. * Builds the material UBO layouts.
  25500. * Used internally during the effect preparation.
  25501. */
  25502. buildUniformLayout(): void;
  25503. /**
  25504. * Unbinds the material from the mesh
  25505. */
  25506. unbind(): void;
  25507. /**
  25508. * Binds the submesh to this material by preparing the effect and shader to draw
  25509. * @param world defines the world transformation matrix
  25510. * @param mesh defines the mesh containing the submesh
  25511. * @param subMesh defines the submesh to bind the material to
  25512. */
  25513. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25514. /**
  25515. * Get the list of animatables in the material.
  25516. * @returns the list of animatables object used in the material
  25517. */
  25518. getAnimatables(): IAnimatable[];
  25519. /**
  25520. * Gets the active textures from the material
  25521. * @returns an array of textures
  25522. */
  25523. getActiveTextures(): BaseTexture[];
  25524. /**
  25525. * Specifies if the material uses a texture
  25526. * @param texture defines the texture to check against the material
  25527. * @returns a boolean specifying if the material uses the texture
  25528. */
  25529. hasTexture(texture: BaseTexture): boolean;
  25530. /**
  25531. * Disposes the material
  25532. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25533. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25534. */
  25535. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25536. /**
  25537. * Makes a duplicate of the material, and gives it a new name
  25538. * @param name defines the new name for the duplicated material
  25539. * @returns the cloned material
  25540. */
  25541. clone(name: string): StandardMaterial;
  25542. /**
  25543. * Serializes this material in a JSON representation
  25544. * @returns the serialized material object
  25545. */
  25546. serialize(): any;
  25547. /**
  25548. * Creates a standard material from parsed material data
  25549. * @param source defines the JSON representation of the material
  25550. * @param scene defines the hosting scene
  25551. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25552. * @returns a new standard material
  25553. */
  25554. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  25555. /**
  25556. * Are diffuse textures enabled in the application.
  25557. */
  25558. static get DiffuseTextureEnabled(): boolean;
  25559. static set DiffuseTextureEnabled(value: boolean);
  25560. /**
  25561. * Are detail textures enabled in the application.
  25562. */
  25563. static get DetailTextureEnabled(): boolean;
  25564. static set DetailTextureEnabled(value: boolean);
  25565. /**
  25566. * Are ambient textures enabled in the application.
  25567. */
  25568. static get AmbientTextureEnabled(): boolean;
  25569. static set AmbientTextureEnabled(value: boolean);
  25570. /**
  25571. * Are opacity textures enabled in the application.
  25572. */
  25573. static get OpacityTextureEnabled(): boolean;
  25574. static set OpacityTextureEnabled(value: boolean);
  25575. /**
  25576. * Are reflection textures enabled in the application.
  25577. */
  25578. static get ReflectionTextureEnabled(): boolean;
  25579. static set ReflectionTextureEnabled(value: boolean);
  25580. /**
  25581. * Are emissive textures enabled in the application.
  25582. */
  25583. static get EmissiveTextureEnabled(): boolean;
  25584. static set EmissiveTextureEnabled(value: boolean);
  25585. /**
  25586. * Are specular textures enabled in the application.
  25587. */
  25588. static get SpecularTextureEnabled(): boolean;
  25589. static set SpecularTextureEnabled(value: boolean);
  25590. /**
  25591. * Are bump textures enabled in the application.
  25592. */
  25593. static get BumpTextureEnabled(): boolean;
  25594. static set BumpTextureEnabled(value: boolean);
  25595. /**
  25596. * Are lightmap textures enabled in the application.
  25597. */
  25598. static get LightmapTextureEnabled(): boolean;
  25599. static set LightmapTextureEnabled(value: boolean);
  25600. /**
  25601. * Are refraction textures enabled in the application.
  25602. */
  25603. static get RefractionTextureEnabled(): boolean;
  25604. static set RefractionTextureEnabled(value: boolean);
  25605. /**
  25606. * Are color grading textures enabled in the application.
  25607. */
  25608. static get ColorGradingTextureEnabled(): boolean;
  25609. static set ColorGradingTextureEnabled(value: boolean);
  25610. /**
  25611. * Are fresnels enabled in the application.
  25612. */
  25613. static get FresnelEnabled(): boolean;
  25614. static set FresnelEnabled(value: boolean);
  25615. }
  25616. }
  25617. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  25618. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25619. /** @hidden */
  25620. export var rgbdDecodePixelShader: {
  25621. name: string;
  25622. shader: string;
  25623. };
  25624. }
  25625. declare module "babylonjs/Misc/rgbdTextureTools" {
  25626. import "babylonjs/Shaders/rgbdDecode.fragment";
  25627. import "babylonjs/Engines/Extensions/engine.renderTarget";
  25628. import { Texture } from "babylonjs/Materials/Textures/texture";
  25629. /**
  25630. * Class used to host RGBD texture specific utilities
  25631. */
  25632. export class RGBDTextureTools {
  25633. /**
  25634. * Expand the RGBD Texture from RGBD to Half Float if possible.
  25635. * @param texture the texture to expand.
  25636. */
  25637. static ExpandRGBDTexture(texture: Texture): void;
  25638. }
  25639. }
  25640. declare module "babylonjs/Misc/brdfTextureTools" {
  25641. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25642. import { Scene } from "babylonjs/scene";
  25643. /**
  25644. * Class used to host texture specific utilities
  25645. */
  25646. export class BRDFTextureTools {
  25647. /**
  25648. * Prevents texture cache collision
  25649. */
  25650. private static _instanceNumber;
  25651. /**
  25652. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  25653. * @param scene defines the hosting scene
  25654. * @returns the environment BRDF texture
  25655. */
  25656. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  25657. private static _environmentBRDFBase64Texture;
  25658. }
  25659. }
  25660. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  25661. import { Nullable } from "babylonjs/types";
  25662. import { Color3 } from "babylonjs/Maths/math.color";
  25663. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25664. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25665. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25666. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25667. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25668. import { Engine } from "babylonjs/Engines/engine";
  25669. import { Scene } from "babylonjs/scene";
  25670. /**
  25671. * @hidden
  25672. */
  25673. export interface IMaterialClearCoatDefines {
  25674. CLEARCOAT: boolean;
  25675. CLEARCOAT_DEFAULTIOR: boolean;
  25676. CLEARCOAT_TEXTURE: boolean;
  25677. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  25678. CLEARCOAT_TEXTUREDIRECTUV: number;
  25679. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  25680. CLEARCOAT_BUMP: boolean;
  25681. CLEARCOAT_BUMPDIRECTUV: number;
  25682. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25683. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25684. CLEARCOAT_REMAP_F0: boolean;
  25685. CLEARCOAT_TINT: boolean;
  25686. CLEARCOAT_TINT_TEXTURE: boolean;
  25687. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  25688. /** @hidden */
  25689. _areTexturesDirty: boolean;
  25690. }
  25691. /**
  25692. * Define the code related to the clear coat parameters of the pbr material.
  25693. */
  25694. export class PBRClearCoatConfiguration {
  25695. /**
  25696. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25697. * The default fits with a polyurethane material.
  25698. */
  25699. private static readonly _DefaultIndexOfRefraction;
  25700. private _isEnabled;
  25701. /**
  25702. * Defines if the clear coat is enabled in the material.
  25703. */
  25704. isEnabled: boolean;
  25705. /**
  25706. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  25707. */
  25708. intensity: number;
  25709. /**
  25710. * Defines the clear coat layer roughness.
  25711. */
  25712. roughness: number;
  25713. private _indexOfRefraction;
  25714. /**
  25715. * Defines the index of refraction of the clear coat.
  25716. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25717. * The default fits with a polyurethane material.
  25718. * Changing the default value is more performance intensive.
  25719. */
  25720. indexOfRefraction: number;
  25721. private _texture;
  25722. /**
  25723. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  25724. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  25725. * if textureRoughness is not empty, else no texture roughness is used
  25726. */
  25727. texture: Nullable<BaseTexture>;
  25728. private _useRoughnessFromMainTexture;
  25729. /**
  25730. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  25731. * If false, the green channel from textureRoughness is used for roughness
  25732. */
  25733. useRoughnessFromMainTexture: boolean;
  25734. private _textureRoughness;
  25735. /**
  25736. * Stores the clear coat roughness in a texture (green channel)
  25737. * Not used if useRoughnessFromMainTexture is true
  25738. */
  25739. textureRoughness: Nullable<BaseTexture>;
  25740. private _remapF0OnInterfaceChange;
  25741. /**
  25742. * Defines if the F0 value should be remapped to account for the interface change in the material.
  25743. */
  25744. remapF0OnInterfaceChange: boolean;
  25745. private _bumpTexture;
  25746. /**
  25747. * Define the clear coat specific bump texture.
  25748. */
  25749. bumpTexture: Nullable<BaseTexture>;
  25750. private _isTintEnabled;
  25751. /**
  25752. * Defines if the clear coat tint is enabled in the material.
  25753. */
  25754. isTintEnabled: boolean;
  25755. /**
  25756. * Defines the clear coat tint of the material.
  25757. * This is only use if tint is enabled
  25758. */
  25759. tintColor: Color3;
  25760. /**
  25761. * Defines the distance at which the tint color should be found in the
  25762. * clear coat media.
  25763. * This is only use if tint is enabled
  25764. */
  25765. tintColorAtDistance: number;
  25766. /**
  25767. * Defines the clear coat layer thickness.
  25768. * This is only use if tint is enabled
  25769. */
  25770. tintThickness: number;
  25771. private _tintTexture;
  25772. /**
  25773. * Stores the clear tint values in a texture.
  25774. * rgb is tint
  25775. * a is a thickness factor
  25776. */
  25777. tintTexture: Nullable<BaseTexture>;
  25778. /** @hidden */
  25779. private _internalMarkAllSubMeshesAsTexturesDirty;
  25780. /** @hidden */
  25781. _markAllSubMeshesAsTexturesDirty(): void;
  25782. /**
  25783. * Instantiate a new istance of clear coat configuration.
  25784. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25785. */
  25786. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25787. /**
  25788. * Gets wehter the submesh is ready to be used or not.
  25789. * @param defines the list of "defines" to update.
  25790. * @param scene defines the scene the material belongs to.
  25791. * @param engine defines the engine the material belongs to.
  25792. * @param disableBumpMap defines wether the material disables bump or not.
  25793. * @returns - boolean indicating that the submesh is ready or not.
  25794. */
  25795. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  25796. /**
  25797. * Checks to see if a texture is used in the material.
  25798. * @param defines the list of "defines" to update.
  25799. * @param scene defines the scene to the material belongs to.
  25800. */
  25801. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  25802. /**
  25803. * Binds the material data.
  25804. * @param uniformBuffer defines the Uniform buffer to fill in.
  25805. * @param scene defines the scene the material belongs to.
  25806. * @param engine defines the engine the material belongs to.
  25807. * @param disableBumpMap defines wether the material disables bump or not.
  25808. * @param isFrozen defines wether the material is frozen or not.
  25809. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25810. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25811. * @param subMesh the submesh to bind data for
  25812. */
  25813. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  25814. /**
  25815. * Checks to see if a texture is used in the material.
  25816. * @param texture - Base texture to use.
  25817. * @returns - Boolean specifying if a texture is used in the material.
  25818. */
  25819. hasTexture(texture: BaseTexture): boolean;
  25820. /**
  25821. * Returns an array of the actively used textures.
  25822. * @param activeTextures Array of BaseTextures
  25823. */
  25824. getActiveTextures(activeTextures: BaseTexture[]): void;
  25825. /**
  25826. * Returns the animatable textures.
  25827. * @param animatables Array of animatable textures.
  25828. */
  25829. getAnimatables(animatables: IAnimatable[]): void;
  25830. /**
  25831. * Disposes the resources of the material.
  25832. * @param forceDisposeTextures - Forces the disposal of all textures.
  25833. */
  25834. dispose(forceDisposeTextures?: boolean): void;
  25835. /**
  25836. * Get the current class name of the texture useful for serialization or dynamic coding.
  25837. * @returns "PBRClearCoatConfiguration"
  25838. */
  25839. getClassName(): string;
  25840. /**
  25841. * Add fallbacks to the effect fallbacks list.
  25842. * @param defines defines the Base texture to use.
  25843. * @param fallbacks defines the current fallback list.
  25844. * @param currentRank defines the current fallback rank.
  25845. * @returns the new fallback rank.
  25846. */
  25847. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25848. /**
  25849. * Add the required uniforms to the current list.
  25850. * @param uniforms defines the current uniform list.
  25851. */
  25852. static AddUniforms(uniforms: string[]): void;
  25853. /**
  25854. * Add the required samplers to the current list.
  25855. * @param samplers defines the current sampler list.
  25856. */
  25857. static AddSamplers(samplers: string[]): void;
  25858. /**
  25859. * Add the required uniforms to the current buffer.
  25860. * @param uniformBuffer defines the current uniform buffer.
  25861. */
  25862. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25863. /**
  25864. * Makes a duplicate of the current configuration into another one.
  25865. * @param clearCoatConfiguration define the config where to copy the info
  25866. */
  25867. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  25868. /**
  25869. * Serializes this clear coat configuration.
  25870. * @returns - An object with the serialized config.
  25871. */
  25872. serialize(): any;
  25873. /**
  25874. * Parses a anisotropy Configuration from a serialized object.
  25875. * @param source - Serialized object.
  25876. * @param scene Defines the scene we are parsing for
  25877. * @param rootUrl Defines the rootUrl to load from
  25878. */
  25879. parse(source: any, scene: Scene, rootUrl: string): void;
  25880. }
  25881. }
  25882. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  25883. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25884. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25885. import { Vector2 } from "babylonjs/Maths/math.vector";
  25886. import { Scene } from "babylonjs/scene";
  25887. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25888. import { Nullable } from "babylonjs/types";
  25889. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25890. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25891. /**
  25892. * @hidden
  25893. */
  25894. export interface IMaterialAnisotropicDefines {
  25895. ANISOTROPIC: boolean;
  25896. ANISOTROPIC_TEXTURE: boolean;
  25897. ANISOTROPIC_TEXTUREDIRECTUV: number;
  25898. MAINUV1: boolean;
  25899. _areTexturesDirty: boolean;
  25900. _needUVs: boolean;
  25901. }
  25902. /**
  25903. * Define the code related to the anisotropic parameters of the pbr material.
  25904. */
  25905. export class PBRAnisotropicConfiguration {
  25906. private _isEnabled;
  25907. /**
  25908. * Defines if the anisotropy is enabled in the material.
  25909. */
  25910. isEnabled: boolean;
  25911. /**
  25912. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  25913. */
  25914. intensity: number;
  25915. /**
  25916. * Defines if the effect is along the tangents, bitangents or in between.
  25917. * By default, the effect is "strectching" the highlights along the tangents.
  25918. */
  25919. direction: Vector2;
  25920. private _texture;
  25921. /**
  25922. * Stores the anisotropy values in a texture.
  25923. * rg is direction (like normal from -1 to 1)
  25924. * b is a intensity
  25925. */
  25926. texture: Nullable<BaseTexture>;
  25927. /** @hidden */
  25928. private _internalMarkAllSubMeshesAsTexturesDirty;
  25929. /** @hidden */
  25930. _markAllSubMeshesAsTexturesDirty(): void;
  25931. /**
  25932. * Instantiate a new istance of anisotropy configuration.
  25933. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25934. */
  25935. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25936. /**
  25937. * Specifies that the submesh is ready to be used.
  25938. * @param defines the list of "defines" to update.
  25939. * @param scene defines the scene the material belongs to.
  25940. * @returns - boolean indicating that the submesh is ready or not.
  25941. */
  25942. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25943. /**
  25944. * Checks to see if a texture is used in the material.
  25945. * @param defines the list of "defines" to update.
  25946. * @param mesh the mesh we are preparing the defines for.
  25947. * @param scene defines the scene the material belongs to.
  25948. */
  25949. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25950. /**
  25951. * Binds the material data.
  25952. * @param uniformBuffer defines the Uniform buffer to fill in.
  25953. * @param scene defines the scene the material belongs to.
  25954. * @param isFrozen defines wether the material is frozen or not.
  25955. */
  25956. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25957. /**
  25958. * Checks to see if a texture is used in the material.
  25959. * @param texture - Base texture to use.
  25960. * @returns - Boolean specifying if a texture is used in the material.
  25961. */
  25962. hasTexture(texture: BaseTexture): boolean;
  25963. /**
  25964. * Returns an array of the actively used textures.
  25965. * @param activeTextures Array of BaseTextures
  25966. */
  25967. getActiveTextures(activeTextures: BaseTexture[]): void;
  25968. /**
  25969. * Returns the animatable textures.
  25970. * @param animatables Array of animatable textures.
  25971. */
  25972. getAnimatables(animatables: IAnimatable[]): void;
  25973. /**
  25974. * Disposes the resources of the material.
  25975. * @param forceDisposeTextures - Forces the disposal of all textures.
  25976. */
  25977. dispose(forceDisposeTextures?: boolean): void;
  25978. /**
  25979. * Get the current class name of the texture useful for serialization or dynamic coding.
  25980. * @returns "PBRAnisotropicConfiguration"
  25981. */
  25982. getClassName(): string;
  25983. /**
  25984. * Add fallbacks to the effect fallbacks list.
  25985. * @param defines defines the Base texture to use.
  25986. * @param fallbacks defines the current fallback list.
  25987. * @param currentRank defines the current fallback rank.
  25988. * @returns the new fallback rank.
  25989. */
  25990. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25991. /**
  25992. * Add the required uniforms to the current list.
  25993. * @param uniforms defines the current uniform list.
  25994. */
  25995. static AddUniforms(uniforms: string[]): void;
  25996. /**
  25997. * Add the required uniforms to the current buffer.
  25998. * @param uniformBuffer defines the current uniform buffer.
  25999. */
  26000. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26001. /**
  26002. * Add the required samplers to the current list.
  26003. * @param samplers defines the current sampler list.
  26004. */
  26005. static AddSamplers(samplers: string[]): void;
  26006. /**
  26007. * Makes a duplicate of the current configuration into another one.
  26008. * @param anisotropicConfiguration define the config where to copy the info
  26009. */
  26010. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  26011. /**
  26012. * Serializes this anisotropy configuration.
  26013. * @returns - An object with the serialized config.
  26014. */
  26015. serialize(): any;
  26016. /**
  26017. * Parses a anisotropy Configuration from a serialized object.
  26018. * @param source - Serialized object.
  26019. * @param scene Defines the scene we are parsing for
  26020. * @param rootUrl Defines the rootUrl to load from
  26021. */
  26022. parse(source: any, scene: Scene, rootUrl: string): void;
  26023. }
  26024. }
  26025. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  26026. import { Scene } from "babylonjs/scene";
  26027. /**
  26028. * @hidden
  26029. */
  26030. export interface IMaterialBRDFDefines {
  26031. BRDF_V_HEIGHT_CORRELATED: boolean;
  26032. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26033. SPHERICAL_HARMONICS: boolean;
  26034. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26035. /** @hidden */
  26036. _areMiscDirty: boolean;
  26037. }
  26038. /**
  26039. * Define the code related to the BRDF parameters of the pbr material.
  26040. */
  26041. export class PBRBRDFConfiguration {
  26042. /**
  26043. * Default value used for the energy conservation.
  26044. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  26045. */
  26046. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  26047. /**
  26048. * Default value used for the Smith Visibility Height Correlated mode.
  26049. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  26050. */
  26051. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  26052. /**
  26053. * Default value used for the IBL diffuse part.
  26054. * This can help switching back to the polynomials mode globally which is a tiny bit
  26055. * less GPU intensive at the drawback of a lower quality.
  26056. */
  26057. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  26058. /**
  26059. * Default value used for activating energy conservation for the specular workflow.
  26060. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  26061. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  26062. */
  26063. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  26064. private _useEnergyConservation;
  26065. /**
  26066. * Defines if the material uses energy conservation.
  26067. */
  26068. useEnergyConservation: boolean;
  26069. private _useSmithVisibilityHeightCorrelated;
  26070. /**
  26071. * LEGACY Mode set to false
  26072. * Defines if the material uses height smith correlated visibility term.
  26073. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  26074. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  26075. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  26076. * Not relying on height correlated will also disable energy conservation.
  26077. */
  26078. useSmithVisibilityHeightCorrelated: boolean;
  26079. private _useSphericalHarmonics;
  26080. /**
  26081. * LEGACY Mode set to false
  26082. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  26083. * diffuse part of the IBL.
  26084. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  26085. * to the ground truth.
  26086. */
  26087. useSphericalHarmonics: boolean;
  26088. private _useSpecularGlossinessInputEnergyConservation;
  26089. /**
  26090. * Defines if the material uses energy conservation, when the specular workflow is active.
  26091. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  26092. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  26093. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  26094. */
  26095. useSpecularGlossinessInputEnergyConservation: boolean;
  26096. /** @hidden */
  26097. private _internalMarkAllSubMeshesAsMiscDirty;
  26098. /** @hidden */
  26099. _markAllSubMeshesAsMiscDirty(): void;
  26100. /**
  26101. * Instantiate a new istance of clear coat configuration.
  26102. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  26103. */
  26104. constructor(markAllSubMeshesAsMiscDirty: () => void);
  26105. /**
  26106. * Checks to see if a texture is used in the material.
  26107. * @param defines the list of "defines" to update.
  26108. */
  26109. prepareDefines(defines: IMaterialBRDFDefines): void;
  26110. /**
  26111. * Get the current class name of the texture useful for serialization or dynamic coding.
  26112. * @returns "PBRClearCoatConfiguration"
  26113. */
  26114. getClassName(): string;
  26115. /**
  26116. * Makes a duplicate of the current configuration into another one.
  26117. * @param brdfConfiguration define the config where to copy the info
  26118. */
  26119. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  26120. /**
  26121. * Serializes this BRDF configuration.
  26122. * @returns - An object with the serialized config.
  26123. */
  26124. serialize(): any;
  26125. /**
  26126. * Parses a anisotropy Configuration from a serialized object.
  26127. * @param source - Serialized object.
  26128. * @param scene Defines the scene we are parsing for
  26129. * @param rootUrl Defines the rootUrl to load from
  26130. */
  26131. parse(source: any, scene: Scene, rootUrl: string): void;
  26132. }
  26133. }
  26134. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  26135. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26136. import { Color3 } from "babylonjs/Maths/math.color";
  26137. import { Scene } from "babylonjs/scene";
  26138. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26139. import { Nullable } from "babylonjs/types";
  26140. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26141. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  26142. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26143. /**
  26144. * @hidden
  26145. */
  26146. export interface IMaterialSheenDefines {
  26147. SHEEN: boolean;
  26148. SHEEN_TEXTURE: boolean;
  26149. SHEEN_TEXTURE_ROUGHNESS: boolean;
  26150. SHEEN_TEXTUREDIRECTUV: number;
  26151. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  26152. SHEEN_LINKWITHALBEDO: boolean;
  26153. SHEEN_ROUGHNESS: boolean;
  26154. SHEEN_ALBEDOSCALING: boolean;
  26155. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26156. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26157. /** @hidden */
  26158. _areTexturesDirty: boolean;
  26159. }
  26160. /**
  26161. * Define the code related to the Sheen parameters of the pbr material.
  26162. */
  26163. export class PBRSheenConfiguration {
  26164. private _isEnabled;
  26165. /**
  26166. * Defines if the material uses sheen.
  26167. */
  26168. isEnabled: boolean;
  26169. private _linkSheenWithAlbedo;
  26170. /**
  26171. * Defines if the sheen is linked to the sheen color.
  26172. */
  26173. linkSheenWithAlbedo: boolean;
  26174. /**
  26175. * Defines the sheen intensity.
  26176. */
  26177. intensity: number;
  26178. /**
  26179. * Defines the sheen color.
  26180. */
  26181. color: Color3;
  26182. private _texture;
  26183. /**
  26184. * Stores the sheen tint values in a texture.
  26185. * rgb is tint
  26186. * 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)
  26187. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  26188. */
  26189. texture: Nullable<BaseTexture>;
  26190. private _useRoughnessFromMainTexture;
  26191. /**
  26192. * Indicates that the alpha channel of the texture property will be used for roughness.
  26193. * Has no effect if the roughness (and texture!) property is not defined
  26194. */
  26195. useRoughnessFromMainTexture: boolean;
  26196. private _roughness;
  26197. /**
  26198. * Defines the sheen roughness.
  26199. * It is not taken into account if linkSheenWithAlbedo is true.
  26200. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  26201. */
  26202. roughness: Nullable<number>;
  26203. private _textureRoughness;
  26204. /**
  26205. * Stores the sheen roughness in a texture.
  26206. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  26207. */
  26208. textureRoughness: Nullable<BaseTexture>;
  26209. private _albedoScaling;
  26210. /**
  26211. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  26212. * It allows the strength of the sheen effect to not depend on the base color of the material,
  26213. * making it easier to setup and tweak the effect
  26214. */
  26215. albedoScaling: boolean;
  26216. /** @hidden */
  26217. private _internalMarkAllSubMeshesAsTexturesDirty;
  26218. /** @hidden */
  26219. _markAllSubMeshesAsTexturesDirty(): void;
  26220. /**
  26221. * Instantiate a new istance of clear coat configuration.
  26222. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26223. */
  26224. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  26225. /**
  26226. * Specifies that the submesh is ready to be used.
  26227. * @param defines the list of "defines" to update.
  26228. * @param scene defines the scene the material belongs to.
  26229. * @returns - boolean indicating that the submesh is ready or not.
  26230. */
  26231. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  26232. /**
  26233. * Checks to see if a texture is used in the material.
  26234. * @param defines the list of "defines" to update.
  26235. * @param scene defines the scene the material belongs to.
  26236. */
  26237. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  26238. /**
  26239. * Binds the material data.
  26240. * @param uniformBuffer defines the Uniform buffer to fill in.
  26241. * @param scene defines the scene the material belongs to.
  26242. * @param isFrozen defines wether the material is frozen or not.
  26243. * @param subMesh the submesh to bind data for
  26244. */
  26245. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  26246. /**
  26247. * Checks to see if a texture is used in the material.
  26248. * @param texture - Base texture to use.
  26249. * @returns - Boolean specifying if a texture is used in the material.
  26250. */
  26251. hasTexture(texture: BaseTexture): boolean;
  26252. /**
  26253. * Returns an array of the actively used textures.
  26254. * @param activeTextures Array of BaseTextures
  26255. */
  26256. getActiveTextures(activeTextures: BaseTexture[]): void;
  26257. /**
  26258. * Returns the animatable textures.
  26259. * @param animatables Array of animatable textures.
  26260. */
  26261. getAnimatables(animatables: IAnimatable[]): void;
  26262. /**
  26263. * Disposes the resources of the material.
  26264. * @param forceDisposeTextures - Forces the disposal of all textures.
  26265. */
  26266. dispose(forceDisposeTextures?: boolean): void;
  26267. /**
  26268. * Get the current class name of the texture useful for serialization or dynamic coding.
  26269. * @returns "PBRSheenConfiguration"
  26270. */
  26271. getClassName(): string;
  26272. /**
  26273. * Add fallbacks to the effect fallbacks list.
  26274. * @param defines defines the Base texture to use.
  26275. * @param fallbacks defines the current fallback list.
  26276. * @param currentRank defines the current fallback rank.
  26277. * @returns the new fallback rank.
  26278. */
  26279. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26280. /**
  26281. * Add the required uniforms to the current list.
  26282. * @param uniforms defines the current uniform list.
  26283. */
  26284. static AddUniforms(uniforms: string[]): void;
  26285. /**
  26286. * Add the required uniforms to the current buffer.
  26287. * @param uniformBuffer defines the current uniform buffer.
  26288. */
  26289. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26290. /**
  26291. * Add the required samplers to the current list.
  26292. * @param samplers defines the current sampler list.
  26293. */
  26294. static AddSamplers(samplers: string[]): void;
  26295. /**
  26296. * Makes a duplicate of the current configuration into another one.
  26297. * @param sheenConfiguration define the config where to copy the info
  26298. */
  26299. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  26300. /**
  26301. * Serializes this BRDF configuration.
  26302. * @returns - An object with the serialized config.
  26303. */
  26304. serialize(): any;
  26305. /**
  26306. * Parses a anisotropy Configuration from a serialized object.
  26307. * @param source - Serialized object.
  26308. * @param scene Defines the scene we are parsing for
  26309. * @param rootUrl Defines the rootUrl to load from
  26310. */
  26311. parse(source: any, scene: Scene, rootUrl: string): void;
  26312. }
  26313. }
  26314. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  26315. import { Nullable } from "babylonjs/types";
  26316. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26317. import { Color3 } from "babylonjs/Maths/math.color";
  26318. import { SmartArray } from "babylonjs/Misc/smartArray";
  26319. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26320. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26321. import { Effect } from "babylonjs/Materials/effect";
  26322. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26323. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  26324. import { Engine } from "babylonjs/Engines/engine";
  26325. import { Scene } from "babylonjs/scene";
  26326. /**
  26327. * @hidden
  26328. */
  26329. export interface IMaterialSubSurfaceDefines {
  26330. SUBSURFACE: boolean;
  26331. SS_REFRACTION: boolean;
  26332. SS_TRANSLUCENCY: boolean;
  26333. SS_SCATTERING: boolean;
  26334. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26335. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26336. SS_REFRACTIONMAP_3D: boolean;
  26337. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26338. SS_LODINREFRACTIONALPHA: boolean;
  26339. SS_GAMMAREFRACTION: boolean;
  26340. SS_RGBDREFRACTION: boolean;
  26341. SS_LINEARSPECULARREFRACTION: boolean;
  26342. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26343. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26344. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26345. /** @hidden */
  26346. _areTexturesDirty: boolean;
  26347. }
  26348. /**
  26349. * Define the code related to the sub surface parameters of the pbr material.
  26350. */
  26351. export class PBRSubSurfaceConfiguration {
  26352. private _isRefractionEnabled;
  26353. /**
  26354. * Defines if the refraction is enabled in the material.
  26355. */
  26356. isRefractionEnabled: boolean;
  26357. private _isTranslucencyEnabled;
  26358. /**
  26359. * Defines if the translucency is enabled in the material.
  26360. */
  26361. isTranslucencyEnabled: boolean;
  26362. private _isScatteringEnabled;
  26363. /**
  26364. * Defines if the sub surface scattering is enabled in the material.
  26365. */
  26366. isScatteringEnabled: boolean;
  26367. private _scatteringDiffusionProfileIndex;
  26368. /**
  26369. * Diffusion profile for subsurface scattering.
  26370. * Useful for better scattering in the skins or foliages.
  26371. */
  26372. get scatteringDiffusionProfile(): Nullable<Color3>;
  26373. set scatteringDiffusionProfile(c: Nullable<Color3>);
  26374. /**
  26375. * Defines the refraction intensity of the material.
  26376. * The refraction when enabled replaces the Diffuse part of the material.
  26377. * The intensity helps transitionning between diffuse and refraction.
  26378. */
  26379. refractionIntensity: number;
  26380. /**
  26381. * Defines the translucency intensity of the material.
  26382. * When translucency has been enabled, this defines how much of the "translucency"
  26383. * is addded to the diffuse part of the material.
  26384. */
  26385. translucencyIntensity: number;
  26386. /**
  26387. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  26388. */
  26389. useAlbedoToTintRefraction: boolean;
  26390. private _thicknessTexture;
  26391. /**
  26392. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  26393. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  26394. * 0 would mean minimumThickness
  26395. * 1 would mean maximumThickness
  26396. * The other channels might be use as a mask to vary the different effects intensity.
  26397. */
  26398. thicknessTexture: Nullable<BaseTexture>;
  26399. private _refractionTexture;
  26400. /**
  26401. * Defines the texture to use for refraction.
  26402. */
  26403. refractionTexture: Nullable<BaseTexture>;
  26404. private _indexOfRefraction;
  26405. /**
  26406. * Index of refraction of the material base layer.
  26407. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26408. *
  26409. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26410. *
  26411. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26412. */
  26413. indexOfRefraction: number;
  26414. private _volumeIndexOfRefraction;
  26415. /**
  26416. * Index of refraction of the material's volume.
  26417. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26418. *
  26419. * This ONLY impacts refraction. If not provided or given a non-valid value,
  26420. * the volume will use the same IOR as the surface.
  26421. */
  26422. get volumeIndexOfRefraction(): number;
  26423. set volumeIndexOfRefraction(value: number);
  26424. private _invertRefractionY;
  26425. /**
  26426. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26427. */
  26428. invertRefractionY: boolean;
  26429. private _linkRefractionWithTransparency;
  26430. /**
  26431. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26432. * Materials half opaque for instance using refraction could benefit from this control.
  26433. */
  26434. linkRefractionWithTransparency: boolean;
  26435. /**
  26436. * Defines the minimum thickness stored in the thickness map.
  26437. * If no thickness map is defined, this value will be used to simulate thickness.
  26438. */
  26439. minimumThickness: number;
  26440. /**
  26441. * Defines the maximum thickness stored in the thickness map.
  26442. */
  26443. maximumThickness: number;
  26444. /**
  26445. * Defines the volume tint of the material.
  26446. * This is used for both translucency and scattering.
  26447. */
  26448. tintColor: Color3;
  26449. /**
  26450. * Defines the distance at which the tint color should be found in the media.
  26451. * This is used for refraction only.
  26452. */
  26453. tintColorAtDistance: number;
  26454. /**
  26455. * Defines how far each channel transmit through the media.
  26456. * It is defined as a color to simplify it selection.
  26457. */
  26458. diffusionDistance: Color3;
  26459. private _useMaskFromThicknessTexture;
  26460. /**
  26461. * Stores the intensity of the different subsurface effects in the thickness texture.
  26462. * * the green channel is the translucency intensity.
  26463. * * the blue channel is the scattering intensity.
  26464. * * the alpha channel is the refraction intensity.
  26465. */
  26466. useMaskFromThicknessTexture: boolean;
  26467. private _scene;
  26468. /** @hidden */
  26469. private _internalMarkAllSubMeshesAsTexturesDirty;
  26470. private _internalMarkScenePrePassDirty;
  26471. /** @hidden */
  26472. _markAllSubMeshesAsTexturesDirty(): void;
  26473. /** @hidden */
  26474. _markScenePrePassDirty(): void;
  26475. /**
  26476. * Instantiate a new istance of sub surface configuration.
  26477. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26478. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  26479. * @param scene The scene
  26480. */
  26481. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  26482. /**
  26483. * Gets wehter the submesh is ready to be used or not.
  26484. * @param defines the list of "defines" to update.
  26485. * @param scene defines the scene the material belongs to.
  26486. * @returns - boolean indicating that the submesh is ready or not.
  26487. */
  26488. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  26489. /**
  26490. * Checks to see if a texture is used in the material.
  26491. * @param defines the list of "defines" to update.
  26492. * @param scene defines the scene to the material belongs to.
  26493. */
  26494. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  26495. /**
  26496. * Binds the material data.
  26497. * @param uniformBuffer defines the Uniform buffer to fill in.
  26498. * @param scene defines the scene the material belongs to.
  26499. * @param engine defines the engine the material belongs to.
  26500. * @param isFrozen defines whether the material is frozen or not.
  26501. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  26502. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  26503. */
  26504. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  26505. /**
  26506. * Unbinds the material from the mesh.
  26507. * @param activeEffect defines the effect that should be unbound from.
  26508. * @returns true if unbound, otherwise false
  26509. */
  26510. unbind(activeEffect: Effect): boolean;
  26511. /**
  26512. * Returns the texture used for refraction or null if none is used.
  26513. * @param scene defines the scene the material belongs to.
  26514. * @returns - Refraction texture if present. If no refraction texture and refraction
  26515. * is linked with transparency, returns environment texture. Otherwise, returns null.
  26516. */
  26517. private _getRefractionTexture;
  26518. /**
  26519. * Returns true if alpha blending should be disabled.
  26520. */
  26521. get disableAlphaBlending(): boolean;
  26522. /**
  26523. * Fills the list of render target textures.
  26524. * @param renderTargets the list of render targets to update
  26525. */
  26526. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  26527. /**
  26528. * Checks to see if a texture is used in the material.
  26529. * @param texture - Base texture to use.
  26530. * @returns - Boolean specifying if a texture is used in the material.
  26531. */
  26532. hasTexture(texture: BaseTexture): boolean;
  26533. /**
  26534. * Gets a boolean indicating that current material needs to register RTT
  26535. * @returns true if this uses a render target otherwise false.
  26536. */
  26537. hasRenderTargetTextures(): boolean;
  26538. /**
  26539. * Returns an array of the actively used textures.
  26540. * @param activeTextures Array of BaseTextures
  26541. */
  26542. getActiveTextures(activeTextures: BaseTexture[]): void;
  26543. /**
  26544. * Returns the animatable textures.
  26545. * @param animatables Array of animatable textures.
  26546. */
  26547. getAnimatables(animatables: IAnimatable[]): void;
  26548. /**
  26549. * Disposes the resources of the material.
  26550. * @param forceDisposeTextures - Forces the disposal of all textures.
  26551. */
  26552. dispose(forceDisposeTextures?: boolean): void;
  26553. /**
  26554. * Get the current class name of the texture useful for serialization or dynamic coding.
  26555. * @returns "PBRSubSurfaceConfiguration"
  26556. */
  26557. getClassName(): string;
  26558. /**
  26559. * Add fallbacks to the effect fallbacks list.
  26560. * @param defines defines the Base texture to use.
  26561. * @param fallbacks defines the current fallback list.
  26562. * @param currentRank defines the current fallback rank.
  26563. * @returns the new fallback rank.
  26564. */
  26565. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26566. /**
  26567. * Add the required uniforms to the current list.
  26568. * @param uniforms defines the current uniform list.
  26569. */
  26570. static AddUniforms(uniforms: string[]): void;
  26571. /**
  26572. * Add the required samplers to the current list.
  26573. * @param samplers defines the current sampler list.
  26574. */
  26575. static AddSamplers(samplers: string[]): void;
  26576. /**
  26577. * Add the required uniforms to the current buffer.
  26578. * @param uniformBuffer defines the current uniform buffer.
  26579. */
  26580. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26581. /**
  26582. * Makes a duplicate of the current configuration into another one.
  26583. * @param configuration define the config where to copy the info
  26584. */
  26585. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  26586. /**
  26587. * Serializes this Sub Surface configuration.
  26588. * @returns - An object with the serialized config.
  26589. */
  26590. serialize(): any;
  26591. /**
  26592. * Parses a anisotropy Configuration from a serialized object.
  26593. * @param source - Serialized object.
  26594. * @param scene Defines the scene we are parsing for
  26595. * @param rootUrl Defines the rootUrl to load from
  26596. */
  26597. parse(source: any, scene: Scene, rootUrl: string): void;
  26598. }
  26599. }
  26600. declare module "babylonjs/Maths/sphericalPolynomial" {
  26601. import { Vector3 } from "babylonjs/Maths/math.vector";
  26602. import { Color3 } from "babylonjs/Maths/math.color";
  26603. /**
  26604. * Class representing spherical harmonics coefficients to the 3rd degree
  26605. */
  26606. export class SphericalHarmonics {
  26607. /**
  26608. * Defines whether or not the harmonics have been prescaled for rendering.
  26609. */
  26610. preScaled: boolean;
  26611. /**
  26612. * The l0,0 coefficients of the spherical harmonics
  26613. */
  26614. l00: Vector3;
  26615. /**
  26616. * The l1,-1 coefficients of the spherical harmonics
  26617. */
  26618. l1_1: Vector3;
  26619. /**
  26620. * The l1,0 coefficients of the spherical harmonics
  26621. */
  26622. l10: Vector3;
  26623. /**
  26624. * The l1,1 coefficients of the spherical harmonics
  26625. */
  26626. l11: Vector3;
  26627. /**
  26628. * The l2,-2 coefficients of the spherical harmonics
  26629. */
  26630. l2_2: Vector3;
  26631. /**
  26632. * The l2,-1 coefficients of the spherical harmonics
  26633. */
  26634. l2_1: Vector3;
  26635. /**
  26636. * The l2,0 coefficients of the spherical harmonics
  26637. */
  26638. l20: Vector3;
  26639. /**
  26640. * The l2,1 coefficients of the spherical harmonics
  26641. */
  26642. l21: Vector3;
  26643. /**
  26644. * The l2,2 coefficients of the spherical harmonics
  26645. */
  26646. l22: Vector3;
  26647. /**
  26648. * Adds a light to the spherical harmonics
  26649. * @param direction the direction of the light
  26650. * @param color the color of the light
  26651. * @param deltaSolidAngle the delta solid angle of the light
  26652. */
  26653. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  26654. /**
  26655. * Scales the spherical harmonics by the given amount
  26656. * @param scale the amount to scale
  26657. */
  26658. scaleInPlace(scale: number): void;
  26659. /**
  26660. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  26661. *
  26662. * ```
  26663. * E_lm = A_l * L_lm
  26664. * ```
  26665. *
  26666. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  26667. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  26668. * the scaling factors are given in equation 9.
  26669. */
  26670. convertIncidentRadianceToIrradiance(): void;
  26671. /**
  26672. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  26673. *
  26674. * ```
  26675. * L = (1/pi) * E * rho
  26676. * ```
  26677. *
  26678. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  26679. */
  26680. convertIrradianceToLambertianRadiance(): void;
  26681. /**
  26682. * Integrates the reconstruction coefficients directly in to the SH preventing further
  26683. * required operations at run time.
  26684. *
  26685. * This is simply done by scaling back the SH with Ylm constants parameter.
  26686. * The trigonometric part being applied by the shader at run time.
  26687. */
  26688. preScaleForRendering(): void;
  26689. /**
  26690. * Constructs a spherical harmonics from an array.
  26691. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  26692. * @returns the spherical harmonics
  26693. */
  26694. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  26695. /**
  26696. * Gets the spherical harmonics from polynomial
  26697. * @param polynomial the spherical polynomial
  26698. * @returns the spherical harmonics
  26699. */
  26700. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  26701. }
  26702. /**
  26703. * Class representing spherical polynomial coefficients to the 3rd degree
  26704. */
  26705. export class SphericalPolynomial {
  26706. private _harmonics;
  26707. /**
  26708. * The spherical harmonics used to create the polynomials.
  26709. */
  26710. get preScaledHarmonics(): SphericalHarmonics;
  26711. /**
  26712. * The x coefficients of the spherical polynomial
  26713. */
  26714. x: Vector3;
  26715. /**
  26716. * The y coefficients of the spherical polynomial
  26717. */
  26718. y: Vector3;
  26719. /**
  26720. * The z coefficients of the spherical polynomial
  26721. */
  26722. z: Vector3;
  26723. /**
  26724. * The xx coefficients of the spherical polynomial
  26725. */
  26726. xx: Vector3;
  26727. /**
  26728. * The yy coefficients of the spherical polynomial
  26729. */
  26730. yy: Vector3;
  26731. /**
  26732. * The zz coefficients of the spherical polynomial
  26733. */
  26734. zz: Vector3;
  26735. /**
  26736. * The xy coefficients of the spherical polynomial
  26737. */
  26738. xy: Vector3;
  26739. /**
  26740. * The yz coefficients of the spherical polynomial
  26741. */
  26742. yz: Vector3;
  26743. /**
  26744. * The zx coefficients of the spherical polynomial
  26745. */
  26746. zx: Vector3;
  26747. /**
  26748. * Adds an ambient color to the spherical polynomial
  26749. * @param color the color to add
  26750. */
  26751. addAmbient(color: Color3): void;
  26752. /**
  26753. * Scales the spherical polynomial by the given amount
  26754. * @param scale the amount to scale
  26755. */
  26756. scaleInPlace(scale: number): void;
  26757. /**
  26758. * Gets the spherical polynomial from harmonics
  26759. * @param harmonics the spherical harmonics
  26760. * @returns the spherical polynomial
  26761. */
  26762. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  26763. /**
  26764. * Constructs a spherical polynomial from an array.
  26765. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  26766. * @returns the spherical polynomial
  26767. */
  26768. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  26769. }
  26770. }
  26771. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  26772. import { Nullable } from "babylonjs/types";
  26773. /**
  26774. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26775. */
  26776. export interface CubeMapInfo {
  26777. /**
  26778. * The pixel array for the front face.
  26779. * This is stored in format, left to right, up to down format.
  26780. */
  26781. front: Nullable<ArrayBufferView>;
  26782. /**
  26783. * The pixel array for the back face.
  26784. * This is stored in format, left to right, up to down format.
  26785. */
  26786. back: Nullable<ArrayBufferView>;
  26787. /**
  26788. * The pixel array for the left face.
  26789. * This is stored in format, left to right, up to down format.
  26790. */
  26791. left: Nullable<ArrayBufferView>;
  26792. /**
  26793. * The pixel array for the right face.
  26794. * This is stored in format, left to right, up to down format.
  26795. */
  26796. right: Nullable<ArrayBufferView>;
  26797. /**
  26798. * The pixel array for the up face.
  26799. * This is stored in format, left to right, up to down format.
  26800. */
  26801. up: Nullable<ArrayBufferView>;
  26802. /**
  26803. * The pixel array for the down face.
  26804. * This is stored in format, left to right, up to down format.
  26805. */
  26806. down: Nullable<ArrayBufferView>;
  26807. /**
  26808. * The size of the cubemap stored.
  26809. *
  26810. * Each faces will be size * size pixels.
  26811. */
  26812. size: number;
  26813. /**
  26814. * The format of the texture.
  26815. *
  26816. * RGBA, RGB.
  26817. */
  26818. format: number;
  26819. /**
  26820. * The type of the texture data.
  26821. *
  26822. * UNSIGNED_INT, FLOAT.
  26823. */
  26824. type: number;
  26825. /**
  26826. * Specifies whether the texture is in gamma space.
  26827. */
  26828. gammaSpace: boolean;
  26829. }
  26830. /**
  26831. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  26832. */
  26833. export class PanoramaToCubeMapTools {
  26834. private static FACE_LEFT;
  26835. private static FACE_RIGHT;
  26836. private static FACE_FRONT;
  26837. private static FACE_BACK;
  26838. private static FACE_DOWN;
  26839. private static FACE_UP;
  26840. /**
  26841. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  26842. *
  26843. * @param float32Array The source data.
  26844. * @param inputWidth The width of the input panorama.
  26845. * @param inputHeight The height of the input panorama.
  26846. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  26847. * @return The cubemap data
  26848. */
  26849. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  26850. private static CreateCubemapTexture;
  26851. private static CalcProjectionSpherical;
  26852. }
  26853. }
  26854. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  26855. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26856. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26857. import { Nullable } from "babylonjs/types";
  26858. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  26859. /**
  26860. * Helper class dealing with the extraction of spherical polynomial dataArray
  26861. * from a cube map.
  26862. */
  26863. export class CubeMapToSphericalPolynomialTools {
  26864. private static FileFaces;
  26865. /**
  26866. * Converts a texture to the according Spherical Polynomial data.
  26867. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26868. *
  26869. * @param texture The texture to extract the information from.
  26870. * @return The Spherical Polynomial data.
  26871. */
  26872. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  26873. /**
  26874. * Converts a cubemap to the according Spherical Polynomial data.
  26875. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26876. *
  26877. * @param cubeInfo The Cube map to extract the information from.
  26878. * @return The Spherical Polynomial data.
  26879. */
  26880. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  26881. }
  26882. }
  26883. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  26884. import { Nullable } from "babylonjs/types";
  26885. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26886. module "babylonjs/Materials/Textures/baseTexture" {
  26887. interface BaseTexture {
  26888. /**
  26889. * Get the polynomial representation of the texture data.
  26890. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26891. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26892. */
  26893. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26894. }
  26895. }
  26896. }
  26897. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  26898. /** @hidden */
  26899. export var pbrFragmentDeclaration: {
  26900. name: string;
  26901. shader: string;
  26902. };
  26903. }
  26904. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  26905. /** @hidden */
  26906. export var pbrUboDeclaration: {
  26907. name: string;
  26908. shader: string;
  26909. };
  26910. }
  26911. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  26912. /** @hidden */
  26913. export var pbrFragmentExtraDeclaration: {
  26914. name: string;
  26915. shader: string;
  26916. };
  26917. }
  26918. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  26919. /** @hidden */
  26920. export var pbrFragmentSamplersDeclaration: {
  26921. name: string;
  26922. shader: string;
  26923. };
  26924. }
  26925. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  26926. /** @hidden */
  26927. export var subSurfaceScatteringFunctions: {
  26928. name: string;
  26929. shader: string;
  26930. };
  26931. }
  26932. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  26933. /** @hidden */
  26934. export var importanceSampling: {
  26935. name: string;
  26936. shader: string;
  26937. };
  26938. }
  26939. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  26940. /** @hidden */
  26941. export var pbrHelperFunctions: {
  26942. name: string;
  26943. shader: string;
  26944. };
  26945. }
  26946. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  26947. /** @hidden */
  26948. export var harmonicsFunctions: {
  26949. name: string;
  26950. shader: string;
  26951. };
  26952. }
  26953. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  26954. /** @hidden */
  26955. export var pbrDirectLightingSetupFunctions: {
  26956. name: string;
  26957. shader: string;
  26958. };
  26959. }
  26960. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  26961. /** @hidden */
  26962. export var pbrDirectLightingFalloffFunctions: {
  26963. name: string;
  26964. shader: string;
  26965. };
  26966. }
  26967. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  26968. /** @hidden */
  26969. export var pbrBRDFFunctions: {
  26970. name: string;
  26971. shader: string;
  26972. };
  26973. }
  26974. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  26975. /** @hidden */
  26976. export var hdrFilteringFunctions: {
  26977. name: string;
  26978. shader: string;
  26979. };
  26980. }
  26981. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  26982. /** @hidden */
  26983. export var pbrDirectLightingFunctions: {
  26984. name: string;
  26985. shader: string;
  26986. };
  26987. }
  26988. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  26989. /** @hidden */
  26990. export var pbrIBLFunctions: {
  26991. name: string;
  26992. shader: string;
  26993. };
  26994. }
  26995. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  26996. /** @hidden */
  26997. export var pbrBlockAlbedoOpacity: {
  26998. name: string;
  26999. shader: string;
  27000. };
  27001. }
  27002. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  27003. /** @hidden */
  27004. export var pbrBlockReflectivity: {
  27005. name: string;
  27006. shader: string;
  27007. };
  27008. }
  27009. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  27010. /** @hidden */
  27011. export var pbrBlockAmbientOcclusion: {
  27012. name: string;
  27013. shader: string;
  27014. };
  27015. }
  27016. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  27017. /** @hidden */
  27018. export var pbrBlockAlphaFresnel: {
  27019. name: string;
  27020. shader: string;
  27021. };
  27022. }
  27023. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  27024. /** @hidden */
  27025. export var pbrBlockAnisotropic: {
  27026. name: string;
  27027. shader: string;
  27028. };
  27029. }
  27030. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  27031. /** @hidden */
  27032. export var pbrBlockReflection: {
  27033. name: string;
  27034. shader: string;
  27035. };
  27036. }
  27037. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  27038. /** @hidden */
  27039. export var pbrBlockSheen: {
  27040. name: string;
  27041. shader: string;
  27042. };
  27043. }
  27044. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  27045. /** @hidden */
  27046. export var pbrBlockClearcoat: {
  27047. name: string;
  27048. shader: string;
  27049. };
  27050. }
  27051. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  27052. /** @hidden */
  27053. export var pbrBlockSubSurface: {
  27054. name: string;
  27055. shader: string;
  27056. };
  27057. }
  27058. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  27059. /** @hidden */
  27060. export var pbrBlockNormalGeometric: {
  27061. name: string;
  27062. shader: string;
  27063. };
  27064. }
  27065. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  27066. /** @hidden */
  27067. export var pbrBlockNormalFinal: {
  27068. name: string;
  27069. shader: string;
  27070. };
  27071. }
  27072. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  27073. /** @hidden */
  27074. export var pbrBlockLightmapInit: {
  27075. name: string;
  27076. shader: string;
  27077. };
  27078. }
  27079. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  27080. /** @hidden */
  27081. export var pbrBlockGeometryInfo: {
  27082. name: string;
  27083. shader: string;
  27084. };
  27085. }
  27086. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  27087. /** @hidden */
  27088. export var pbrBlockReflectance0: {
  27089. name: string;
  27090. shader: string;
  27091. };
  27092. }
  27093. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  27094. /** @hidden */
  27095. export var pbrBlockReflectance: {
  27096. name: string;
  27097. shader: string;
  27098. };
  27099. }
  27100. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  27101. /** @hidden */
  27102. export var pbrBlockDirectLighting: {
  27103. name: string;
  27104. shader: string;
  27105. };
  27106. }
  27107. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  27108. /** @hidden */
  27109. export var pbrBlockFinalLitComponents: {
  27110. name: string;
  27111. shader: string;
  27112. };
  27113. }
  27114. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  27115. /** @hidden */
  27116. export var pbrBlockFinalUnlitComponents: {
  27117. name: string;
  27118. shader: string;
  27119. };
  27120. }
  27121. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  27122. /** @hidden */
  27123. export var pbrBlockFinalColorComposition: {
  27124. name: string;
  27125. shader: string;
  27126. };
  27127. }
  27128. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  27129. /** @hidden */
  27130. export var pbrBlockImageProcessing: {
  27131. name: string;
  27132. shader: string;
  27133. };
  27134. }
  27135. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  27136. /** @hidden */
  27137. export var pbrDebug: {
  27138. name: string;
  27139. shader: string;
  27140. };
  27141. }
  27142. declare module "babylonjs/Shaders/pbr.fragment" {
  27143. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  27144. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  27145. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  27146. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  27147. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27148. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27149. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  27150. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27151. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27152. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27153. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27154. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27155. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  27156. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  27157. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  27158. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27159. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27160. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  27161. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  27162. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  27163. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  27164. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  27165. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  27166. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  27167. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  27168. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27169. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27170. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  27171. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  27172. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  27173. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  27174. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  27175. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  27176. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  27177. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  27178. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  27179. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27180. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  27181. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27182. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  27183. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27184. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  27185. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  27186. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  27187. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  27188. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  27189. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27190. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  27191. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  27192. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  27193. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27194. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27195. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  27196. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  27197. /** @hidden */
  27198. export var pbrPixelShader: {
  27199. name: string;
  27200. shader: string;
  27201. };
  27202. }
  27203. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  27204. /** @hidden */
  27205. export var pbrVertexDeclaration: {
  27206. name: string;
  27207. shader: string;
  27208. };
  27209. }
  27210. declare module "babylonjs/Shaders/pbr.vertex" {
  27211. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  27212. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  27213. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27214. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27215. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27216. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  27217. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  27218. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27219. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27220. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27221. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27222. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27223. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27224. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27225. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27226. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27227. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27228. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27229. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  27230. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27231. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27232. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27233. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27234. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27235. /** @hidden */
  27236. export var pbrVertexShader: {
  27237. name: string;
  27238. shader: string;
  27239. };
  27240. }
  27241. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  27242. import { Nullable } from "babylonjs/types";
  27243. import { Scene } from "babylonjs/scene";
  27244. import { Matrix } from "babylonjs/Maths/math.vector";
  27245. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27247. import { Mesh } from "babylonjs/Meshes/mesh";
  27248. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  27249. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  27250. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  27251. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  27252. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  27253. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  27254. import { Color3 } from "babylonjs/Maths/math.color";
  27255. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27256. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  27257. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27258. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27259. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27260. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27261. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  27262. import "babylonjs/Shaders/pbr.fragment";
  27263. import "babylonjs/Shaders/pbr.vertex";
  27264. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  27265. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  27266. /**
  27267. * Manages the defines for the PBR Material.
  27268. * @hidden
  27269. */
  27270. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  27271. PBR: boolean;
  27272. NUM_SAMPLES: string;
  27273. REALTIME_FILTERING: boolean;
  27274. MAINUV1: boolean;
  27275. MAINUV2: boolean;
  27276. UV1: boolean;
  27277. UV2: boolean;
  27278. ALBEDO: boolean;
  27279. GAMMAALBEDO: boolean;
  27280. ALBEDODIRECTUV: number;
  27281. VERTEXCOLOR: boolean;
  27282. DETAIL: boolean;
  27283. DETAILDIRECTUV: number;
  27284. DETAIL_NORMALBLENDMETHOD: number;
  27285. AMBIENT: boolean;
  27286. AMBIENTDIRECTUV: number;
  27287. AMBIENTINGRAYSCALE: boolean;
  27288. OPACITY: boolean;
  27289. VERTEXALPHA: boolean;
  27290. OPACITYDIRECTUV: number;
  27291. OPACITYRGB: boolean;
  27292. ALPHATEST: boolean;
  27293. DEPTHPREPASS: boolean;
  27294. ALPHABLEND: boolean;
  27295. ALPHAFROMALBEDO: boolean;
  27296. ALPHATESTVALUE: string;
  27297. SPECULAROVERALPHA: boolean;
  27298. RADIANCEOVERALPHA: boolean;
  27299. ALPHAFRESNEL: boolean;
  27300. LINEARALPHAFRESNEL: boolean;
  27301. PREMULTIPLYALPHA: boolean;
  27302. EMISSIVE: boolean;
  27303. EMISSIVEDIRECTUV: number;
  27304. REFLECTIVITY: boolean;
  27305. REFLECTIVITYDIRECTUV: number;
  27306. SPECULARTERM: boolean;
  27307. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  27308. MICROSURFACEAUTOMATIC: boolean;
  27309. LODBASEDMICROSFURACE: boolean;
  27310. MICROSURFACEMAP: boolean;
  27311. MICROSURFACEMAPDIRECTUV: number;
  27312. METALLICWORKFLOW: boolean;
  27313. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  27314. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  27315. METALLNESSSTOREINMETALMAPBLUE: boolean;
  27316. AOSTOREINMETALMAPRED: boolean;
  27317. METALLIC_REFLECTANCE: boolean;
  27318. METALLIC_REFLECTANCEDIRECTUV: number;
  27319. ENVIRONMENTBRDF: boolean;
  27320. ENVIRONMENTBRDF_RGBD: boolean;
  27321. NORMAL: boolean;
  27322. TANGENT: boolean;
  27323. BUMP: boolean;
  27324. BUMPDIRECTUV: number;
  27325. OBJECTSPACE_NORMALMAP: boolean;
  27326. PARALLAX: boolean;
  27327. PARALLAXOCCLUSION: boolean;
  27328. NORMALXYSCALE: boolean;
  27329. LIGHTMAP: boolean;
  27330. LIGHTMAPDIRECTUV: number;
  27331. USELIGHTMAPASSHADOWMAP: boolean;
  27332. GAMMALIGHTMAP: boolean;
  27333. RGBDLIGHTMAP: boolean;
  27334. REFLECTION: boolean;
  27335. REFLECTIONMAP_3D: boolean;
  27336. REFLECTIONMAP_SPHERICAL: boolean;
  27337. REFLECTIONMAP_PLANAR: boolean;
  27338. REFLECTIONMAP_CUBIC: boolean;
  27339. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27340. REFLECTIONMAP_PROJECTION: boolean;
  27341. REFLECTIONMAP_SKYBOX: boolean;
  27342. REFLECTIONMAP_EXPLICIT: boolean;
  27343. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27344. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27345. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27346. INVERTCUBICMAP: boolean;
  27347. USESPHERICALFROMREFLECTIONMAP: boolean;
  27348. USEIRRADIANCEMAP: boolean;
  27349. SPHERICAL_HARMONICS: boolean;
  27350. USESPHERICALINVERTEX: boolean;
  27351. REFLECTIONMAP_OPPOSITEZ: boolean;
  27352. LODINREFLECTIONALPHA: boolean;
  27353. GAMMAREFLECTION: boolean;
  27354. RGBDREFLECTION: boolean;
  27355. LINEARSPECULARREFLECTION: boolean;
  27356. RADIANCEOCCLUSION: boolean;
  27357. HORIZONOCCLUSION: boolean;
  27358. INSTANCES: boolean;
  27359. THIN_INSTANCES: boolean;
  27360. PREPASS: boolean;
  27361. PREPASS_IRRADIANCE: boolean;
  27362. PREPASS_IRRADIANCE_INDEX: number;
  27363. PREPASS_ALBEDO: boolean;
  27364. PREPASS_ALBEDO_INDEX: number;
  27365. PREPASS_DEPTHNORMAL: boolean;
  27366. PREPASS_DEPTHNORMAL_INDEX: number;
  27367. PREPASS_POSITION: boolean;
  27368. PREPASS_POSITION_INDEX: number;
  27369. PREPASS_VELOCITY: boolean;
  27370. PREPASS_VELOCITY_INDEX: number;
  27371. PREPASS_REFLECTIVITY: boolean;
  27372. PREPASS_REFLECTIVITY_INDEX: number;
  27373. SCENE_MRT_COUNT: number;
  27374. NUM_BONE_INFLUENCERS: number;
  27375. BonesPerMesh: number;
  27376. BONETEXTURE: boolean;
  27377. BONES_VELOCITY_ENABLED: boolean;
  27378. NONUNIFORMSCALING: boolean;
  27379. MORPHTARGETS: boolean;
  27380. MORPHTARGETS_NORMAL: boolean;
  27381. MORPHTARGETS_TANGENT: boolean;
  27382. MORPHTARGETS_UV: boolean;
  27383. NUM_MORPH_INFLUENCERS: number;
  27384. IMAGEPROCESSING: boolean;
  27385. VIGNETTE: boolean;
  27386. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27387. VIGNETTEBLENDMODEOPAQUE: boolean;
  27388. TONEMAPPING: boolean;
  27389. TONEMAPPING_ACES: boolean;
  27390. CONTRAST: boolean;
  27391. COLORCURVES: boolean;
  27392. COLORGRADING: boolean;
  27393. COLORGRADING3D: boolean;
  27394. SAMPLER3DGREENDEPTH: boolean;
  27395. SAMPLER3DBGRMAP: boolean;
  27396. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27397. EXPOSURE: boolean;
  27398. MULTIVIEW: boolean;
  27399. USEPHYSICALLIGHTFALLOFF: boolean;
  27400. USEGLTFLIGHTFALLOFF: boolean;
  27401. TWOSIDEDLIGHTING: boolean;
  27402. SHADOWFLOAT: boolean;
  27403. CLIPPLANE: boolean;
  27404. CLIPPLANE2: boolean;
  27405. CLIPPLANE3: boolean;
  27406. CLIPPLANE4: boolean;
  27407. CLIPPLANE5: boolean;
  27408. CLIPPLANE6: boolean;
  27409. POINTSIZE: boolean;
  27410. FOG: boolean;
  27411. LOGARITHMICDEPTH: boolean;
  27412. FORCENORMALFORWARD: boolean;
  27413. SPECULARAA: boolean;
  27414. CLEARCOAT: boolean;
  27415. CLEARCOAT_DEFAULTIOR: boolean;
  27416. CLEARCOAT_TEXTURE: boolean;
  27417. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  27418. CLEARCOAT_TEXTUREDIRECTUV: number;
  27419. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  27420. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27421. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27422. CLEARCOAT_BUMP: boolean;
  27423. CLEARCOAT_BUMPDIRECTUV: number;
  27424. CLEARCOAT_REMAP_F0: boolean;
  27425. CLEARCOAT_TINT: boolean;
  27426. CLEARCOAT_TINT_TEXTURE: boolean;
  27427. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  27428. ANISOTROPIC: boolean;
  27429. ANISOTROPIC_TEXTURE: boolean;
  27430. ANISOTROPIC_TEXTUREDIRECTUV: number;
  27431. BRDF_V_HEIGHT_CORRELATED: boolean;
  27432. MS_BRDF_ENERGY_CONSERVATION: boolean;
  27433. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  27434. SHEEN: boolean;
  27435. SHEEN_TEXTURE: boolean;
  27436. SHEEN_TEXTURE_ROUGHNESS: boolean;
  27437. SHEEN_TEXTUREDIRECTUV: number;
  27438. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  27439. SHEEN_LINKWITHALBEDO: boolean;
  27440. SHEEN_ROUGHNESS: boolean;
  27441. SHEEN_ALBEDOSCALING: boolean;
  27442. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27443. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27444. SUBSURFACE: boolean;
  27445. SS_REFRACTION: boolean;
  27446. SS_TRANSLUCENCY: boolean;
  27447. SS_SCATTERING: boolean;
  27448. SS_THICKNESSANDMASK_TEXTURE: boolean;
  27449. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  27450. SS_REFRACTIONMAP_3D: boolean;
  27451. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  27452. SS_LODINREFRACTIONALPHA: boolean;
  27453. SS_GAMMAREFRACTION: boolean;
  27454. SS_RGBDREFRACTION: boolean;
  27455. SS_LINEARSPECULARREFRACTION: boolean;
  27456. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  27457. SS_ALBEDOFORREFRACTIONTINT: boolean;
  27458. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  27459. UNLIT: boolean;
  27460. DEBUGMODE: number;
  27461. /**
  27462. * Initializes the PBR Material defines.
  27463. */
  27464. constructor();
  27465. /**
  27466. * Resets the PBR Material defines.
  27467. */
  27468. reset(): void;
  27469. }
  27470. /**
  27471. * The Physically based material base class of BJS.
  27472. *
  27473. * This offers the main features of a standard PBR material.
  27474. * For more information, please refer to the documentation :
  27475. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27476. */
  27477. export abstract class PBRBaseMaterial extends PushMaterial {
  27478. /**
  27479. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27480. */
  27481. static readonly PBRMATERIAL_OPAQUE: number;
  27482. /**
  27483. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27484. */
  27485. static readonly PBRMATERIAL_ALPHATEST: number;
  27486. /**
  27487. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27488. */
  27489. static readonly PBRMATERIAL_ALPHABLEND: number;
  27490. /**
  27491. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27492. * They are also discarded below the alpha cutoff threshold to improve performances.
  27493. */
  27494. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27495. /**
  27496. * Defines the default value of how much AO map is occluding the analytical lights
  27497. * (point spot...).
  27498. */
  27499. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27500. /**
  27501. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  27502. */
  27503. static readonly LIGHTFALLOFF_PHYSICAL: number;
  27504. /**
  27505. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  27506. * to enhance interoperability with other engines.
  27507. */
  27508. static readonly LIGHTFALLOFF_GLTF: number;
  27509. /**
  27510. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  27511. * to enhance interoperability with other materials.
  27512. */
  27513. static readonly LIGHTFALLOFF_STANDARD: number;
  27514. /**
  27515. * Intensity of the direct lights e.g. the four lights available in your scene.
  27516. * This impacts both the direct diffuse and specular highlights.
  27517. */
  27518. protected _directIntensity: number;
  27519. /**
  27520. * Intensity of the emissive part of the material.
  27521. * This helps controlling the emissive effect without modifying the emissive color.
  27522. */
  27523. protected _emissiveIntensity: number;
  27524. /**
  27525. * Intensity of the environment e.g. how much the environment will light the object
  27526. * either through harmonics for rough material or through the refelction for shiny ones.
  27527. */
  27528. protected _environmentIntensity: number;
  27529. /**
  27530. * This is a special control allowing the reduction of the specular highlights coming from the
  27531. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27532. */
  27533. protected _specularIntensity: number;
  27534. /**
  27535. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  27536. */
  27537. private _lightingInfos;
  27538. /**
  27539. * Debug Control allowing disabling the bump map on this material.
  27540. */
  27541. protected _disableBumpMap: boolean;
  27542. /**
  27543. * AKA Diffuse Texture in standard nomenclature.
  27544. */
  27545. protected _albedoTexture: Nullable<BaseTexture>;
  27546. /**
  27547. * AKA Occlusion Texture in other nomenclature.
  27548. */
  27549. protected _ambientTexture: Nullable<BaseTexture>;
  27550. /**
  27551. * AKA Occlusion Texture Intensity in other nomenclature.
  27552. */
  27553. protected _ambientTextureStrength: number;
  27554. /**
  27555. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27556. * 1 means it completely occludes it
  27557. * 0 mean it has no impact
  27558. */
  27559. protected _ambientTextureImpactOnAnalyticalLights: number;
  27560. /**
  27561. * Stores the alpha values in a texture.
  27562. */
  27563. protected _opacityTexture: Nullable<BaseTexture>;
  27564. /**
  27565. * Stores the reflection values in a texture.
  27566. */
  27567. protected _reflectionTexture: Nullable<BaseTexture>;
  27568. /**
  27569. * Stores the emissive values in a texture.
  27570. */
  27571. protected _emissiveTexture: Nullable<BaseTexture>;
  27572. /**
  27573. * AKA Specular texture in other nomenclature.
  27574. */
  27575. protected _reflectivityTexture: Nullable<BaseTexture>;
  27576. /**
  27577. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27578. */
  27579. protected _metallicTexture: Nullable<BaseTexture>;
  27580. /**
  27581. * Specifies the metallic scalar of the metallic/roughness workflow.
  27582. * Can also be used to scale the metalness values of the metallic texture.
  27583. */
  27584. protected _metallic: Nullable<number>;
  27585. /**
  27586. * Specifies the roughness scalar of the metallic/roughness workflow.
  27587. * Can also be used to scale the roughness values of the metallic texture.
  27588. */
  27589. protected _roughness: Nullable<number>;
  27590. /**
  27591. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27592. * By default the indexOfrefraction is used to compute F0;
  27593. *
  27594. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27595. *
  27596. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27597. * F90 = metallicReflectanceColor;
  27598. */
  27599. protected _metallicF0Factor: number;
  27600. /**
  27601. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27602. * By default the F90 is always 1;
  27603. *
  27604. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27605. *
  27606. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27607. * F90 = metallicReflectanceColor;
  27608. */
  27609. protected _metallicReflectanceColor: Color3;
  27610. /**
  27611. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27612. * This is multiply against the scalar values defined in the material.
  27613. */
  27614. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  27615. /**
  27616. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27617. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27618. */
  27619. protected _microSurfaceTexture: Nullable<BaseTexture>;
  27620. /**
  27621. * Stores surface normal data used to displace a mesh in a texture.
  27622. */
  27623. protected _bumpTexture: Nullable<BaseTexture>;
  27624. /**
  27625. * Stores the pre-calculated light information of a mesh in a texture.
  27626. */
  27627. protected _lightmapTexture: Nullable<BaseTexture>;
  27628. /**
  27629. * The color of a material in ambient lighting.
  27630. */
  27631. protected _ambientColor: Color3;
  27632. /**
  27633. * AKA Diffuse Color in other nomenclature.
  27634. */
  27635. protected _albedoColor: Color3;
  27636. /**
  27637. * AKA Specular Color in other nomenclature.
  27638. */
  27639. protected _reflectivityColor: Color3;
  27640. /**
  27641. * The color applied when light is reflected from a material.
  27642. */
  27643. protected _reflectionColor: Color3;
  27644. /**
  27645. * The color applied when light is emitted from a material.
  27646. */
  27647. protected _emissiveColor: Color3;
  27648. /**
  27649. * AKA Glossiness in other nomenclature.
  27650. */
  27651. protected _microSurface: number;
  27652. /**
  27653. * Specifies that the material will use the light map as a show map.
  27654. */
  27655. protected _useLightmapAsShadowmap: boolean;
  27656. /**
  27657. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27658. * makes the reflect vector face the model (under horizon).
  27659. */
  27660. protected _useHorizonOcclusion: boolean;
  27661. /**
  27662. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27663. * too much the area relying on ambient texture to define their ambient occlusion.
  27664. */
  27665. protected _useRadianceOcclusion: boolean;
  27666. /**
  27667. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27668. */
  27669. protected _useAlphaFromAlbedoTexture: boolean;
  27670. /**
  27671. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27672. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27673. */
  27674. protected _useSpecularOverAlpha: boolean;
  27675. /**
  27676. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27677. */
  27678. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27679. /**
  27680. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27681. */
  27682. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  27683. /**
  27684. * Specifies if the metallic texture contains the roughness information in its green channel.
  27685. */
  27686. protected _useRoughnessFromMetallicTextureGreen: boolean;
  27687. /**
  27688. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27689. */
  27690. protected _useMetallnessFromMetallicTextureBlue: boolean;
  27691. /**
  27692. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27693. */
  27694. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  27695. /**
  27696. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27697. */
  27698. protected _useAmbientInGrayScale: boolean;
  27699. /**
  27700. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27701. * The material will try to infer what glossiness each pixel should be.
  27702. */
  27703. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  27704. /**
  27705. * Defines the falloff type used in this material.
  27706. * It by default is Physical.
  27707. */
  27708. protected _lightFalloff: number;
  27709. /**
  27710. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27711. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27712. */
  27713. protected _useRadianceOverAlpha: boolean;
  27714. /**
  27715. * Allows using an object space normal map (instead of tangent space).
  27716. */
  27717. protected _useObjectSpaceNormalMap: boolean;
  27718. /**
  27719. * Allows using the bump map in parallax mode.
  27720. */
  27721. protected _useParallax: boolean;
  27722. /**
  27723. * Allows using the bump map in parallax occlusion mode.
  27724. */
  27725. protected _useParallaxOcclusion: boolean;
  27726. /**
  27727. * Controls the scale bias of the parallax mode.
  27728. */
  27729. protected _parallaxScaleBias: number;
  27730. /**
  27731. * If sets to true, disables all the lights affecting the material.
  27732. */
  27733. protected _disableLighting: boolean;
  27734. /**
  27735. * Number of Simultaneous lights allowed on the material.
  27736. */
  27737. protected _maxSimultaneousLights: number;
  27738. /**
  27739. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  27740. */
  27741. protected _invertNormalMapX: boolean;
  27742. /**
  27743. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  27744. */
  27745. protected _invertNormalMapY: boolean;
  27746. /**
  27747. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27748. */
  27749. protected _twoSidedLighting: boolean;
  27750. /**
  27751. * Defines the alpha limits in alpha test mode.
  27752. */
  27753. protected _alphaCutOff: number;
  27754. /**
  27755. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27756. */
  27757. protected _forceAlphaTest: boolean;
  27758. /**
  27759. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27760. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27761. */
  27762. protected _useAlphaFresnel: boolean;
  27763. /**
  27764. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27765. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27766. */
  27767. protected _useLinearAlphaFresnel: boolean;
  27768. /**
  27769. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  27770. * from cos thetav and roughness:
  27771. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  27772. */
  27773. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  27774. /**
  27775. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27776. */
  27777. protected _forceIrradianceInFragment: boolean;
  27778. private _realTimeFiltering;
  27779. /**
  27780. * Enables realtime filtering on the texture.
  27781. */
  27782. get realTimeFiltering(): boolean;
  27783. set realTimeFiltering(b: boolean);
  27784. private _realTimeFilteringQuality;
  27785. /**
  27786. * Quality switch for realtime filtering
  27787. */
  27788. get realTimeFilteringQuality(): number;
  27789. set realTimeFilteringQuality(n: number);
  27790. /**
  27791. * Can this material render to several textures at once
  27792. */
  27793. get canRenderToMRT(): boolean;
  27794. /**
  27795. * Force normal to face away from face.
  27796. */
  27797. protected _forceNormalForward: boolean;
  27798. /**
  27799. * Enables specular anti aliasing in the PBR shader.
  27800. * It will both interacts on the Geometry for analytical and IBL lighting.
  27801. * It also prefilter the roughness map based on the bump values.
  27802. */
  27803. protected _enableSpecularAntiAliasing: boolean;
  27804. /**
  27805. * Default configuration related to image processing available in the PBR Material.
  27806. */
  27807. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27808. /**
  27809. * Keep track of the image processing observer to allow dispose and replace.
  27810. */
  27811. private _imageProcessingObserver;
  27812. /**
  27813. * Attaches a new image processing configuration to the PBR Material.
  27814. * @param configuration
  27815. */
  27816. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27817. /**
  27818. * Stores the available render targets.
  27819. */
  27820. private _renderTargets;
  27821. /**
  27822. * Sets the global ambient color for the material used in lighting calculations.
  27823. */
  27824. private _globalAmbientColor;
  27825. /**
  27826. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  27827. */
  27828. private _useLogarithmicDepth;
  27829. /**
  27830. * If set to true, no lighting calculations will be applied.
  27831. */
  27832. private _unlit;
  27833. private _debugMode;
  27834. /**
  27835. * @hidden
  27836. * This is reserved for the inspector.
  27837. * Defines the material debug mode.
  27838. * It helps seeing only some components of the material while troubleshooting.
  27839. */
  27840. debugMode: number;
  27841. /**
  27842. * @hidden
  27843. * This is reserved for the inspector.
  27844. * Specify from where on screen the debug mode should start.
  27845. * The value goes from -1 (full screen) to 1 (not visible)
  27846. * It helps with side by side comparison against the final render
  27847. * This defaults to -1
  27848. */
  27849. private debugLimit;
  27850. /**
  27851. * @hidden
  27852. * This is reserved for the inspector.
  27853. * As the default viewing range might not be enough (if the ambient is really small for instance)
  27854. * You can use the factor to better multiply the final value.
  27855. */
  27856. private debugFactor;
  27857. /**
  27858. * Defines the clear coat layer parameters for the material.
  27859. */
  27860. readonly clearCoat: PBRClearCoatConfiguration;
  27861. /**
  27862. * Defines the anisotropic parameters for the material.
  27863. */
  27864. readonly anisotropy: PBRAnisotropicConfiguration;
  27865. /**
  27866. * Defines the BRDF parameters for the material.
  27867. */
  27868. readonly brdf: PBRBRDFConfiguration;
  27869. /**
  27870. * Defines the Sheen parameters for the material.
  27871. */
  27872. readonly sheen: PBRSheenConfiguration;
  27873. /**
  27874. * Defines the SubSurface parameters for the material.
  27875. */
  27876. readonly subSurface: PBRSubSurfaceConfiguration;
  27877. /**
  27878. * Defines additionnal PrePass parameters for the material.
  27879. */
  27880. readonly prePassConfiguration: PrePassConfiguration;
  27881. /**
  27882. * Defines the detail map parameters for the material.
  27883. */
  27884. readonly detailMap: DetailMapConfiguration;
  27885. protected _rebuildInParallel: boolean;
  27886. /**
  27887. * Instantiates a new PBRMaterial instance.
  27888. *
  27889. * @param name The material name
  27890. * @param scene The scene the material will be use in.
  27891. */
  27892. constructor(name: string, scene: Scene);
  27893. /**
  27894. * Gets a boolean indicating that current material needs to register RTT
  27895. */
  27896. get hasRenderTargetTextures(): boolean;
  27897. /**
  27898. * Gets the name of the material class.
  27899. */
  27900. getClassName(): string;
  27901. /**
  27902. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27903. */
  27904. get useLogarithmicDepth(): boolean;
  27905. /**
  27906. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27907. */
  27908. set useLogarithmicDepth(value: boolean);
  27909. /**
  27910. * Returns true if alpha blending should be disabled.
  27911. */
  27912. protected get _disableAlphaBlending(): boolean;
  27913. /**
  27914. * Specifies whether or not this material should be rendered in alpha blend mode.
  27915. */
  27916. needAlphaBlending(): boolean;
  27917. /**
  27918. * Specifies whether or not this material should be rendered in alpha test mode.
  27919. */
  27920. needAlphaTesting(): boolean;
  27921. /**
  27922. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  27923. */
  27924. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  27925. /**
  27926. * Specifies whether or not there is a usable alpha channel for transparency.
  27927. */
  27928. protected _hasAlphaChannel(): boolean;
  27929. /**
  27930. * Gets the texture used for the alpha test.
  27931. */
  27932. getAlphaTestTexture(): Nullable<BaseTexture>;
  27933. /**
  27934. * Specifies that the submesh is ready to be used.
  27935. * @param mesh - BJS mesh.
  27936. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  27937. * @param useInstances - Specifies that instances should be used.
  27938. * @returns - boolean indicating that the submesh is ready or not.
  27939. */
  27940. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27941. /**
  27942. * Specifies if the material uses metallic roughness workflow.
  27943. * @returns boolean specifiying if the material uses metallic roughness workflow.
  27944. */
  27945. isMetallicWorkflow(): boolean;
  27946. private _prepareEffect;
  27947. private _prepareDefines;
  27948. /**
  27949. * Force shader compilation
  27950. */
  27951. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  27952. /**
  27953. * Initializes the uniform buffer layout for the shader.
  27954. */
  27955. buildUniformLayout(): void;
  27956. /**
  27957. * Unbinds the material from the mesh
  27958. */
  27959. unbind(): void;
  27960. /**
  27961. * Binds the submesh data.
  27962. * @param world - The world matrix.
  27963. * @param mesh - The BJS mesh.
  27964. * @param subMesh - A submesh of the BJS mesh.
  27965. */
  27966. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27967. /**
  27968. * Returns the animatable textures.
  27969. * @returns - Array of animatable textures.
  27970. */
  27971. getAnimatables(): IAnimatable[];
  27972. /**
  27973. * Returns the texture used for reflections.
  27974. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  27975. */
  27976. private _getReflectionTexture;
  27977. /**
  27978. * Returns an array of the actively used textures.
  27979. * @returns - Array of BaseTextures
  27980. */
  27981. getActiveTextures(): BaseTexture[];
  27982. /**
  27983. * Checks to see if a texture is used in the material.
  27984. * @param texture - Base texture to use.
  27985. * @returns - Boolean specifying if a texture is used in the material.
  27986. */
  27987. hasTexture(texture: BaseTexture): boolean;
  27988. /**
  27989. * Sets the required values to the prepass renderer.
  27990. * @param prePassRenderer defines the prepass renderer to setup
  27991. */
  27992. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27993. /**
  27994. * Disposes the resources of the material.
  27995. * @param forceDisposeEffect - Forces the disposal of effects.
  27996. * @param forceDisposeTextures - Forces the disposal of all textures.
  27997. */
  27998. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27999. }
  28000. }
  28001. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  28002. import { Nullable } from "babylonjs/types";
  28003. import { Scene } from "babylonjs/scene";
  28004. import { Color3 } from "babylonjs/Maths/math.color";
  28005. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  28006. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  28007. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28008. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  28009. /**
  28010. * The Physically based material of BJS.
  28011. *
  28012. * This offers the main features of a standard PBR material.
  28013. * For more information, please refer to the documentation :
  28014. * https://doc.babylonjs.com/how_to/physically_based_rendering
  28015. */
  28016. export class PBRMaterial extends PBRBaseMaterial {
  28017. /**
  28018. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  28019. */
  28020. static readonly PBRMATERIAL_OPAQUE: number;
  28021. /**
  28022. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  28023. */
  28024. static readonly PBRMATERIAL_ALPHATEST: number;
  28025. /**
  28026. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28027. */
  28028. static readonly PBRMATERIAL_ALPHABLEND: number;
  28029. /**
  28030. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28031. * They are also discarded below the alpha cutoff threshold to improve performances.
  28032. */
  28033. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  28034. /**
  28035. * Defines the default value of how much AO map is occluding the analytical lights
  28036. * (point spot...).
  28037. */
  28038. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  28039. /**
  28040. * Intensity of the direct lights e.g. the four lights available in your scene.
  28041. * This impacts both the direct diffuse and specular highlights.
  28042. */
  28043. directIntensity: number;
  28044. /**
  28045. * Intensity of the emissive part of the material.
  28046. * This helps controlling the emissive effect without modifying the emissive color.
  28047. */
  28048. emissiveIntensity: number;
  28049. /**
  28050. * Intensity of the environment e.g. how much the environment will light the object
  28051. * either through harmonics for rough material or through the refelction for shiny ones.
  28052. */
  28053. environmentIntensity: number;
  28054. /**
  28055. * This is a special control allowing the reduction of the specular highlights coming from the
  28056. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  28057. */
  28058. specularIntensity: number;
  28059. /**
  28060. * Debug Control allowing disabling the bump map on this material.
  28061. */
  28062. disableBumpMap: boolean;
  28063. /**
  28064. * AKA Diffuse Texture in standard nomenclature.
  28065. */
  28066. albedoTexture: BaseTexture;
  28067. /**
  28068. * AKA Occlusion Texture in other nomenclature.
  28069. */
  28070. ambientTexture: BaseTexture;
  28071. /**
  28072. * AKA Occlusion Texture Intensity in other nomenclature.
  28073. */
  28074. ambientTextureStrength: number;
  28075. /**
  28076. * Defines how much the AO map is occluding the analytical lights (point spot...).
  28077. * 1 means it completely occludes it
  28078. * 0 mean it has no impact
  28079. */
  28080. ambientTextureImpactOnAnalyticalLights: number;
  28081. /**
  28082. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  28083. */
  28084. opacityTexture: BaseTexture;
  28085. /**
  28086. * Stores the reflection values in a texture.
  28087. */
  28088. reflectionTexture: Nullable<BaseTexture>;
  28089. /**
  28090. * Stores the emissive values in a texture.
  28091. */
  28092. emissiveTexture: BaseTexture;
  28093. /**
  28094. * AKA Specular texture in other nomenclature.
  28095. */
  28096. reflectivityTexture: BaseTexture;
  28097. /**
  28098. * Used to switch from specular/glossiness to metallic/roughness workflow.
  28099. */
  28100. metallicTexture: BaseTexture;
  28101. /**
  28102. * Specifies the metallic scalar of the metallic/roughness workflow.
  28103. * Can also be used to scale the metalness values of the metallic texture.
  28104. */
  28105. metallic: Nullable<number>;
  28106. /**
  28107. * Specifies the roughness scalar of the metallic/roughness workflow.
  28108. * Can also be used to scale the roughness values of the metallic texture.
  28109. */
  28110. roughness: Nullable<number>;
  28111. /**
  28112. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  28113. * By default the indexOfrefraction is used to compute F0;
  28114. *
  28115. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  28116. *
  28117. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  28118. * F90 = metallicReflectanceColor;
  28119. */
  28120. metallicF0Factor: number;
  28121. /**
  28122. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  28123. * By default the F90 is always 1;
  28124. *
  28125. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  28126. *
  28127. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  28128. * F90 = metallicReflectanceColor;
  28129. */
  28130. metallicReflectanceColor: Color3;
  28131. /**
  28132. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  28133. * This is multiply against the scalar values defined in the material.
  28134. */
  28135. metallicReflectanceTexture: Nullable<BaseTexture>;
  28136. /**
  28137. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  28138. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  28139. */
  28140. microSurfaceTexture: BaseTexture;
  28141. /**
  28142. * Stores surface normal data used to displace a mesh in a texture.
  28143. */
  28144. bumpTexture: BaseTexture;
  28145. /**
  28146. * Stores the pre-calculated light information of a mesh in a texture.
  28147. */
  28148. lightmapTexture: BaseTexture;
  28149. /**
  28150. * Stores the refracted light information in a texture.
  28151. */
  28152. get refractionTexture(): Nullable<BaseTexture>;
  28153. set refractionTexture(value: Nullable<BaseTexture>);
  28154. /**
  28155. * The color of a material in ambient lighting.
  28156. */
  28157. ambientColor: Color3;
  28158. /**
  28159. * AKA Diffuse Color in other nomenclature.
  28160. */
  28161. albedoColor: Color3;
  28162. /**
  28163. * AKA Specular Color in other nomenclature.
  28164. */
  28165. reflectivityColor: Color3;
  28166. /**
  28167. * The color reflected from the material.
  28168. */
  28169. reflectionColor: Color3;
  28170. /**
  28171. * The color emitted from the material.
  28172. */
  28173. emissiveColor: Color3;
  28174. /**
  28175. * AKA Glossiness in other nomenclature.
  28176. */
  28177. microSurface: number;
  28178. /**
  28179. * Index of refraction of the material base layer.
  28180. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  28181. *
  28182. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  28183. *
  28184. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  28185. */
  28186. get indexOfRefraction(): number;
  28187. set indexOfRefraction(value: number);
  28188. /**
  28189. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  28190. */
  28191. get invertRefractionY(): boolean;
  28192. set invertRefractionY(value: boolean);
  28193. /**
  28194. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  28195. * Materials half opaque for instance using refraction could benefit from this control.
  28196. */
  28197. get linkRefractionWithTransparency(): boolean;
  28198. set linkRefractionWithTransparency(value: boolean);
  28199. /**
  28200. * If true, the light map contains occlusion information instead of lighting info.
  28201. */
  28202. useLightmapAsShadowmap: boolean;
  28203. /**
  28204. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  28205. */
  28206. useAlphaFromAlbedoTexture: boolean;
  28207. /**
  28208. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  28209. */
  28210. forceAlphaTest: boolean;
  28211. /**
  28212. * Defines the alpha limits in alpha test mode.
  28213. */
  28214. alphaCutOff: number;
  28215. /**
  28216. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  28217. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  28218. */
  28219. useSpecularOverAlpha: boolean;
  28220. /**
  28221. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  28222. */
  28223. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  28224. /**
  28225. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  28226. */
  28227. useRoughnessFromMetallicTextureAlpha: boolean;
  28228. /**
  28229. * Specifies if the metallic texture contains the roughness information in its green channel.
  28230. */
  28231. useRoughnessFromMetallicTextureGreen: boolean;
  28232. /**
  28233. * Specifies if the metallic texture contains the metallness information in its blue channel.
  28234. */
  28235. useMetallnessFromMetallicTextureBlue: boolean;
  28236. /**
  28237. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  28238. */
  28239. useAmbientOcclusionFromMetallicTextureRed: boolean;
  28240. /**
  28241. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  28242. */
  28243. useAmbientInGrayScale: boolean;
  28244. /**
  28245. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  28246. * The material will try to infer what glossiness each pixel should be.
  28247. */
  28248. useAutoMicroSurfaceFromReflectivityMap: boolean;
  28249. /**
  28250. * BJS is using an harcoded light falloff based on a manually sets up range.
  28251. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  28252. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  28253. */
  28254. get usePhysicalLightFalloff(): boolean;
  28255. /**
  28256. * BJS is using an harcoded light falloff based on a manually sets up range.
  28257. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  28258. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  28259. */
  28260. set usePhysicalLightFalloff(value: boolean);
  28261. /**
  28262. * In order to support the falloff compatibility with gltf, a special mode has been added
  28263. * to reproduce the gltf light falloff.
  28264. */
  28265. get useGLTFLightFalloff(): boolean;
  28266. /**
  28267. * In order to support the falloff compatibility with gltf, a special mode has been added
  28268. * to reproduce the gltf light falloff.
  28269. */
  28270. set useGLTFLightFalloff(value: boolean);
  28271. /**
  28272. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  28273. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  28274. */
  28275. useRadianceOverAlpha: boolean;
  28276. /**
  28277. * Allows using an object space normal map (instead of tangent space).
  28278. */
  28279. useObjectSpaceNormalMap: boolean;
  28280. /**
  28281. * Allows using the bump map in parallax mode.
  28282. */
  28283. useParallax: boolean;
  28284. /**
  28285. * Allows using the bump map in parallax occlusion mode.
  28286. */
  28287. useParallaxOcclusion: boolean;
  28288. /**
  28289. * Controls the scale bias of the parallax mode.
  28290. */
  28291. parallaxScaleBias: number;
  28292. /**
  28293. * If sets to true, disables all the lights affecting the material.
  28294. */
  28295. disableLighting: boolean;
  28296. /**
  28297. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  28298. */
  28299. forceIrradianceInFragment: boolean;
  28300. /**
  28301. * Number of Simultaneous lights allowed on the material.
  28302. */
  28303. maxSimultaneousLights: number;
  28304. /**
  28305. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  28306. */
  28307. invertNormalMapX: boolean;
  28308. /**
  28309. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  28310. */
  28311. invertNormalMapY: boolean;
  28312. /**
  28313. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  28314. */
  28315. twoSidedLighting: boolean;
  28316. /**
  28317. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28318. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  28319. */
  28320. useAlphaFresnel: boolean;
  28321. /**
  28322. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28323. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  28324. */
  28325. useLinearAlphaFresnel: boolean;
  28326. /**
  28327. * Let user defines the brdf lookup texture used for IBL.
  28328. * A default 8bit version is embedded but you could point at :
  28329. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  28330. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  28331. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  28332. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  28333. */
  28334. environmentBRDFTexture: Nullable<BaseTexture>;
  28335. /**
  28336. * Force normal to face away from face.
  28337. */
  28338. forceNormalForward: boolean;
  28339. /**
  28340. * Enables specular anti aliasing in the PBR shader.
  28341. * It will both interacts on the Geometry for analytical and IBL lighting.
  28342. * It also prefilter the roughness map based on the bump values.
  28343. */
  28344. enableSpecularAntiAliasing: boolean;
  28345. /**
  28346. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  28347. * makes the reflect vector face the model (under horizon).
  28348. */
  28349. useHorizonOcclusion: boolean;
  28350. /**
  28351. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  28352. * too much the area relying on ambient texture to define their ambient occlusion.
  28353. */
  28354. useRadianceOcclusion: boolean;
  28355. /**
  28356. * If set to true, no lighting calculations will be applied.
  28357. */
  28358. unlit: boolean;
  28359. /**
  28360. * Gets the image processing configuration used either in this material.
  28361. */
  28362. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28363. /**
  28364. * Sets the Default image processing configuration used either in the this material.
  28365. *
  28366. * If sets to null, the scene one is in use.
  28367. */
  28368. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28369. /**
  28370. * Gets wether the color curves effect is enabled.
  28371. */
  28372. get cameraColorCurvesEnabled(): boolean;
  28373. /**
  28374. * Sets wether the color curves effect is enabled.
  28375. */
  28376. set cameraColorCurvesEnabled(value: boolean);
  28377. /**
  28378. * Gets wether the color grading effect is enabled.
  28379. */
  28380. get cameraColorGradingEnabled(): boolean;
  28381. /**
  28382. * Gets wether the color grading effect is enabled.
  28383. */
  28384. set cameraColorGradingEnabled(value: boolean);
  28385. /**
  28386. * Gets wether tonemapping is enabled or not.
  28387. */
  28388. get cameraToneMappingEnabled(): boolean;
  28389. /**
  28390. * Sets wether tonemapping is enabled or not
  28391. */
  28392. set cameraToneMappingEnabled(value: boolean);
  28393. /**
  28394. * The camera exposure used on this material.
  28395. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28396. * This corresponds to a photographic exposure.
  28397. */
  28398. get cameraExposure(): number;
  28399. /**
  28400. * The camera exposure used on this material.
  28401. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28402. * This corresponds to a photographic exposure.
  28403. */
  28404. set cameraExposure(value: number);
  28405. /**
  28406. * Gets The camera contrast used on this material.
  28407. */
  28408. get cameraContrast(): number;
  28409. /**
  28410. * Sets The camera contrast used on this material.
  28411. */
  28412. set cameraContrast(value: number);
  28413. /**
  28414. * Gets the Color Grading 2D Lookup Texture.
  28415. */
  28416. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28417. /**
  28418. * Sets the Color Grading 2D Lookup Texture.
  28419. */
  28420. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28421. /**
  28422. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28423. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28424. * 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;
  28425. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28426. */
  28427. get cameraColorCurves(): Nullable<ColorCurves>;
  28428. /**
  28429. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28430. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28431. * 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;
  28432. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28433. */
  28434. set cameraColorCurves(value: Nullable<ColorCurves>);
  28435. /**
  28436. * Instantiates a new PBRMaterial instance.
  28437. *
  28438. * @param name The material name
  28439. * @param scene The scene the material will be use in.
  28440. */
  28441. constructor(name: string, scene: Scene);
  28442. /**
  28443. * Returns the name of this material class.
  28444. */
  28445. getClassName(): string;
  28446. /**
  28447. * Makes a duplicate of the current material.
  28448. * @param name - name to use for the new material.
  28449. */
  28450. clone(name: string): PBRMaterial;
  28451. /**
  28452. * Serializes this PBR Material.
  28453. * @returns - An object with the serialized material.
  28454. */
  28455. serialize(): any;
  28456. /**
  28457. * Parses a PBR Material from a serialized object.
  28458. * @param source - Serialized object.
  28459. * @param scene - BJS scene instance.
  28460. * @param rootUrl - url for the scene object
  28461. * @returns - PBRMaterial
  28462. */
  28463. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  28464. }
  28465. }
  28466. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  28467. /** @hidden */
  28468. export var mrtFragmentDeclaration: {
  28469. name: string;
  28470. shader: string;
  28471. };
  28472. }
  28473. declare module "babylonjs/Shaders/geometry.fragment" {
  28474. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  28475. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  28476. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  28477. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  28478. /** @hidden */
  28479. export var geometryPixelShader: {
  28480. name: string;
  28481. shader: string;
  28482. };
  28483. }
  28484. declare module "babylonjs/Shaders/geometry.vertex" {
  28485. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28486. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28487. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28488. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28489. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28490. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28491. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28492. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  28493. /** @hidden */
  28494. export var geometryVertexShader: {
  28495. name: string;
  28496. shader: string;
  28497. };
  28498. }
  28499. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  28500. import { Matrix } from "babylonjs/Maths/math.vector";
  28501. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28502. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28503. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28504. import { Effect } from "babylonjs/Materials/effect";
  28505. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28506. import { Scene } from "babylonjs/scene";
  28507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28508. import { Nullable } from "babylonjs/types";
  28509. import "babylonjs/Shaders/geometry.fragment";
  28510. import "babylonjs/Shaders/geometry.vertex";
  28511. /** @hidden */
  28512. interface ISavedTransformationMatrix {
  28513. world: Matrix;
  28514. viewProjection: Matrix;
  28515. }
  28516. /**
  28517. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28518. */
  28519. export class GeometryBufferRenderer {
  28520. /**
  28521. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  28522. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  28523. */
  28524. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  28525. /**
  28526. * Constant used to retrieve the position texture index in the G-Buffer textures array
  28527. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  28528. */
  28529. static readonly POSITION_TEXTURE_TYPE: number;
  28530. /**
  28531. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  28532. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  28533. */
  28534. static readonly VELOCITY_TEXTURE_TYPE: number;
  28535. /**
  28536. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  28537. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  28538. */
  28539. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  28540. /**
  28541. * Dictionary used to store the previous transformation matrices of each rendered mesh
  28542. * in order to compute objects velocities when enableVelocity is set to "true"
  28543. * @hidden
  28544. */
  28545. _previousTransformationMatrices: {
  28546. [index: number]: ISavedTransformationMatrix;
  28547. };
  28548. /**
  28549. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  28550. * in order to compute objects velocities when enableVelocity is set to "true"
  28551. * @hidden
  28552. */
  28553. _previousBonesTransformationMatrices: {
  28554. [index: number]: Float32Array;
  28555. };
  28556. /**
  28557. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  28558. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  28559. */
  28560. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  28561. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  28562. renderTransparentMeshes: boolean;
  28563. private _scene;
  28564. private _resizeObserver;
  28565. private _multiRenderTarget;
  28566. private _ratio;
  28567. private _enablePosition;
  28568. private _enableVelocity;
  28569. private _enableReflectivity;
  28570. private _positionIndex;
  28571. private _velocityIndex;
  28572. private _reflectivityIndex;
  28573. private _depthNormalIndex;
  28574. private _linkedWithPrePass;
  28575. private _prePassRenderer;
  28576. private _attachments;
  28577. protected _effect: Effect;
  28578. protected _cachedDefines: string;
  28579. /**
  28580. * @hidden
  28581. * Sets up internal structures to share outputs with PrePassRenderer
  28582. * This method should only be called by the PrePassRenderer itself
  28583. */
  28584. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  28585. /**
  28586. * @hidden
  28587. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  28588. * This method should only be called by the PrePassRenderer itself
  28589. */
  28590. _unlinkPrePassRenderer(): void;
  28591. /**
  28592. * @hidden
  28593. * Resets the geometry buffer layout
  28594. */
  28595. _resetLayout(): void;
  28596. /**
  28597. * @hidden
  28598. * Replaces a texture in the geometry buffer renderer
  28599. * Useful when linking textures of the prepass renderer
  28600. */
  28601. _forceTextureType(geometryBufferType: number, index: number): void;
  28602. /**
  28603. * @hidden
  28604. * Sets texture attachments
  28605. * Useful when linking textures of the prepass renderer
  28606. */
  28607. _setAttachments(attachments: number[]): void;
  28608. /**
  28609. * @hidden
  28610. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  28611. * Useful when linking textures of the prepass renderer
  28612. */
  28613. _linkInternalTexture(internalTexture: InternalTexture): void;
  28614. /**
  28615. * Gets the render list (meshes to be rendered) used in the G buffer.
  28616. */
  28617. get renderList(): Nullable<AbstractMesh[]>;
  28618. /**
  28619. * Set the render list (meshes to be rendered) used in the G buffer.
  28620. */
  28621. set renderList(meshes: Nullable<AbstractMesh[]>);
  28622. /**
  28623. * Gets wether or not G buffer are supported by the running hardware.
  28624. * This requires draw buffer supports
  28625. */
  28626. get isSupported(): boolean;
  28627. /**
  28628. * Returns the index of the given texture type in the G-Buffer textures array
  28629. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  28630. * @returns the index of the given texture type in the G-Buffer textures array
  28631. */
  28632. getTextureIndex(textureType: number): number;
  28633. /**
  28634. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  28635. */
  28636. get enablePosition(): boolean;
  28637. /**
  28638. * Sets whether or not objects positions are enabled for the G buffer.
  28639. */
  28640. set enablePosition(enable: boolean);
  28641. /**
  28642. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  28643. */
  28644. get enableVelocity(): boolean;
  28645. /**
  28646. * Sets wether or not objects velocities are enabled for the G buffer.
  28647. */
  28648. set enableVelocity(enable: boolean);
  28649. /**
  28650. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  28651. */
  28652. get enableReflectivity(): boolean;
  28653. /**
  28654. * Sets wether or not objects roughness are enabled for the G buffer.
  28655. */
  28656. set enableReflectivity(enable: boolean);
  28657. /**
  28658. * Gets the scene associated with the buffer.
  28659. */
  28660. get scene(): Scene;
  28661. /**
  28662. * Gets the ratio used by the buffer during its creation.
  28663. * How big is the buffer related to the main canvas.
  28664. */
  28665. get ratio(): number;
  28666. /** @hidden */
  28667. static _SceneComponentInitialization: (scene: Scene) => void;
  28668. /**
  28669. * Creates a new G Buffer for the scene
  28670. * @param scene The scene the buffer belongs to
  28671. * @param ratio How big is the buffer related to the main canvas.
  28672. */
  28673. constructor(scene: Scene, ratio?: number);
  28674. /**
  28675. * Checks wether everything is ready to render a submesh to the G buffer.
  28676. * @param subMesh the submesh to check readiness for
  28677. * @param useInstances is the mesh drawn using instance or not
  28678. * @returns true if ready otherwise false
  28679. */
  28680. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28681. /**
  28682. * Gets the current underlying G Buffer.
  28683. * @returns the buffer
  28684. */
  28685. getGBuffer(): MultiRenderTarget;
  28686. /**
  28687. * Gets the number of samples used to render the buffer (anti aliasing).
  28688. */
  28689. get samples(): number;
  28690. /**
  28691. * Sets the number of samples used to render the buffer (anti aliasing).
  28692. */
  28693. set samples(value: number);
  28694. /**
  28695. * Disposes the renderer and frees up associated resources.
  28696. */
  28697. dispose(): void;
  28698. private _assignRenderTargetIndices;
  28699. protected _createRenderTargets(): void;
  28700. private _copyBonesTransformationMatrices;
  28701. }
  28702. }
  28703. declare module "babylonjs/Rendering/prePassRenderer" {
  28704. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28705. import { Scene } from "babylonjs/scene";
  28706. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  28707. import { Effect } from "babylonjs/Materials/effect";
  28708. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28710. import { Material } from "babylonjs/Materials/material";
  28711. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28712. /**
  28713. * Renders a pre pass of the scene
  28714. * This means every mesh in the scene will be rendered to a render target texture
  28715. * And then this texture will be composited to the rendering canvas with post processes
  28716. * It is necessary for effects like subsurface scattering or deferred shading
  28717. */
  28718. export class PrePassRenderer {
  28719. /** @hidden */
  28720. static _SceneComponentInitialization: (scene: Scene) => void;
  28721. private _textureFormats;
  28722. /**
  28723. * To save performance, we can excluded skinned meshes from the prepass
  28724. */
  28725. excludedSkinnedMesh: AbstractMesh[];
  28726. /**
  28727. * Force material to be excluded from the prepass
  28728. * Can be useful when `useGeometryBufferFallback` is set to `true`
  28729. * and you don't want a material to show in the effect.
  28730. */
  28731. excludedMaterials: Material[];
  28732. private _textureIndices;
  28733. private _scene;
  28734. private _engine;
  28735. private _isDirty;
  28736. /**
  28737. * Number of textures in the multi render target texture where the scene is directly rendered
  28738. */
  28739. mrtCount: number;
  28740. /**
  28741. * The render target where the scene is directly rendered
  28742. */
  28743. prePassRT: MultiRenderTarget;
  28744. private _multiRenderAttachments;
  28745. private _defaultAttachments;
  28746. private _clearAttachments;
  28747. private _postProcesses;
  28748. private readonly _clearColor;
  28749. /**
  28750. * Image processing post process for composition
  28751. */
  28752. imageProcessingPostProcess: ImageProcessingPostProcess;
  28753. /**
  28754. * Configuration for prepass effects
  28755. */
  28756. private _effectConfigurations;
  28757. private _mrtFormats;
  28758. private _mrtLayout;
  28759. private _enabled;
  28760. /**
  28761. * Indicates if the prepass is enabled
  28762. */
  28763. get enabled(): boolean;
  28764. /**
  28765. * How many samples are used for MSAA of the scene render target
  28766. */
  28767. get samples(): number;
  28768. set samples(n: number);
  28769. private _geometryBuffer;
  28770. private _useGeometryBufferFallback;
  28771. /**
  28772. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  28773. */
  28774. get useGeometryBufferFallback(): boolean;
  28775. set useGeometryBufferFallback(value: boolean);
  28776. /**
  28777. * Instanciates a prepass renderer
  28778. * @param scene The scene
  28779. */
  28780. constructor(scene: Scene);
  28781. private _initializeAttachments;
  28782. private _createCompositionEffect;
  28783. /**
  28784. * Indicates if rendering a prepass is supported
  28785. */
  28786. get isSupported(): boolean;
  28787. /**
  28788. * Sets the proper output textures to draw in the engine.
  28789. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  28790. * @param subMesh Submesh on which the effect is applied
  28791. */
  28792. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  28793. /**
  28794. * @hidden
  28795. */
  28796. _beforeCameraDraw(): void;
  28797. /**
  28798. * @hidden
  28799. */
  28800. _afterCameraDraw(): void;
  28801. private _checkRTSize;
  28802. private _bindFrameBuffer;
  28803. /**
  28804. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  28805. */
  28806. clear(): void;
  28807. private _setState;
  28808. private _updateGeometryBufferLayout;
  28809. /**
  28810. * Adds an effect configuration to the prepass.
  28811. * If an effect has already been added, it won't add it twice and will return the configuration
  28812. * already present.
  28813. * @param cfg the effect configuration
  28814. * @return the effect configuration now used by the prepass
  28815. */
  28816. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  28817. /**
  28818. * Returns the index of a texture in the multi render target texture array.
  28819. * @param type Texture type
  28820. * @return The index
  28821. */
  28822. getIndex(type: number): number;
  28823. private _enable;
  28824. private _disable;
  28825. private _resetLayout;
  28826. private _resetPostProcessChain;
  28827. private _bindPostProcessChain;
  28828. /**
  28829. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  28830. */
  28831. markAsDirty(): void;
  28832. /**
  28833. * Enables a texture on the MultiRenderTarget for prepass
  28834. */
  28835. private _enableTextures;
  28836. private _update;
  28837. private _markAllMaterialsAsPrePassDirty;
  28838. /**
  28839. * Disposes the prepass renderer.
  28840. */
  28841. dispose(): void;
  28842. }
  28843. }
  28844. declare module "babylonjs/PostProcesses/postProcess" {
  28845. import { Nullable } from "babylonjs/types";
  28846. import { SmartArray } from "babylonjs/Misc/smartArray";
  28847. import { Observable } from "babylonjs/Misc/observable";
  28848. import { Vector2 } from "babylonjs/Maths/math.vector";
  28849. import { Camera } from "babylonjs/Cameras/camera";
  28850. import { Effect } from "babylonjs/Materials/effect";
  28851. import "babylonjs/Shaders/postprocess.vertex";
  28852. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28853. import { Engine } from "babylonjs/Engines/engine";
  28854. import { Color4 } from "babylonjs/Maths/math.color";
  28855. import "babylonjs/Engines/Extensions/engine.renderTarget";
  28856. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  28857. import { Scene } from "babylonjs/scene";
  28858. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28859. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28860. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28861. /**
  28862. * Size options for a post process
  28863. */
  28864. export type PostProcessOptions = {
  28865. width: number;
  28866. height: number;
  28867. };
  28868. /**
  28869. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28870. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28871. */
  28872. export class PostProcess {
  28873. /**
  28874. * Gets or sets the unique id of the post process
  28875. */
  28876. uniqueId: number;
  28877. /** Name of the PostProcess. */
  28878. name: string;
  28879. /**
  28880. * Width of the texture to apply the post process on
  28881. */
  28882. width: number;
  28883. /**
  28884. * Height of the texture to apply the post process on
  28885. */
  28886. height: number;
  28887. /**
  28888. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  28889. */
  28890. nodeMaterialSource: Nullable<NodeMaterial>;
  28891. /**
  28892. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28893. * @hidden
  28894. */
  28895. _outputTexture: Nullable<InternalTexture>;
  28896. /**
  28897. * Sampling mode used by the shader
  28898. * See https://doc.babylonjs.com/classes/3.1/texture
  28899. */
  28900. renderTargetSamplingMode: number;
  28901. /**
  28902. * Clear color to use when screen clearing
  28903. */
  28904. clearColor: Color4;
  28905. /**
  28906. * If the buffer needs to be cleared before applying the post process. (default: true)
  28907. * Should be set to false if shader will overwrite all previous pixels.
  28908. */
  28909. autoClear: boolean;
  28910. /**
  28911. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28912. */
  28913. alphaMode: number;
  28914. /**
  28915. * Sets the setAlphaBlendConstants of the babylon engine
  28916. */
  28917. alphaConstants: Color4;
  28918. /**
  28919. * Animations to be used for the post processing
  28920. */
  28921. animations: import("babylonjs/Animations/animation").Animation[];
  28922. /**
  28923. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28924. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28925. */
  28926. enablePixelPerfectMode: boolean;
  28927. /**
  28928. * Force the postprocess to be applied without taking in account viewport
  28929. */
  28930. forceFullscreenViewport: boolean;
  28931. /**
  28932. * List of inspectable custom properties (used by the Inspector)
  28933. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28934. */
  28935. inspectableCustomProperties: IInspectable[];
  28936. /**
  28937. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28938. *
  28939. * | Value | Type | Description |
  28940. * | ----- | ----------------------------------- | ----------- |
  28941. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28942. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28943. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28944. *
  28945. */
  28946. scaleMode: number;
  28947. /**
  28948. * Force textures to be a power of two (default: false)
  28949. */
  28950. alwaysForcePOT: boolean;
  28951. private _samples;
  28952. /**
  28953. * Number of sample textures (default: 1)
  28954. */
  28955. get samples(): number;
  28956. set samples(n: number);
  28957. /**
  28958. * Modify the scale of the post process to be the same as the viewport (default: false)
  28959. */
  28960. adaptScaleToCurrentViewport: boolean;
  28961. private _camera;
  28962. protected _scene: Scene;
  28963. private _engine;
  28964. private _options;
  28965. private _reusable;
  28966. private _textureType;
  28967. private _textureFormat;
  28968. /**
  28969. * Smart array of input and output textures for the post process.
  28970. * @hidden
  28971. */
  28972. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  28973. /**
  28974. * The index in _textures that corresponds to the output texture.
  28975. * @hidden
  28976. */
  28977. _currentRenderTextureInd: number;
  28978. private _effect;
  28979. private _samplers;
  28980. private _fragmentUrl;
  28981. private _vertexUrl;
  28982. private _parameters;
  28983. private _scaleRatio;
  28984. protected _indexParameters: any;
  28985. private _shareOutputWithPostProcess;
  28986. private _texelSize;
  28987. private _forcedOutputTexture;
  28988. /**
  28989. * Prepass configuration in case this post process needs a texture from prepass
  28990. * @hidden
  28991. */
  28992. _prePassEffectConfiguration: PrePassEffectConfiguration;
  28993. /**
  28994. * Returns the fragment url or shader name used in the post process.
  28995. * @returns the fragment url or name in the shader store.
  28996. */
  28997. getEffectName(): string;
  28998. /**
  28999. * An event triggered when the postprocess is activated.
  29000. */
  29001. onActivateObservable: Observable<Camera>;
  29002. private _onActivateObserver;
  29003. /**
  29004. * A function that is added to the onActivateObservable
  29005. */
  29006. set onActivate(callback: Nullable<(camera: Camera) => void>);
  29007. /**
  29008. * An event triggered when the postprocess changes its size.
  29009. */
  29010. onSizeChangedObservable: Observable<PostProcess>;
  29011. private _onSizeChangedObserver;
  29012. /**
  29013. * A function that is added to the onSizeChangedObservable
  29014. */
  29015. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  29016. /**
  29017. * An event triggered when the postprocess applies its effect.
  29018. */
  29019. onApplyObservable: Observable<Effect>;
  29020. private _onApplyObserver;
  29021. /**
  29022. * A function that is added to the onApplyObservable
  29023. */
  29024. set onApply(callback: (effect: Effect) => void);
  29025. /**
  29026. * An event triggered before rendering the postprocess
  29027. */
  29028. onBeforeRenderObservable: Observable<Effect>;
  29029. private _onBeforeRenderObserver;
  29030. /**
  29031. * A function that is added to the onBeforeRenderObservable
  29032. */
  29033. set onBeforeRender(callback: (effect: Effect) => void);
  29034. /**
  29035. * An event triggered after rendering the postprocess
  29036. */
  29037. onAfterRenderObservable: Observable<Effect>;
  29038. private _onAfterRenderObserver;
  29039. /**
  29040. * A function that is added to the onAfterRenderObservable
  29041. */
  29042. set onAfterRender(callback: (efect: Effect) => void);
  29043. /**
  29044. * 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
  29045. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  29046. */
  29047. get inputTexture(): InternalTexture;
  29048. set inputTexture(value: InternalTexture);
  29049. /**
  29050. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  29051. * the only way to unset it is to use this function to restore its internal state
  29052. */
  29053. restoreDefaultInputTexture(): void;
  29054. /**
  29055. * Gets the camera which post process is applied to.
  29056. * @returns The camera the post process is applied to.
  29057. */
  29058. getCamera(): Camera;
  29059. /**
  29060. * Gets the texel size of the postprocess.
  29061. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  29062. */
  29063. get texelSize(): Vector2;
  29064. /**
  29065. * Creates a new instance PostProcess
  29066. * @param name The name of the PostProcess.
  29067. * @param fragmentUrl The url of the fragment shader to be used.
  29068. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  29069. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  29070. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  29071. * @param camera The camera to apply the render pass to.
  29072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  29073. * @param engine The engine which the post process will be applied. (default: current engine)
  29074. * @param reusable If the post process can be reused on the same frame. (default: false)
  29075. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  29076. * @param textureType Type of textures used when performing the post process. (default: 0)
  29077. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  29078. * @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
  29079. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  29080. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  29081. */
  29082. 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);
  29083. /**
  29084. * Gets a string identifying the name of the class
  29085. * @returns "PostProcess" string
  29086. */
  29087. getClassName(): string;
  29088. /**
  29089. * Gets the engine which this post process belongs to.
  29090. * @returns The engine the post process was enabled with.
  29091. */
  29092. getEngine(): Engine;
  29093. /**
  29094. * The effect that is created when initializing the post process.
  29095. * @returns The created effect corresponding the the postprocess.
  29096. */
  29097. getEffect(): Effect;
  29098. /**
  29099. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  29100. * @param postProcess The post process to share the output with.
  29101. * @returns This post process.
  29102. */
  29103. shareOutputWith(postProcess: PostProcess): PostProcess;
  29104. /**
  29105. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  29106. * This should be called if the post process that shares output with this post process is disabled/disposed.
  29107. */
  29108. useOwnOutput(): void;
  29109. /**
  29110. * Updates the effect with the current post process compile time values and recompiles the shader.
  29111. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  29112. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  29113. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  29114. * @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
  29115. * @param onCompiled Called when the shader has been compiled.
  29116. * @param onError Called if there is an error when compiling a shader.
  29117. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  29118. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  29119. */
  29120. 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;
  29121. /**
  29122. * The post process is reusable if it can be used multiple times within one frame.
  29123. * @returns If the post process is reusable
  29124. */
  29125. isReusable(): boolean;
  29126. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  29127. markTextureDirty(): void;
  29128. /**
  29129. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  29130. * 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.
  29131. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  29132. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  29133. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  29134. * @returns The target texture that was bound to be written to.
  29135. */
  29136. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  29137. /**
  29138. * If the post process is supported.
  29139. */
  29140. get isSupported(): boolean;
  29141. /**
  29142. * The aspect ratio of the output texture.
  29143. */
  29144. get aspectRatio(): number;
  29145. /**
  29146. * Get a value indicating if the post-process is ready to be used
  29147. * @returns true if the post-process is ready (shader is compiled)
  29148. */
  29149. isReady(): boolean;
  29150. /**
  29151. * Binds all textures and uniforms to the shader, this will be run on every pass.
  29152. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  29153. */
  29154. apply(): Nullable<Effect>;
  29155. private _disposeTextures;
  29156. /**
  29157. * Sets the required values to the prepass renderer.
  29158. * @param prePassRenderer defines the prepass renderer to setup.
  29159. * @returns true if the pre pass is needed.
  29160. */
  29161. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29162. /**
  29163. * Disposes the post process.
  29164. * @param camera The camera to dispose the post process on.
  29165. */
  29166. dispose(camera?: Camera): void;
  29167. /**
  29168. * Serializes the particle system to a JSON object
  29169. * @returns the JSON object
  29170. */
  29171. serialize(): any;
  29172. /**
  29173. * Creates a material from parsed material data
  29174. * @param parsedPostProcess defines parsed post process data
  29175. * @param scene defines the hosting scene
  29176. * @param rootUrl defines the root URL to use to load textures
  29177. * @returns a new post process
  29178. */
  29179. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  29180. }
  29181. }
  29182. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  29183. /** @hidden */
  29184. export var kernelBlurVaryingDeclaration: {
  29185. name: string;
  29186. shader: string;
  29187. };
  29188. }
  29189. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  29190. /** @hidden */
  29191. export var kernelBlurFragment: {
  29192. name: string;
  29193. shader: string;
  29194. };
  29195. }
  29196. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  29197. /** @hidden */
  29198. export var kernelBlurFragment2: {
  29199. name: string;
  29200. shader: string;
  29201. };
  29202. }
  29203. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  29204. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  29205. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  29206. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  29207. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  29208. /** @hidden */
  29209. export var kernelBlurPixelShader: {
  29210. name: string;
  29211. shader: string;
  29212. };
  29213. }
  29214. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  29215. /** @hidden */
  29216. export var kernelBlurVertex: {
  29217. name: string;
  29218. shader: string;
  29219. };
  29220. }
  29221. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  29222. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  29223. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  29224. /** @hidden */
  29225. export var kernelBlurVertexShader: {
  29226. name: string;
  29227. shader: string;
  29228. };
  29229. }
  29230. declare module "babylonjs/PostProcesses/blurPostProcess" {
  29231. import { Vector2 } from "babylonjs/Maths/math.vector";
  29232. import { Nullable } from "babylonjs/types";
  29233. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  29234. import { Camera } from "babylonjs/Cameras/camera";
  29235. import { Effect } from "babylonjs/Materials/effect";
  29236. import { Engine } from "babylonjs/Engines/engine";
  29237. import "babylonjs/Shaders/kernelBlur.fragment";
  29238. import "babylonjs/Shaders/kernelBlur.vertex";
  29239. import { Scene } from "babylonjs/scene";
  29240. /**
  29241. * The Blur Post Process which blurs an image based on a kernel and direction.
  29242. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  29243. */
  29244. export class BlurPostProcess extends PostProcess {
  29245. private blockCompilation;
  29246. protected _kernel: number;
  29247. protected _idealKernel: number;
  29248. protected _packedFloat: boolean;
  29249. private _staticDefines;
  29250. /** The direction in which to blur the image. */
  29251. direction: Vector2;
  29252. /**
  29253. * Sets the length in pixels of the blur sample region
  29254. */
  29255. set kernel(v: number);
  29256. /**
  29257. * Gets the length in pixels of the blur sample region
  29258. */
  29259. get kernel(): number;
  29260. /**
  29261. * Sets wether or not the blur needs to unpack/repack floats
  29262. */
  29263. set packedFloat(v: boolean);
  29264. /**
  29265. * Gets wether or not the blur is unpacking/repacking floats
  29266. */
  29267. get packedFloat(): boolean;
  29268. /**
  29269. * Gets a string identifying the name of the class
  29270. * @returns "BlurPostProcess" string
  29271. */
  29272. getClassName(): string;
  29273. /**
  29274. * Creates a new instance BlurPostProcess
  29275. * @param name The name of the effect.
  29276. * @param direction The direction in which to blur the image.
  29277. * @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.
  29278. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  29279. * @param camera The camera to apply the render pass to.
  29280. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  29281. * @param engine The engine which the post process will be applied. (default: current engine)
  29282. * @param reusable If the post process can be reused on the same frame. (default: false)
  29283. * @param textureType Type of textures used when performing the post process. (default: 0)
  29284. * @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)
  29285. */
  29286. 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);
  29287. /**
  29288. * Updates the effect with the current post process compile time values and recompiles the shader.
  29289. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  29290. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  29291. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  29292. * @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
  29293. * @param onCompiled Called when the shader has been compiled.
  29294. * @param onError Called if there is an error when compiling a shader.
  29295. */
  29296. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29297. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29298. /**
  29299. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  29300. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  29301. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  29302. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  29303. * The gaps between physical kernels are compensated for in the weighting of the samples
  29304. * @param idealKernel Ideal blur kernel.
  29305. * @return Nearest best kernel.
  29306. */
  29307. protected _nearestBestKernel(idealKernel: number): number;
  29308. /**
  29309. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  29310. * @param x The point on the Gaussian distribution to sample.
  29311. * @return the value of the Gaussian function at x.
  29312. */
  29313. protected _gaussianWeight(x: number): number;
  29314. /**
  29315. * Generates a string that can be used as a floating point number in GLSL.
  29316. * @param x Value to print.
  29317. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  29318. * @return GLSL float string.
  29319. */
  29320. protected _glslFloat(x: number, decimalFigures?: number): string;
  29321. /** @hidden */
  29322. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  29323. }
  29324. }
  29325. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  29326. import { Scene } from "babylonjs/scene";
  29327. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29328. import { Plane } from "babylonjs/Maths/math.plane";
  29329. /**
  29330. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29331. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29332. * You can then easily use it as a reflectionTexture on a flat surface.
  29333. * In case the surface is not a plane, please consider relying on reflection probes.
  29334. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29335. */
  29336. export class MirrorTexture extends RenderTargetTexture {
  29337. private scene;
  29338. /**
  29339. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  29340. * 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.
  29341. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29342. */
  29343. mirrorPlane: Plane;
  29344. /**
  29345. * Define the blur ratio used to blur the reflection if needed.
  29346. */
  29347. set blurRatio(value: number);
  29348. get blurRatio(): number;
  29349. /**
  29350. * Define the adaptive blur kernel used to blur the reflection if needed.
  29351. * This will autocompute the closest best match for the `blurKernel`
  29352. */
  29353. set adaptiveBlurKernel(value: number);
  29354. /**
  29355. * Define the blur kernel used to blur the reflection if needed.
  29356. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29357. */
  29358. set blurKernel(value: number);
  29359. /**
  29360. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  29361. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29362. */
  29363. set blurKernelX(value: number);
  29364. get blurKernelX(): number;
  29365. /**
  29366. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  29367. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29368. */
  29369. set blurKernelY(value: number);
  29370. get blurKernelY(): number;
  29371. private _autoComputeBlurKernel;
  29372. protected _onRatioRescale(): void;
  29373. private _updateGammaSpace;
  29374. private _imageProcessingConfigChangeObserver;
  29375. private _transformMatrix;
  29376. private _mirrorMatrix;
  29377. private _savedViewMatrix;
  29378. private _blurX;
  29379. private _blurY;
  29380. private _adaptiveBlurKernel;
  29381. private _blurKernelX;
  29382. private _blurKernelY;
  29383. private _blurRatio;
  29384. /**
  29385. * Instantiates a Mirror Texture.
  29386. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29387. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29388. * You can then easily use it as a reflectionTexture on a flat surface.
  29389. * In case the surface is not a plane, please consider relying on reflection probes.
  29390. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29391. * @param name
  29392. * @param size
  29393. * @param scene
  29394. * @param generateMipMaps
  29395. * @param type
  29396. * @param samplingMode
  29397. * @param generateDepthBuffer
  29398. */
  29399. constructor(name: string, size: number | {
  29400. width: number;
  29401. height: number;
  29402. } | {
  29403. ratio: number;
  29404. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  29405. private _preparePostProcesses;
  29406. /**
  29407. * Clone the mirror texture.
  29408. * @returns the cloned texture
  29409. */
  29410. clone(): MirrorTexture;
  29411. /**
  29412. * Serialize the texture to a JSON representation you could use in Parse later on
  29413. * @returns the serialized JSON representation
  29414. */
  29415. serialize(): any;
  29416. /**
  29417. * Dispose the texture and release its associated resources.
  29418. */
  29419. dispose(): void;
  29420. }
  29421. }
  29422. declare module "babylonjs/Materials/Textures/texture" {
  29423. import { Observable } from "babylonjs/Misc/observable";
  29424. import { Nullable } from "babylonjs/types";
  29425. import { Matrix } from "babylonjs/Maths/math.vector";
  29426. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29427. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29428. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29429. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  29430. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  29431. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29432. import { Scene } from "babylonjs/scene";
  29433. /**
  29434. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29435. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29436. */
  29437. export class Texture extends BaseTexture {
  29438. /**
  29439. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  29440. */
  29441. static SerializeBuffers: boolean;
  29442. /** @hidden */
  29443. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  29444. /** @hidden */
  29445. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  29446. /** @hidden */
  29447. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  29448. /** nearest is mag = nearest and min = nearest and mip = linear */
  29449. static readonly NEAREST_SAMPLINGMODE: number;
  29450. /** nearest is mag = nearest and min = nearest and mip = linear */
  29451. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  29452. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29453. static readonly BILINEAR_SAMPLINGMODE: number;
  29454. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29455. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  29456. /** Trilinear is mag = linear and min = linear and mip = linear */
  29457. static readonly TRILINEAR_SAMPLINGMODE: number;
  29458. /** Trilinear is mag = linear and min = linear and mip = linear */
  29459. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  29460. /** mag = nearest and min = nearest and mip = nearest */
  29461. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  29462. /** mag = nearest and min = linear and mip = nearest */
  29463. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  29464. /** mag = nearest and min = linear and mip = linear */
  29465. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  29466. /** mag = nearest and min = linear and mip = none */
  29467. static readonly NEAREST_LINEAR: number;
  29468. /** mag = nearest and min = nearest and mip = none */
  29469. static readonly NEAREST_NEAREST: number;
  29470. /** mag = linear and min = nearest and mip = nearest */
  29471. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  29472. /** mag = linear and min = nearest and mip = linear */
  29473. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  29474. /** mag = linear and min = linear and mip = none */
  29475. static readonly LINEAR_LINEAR: number;
  29476. /** mag = linear and min = nearest and mip = none */
  29477. static readonly LINEAR_NEAREST: number;
  29478. /** Explicit coordinates mode */
  29479. static readonly EXPLICIT_MODE: number;
  29480. /** Spherical coordinates mode */
  29481. static readonly SPHERICAL_MODE: number;
  29482. /** Planar coordinates mode */
  29483. static readonly PLANAR_MODE: number;
  29484. /** Cubic coordinates mode */
  29485. static readonly CUBIC_MODE: number;
  29486. /** Projection coordinates mode */
  29487. static readonly PROJECTION_MODE: number;
  29488. /** Inverse Cubic coordinates mode */
  29489. static readonly SKYBOX_MODE: number;
  29490. /** Inverse Cubic coordinates mode */
  29491. static readonly INVCUBIC_MODE: number;
  29492. /** Equirectangular coordinates mode */
  29493. static readonly EQUIRECTANGULAR_MODE: number;
  29494. /** Equirectangular Fixed coordinates mode */
  29495. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  29496. /** Equirectangular Fixed Mirrored coordinates mode */
  29497. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29498. /** Texture is not repeating outside of 0..1 UVs */
  29499. static readonly CLAMP_ADDRESSMODE: number;
  29500. /** Texture is repeating outside of 0..1 UVs */
  29501. static readonly WRAP_ADDRESSMODE: number;
  29502. /** Texture is repeating and mirrored */
  29503. static readonly MIRROR_ADDRESSMODE: number;
  29504. /**
  29505. * 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
  29506. */
  29507. static UseSerializedUrlIfAny: boolean;
  29508. /**
  29509. * Define the url of the texture.
  29510. */
  29511. url: Nullable<string>;
  29512. /**
  29513. * Define an offset on the texture to offset the u coordinates of the UVs
  29514. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29515. */
  29516. uOffset: number;
  29517. /**
  29518. * Define an offset on the texture to offset the v coordinates of the UVs
  29519. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29520. */
  29521. vOffset: number;
  29522. /**
  29523. * Define an offset on the texture to scale the u coordinates of the UVs
  29524. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29525. */
  29526. uScale: number;
  29527. /**
  29528. * Define an offset on the texture to scale the v coordinates of the UVs
  29529. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29530. */
  29531. vScale: number;
  29532. /**
  29533. * Define an offset on the texture to rotate around the u coordinates of the UVs
  29534. * @see https://doc.babylonjs.com/how_to/more_materials
  29535. */
  29536. uAng: number;
  29537. /**
  29538. * Define an offset on the texture to rotate around the v coordinates of the UVs
  29539. * @see https://doc.babylonjs.com/how_to/more_materials
  29540. */
  29541. vAng: number;
  29542. /**
  29543. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  29544. * @see https://doc.babylonjs.com/how_to/more_materials
  29545. */
  29546. wAng: number;
  29547. /**
  29548. * Defines the center of rotation (U)
  29549. */
  29550. uRotationCenter: number;
  29551. /**
  29552. * Defines the center of rotation (V)
  29553. */
  29554. vRotationCenter: number;
  29555. /**
  29556. * Defines the center of rotation (W)
  29557. */
  29558. wRotationCenter: number;
  29559. /**
  29560. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  29561. */
  29562. homogeneousRotationInUVTransform: boolean;
  29563. /**
  29564. * Are mip maps generated for this texture or not.
  29565. */
  29566. get noMipmap(): boolean;
  29567. /**
  29568. * List of inspectable custom properties (used by the Inspector)
  29569. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29570. */
  29571. inspectableCustomProperties: Nullable<IInspectable[]>;
  29572. private _noMipmap;
  29573. /** @hidden */
  29574. _invertY: boolean;
  29575. private _rowGenerationMatrix;
  29576. private _cachedTextureMatrix;
  29577. private _projectionModeMatrix;
  29578. private _t0;
  29579. private _t1;
  29580. private _t2;
  29581. private _cachedUOffset;
  29582. private _cachedVOffset;
  29583. private _cachedUScale;
  29584. private _cachedVScale;
  29585. private _cachedUAng;
  29586. private _cachedVAng;
  29587. private _cachedWAng;
  29588. private _cachedProjectionMatrixId;
  29589. private _cachedURotationCenter;
  29590. private _cachedVRotationCenter;
  29591. private _cachedWRotationCenter;
  29592. private _cachedHomogeneousRotationInUVTransform;
  29593. private _cachedCoordinatesMode;
  29594. /** @hidden */
  29595. protected _initialSamplingMode: number;
  29596. /** @hidden */
  29597. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  29598. private _deleteBuffer;
  29599. protected _format: Nullable<number>;
  29600. private _delayedOnLoad;
  29601. private _delayedOnError;
  29602. private _mimeType?;
  29603. private _loaderOptions?;
  29604. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  29605. get mimeType(): string | undefined;
  29606. /**
  29607. * Observable triggered once the texture has been loaded.
  29608. */
  29609. onLoadObservable: Observable<Texture>;
  29610. protected _isBlocking: boolean;
  29611. /**
  29612. * Is the texture preventing material to render while loading.
  29613. * If false, a default texture will be used instead of the loading one during the preparation step.
  29614. */
  29615. set isBlocking(value: boolean);
  29616. get isBlocking(): boolean;
  29617. /**
  29618. * Get the current sampling mode associated with the texture.
  29619. */
  29620. get samplingMode(): number;
  29621. /**
  29622. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  29623. */
  29624. get invertY(): boolean;
  29625. /**
  29626. * Instantiates a new texture.
  29627. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29628. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29629. * @param url defines the url of the picture to load as a texture
  29630. * @param sceneOrEngine defines the scene or engine the texture will belong to
  29631. * @param noMipmap defines if the texture will require mip maps or not
  29632. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  29633. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29634. * @param onLoad defines a callback triggered when the texture has been loaded
  29635. * @param onError defines a callback triggered when an error occurred during the loading session
  29636. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  29637. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  29638. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29639. * @param mimeType defines an optional mime type information
  29640. * @param loaderOptions options to be passed to the loader
  29641. */
  29642. 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);
  29643. /**
  29644. * Update the url (and optional buffer) of this texture if url was null during construction.
  29645. * @param url the url of the texture
  29646. * @param buffer the buffer of the texture (defaults to null)
  29647. * @param onLoad callback called when the texture is loaded (defaults to null)
  29648. */
  29649. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  29650. /**
  29651. * Finish the loading sequence of a texture flagged as delayed load.
  29652. * @hidden
  29653. */
  29654. delayLoad(): void;
  29655. private _prepareRowForTextureGeneration;
  29656. /**
  29657. * Checks if the texture has the same transform matrix than another texture
  29658. * @param texture texture to check against
  29659. * @returns true if the transforms are the same, else false
  29660. */
  29661. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  29662. /**
  29663. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  29664. * @returns the transform matrix of the texture.
  29665. */
  29666. getTextureMatrix(uBase?: number): Matrix;
  29667. /**
  29668. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  29669. * @returns The reflection texture transform
  29670. */
  29671. getReflectionTextureMatrix(): Matrix;
  29672. /**
  29673. * Clones the texture.
  29674. * @returns the cloned texture
  29675. */
  29676. clone(): Texture;
  29677. /**
  29678. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29679. * @returns The JSON representation of the texture
  29680. */
  29681. serialize(): any;
  29682. /**
  29683. * Get the current class name of the texture useful for serialization or dynamic coding.
  29684. * @returns "Texture"
  29685. */
  29686. getClassName(): string;
  29687. /**
  29688. * Dispose the texture and release its associated resources.
  29689. */
  29690. dispose(): void;
  29691. /**
  29692. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  29693. * @param parsedTexture Define the JSON representation of the texture
  29694. * @param scene Define the scene the parsed texture should be instantiated in
  29695. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  29696. * @returns The parsed texture if successful
  29697. */
  29698. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  29699. /**
  29700. * Creates a texture from its base 64 representation.
  29701. * @param data Define the base64 payload without the data: prefix
  29702. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29703. * @param scene Define the scene the texture should belong to
  29704. * @param noMipmap Forces the texture to not create mip map information if true
  29705. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29706. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29707. * @param onLoad define a callback triggered when the texture has been loaded
  29708. * @param onError define a callback triggered when an error occurred during the loading session
  29709. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29710. * @returns the created texture
  29711. */
  29712. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  29713. /**
  29714. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  29715. * @param data Define the base64 payload without the data: prefix
  29716. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29717. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  29718. * @param scene Define the scene the texture should belong to
  29719. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  29720. * @param noMipmap Forces the texture to not create mip map information if true
  29721. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29722. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29723. * @param onLoad define a callback triggered when the texture has been loaded
  29724. * @param onError define a callback triggered when an error occurred during the loading session
  29725. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29726. * @returns the created texture
  29727. */
  29728. 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;
  29729. }
  29730. }
  29731. declare module "babylonjs/PostProcesses/postProcessManager" {
  29732. import { Nullable } from "babylonjs/types";
  29733. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29734. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29735. import { Scene } from "babylonjs/scene";
  29736. /**
  29737. * PostProcessManager is used to manage one or more post processes or post process pipelines
  29738. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  29739. */
  29740. export class PostProcessManager {
  29741. private _scene;
  29742. private _indexBuffer;
  29743. private _vertexBuffers;
  29744. /**
  29745. * Creates a new instance PostProcess
  29746. * @param scene The scene that the post process is associated with.
  29747. */
  29748. constructor(scene: Scene);
  29749. private _prepareBuffers;
  29750. private _buildIndexBuffer;
  29751. /**
  29752. * Rebuilds the vertex buffers of the manager.
  29753. * @hidden
  29754. */
  29755. _rebuild(): void;
  29756. /**
  29757. * Prepares a frame to be run through a post process.
  29758. * @param sourceTexture The input texture to the post procesess. (default: null)
  29759. * @param postProcesses An array of post processes to be run. (default: null)
  29760. * @returns True if the post processes were able to be run.
  29761. * @hidden
  29762. */
  29763. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  29764. /**
  29765. * Manually render a set of post processes to a texture.
  29766. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  29767. * @param postProcesses An array of post processes to be run.
  29768. * @param targetTexture The target texture to render to.
  29769. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  29770. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  29771. * @param lodLevel defines which lod of the texture to render to
  29772. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  29773. */
  29774. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  29775. /**
  29776. * Finalize the result of the output of the postprocesses.
  29777. * @param doNotPresent If true the result will not be displayed to the screen.
  29778. * @param targetTexture The target texture to render to.
  29779. * @param faceIndex The index of the face to bind the target texture to.
  29780. * @param postProcesses The array of post processes to render.
  29781. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  29782. * @hidden
  29783. */
  29784. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  29785. /**
  29786. * Disposes of the post process manager.
  29787. */
  29788. dispose(): void;
  29789. }
  29790. }
  29791. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  29792. import { Observable } from "babylonjs/Misc/observable";
  29793. import { SmartArray } from "babylonjs/Misc/smartArray";
  29794. import { Nullable, Immutable } from "babylonjs/types";
  29795. import { Camera } from "babylonjs/Cameras/camera";
  29796. import { Scene } from "babylonjs/scene";
  29797. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29798. import { Color4 } from "babylonjs/Maths/math.color";
  29799. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  29800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29801. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29802. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29803. import { Texture } from "babylonjs/Materials/Textures/texture";
  29804. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29805. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  29806. import "babylonjs/Engines/Extensions/engine.renderTarget";
  29807. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  29808. import { Engine } from "babylonjs/Engines/engine";
  29809. /**
  29810. * This Helps creating a texture that will be created from a camera in your scene.
  29811. * It is basically a dynamic texture that could be used to create special effects for instance.
  29812. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  29813. */
  29814. export class RenderTargetTexture extends Texture {
  29815. /**
  29816. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  29817. */
  29818. static readonly REFRESHRATE_RENDER_ONCE: number;
  29819. /**
  29820. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  29821. */
  29822. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  29823. /**
  29824. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  29825. * the central point of your effect and can save a lot of performances.
  29826. */
  29827. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  29828. /**
  29829. * Use this predicate to dynamically define the list of mesh you want to render.
  29830. * If set, the renderList property will be overwritten.
  29831. */
  29832. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  29833. private _renderList;
  29834. /**
  29835. * Use this list to define the list of mesh you want to render.
  29836. */
  29837. get renderList(): Nullable<Array<AbstractMesh>>;
  29838. set renderList(value: Nullable<Array<AbstractMesh>>);
  29839. /**
  29840. * Use this function to overload the renderList array at rendering time.
  29841. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  29842. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  29843. * the cube (if the RTT is a cube, else layerOrFace=0).
  29844. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  29845. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  29846. * hold dummy elements!
  29847. */
  29848. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  29849. private _hookArray;
  29850. /**
  29851. * Define if particles should be rendered in your texture.
  29852. */
  29853. renderParticles: boolean;
  29854. /**
  29855. * Define if sprites should be rendered in your texture.
  29856. */
  29857. renderSprites: boolean;
  29858. /**
  29859. * Define the camera used to render the texture.
  29860. */
  29861. activeCamera: Nullable<Camera>;
  29862. /**
  29863. * Override the mesh isReady function with your own one.
  29864. */
  29865. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  29866. /**
  29867. * Override the render function of the texture with your own one.
  29868. */
  29869. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  29870. /**
  29871. * Define if camera post processes should be use while rendering the texture.
  29872. */
  29873. useCameraPostProcesses: boolean;
  29874. /**
  29875. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  29876. */
  29877. ignoreCameraViewport: boolean;
  29878. private _postProcessManager;
  29879. private _postProcesses;
  29880. private _resizeObserver;
  29881. /**
  29882. * An event triggered when the texture is unbind.
  29883. */
  29884. onBeforeBindObservable: Observable<RenderTargetTexture>;
  29885. /**
  29886. * An event triggered when the texture is unbind.
  29887. */
  29888. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  29889. private _onAfterUnbindObserver;
  29890. /**
  29891. * Set a after unbind callback in the texture.
  29892. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  29893. */
  29894. set onAfterUnbind(callback: () => void);
  29895. /**
  29896. * An event triggered before rendering the texture
  29897. */
  29898. onBeforeRenderObservable: Observable<number>;
  29899. private _onBeforeRenderObserver;
  29900. /**
  29901. * Set a before render callback in the texture.
  29902. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  29903. */
  29904. set onBeforeRender(callback: (faceIndex: number) => void);
  29905. /**
  29906. * An event triggered after rendering the texture
  29907. */
  29908. onAfterRenderObservable: Observable<number>;
  29909. private _onAfterRenderObserver;
  29910. /**
  29911. * Set a after render callback in the texture.
  29912. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  29913. */
  29914. set onAfterRender(callback: (faceIndex: number) => void);
  29915. /**
  29916. * An event triggered after the texture clear
  29917. */
  29918. onClearObservable: Observable<Engine>;
  29919. private _onClearObserver;
  29920. /**
  29921. * Set a clear callback in the texture.
  29922. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  29923. */
  29924. set onClear(callback: (Engine: Engine) => void);
  29925. /**
  29926. * An event triggered when the texture is resized.
  29927. */
  29928. onResizeObservable: Observable<RenderTargetTexture>;
  29929. /**
  29930. * Define the clear color of the Render Target if it should be different from the scene.
  29931. */
  29932. clearColor: Color4;
  29933. protected _size: number | {
  29934. width: number;
  29935. height: number;
  29936. layers?: number;
  29937. };
  29938. protected _initialSizeParameter: number | {
  29939. width: number;
  29940. height: number;
  29941. } | {
  29942. ratio: number;
  29943. };
  29944. protected _sizeRatio: Nullable<number>;
  29945. /** @hidden */
  29946. _generateMipMaps: boolean;
  29947. protected _renderingManager: RenderingManager;
  29948. /** @hidden */
  29949. _waitingRenderList?: string[];
  29950. protected _doNotChangeAspectRatio: boolean;
  29951. protected _currentRefreshId: number;
  29952. protected _refreshRate: number;
  29953. protected _textureMatrix: Matrix;
  29954. protected _samples: number;
  29955. protected _renderTargetOptions: RenderTargetCreationOptions;
  29956. /**
  29957. * Gets render target creation options that were used.
  29958. */
  29959. get renderTargetOptions(): RenderTargetCreationOptions;
  29960. protected _onRatioRescale(): void;
  29961. /**
  29962. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  29963. * It must define where the camera used to render the texture is set
  29964. */
  29965. boundingBoxPosition: Vector3;
  29966. private _boundingBoxSize;
  29967. /**
  29968. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  29969. * When defined, the cubemap will switch to local mode
  29970. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  29971. * @example https://www.babylonjs-playground.com/#RNASML
  29972. */
  29973. set boundingBoxSize(value: Vector3);
  29974. get boundingBoxSize(): Vector3;
  29975. /**
  29976. * In case the RTT has been created with a depth texture, get the associated
  29977. * depth texture.
  29978. * Otherwise, return null.
  29979. */
  29980. get depthStencilTexture(): Nullable<InternalTexture>;
  29981. /**
  29982. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  29983. * or used a shadow, depth texture...
  29984. * @param name The friendly name of the texture
  29985. * @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)
  29986. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  29987. * @param generateMipMaps True if mip maps need to be generated after render.
  29988. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  29989. * @param type The type of the buffer in the RTT (int, half float, float...)
  29990. * @param isCube True if a cube texture needs to be created
  29991. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  29992. * @param generateDepthBuffer True to generate a depth buffer
  29993. * @param generateStencilBuffer True to generate a stencil buffer
  29994. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  29995. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  29996. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29997. */
  29998. constructor(name: string, size: number | {
  29999. width: number;
  30000. height: number;
  30001. layers?: number;
  30002. } | {
  30003. ratio: number;
  30004. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  30005. /**
  30006. * Creates a depth stencil texture.
  30007. * This is only available in WebGL 2 or with the depth texture extension available.
  30008. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  30009. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  30010. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  30011. */
  30012. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  30013. private _processSizeParameter;
  30014. /**
  30015. * Define the number of samples to use in case of MSAA.
  30016. * It defaults to one meaning no MSAA has been enabled.
  30017. */
  30018. get samples(): number;
  30019. set samples(value: number);
  30020. /**
  30021. * Resets the refresh counter of the texture and start bak from scratch.
  30022. * Could be useful to regenerate the texture if it is setup to render only once.
  30023. */
  30024. resetRefreshCounter(): void;
  30025. /**
  30026. * Define the refresh rate of the texture or the rendering frequency.
  30027. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  30028. */
  30029. get refreshRate(): number;
  30030. set refreshRate(value: number);
  30031. /**
  30032. * Adds a post process to the render target rendering passes.
  30033. * @param postProcess define the post process to add
  30034. */
  30035. addPostProcess(postProcess: PostProcess): void;
  30036. /**
  30037. * Clear all the post processes attached to the render target
  30038. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  30039. */
  30040. clearPostProcesses(dispose?: boolean): void;
  30041. /**
  30042. * Remove one of the post process from the list of attached post processes to the texture
  30043. * @param postProcess define the post process to remove from the list
  30044. */
  30045. removePostProcess(postProcess: PostProcess): void;
  30046. /** @hidden */
  30047. _shouldRender(): boolean;
  30048. /**
  30049. * Gets the actual render size of the texture.
  30050. * @returns the width of the render size
  30051. */
  30052. getRenderSize(): number;
  30053. /**
  30054. * Gets the actual render width of the texture.
  30055. * @returns the width of the render size
  30056. */
  30057. getRenderWidth(): number;
  30058. /**
  30059. * Gets the actual render height of the texture.
  30060. * @returns the height of the render size
  30061. */
  30062. getRenderHeight(): number;
  30063. /**
  30064. * Gets the actual number of layers of the texture.
  30065. * @returns the number of layers
  30066. */
  30067. getRenderLayers(): number;
  30068. /**
  30069. * Get if the texture can be rescaled or not.
  30070. */
  30071. get canRescale(): boolean;
  30072. /**
  30073. * Resize the texture using a ratio.
  30074. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  30075. */
  30076. scale(ratio: number): void;
  30077. /**
  30078. * Get the texture reflection matrix used to rotate/transform the reflection.
  30079. * @returns the reflection matrix
  30080. */
  30081. getReflectionTextureMatrix(): Matrix;
  30082. /**
  30083. * Resize the texture to a new desired size.
  30084. * Be carrefull as it will recreate all the data in the new texture.
  30085. * @param size Define the new size. It can be:
  30086. * - a number for squared texture,
  30087. * - an object containing { width: number, height: number }
  30088. * - or an object containing a ratio { ratio: number }
  30089. */
  30090. resize(size: number | {
  30091. width: number;
  30092. height: number;
  30093. } | {
  30094. ratio: number;
  30095. }): void;
  30096. private _defaultRenderListPrepared;
  30097. /**
  30098. * Renders all the objects from the render list into the texture.
  30099. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  30100. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  30101. */
  30102. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  30103. private _bestReflectionRenderTargetDimension;
  30104. private _prepareRenderingManager;
  30105. /**
  30106. * @hidden
  30107. * @param faceIndex face index to bind to if this is a cubetexture
  30108. * @param layer defines the index of the texture to bind in the array
  30109. */
  30110. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  30111. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  30112. private renderToTarget;
  30113. /**
  30114. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  30115. * This allowed control for front to back rendering or reversly depending of the special needs.
  30116. *
  30117. * @param renderingGroupId The rendering group id corresponding to its index
  30118. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  30119. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  30120. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  30121. */
  30122. 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;
  30123. /**
  30124. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  30125. *
  30126. * @param renderingGroupId The rendering group id corresponding to its index
  30127. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  30128. */
  30129. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  30130. /**
  30131. * Clones the texture.
  30132. * @returns the cloned texture
  30133. */
  30134. clone(): RenderTargetTexture;
  30135. /**
  30136. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  30137. * @returns The JSON representation of the texture
  30138. */
  30139. serialize(): any;
  30140. /**
  30141. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  30142. */
  30143. disposeFramebufferObjects(): void;
  30144. /**
  30145. * Dispose the texture and release its associated resources.
  30146. */
  30147. dispose(): void;
  30148. /** @hidden */
  30149. _rebuild(): void;
  30150. /**
  30151. * Clear the info related to rendering groups preventing retention point in material dispose.
  30152. */
  30153. freeRenderingGroups(): void;
  30154. /**
  30155. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  30156. * @returns the view count
  30157. */
  30158. getViewCount(): number;
  30159. }
  30160. }
  30161. declare module "babylonjs/Misc/guid" {
  30162. /**
  30163. * Class used to manipulate GUIDs
  30164. */
  30165. export class GUID {
  30166. /**
  30167. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30168. * Be aware Math.random() could cause collisions, but:
  30169. * "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"
  30170. * @returns a pseudo random id
  30171. */
  30172. static RandomId(): string;
  30173. }
  30174. }
  30175. declare module "babylonjs/Materials/shadowDepthWrapper" {
  30176. import { Nullable } from "babylonjs/types";
  30177. import { Scene } from "babylonjs/scene";
  30178. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30179. import { Material } from "babylonjs/Materials/material";
  30180. import { Effect } from "babylonjs/Materials/effect";
  30181. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  30182. /**
  30183. * Options to be used when creating a shadow depth material
  30184. */
  30185. export interface IIOptionShadowDepthMaterial {
  30186. /** Variables in the vertex shader code that need to have their names remapped.
  30187. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30188. * "var_name" should be either: worldPos or vNormalW
  30189. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30190. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30191. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30192. */
  30193. remappedVariables?: string[];
  30194. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30195. standalone?: boolean;
  30196. }
  30197. /**
  30198. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30199. */
  30200. export class ShadowDepthWrapper {
  30201. private _scene;
  30202. private _options?;
  30203. private _baseMaterial;
  30204. private _onEffectCreatedObserver;
  30205. private _subMeshToEffect;
  30206. private _subMeshToDepthEffect;
  30207. private _meshes;
  30208. /** @hidden */
  30209. _matriceNames: any;
  30210. /** Gets the standalone status of the wrapper */
  30211. get standalone(): boolean;
  30212. /** Gets the base material the wrapper is built upon */
  30213. get baseMaterial(): Material;
  30214. /**
  30215. * Instantiate a new shadow depth wrapper.
  30216. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30217. * generate the shadow depth map. For more information, please refer to the documentation:
  30218. * https://doc.babylonjs.com/babylon101/shadows
  30219. * @param baseMaterial Material to wrap
  30220. * @param scene Define the scene the material belongs to
  30221. * @param options Options used to create the wrapper
  30222. */
  30223. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30224. /**
  30225. * Gets the effect to use to generate the depth map
  30226. * @param subMesh subMesh to get the effect for
  30227. * @param shadowGenerator shadow generator to get the effect for
  30228. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30229. */
  30230. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30231. /**
  30232. * Specifies that the submesh is ready to be used for depth rendering
  30233. * @param subMesh submesh to check
  30234. * @param defines the list of defines to take into account when checking the effect
  30235. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30236. * @param useInstances specifies that instances should be used
  30237. * @returns a boolean indicating that the submesh is ready or not
  30238. */
  30239. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30240. /**
  30241. * Disposes the resources
  30242. */
  30243. dispose(): void;
  30244. private _makeEffect;
  30245. }
  30246. }
  30247. declare module "babylonjs/Materials/material" {
  30248. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30249. import { SmartArray } from "babylonjs/Misc/smartArray";
  30250. import { Observable } from "babylonjs/Misc/observable";
  30251. import { Nullable } from "babylonjs/types";
  30252. import { Scene } from "babylonjs/scene";
  30253. import { Matrix } from "babylonjs/Maths/math.vector";
  30254. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30256. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30257. import { Effect } from "babylonjs/Materials/effect";
  30258. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30259. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30260. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30261. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30262. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  30263. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  30264. import { Mesh } from "babylonjs/Meshes/mesh";
  30265. import { Animation } from "babylonjs/Animations/animation";
  30266. /**
  30267. * Options for compiling materials.
  30268. */
  30269. export interface IMaterialCompilationOptions {
  30270. /**
  30271. * Defines whether clip planes are enabled.
  30272. */
  30273. clipPlane: boolean;
  30274. /**
  30275. * Defines whether instances are enabled.
  30276. */
  30277. useInstances: boolean;
  30278. }
  30279. /**
  30280. * Options passed when calling customShaderNameResolve
  30281. */
  30282. export interface ICustomShaderNameResolveOptions {
  30283. /**
  30284. * 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
  30285. */
  30286. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30287. }
  30288. /**
  30289. * Base class for the main features of a material in Babylon.js
  30290. */
  30291. export class Material implements IAnimatable {
  30292. /**
  30293. * Returns the triangle fill mode
  30294. */
  30295. static readonly TriangleFillMode: number;
  30296. /**
  30297. * Returns the wireframe mode
  30298. */
  30299. static readonly WireFrameFillMode: number;
  30300. /**
  30301. * Returns the point fill mode
  30302. */
  30303. static readonly PointFillMode: number;
  30304. /**
  30305. * Returns the point list draw mode
  30306. */
  30307. static readonly PointListDrawMode: number;
  30308. /**
  30309. * Returns the line list draw mode
  30310. */
  30311. static readonly LineListDrawMode: number;
  30312. /**
  30313. * Returns the line loop draw mode
  30314. */
  30315. static readonly LineLoopDrawMode: number;
  30316. /**
  30317. * Returns the line strip draw mode
  30318. */
  30319. static readonly LineStripDrawMode: number;
  30320. /**
  30321. * Returns the triangle strip draw mode
  30322. */
  30323. static readonly TriangleStripDrawMode: number;
  30324. /**
  30325. * Returns the triangle fan draw mode
  30326. */
  30327. static readonly TriangleFanDrawMode: number;
  30328. /**
  30329. * Stores the clock-wise side orientation
  30330. */
  30331. static readonly ClockWiseSideOrientation: number;
  30332. /**
  30333. * Stores the counter clock-wise side orientation
  30334. */
  30335. static readonly CounterClockWiseSideOrientation: number;
  30336. /**
  30337. * The dirty texture flag value
  30338. */
  30339. static readonly TextureDirtyFlag: number;
  30340. /**
  30341. * The dirty light flag value
  30342. */
  30343. static readonly LightDirtyFlag: number;
  30344. /**
  30345. * The dirty fresnel flag value
  30346. */
  30347. static readonly FresnelDirtyFlag: number;
  30348. /**
  30349. * The dirty attribute flag value
  30350. */
  30351. static readonly AttributesDirtyFlag: number;
  30352. /**
  30353. * The dirty misc flag value
  30354. */
  30355. static readonly MiscDirtyFlag: number;
  30356. /**
  30357. * The dirty prepass flag value
  30358. */
  30359. static readonly PrePassDirtyFlag: number;
  30360. /**
  30361. * The all dirty flag value
  30362. */
  30363. static readonly AllDirtyFlag: number;
  30364. /**
  30365. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30366. */
  30367. static readonly MATERIAL_OPAQUE: number;
  30368. /**
  30369. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30370. */
  30371. static readonly MATERIAL_ALPHATEST: number;
  30372. /**
  30373. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30374. */
  30375. static readonly MATERIAL_ALPHABLEND: number;
  30376. /**
  30377. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30378. * They are also discarded below the alpha cutoff threshold to improve performances.
  30379. */
  30380. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30381. /**
  30382. * The Whiteout method is used to blend normals.
  30383. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30384. */
  30385. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30386. /**
  30387. * The Reoriented Normal Mapping method is used to blend normals.
  30388. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30389. */
  30390. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30391. /**
  30392. * Custom callback helping to override the default shader used in the material.
  30393. */
  30394. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30395. /**
  30396. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30397. */
  30398. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30399. /**
  30400. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30401. * This means that the material can keep using a previous shader while a new one is being compiled.
  30402. * This is mostly used when shader parallel compilation is supported (true by default)
  30403. */
  30404. allowShaderHotSwapping: boolean;
  30405. /**
  30406. * The ID of the material
  30407. */
  30408. id: string;
  30409. /**
  30410. * Gets or sets the unique id of the material
  30411. */
  30412. uniqueId: number;
  30413. /**
  30414. * The name of the material
  30415. */
  30416. name: string;
  30417. /**
  30418. * Gets or sets user defined metadata
  30419. */
  30420. metadata: any;
  30421. /**
  30422. * For internal use only. Please do not use.
  30423. */
  30424. reservedDataStore: any;
  30425. /**
  30426. * Specifies if the ready state should be checked on each call
  30427. */
  30428. checkReadyOnEveryCall: boolean;
  30429. /**
  30430. * Specifies if the ready state should be checked once
  30431. */
  30432. checkReadyOnlyOnce: boolean;
  30433. /**
  30434. * The state of the material
  30435. */
  30436. state: string;
  30437. /**
  30438. * If the material can be rendered to several textures with MRT extension
  30439. */
  30440. get canRenderToMRT(): boolean;
  30441. /**
  30442. * The alpha value of the material
  30443. */
  30444. protected _alpha: number;
  30445. /**
  30446. * List of inspectable custom properties (used by the Inspector)
  30447. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30448. */
  30449. inspectableCustomProperties: IInspectable[];
  30450. /**
  30451. * Sets the alpha value of the material
  30452. */
  30453. set alpha(value: number);
  30454. /**
  30455. * Gets the alpha value of the material
  30456. */
  30457. get alpha(): number;
  30458. /**
  30459. * Specifies if back face culling is enabled
  30460. */
  30461. protected _backFaceCulling: boolean;
  30462. /**
  30463. * Sets the back-face culling state
  30464. */
  30465. set backFaceCulling(value: boolean);
  30466. /**
  30467. * Gets the back-face culling state
  30468. */
  30469. get backFaceCulling(): boolean;
  30470. /**
  30471. * Stores the value for side orientation
  30472. */
  30473. sideOrientation: number;
  30474. /**
  30475. * Callback triggered when the material is compiled
  30476. */
  30477. onCompiled: Nullable<(effect: Effect) => void>;
  30478. /**
  30479. * Callback triggered when an error occurs
  30480. */
  30481. onError: Nullable<(effect: Effect, errors: string) => void>;
  30482. /**
  30483. * Callback triggered to get the render target textures
  30484. */
  30485. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30486. /**
  30487. * Gets a boolean indicating that current material needs to register RTT
  30488. */
  30489. get hasRenderTargetTextures(): boolean;
  30490. /**
  30491. * Specifies if the material should be serialized
  30492. */
  30493. doNotSerialize: boolean;
  30494. /**
  30495. * @hidden
  30496. */
  30497. _storeEffectOnSubMeshes: boolean;
  30498. /**
  30499. * Stores the animations for the material
  30500. */
  30501. animations: Nullable<Array<Animation>>;
  30502. /**
  30503. * An event triggered when the material is disposed
  30504. */
  30505. onDisposeObservable: Observable<Material>;
  30506. /**
  30507. * An observer which watches for dispose events
  30508. */
  30509. private _onDisposeObserver;
  30510. private _onUnBindObservable;
  30511. /**
  30512. * Called during a dispose event
  30513. */
  30514. set onDispose(callback: () => void);
  30515. private _onBindObservable;
  30516. /**
  30517. * An event triggered when the material is bound
  30518. */
  30519. get onBindObservable(): Observable<AbstractMesh>;
  30520. /**
  30521. * An observer which watches for bind events
  30522. */
  30523. private _onBindObserver;
  30524. /**
  30525. * Called during a bind event
  30526. */
  30527. set onBind(callback: (Mesh: AbstractMesh) => void);
  30528. /**
  30529. * An event triggered when the material is unbound
  30530. */
  30531. get onUnBindObservable(): Observable<Material>;
  30532. protected _onEffectCreatedObservable: Nullable<Observable<{
  30533. effect: Effect;
  30534. subMesh: Nullable<SubMesh>;
  30535. }>>;
  30536. /**
  30537. * An event triggered when the effect is (re)created
  30538. */
  30539. get onEffectCreatedObservable(): Observable<{
  30540. effect: Effect;
  30541. subMesh: Nullable<SubMesh>;
  30542. }>;
  30543. /**
  30544. * Stores the value of the alpha mode
  30545. */
  30546. private _alphaMode;
  30547. /**
  30548. * Sets the value of the alpha mode.
  30549. *
  30550. * | Value | Type | Description |
  30551. * | --- | --- | --- |
  30552. * | 0 | ALPHA_DISABLE | |
  30553. * | 1 | ALPHA_ADD | |
  30554. * | 2 | ALPHA_COMBINE | |
  30555. * | 3 | ALPHA_SUBTRACT | |
  30556. * | 4 | ALPHA_MULTIPLY | |
  30557. * | 5 | ALPHA_MAXIMIZED | |
  30558. * | 6 | ALPHA_ONEONE | |
  30559. * | 7 | ALPHA_PREMULTIPLIED | |
  30560. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30561. * | 9 | ALPHA_INTERPOLATE | |
  30562. * | 10 | ALPHA_SCREENMODE | |
  30563. *
  30564. */
  30565. set alphaMode(value: number);
  30566. /**
  30567. * Gets the value of the alpha mode
  30568. */
  30569. get alphaMode(): number;
  30570. /**
  30571. * Stores the state of the need depth pre-pass value
  30572. */
  30573. private _needDepthPrePass;
  30574. /**
  30575. * Sets the need depth pre-pass value
  30576. */
  30577. set needDepthPrePass(value: boolean);
  30578. /**
  30579. * Gets the depth pre-pass value
  30580. */
  30581. get needDepthPrePass(): boolean;
  30582. /**
  30583. * Specifies if depth writing should be disabled
  30584. */
  30585. disableDepthWrite: boolean;
  30586. /**
  30587. * Specifies if color writing should be disabled
  30588. */
  30589. disableColorWrite: boolean;
  30590. /**
  30591. * Specifies if depth writing should be forced
  30592. */
  30593. forceDepthWrite: boolean;
  30594. /**
  30595. * Specifies the depth function that should be used. 0 means the default engine function
  30596. */
  30597. depthFunction: number;
  30598. /**
  30599. * Specifies if there should be a separate pass for culling
  30600. */
  30601. separateCullingPass: boolean;
  30602. /**
  30603. * Stores the state specifing if fog should be enabled
  30604. */
  30605. private _fogEnabled;
  30606. /**
  30607. * Sets the state for enabling fog
  30608. */
  30609. set fogEnabled(value: boolean);
  30610. /**
  30611. * Gets the value of the fog enabled state
  30612. */
  30613. get fogEnabled(): boolean;
  30614. /**
  30615. * Stores the size of points
  30616. */
  30617. pointSize: number;
  30618. /**
  30619. * Stores the z offset value
  30620. */
  30621. zOffset: number;
  30622. get wireframe(): boolean;
  30623. /**
  30624. * Sets the state of wireframe mode
  30625. */
  30626. set wireframe(value: boolean);
  30627. /**
  30628. * Gets the value specifying if point clouds are enabled
  30629. */
  30630. get pointsCloud(): boolean;
  30631. /**
  30632. * Sets the state of point cloud mode
  30633. */
  30634. set pointsCloud(value: boolean);
  30635. /**
  30636. * Gets the material fill mode
  30637. */
  30638. get fillMode(): number;
  30639. /**
  30640. * Sets the material fill mode
  30641. */
  30642. set fillMode(value: number);
  30643. /**
  30644. * @hidden
  30645. * Stores the effects for the material
  30646. */
  30647. _effect: Nullable<Effect>;
  30648. /**
  30649. * Specifies if uniform buffers should be used
  30650. */
  30651. private _useUBO;
  30652. /**
  30653. * Stores a reference to the scene
  30654. */
  30655. private _scene;
  30656. /**
  30657. * Stores the fill mode state
  30658. */
  30659. private _fillMode;
  30660. /**
  30661. * Specifies if the depth write state should be cached
  30662. */
  30663. private _cachedDepthWriteState;
  30664. /**
  30665. * Specifies if the color write state should be cached
  30666. */
  30667. private _cachedColorWriteState;
  30668. /**
  30669. * Specifies if the depth function state should be cached
  30670. */
  30671. private _cachedDepthFunctionState;
  30672. /**
  30673. * Stores the uniform buffer
  30674. */
  30675. protected _uniformBuffer: UniformBuffer;
  30676. /** @hidden */
  30677. _indexInSceneMaterialArray: number;
  30678. /** @hidden */
  30679. meshMap: Nullable<{
  30680. [id: string]: AbstractMesh | undefined;
  30681. }>;
  30682. /**
  30683. * Creates a material instance
  30684. * @param name defines the name of the material
  30685. * @param scene defines the scene to reference
  30686. * @param doNotAdd specifies if the material should be added to the scene
  30687. */
  30688. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30689. /**
  30690. * Returns a string representation of the current material
  30691. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30692. * @returns a string with material information
  30693. */
  30694. toString(fullDetails?: boolean): string;
  30695. /**
  30696. * Gets the class name of the material
  30697. * @returns a string with the class name of the material
  30698. */
  30699. getClassName(): string;
  30700. /**
  30701. * Specifies if updates for the material been locked
  30702. */
  30703. get isFrozen(): boolean;
  30704. /**
  30705. * Locks updates for the material
  30706. */
  30707. freeze(): void;
  30708. /**
  30709. * Unlocks updates for the material
  30710. */
  30711. unfreeze(): void;
  30712. /**
  30713. * Specifies if the material is ready to be used
  30714. * @param mesh defines the mesh to check
  30715. * @param useInstances specifies if instances should be used
  30716. * @returns a boolean indicating if the material is ready to be used
  30717. */
  30718. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30719. /**
  30720. * Specifies that the submesh is ready to be used
  30721. * @param mesh defines the mesh to check
  30722. * @param subMesh defines which submesh to check
  30723. * @param useInstances specifies that instances should be used
  30724. * @returns a boolean indicating that the submesh is ready or not
  30725. */
  30726. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30727. /**
  30728. * Returns the material effect
  30729. * @returns the effect associated with the material
  30730. */
  30731. getEffect(): Nullable<Effect>;
  30732. /**
  30733. * Returns the current scene
  30734. * @returns a Scene
  30735. */
  30736. getScene(): Scene;
  30737. /**
  30738. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30739. */
  30740. protected _forceAlphaTest: boolean;
  30741. /**
  30742. * The transparency mode of the material.
  30743. */
  30744. protected _transparencyMode: Nullable<number>;
  30745. /**
  30746. * Gets the current transparency mode.
  30747. */
  30748. get transparencyMode(): Nullable<number>;
  30749. /**
  30750. * Sets the transparency mode of the material.
  30751. *
  30752. * | Value | Type | Description |
  30753. * | ----- | ----------------------------------- | ----------- |
  30754. * | 0 | OPAQUE | |
  30755. * | 1 | ALPHATEST | |
  30756. * | 2 | ALPHABLEND | |
  30757. * | 3 | ALPHATESTANDBLEND | |
  30758. *
  30759. */
  30760. set transparencyMode(value: Nullable<number>);
  30761. /**
  30762. * Returns true if alpha blending should be disabled.
  30763. */
  30764. protected get _disableAlphaBlending(): boolean;
  30765. /**
  30766. * Specifies whether or not this material should be rendered in alpha blend mode.
  30767. * @returns a boolean specifying if alpha blending is needed
  30768. */
  30769. needAlphaBlending(): boolean;
  30770. /**
  30771. * Specifies if the mesh will require alpha blending
  30772. * @param mesh defines the mesh to check
  30773. * @returns a boolean specifying if alpha blending is needed for the mesh
  30774. */
  30775. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30776. /**
  30777. * Specifies whether or not this material should be rendered in alpha test mode.
  30778. * @returns a boolean specifying if an alpha test is needed.
  30779. */
  30780. needAlphaTesting(): boolean;
  30781. /**
  30782. * Specifies if material alpha testing should be turned on for the mesh
  30783. * @param mesh defines the mesh to check
  30784. */
  30785. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30786. /**
  30787. * Gets the texture used for the alpha test
  30788. * @returns the texture to use for alpha testing
  30789. */
  30790. getAlphaTestTexture(): Nullable<BaseTexture>;
  30791. /**
  30792. * Marks the material to indicate that it needs to be re-calculated
  30793. */
  30794. markDirty(): void;
  30795. /** @hidden */
  30796. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30797. /**
  30798. * Binds the material to the mesh
  30799. * @param world defines the world transformation matrix
  30800. * @param mesh defines the mesh to bind the material to
  30801. */
  30802. bind(world: Matrix, mesh?: Mesh): void;
  30803. /**
  30804. * Binds the submesh to the material
  30805. * @param world defines the world transformation matrix
  30806. * @param mesh defines the mesh containing the submesh
  30807. * @param subMesh defines the submesh to bind the material to
  30808. */
  30809. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30810. /**
  30811. * Binds the world matrix to the material
  30812. * @param world defines the world transformation matrix
  30813. */
  30814. bindOnlyWorldMatrix(world: Matrix): void;
  30815. /**
  30816. * Binds the scene's uniform buffer to the effect.
  30817. * @param effect defines the effect to bind to the scene uniform buffer
  30818. * @param sceneUbo defines the uniform buffer storing scene data
  30819. */
  30820. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30821. /**
  30822. * Binds the view matrix to the effect
  30823. * @param effect defines the effect to bind the view matrix to
  30824. */
  30825. bindView(effect: Effect): void;
  30826. /**
  30827. * Binds the view projection matrix to the effect
  30828. * @param effect defines the effect to bind the view projection matrix to
  30829. */
  30830. bindViewProjection(effect: Effect): void;
  30831. /**
  30832. * Processes to execute after binding the material to a mesh
  30833. * @param mesh defines the rendered mesh
  30834. */
  30835. protected _afterBind(mesh?: Mesh): void;
  30836. /**
  30837. * Unbinds the material from the mesh
  30838. */
  30839. unbind(): void;
  30840. /**
  30841. * Gets the active textures from the material
  30842. * @returns an array of textures
  30843. */
  30844. getActiveTextures(): BaseTexture[];
  30845. /**
  30846. * Specifies if the material uses a texture
  30847. * @param texture defines the texture to check against the material
  30848. * @returns a boolean specifying if the material uses the texture
  30849. */
  30850. hasTexture(texture: BaseTexture): boolean;
  30851. /**
  30852. * Makes a duplicate of the material, and gives it a new name
  30853. * @param name defines the new name for the duplicated material
  30854. * @returns the cloned material
  30855. */
  30856. clone(name: string): Nullable<Material>;
  30857. /**
  30858. * Gets the meshes bound to the material
  30859. * @returns an array of meshes bound to the material
  30860. */
  30861. getBindedMeshes(): AbstractMesh[];
  30862. /**
  30863. * Force shader compilation
  30864. * @param mesh defines the mesh associated with this material
  30865. * @param onCompiled defines a function to execute once the material is compiled
  30866. * @param options defines the options to configure the compilation
  30867. * @param onError defines a function to execute if the material fails compiling
  30868. */
  30869. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30870. /**
  30871. * Force shader compilation
  30872. * @param mesh defines the mesh that will use this material
  30873. * @param options defines additional options for compiling the shaders
  30874. * @returns a promise that resolves when the compilation completes
  30875. */
  30876. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30877. private static readonly _AllDirtyCallBack;
  30878. private static readonly _ImageProcessingDirtyCallBack;
  30879. private static readonly _TextureDirtyCallBack;
  30880. private static readonly _FresnelDirtyCallBack;
  30881. private static readonly _MiscDirtyCallBack;
  30882. private static readonly _PrePassDirtyCallBack;
  30883. private static readonly _LightsDirtyCallBack;
  30884. private static readonly _AttributeDirtyCallBack;
  30885. private static _FresnelAndMiscDirtyCallBack;
  30886. private static _TextureAndMiscDirtyCallBack;
  30887. private static readonly _DirtyCallbackArray;
  30888. private static readonly _RunDirtyCallBacks;
  30889. /**
  30890. * Marks a define in the material to indicate that it needs to be re-computed
  30891. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30892. */
  30893. markAsDirty(flag: number): void;
  30894. /**
  30895. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30896. * @param func defines a function which checks material defines against the submeshes
  30897. */
  30898. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30899. /**
  30900. * Indicates that the scene should check if the rendering now needs a prepass
  30901. */
  30902. protected _markScenePrePassDirty(): void;
  30903. /**
  30904. * Indicates that we need to re-calculated for all submeshes
  30905. */
  30906. protected _markAllSubMeshesAsAllDirty(): void;
  30907. /**
  30908. * Indicates that image processing needs to be re-calculated for all submeshes
  30909. */
  30910. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30911. /**
  30912. * Indicates that textures need to be re-calculated for all submeshes
  30913. */
  30914. protected _markAllSubMeshesAsTexturesDirty(): void;
  30915. /**
  30916. * Indicates that fresnel needs to be re-calculated for all submeshes
  30917. */
  30918. protected _markAllSubMeshesAsFresnelDirty(): void;
  30919. /**
  30920. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30921. */
  30922. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30923. /**
  30924. * Indicates that lights need to be re-calculated for all submeshes
  30925. */
  30926. protected _markAllSubMeshesAsLightsDirty(): void;
  30927. /**
  30928. * Indicates that attributes need to be re-calculated for all submeshes
  30929. */
  30930. protected _markAllSubMeshesAsAttributesDirty(): void;
  30931. /**
  30932. * Indicates that misc needs to be re-calculated for all submeshes
  30933. */
  30934. protected _markAllSubMeshesAsMiscDirty(): void;
  30935. /**
  30936. * Indicates that prepass needs to be re-calculated for all submeshes
  30937. */
  30938. protected _markAllSubMeshesAsPrePassDirty(): void;
  30939. /**
  30940. * Indicates that textures and misc need to be re-calculated for all submeshes
  30941. */
  30942. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30943. /**
  30944. * Sets the required values to the prepass renderer.
  30945. * @param prePassRenderer defines the prepass renderer to setup.
  30946. * @returns true if the pre pass is needed.
  30947. */
  30948. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30949. /**
  30950. * Disposes the material
  30951. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30952. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30953. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30954. */
  30955. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30956. /** @hidden */
  30957. private releaseVertexArrayObject;
  30958. /**
  30959. * Serializes this material
  30960. * @returns the serialized material object
  30961. */
  30962. serialize(): any;
  30963. /**
  30964. * Creates a material from parsed material data
  30965. * @param parsedMaterial defines parsed material data
  30966. * @param scene defines the hosting scene
  30967. * @param rootUrl defines the root URL to use to load textures
  30968. * @returns a new material
  30969. */
  30970. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30971. }
  30972. }
  30973. declare module "babylonjs/Materials/multiMaterial" {
  30974. import { Nullable } from "babylonjs/types";
  30975. import { Scene } from "babylonjs/scene";
  30976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30977. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30979. import { Material } from "babylonjs/Materials/material";
  30980. /**
  30981. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30982. * separate meshes. This can be use to improve performances.
  30983. * @see https://doc.babylonjs.com/how_to/multi_materials
  30984. */
  30985. export class MultiMaterial extends Material {
  30986. private _subMaterials;
  30987. /**
  30988. * Gets or Sets the list of Materials used within the multi material.
  30989. * They need to be ordered according to the submeshes order in the associated mesh
  30990. */
  30991. get subMaterials(): Nullable<Material>[];
  30992. set subMaterials(value: Nullable<Material>[]);
  30993. /**
  30994. * Function used to align with Node.getChildren()
  30995. * @returns the list of Materials used within the multi material
  30996. */
  30997. getChildren(): Nullable<Material>[];
  30998. /**
  30999. * Instantiates a new Multi Material
  31000. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31001. * separate meshes. This can be use to improve performances.
  31002. * @see https://doc.babylonjs.com/how_to/multi_materials
  31003. * @param name Define the name in the scene
  31004. * @param scene Define the scene the material belongs to
  31005. */
  31006. constructor(name: string, scene: Scene);
  31007. private _hookArray;
  31008. /**
  31009. * Get one of the submaterial by its index in the submaterials array
  31010. * @param index The index to look the sub material at
  31011. * @returns The Material if the index has been defined
  31012. */
  31013. getSubMaterial(index: number): Nullable<Material>;
  31014. /**
  31015. * Get the list of active textures for the whole sub materials list.
  31016. * @returns All the textures that will be used during the rendering
  31017. */
  31018. getActiveTextures(): BaseTexture[];
  31019. /**
  31020. * Gets the current class name of the material e.g. "MultiMaterial"
  31021. * Mainly use in serialization.
  31022. * @returns the class name
  31023. */
  31024. getClassName(): string;
  31025. /**
  31026. * Checks if the material is ready to render the requested sub mesh
  31027. * @param mesh Define the mesh the submesh belongs to
  31028. * @param subMesh Define the sub mesh to look readyness for
  31029. * @param useInstances Define whether or not the material is used with instances
  31030. * @returns true if ready, otherwise false
  31031. */
  31032. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31033. /**
  31034. * Clones the current material and its related sub materials
  31035. * @param name Define the name of the newly cloned material
  31036. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31037. * @returns the cloned material
  31038. */
  31039. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31040. /**
  31041. * Serializes the materials into a JSON representation.
  31042. * @returns the JSON representation
  31043. */
  31044. serialize(): any;
  31045. /**
  31046. * Dispose the material and release its associated resources
  31047. * @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)
  31048. * @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)
  31049. * @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)
  31050. */
  31051. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31052. /**
  31053. * Creates a MultiMaterial from parsed MultiMaterial data.
  31054. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31055. * @param scene defines the hosting scene
  31056. * @returns a new MultiMaterial
  31057. */
  31058. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31059. }
  31060. }
  31061. declare module "babylonjs/Meshes/subMesh" {
  31062. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  31063. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  31064. import { Engine } from "babylonjs/Engines/engine";
  31065. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  31066. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31067. import { Effect } from "babylonjs/Materials/effect";
  31068. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31069. import { Plane } from "babylonjs/Maths/math.plane";
  31070. import { Collider } from "babylonjs/Collisions/collider";
  31071. import { Material } from "babylonjs/Materials/material";
  31072. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31074. import { Mesh } from "babylonjs/Meshes/mesh";
  31075. import { Ray } from "babylonjs/Culling/ray";
  31076. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31077. /**
  31078. * Defines a subdivision inside a mesh
  31079. */
  31080. export class SubMesh implements ICullable {
  31081. /** the material index to use */
  31082. materialIndex: number;
  31083. /** vertex index start */
  31084. verticesStart: number;
  31085. /** vertices count */
  31086. verticesCount: number;
  31087. /** index start */
  31088. indexStart: number;
  31089. /** indices count */
  31090. indexCount: number;
  31091. /** @hidden */
  31092. _materialDefines: Nullable<MaterialDefines>;
  31093. /** @hidden */
  31094. _materialEffect: Nullable<Effect>;
  31095. /** @hidden */
  31096. _effectOverride: Nullable<Effect>;
  31097. /**
  31098. * Gets material defines used by the effect associated to the sub mesh
  31099. */
  31100. get materialDefines(): Nullable<MaterialDefines>;
  31101. /**
  31102. * Sets material defines used by the effect associated to the sub mesh
  31103. */
  31104. set materialDefines(defines: Nullable<MaterialDefines>);
  31105. /**
  31106. * Gets associated effect
  31107. */
  31108. get effect(): Nullable<Effect>;
  31109. /**
  31110. * Sets associated effect (effect used to render this submesh)
  31111. * @param effect defines the effect to associate with
  31112. * @param defines defines the set of defines used to compile this effect
  31113. */
  31114. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31115. /** @hidden */
  31116. _linesIndexCount: number;
  31117. private _mesh;
  31118. private _renderingMesh;
  31119. private _boundingInfo;
  31120. private _linesIndexBuffer;
  31121. /** @hidden */
  31122. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31123. /** @hidden */
  31124. _trianglePlanes: Plane[];
  31125. /** @hidden */
  31126. _lastColliderTransformMatrix: Nullable<Matrix>;
  31127. /** @hidden */
  31128. _renderId: number;
  31129. /** @hidden */
  31130. _alphaIndex: number;
  31131. /** @hidden */
  31132. _distanceToCamera: number;
  31133. /** @hidden */
  31134. _id: number;
  31135. private _currentMaterial;
  31136. /**
  31137. * Add a new submesh to a mesh
  31138. * @param materialIndex defines the material index to use
  31139. * @param verticesStart defines vertex index start
  31140. * @param verticesCount defines vertices count
  31141. * @param indexStart defines index start
  31142. * @param indexCount defines indices count
  31143. * @param mesh defines the parent mesh
  31144. * @param renderingMesh defines an optional rendering mesh
  31145. * @param createBoundingBox defines if bounding box should be created for this submesh
  31146. * @returns the new submesh
  31147. */
  31148. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31149. /**
  31150. * Creates a new submesh
  31151. * @param materialIndex defines the material index to use
  31152. * @param verticesStart defines vertex index start
  31153. * @param verticesCount defines vertices count
  31154. * @param indexStart defines index start
  31155. * @param indexCount defines indices count
  31156. * @param mesh defines the parent mesh
  31157. * @param renderingMesh defines an optional rendering mesh
  31158. * @param createBoundingBox defines if bounding box should be created for this submesh
  31159. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31160. */
  31161. constructor(
  31162. /** the material index to use */
  31163. materialIndex: number,
  31164. /** vertex index start */
  31165. verticesStart: number,
  31166. /** vertices count */
  31167. verticesCount: number,
  31168. /** index start */
  31169. indexStart: number,
  31170. /** indices count */
  31171. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31172. /**
  31173. * Returns true if this submesh covers the entire parent mesh
  31174. * @ignorenaming
  31175. */
  31176. get IsGlobal(): boolean;
  31177. /**
  31178. * Returns the submesh BoudingInfo object
  31179. * @returns current bounding info (or mesh's one if the submesh is global)
  31180. */
  31181. getBoundingInfo(): BoundingInfo;
  31182. /**
  31183. * Sets the submesh BoundingInfo
  31184. * @param boundingInfo defines the new bounding info to use
  31185. * @returns the SubMesh
  31186. */
  31187. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31188. /**
  31189. * Returns the mesh of the current submesh
  31190. * @return the parent mesh
  31191. */
  31192. getMesh(): AbstractMesh;
  31193. /**
  31194. * Returns the rendering mesh of the submesh
  31195. * @returns the rendering mesh (could be different from parent mesh)
  31196. */
  31197. getRenderingMesh(): Mesh;
  31198. /**
  31199. * Returns the replacement mesh of the submesh
  31200. * @returns the replacement mesh (could be different from parent mesh)
  31201. */
  31202. getReplacementMesh(): Nullable<AbstractMesh>;
  31203. /**
  31204. * Returns the effective mesh of the submesh
  31205. * @returns the effective mesh (could be different from parent mesh)
  31206. */
  31207. getEffectiveMesh(): AbstractMesh;
  31208. /**
  31209. * Returns the submesh material
  31210. * @returns null or the current material
  31211. */
  31212. getMaterial(): Nullable<Material>;
  31213. private _IsMultiMaterial;
  31214. /**
  31215. * Sets a new updated BoundingInfo object to the submesh
  31216. * @param data defines an optional position array to use to determine the bounding info
  31217. * @returns the SubMesh
  31218. */
  31219. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31220. /** @hidden */
  31221. _checkCollision(collider: Collider): boolean;
  31222. /**
  31223. * Updates the submesh BoundingInfo
  31224. * @param world defines the world matrix to use to update the bounding info
  31225. * @returns the submesh
  31226. */
  31227. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31228. /**
  31229. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31230. * @param frustumPlanes defines the frustum planes
  31231. * @returns true if the submesh is intersecting with the frustum
  31232. */
  31233. isInFrustum(frustumPlanes: Plane[]): boolean;
  31234. /**
  31235. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31236. * @param frustumPlanes defines the frustum planes
  31237. * @returns true if the submesh is inside the frustum
  31238. */
  31239. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31240. /**
  31241. * Renders the submesh
  31242. * @param enableAlphaMode defines if alpha needs to be used
  31243. * @returns the submesh
  31244. */
  31245. render(enableAlphaMode: boolean): SubMesh;
  31246. /**
  31247. * @hidden
  31248. */
  31249. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31250. /**
  31251. * Checks if the submesh intersects with a ray
  31252. * @param ray defines the ray to test
  31253. * @returns true is the passed ray intersects the submesh bounding box
  31254. */
  31255. canIntersects(ray: Ray): boolean;
  31256. /**
  31257. * Intersects current submesh with a ray
  31258. * @param ray defines the ray to test
  31259. * @param positions defines mesh's positions array
  31260. * @param indices defines mesh's indices array
  31261. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31262. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31263. * @returns intersection info or null if no intersection
  31264. */
  31265. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31266. /** @hidden */
  31267. private _intersectLines;
  31268. /** @hidden */
  31269. private _intersectUnIndexedLines;
  31270. /** @hidden */
  31271. private _intersectTriangles;
  31272. /** @hidden */
  31273. private _intersectUnIndexedTriangles;
  31274. /** @hidden */
  31275. _rebuild(): void;
  31276. /**
  31277. * Creates a new submesh from the passed mesh
  31278. * @param newMesh defines the new hosting mesh
  31279. * @param newRenderingMesh defines an optional rendering mesh
  31280. * @returns the new submesh
  31281. */
  31282. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31283. /**
  31284. * Release associated resources
  31285. */
  31286. dispose(): void;
  31287. /**
  31288. * Gets the class name
  31289. * @returns the string "SubMesh".
  31290. */
  31291. getClassName(): string;
  31292. /**
  31293. * Creates a new submesh from indices data
  31294. * @param materialIndex the index of the main mesh material
  31295. * @param startIndex the index where to start the copy in the mesh indices array
  31296. * @param indexCount the number of indices to copy then from the startIndex
  31297. * @param mesh the main mesh to create the submesh from
  31298. * @param renderingMesh the optional rendering mesh
  31299. * @returns a new submesh
  31300. */
  31301. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31302. }
  31303. }
  31304. declare module "babylonjs/Loading/sceneLoaderFlags" {
  31305. /**
  31306. * Class used to represent data loading progression
  31307. */
  31308. export class SceneLoaderFlags {
  31309. private static _ForceFullSceneLoadingForIncremental;
  31310. private static _ShowLoadingScreen;
  31311. private static _CleanBoneMatrixWeights;
  31312. private static _loggingLevel;
  31313. /**
  31314. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31315. */
  31316. static get ForceFullSceneLoadingForIncremental(): boolean;
  31317. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31318. /**
  31319. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31320. */
  31321. static get ShowLoadingScreen(): boolean;
  31322. static set ShowLoadingScreen(value: boolean);
  31323. /**
  31324. * Defines the current logging level (while loading the scene)
  31325. * @ignorenaming
  31326. */
  31327. static get loggingLevel(): number;
  31328. static set loggingLevel(value: number);
  31329. /**
  31330. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31331. */
  31332. static get CleanBoneMatrixWeights(): boolean;
  31333. static set CleanBoneMatrixWeights(value: boolean);
  31334. }
  31335. }
  31336. declare module "babylonjs/Meshes/geometry" {
  31337. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  31338. import { Scene } from "babylonjs/scene";
  31339. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31340. import { Engine } from "babylonjs/Engines/engine";
  31341. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  31342. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31343. import { Effect } from "babylonjs/Materials/effect";
  31344. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31345. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31346. import { Mesh } from "babylonjs/Meshes/mesh";
  31347. /**
  31348. * Class used to store geometry data (vertex buffers + index buffer)
  31349. */
  31350. export class Geometry implements IGetSetVerticesData {
  31351. /**
  31352. * Gets or sets the ID of the geometry
  31353. */
  31354. id: string;
  31355. /**
  31356. * Gets or sets the unique ID of the geometry
  31357. */
  31358. uniqueId: number;
  31359. /**
  31360. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31361. */
  31362. delayLoadState: number;
  31363. /**
  31364. * Gets the file containing the data to load when running in delay load state
  31365. */
  31366. delayLoadingFile: Nullable<string>;
  31367. /**
  31368. * Callback called when the geometry is updated
  31369. */
  31370. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31371. private _scene;
  31372. private _engine;
  31373. private _meshes;
  31374. private _totalVertices;
  31375. /** @hidden */
  31376. _indices: IndicesArray;
  31377. /** @hidden */
  31378. _vertexBuffers: {
  31379. [key: string]: VertexBuffer;
  31380. };
  31381. private _isDisposed;
  31382. private _extend;
  31383. private _boundingBias;
  31384. /** @hidden */
  31385. _delayInfo: Array<string>;
  31386. private _indexBuffer;
  31387. private _indexBufferIsUpdatable;
  31388. /** @hidden */
  31389. _boundingInfo: Nullable<BoundingInfo>;
  31390. /** @hidden */
  31391. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31392. /** @hidden */
  31393. _softwareSkinningFrameId: number;
  31394. private _vertexArrayObjects;
  31395. private _updatable;
  31396. /** @hidden */
  31397. _positions: Nullable<Vector3[]>;
  31398. private _positionsCache;
  31399. /**
  31400. * 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
  31401. */
  31402. get boundingBias(): Vector2;
  31403. /**
  31404. * 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
  31405. */
  31406. set boundingBias(value: Vector2);
  31407. /**
  31408. * Static function used to attach a new empty geometry to a mesh
  31409. * @param mesh defines the mesh to attach the geometry to
  31410. * @returns the new Geometry
  31411. */
  31412. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31413. /** Get the list of meshes using this geometry */
  31414. get meshes(): Mesh[];
  31415. /**
  31416. * 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
  31417. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31418. */
  31419. useBoundingInfoFromGeometry: boolean;
  31420. /**
  31421. * Creates a new geometry
  31422. * @param id defines the unique ID
  31423. * @param scene defines the hosting scene
  31424. * @param vertexData defines the VertexData used to get geometry data
  31425. * @param updatable defines if geometry must be updatable (false by default)
  31426. * @param mesh defines the mesh that will be associated with the geometry
  31427. */
  31428. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31429. /**
  31430. * Gets the current extend of the geometry
  31431. */
  31432. get extend(): {
  31433. minimum: Vector3;
  31434. maximum: Vector3;
  31435. };
  31436. /**
  31437. * Gets the hosting scene
  31438. * @returns the hosting Scene
  31439. */
  31440. getScene(): Scene;
  31441. /**
  31442. * Gets the hosting engine
  31443. * @returns the hosting Engine
  31444. */
  31445. getEngine(): Engine;
  31446. /**
  31447. * Defines if the geometry is ready to use
  31448. * @returns true if the geometry is ready to be used
  31449. */
  31450. isReady(): boolean;
  31451. /**
  31452. * Gets a value indicating that the geometry should not be serialized
  31453. */
  31454. get doNotSerialize(): boolean;
  31455. /** @hidden */
  31456. _rebuild(): void;
  31457. /**
  31458. * Affects all geometry data in one call
  31459. * @param vertexData defines the geometry data
  31460. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31461. */
  31462. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31463. /**
  31464. * Set specific vertex data
  31465. * @param kind defines the data kind (Position, normal, etc...)
  31466. * @param data defines the vertex data to use
  31467. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31468. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31469. */
  31470. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31471. /**
  31472. * Removes a specific vertex data
  31473. * @param kind defines the data kind (Position, normal, etc...)
  31474. */
  31475. removeVerticesData(kind: string): void;
  31476. /**
  31477. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31478. * @param buffer defines the vertex buffer to use
  31479. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31480. */
  31481. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31482. /**
  31483. * Update a specific vertex buffer
  31484. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31485. * It will do nothing if the buffer is not updatable
  31486. * @param kind defines the data kind (Position, normal, etc...)
  31487. * @param data defines the data to use
  31488. * @param offset defines the offset in the target buffer where to store the data
  31489. * @param useBytes set to true if the offset is in bytes
  31490. */
  31491. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31492. /**
  31493. * Update a specific vertex buffer
  31494. * This function will create a new buffer if the current one is not updatable
  31495. * @param kind defines the data kind (Position, normal, etc...)
  31496. * @param data defines the data to use
  31497. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31498. */
  31499. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31500. private _updateBoundingInfo;
  31501. /** @hidden */
  31502. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31503. /**
  31504. * Gets total number of vertices
  31505. * @returns the total number of vertices
  31506. */
  31507. getTotalVertices(): number;
  31508. /**
  31509. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31510. * @param kind defines the data kind (Position, normal, etc...)
  31511. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31512. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31513. * @returns a float array containing vertex data
  31514. */
  31515. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31516. /**
  31517. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31518. * @param kind defines the data kind (Position, normal, etc...)
  31519. * @returns true if the vertex buffer with the specified kind is updatable
  31520. */
  31521. isVertexBufferUpdatable(kind: string): boolean;
  31522. /**
  31523. * Gets a specific vertex buffer
  31524. * @param kind defines the data kind (Position, normal, etc...)
  31525. * @returns a VertexBuffer
  31526. */
  31527. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31528. /**
  31529. * Returns all vertex buffers
  31530. * @return an object holding all vertex buffers indexed by kind
  31531. */
  31532. getVertexBuffers(): Nullable<{
  31533. [key: string]: VertexBuffer;
  31534. }>;
  31535. /**
  31536. * Gets a boolean indicating if specific vertex buffer is present
  31537. * @param kind defines the data kind (Position, normal, etc...)
  31538. * @returns true if data is present
  31539. */
  31540. isVerticesDataPresent(kind: string): boolean;
  31541. /**
  31542. * Gets a list of all attached data kinds (Position, normal, etc...)
  31543. * @returns a list of string containing all kinds
  31544. */
  31545. getVerticesDataKinds(): string[];
  31546. /**
  31547. * Update index buffer
  31548. * @param indices defines the indices to store in the index buffer
  31549. * @param offset defines the offset in the target buffer where to store the data
  31550. * @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)
  31551. */
  31552. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31553. /**
  31554. * Creates a new index buffer
  31555. * @param indices defines the indices to store in the index buffer
  31556. * @param totalVertices defines the total number of vertices (could be null)
  31557. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31558. */
  31559. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31560. /**
  31561. * Return the total number of indices
  31562. * @returns the total number of indices
  31563. */
  31564. getTotalIndices(): number;
  31565. /**
  31566. * Gets the index buffer array
  31567. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31568. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31569. * @returns the index buffer array
  31570. */
  31571. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31572. /**
  31573. * Gets the index buffer
  31574. * @return the index buffer
  31575. */
  31576. getIndexBuffer(): Nullable<DataBuffer>;
  31577. /** @hidden */
  31578. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31579. /**
  31580. * Release the associated resources for a specific mesh
  31581. * @param mesh defines the source mesh
  31582. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31583. */
  31584. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31585. /**
  31586. * Apply current geometry to a given mesh
  31587. * @param mesh defines the mesh to apply geometry to
  31588. */
  31589. applyToMesh(mesh: Mesh): void;
  31590. private _updateExtend;
  31591. private _applyToMesh;
  31592. private notifyUpdate;
  31593. /**
  31594. * Load the geometry if it was flagged as delay loaded
  31595. * @param scene defines the hosting scene
  31596. * @param onLoaded defines a callback called when the geometry is loaded
  31597. */
  31598. load(scene: Scene, onLoaded?: () => void): void;
  31599. private _queueLoad;
  31600. /**
  31601. * Invert the geometry to move from a right handed system to a left handed one.
  31602. */
  31603. toLeftHanded(): void;
  31604. /** @hidden */
  31605. _resetPointsArrayCache(): void;
  31606. /** @hidden */
  31607. _generatePointsArray(): boolean;
  31608. /**
  31609. * Gets a value indicating if the geometry is disposed
  31610. * @returns true if the geometry was disposed
  31611. */
  31612. isDisposed(): boolean;
  31613. private _disposeVertexArrayObjects;
  31614. /**
  31615. * Free all associated resources
  31616. */
  31617. dispose(): void;
  31618. /**
  31619. * Clone the current geometry into a new geometry
  31620. * @param id defines the unique ID of the new geometry
  31621. * @returns a new geometry object
  31622. */
  31623. copy(id: string): Geometry;
  31624. /**
  31625. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31626. * @return a JSON representation of the current geometry data (without the vertices data)
  31627. */
  31628. serialize(): any;
  31629. private toNumberArray;
  31630. /**
  31631. * Serialize all vertices data into a JSON oject
  31632. * @returns a JSON representation of the current geometry data
  31633. */
  31634. serializeVerticeData(): any;
  31635. /**
  31636. * Extracts a clone of a mesh geometry
  31637. * @param mesh defines the source mesh
  31638. * @param id defines the unique ID of the new geometry object
  31639. * @returns the new geometry object
  31640. */
  31641. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31642. /**
  31643. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31644. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31645. * Be aware Math.random() could cause collisions, but:
  31646. * "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"
  31647. * @returns a string containing a new GUID
  31648. */
  31649. static RandomId(): string;
  31650. /** @hidden */
  31651. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31652. private static _CleanMatricesWeights;
  31653. /**
  31654. * Create a new geometry from persisted data (Using .babylon file format)
  31655. * @param parsedVertexData defines the persisted data
  31656. * @param scene defines the hosting scene
  31657. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31658. * @returns the new geometry object
  31659. */
  31660. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31661. }
  31662. }
  31663. declare module "babylonjs/Meshes/mesh.vertexData" {
  31664. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  31665. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  31666. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  31667. import { Geometry } from "babylonjs/Meshes/geometry";
  31668. import { Mesh } from "babylonjs/Meshes/mesh";
  31669. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  31670. /**
  31671. * Define an interface for all classes that will get and set the data on vertices
  31672. */
  31673. export interface IGetSetVerticesData {
  31674. /**
  31675. * Gets a boolean indicating if specific vertex data is present
  31676. * @param kind defines the vertex data kind to use
  31677. * @returns true is data kind is present
  31678. */
  31679. isVerticesDataPresent(kind: string): boolean;
  31680. /**
  31681. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31682. * @param kind defines the data kind (Position, normal, etc...)
  31683. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31684. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31685. * @returns a float array containing vertex data
  31686. */
  31687. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31688. /**
  31689. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  31690. * @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.
  31691. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31692. * @returns the indices array or an empty array if the mesh has no geometry
  31693. */
  31694. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31695. /**
  31696. * Set specific vertex data
  31697. * @param kind defines the data kind (Position, normal, etc...)
  31698. * @param data defines the vertex data to use
  31699. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31700. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31701. */
  31702. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  31703. /**
  31704. * Update a specific associated vertex buffer
  31705. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  31706. * - VertexBuffer.PositionKind
  31707. * - VertexBuffer.UVKind
  31708. * - VertexBuffer.UV2Kind
  31709. * - VertexBuffer.UV3Kind
  31710. * - VertexBuffer.UV4Kind
  31711. * - VertexBuffer.UV5Kind
  31712. * - VertexBuffer.UV6Kind
  31713. * - VertexBuffer.ColorKind
  31714. * - VertexBuffer.MatricesIndicesKind
  31715. * - VertexBuffer.MatricesIndicesExtraKind
  31716. * - VertexBuffer.MatricesWeightsKind
  31717. * - VertexBuffer.MatricesWeightsExtraKind
  31718. * @param data defines the data source
  31719. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  31720. * @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)
  31721. */
  31722. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  31723. /**
  31724. * Creates a new index buffer
  31725. * @param indices defines the indices to store in the index buffer
  31726. * @param totalVertices defines the total number of vertices (could be null)
  31727. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31728. */
  31729. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  31730. }
  31731. /**
  31732. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  31733. */
  31734. export class VertexData {
  31735. /**
  31736. * Mesh side orientation : usually the external or front surface
  31737. */
  31738. static readonly FRONTSIDE: number;
  31739. /**
  31740. * Mesh side orientation : usually the internal or back surface
  31741. */
  31742. static readonly BACKSIDE: number;
  31743. /**
  31744. * Mesh side orientation : both internal and external or front and back surfaces
  31745. */
  31746. static readonly DOUBLESIDE: number;
  31747. /**
  31748. * Mesh side orientation : by default, `FRONTSIDE`
  31749. */
  31750. static readonly DEFAULTSIDE: number;
  31751. /**
  31752. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  31753. */
  31754. positions: Nullable<FloatArray>;
  31755. /**
  31756. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  31757. */
  31758. normals: Nullable<FloatArray>;
  31759. /**
  31760. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  31761. */
  31762. tangents: Nullable<FloatArray>;
  31763. /**
  31764. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31765. */
  31766. uvs: Nullable<FloatArray>;
  31767. /**
  31768. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31769. */
  31770. uvs2: Nullable<FloatArray>;
  31771. /**
  31772. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31773. */
  31774. uvs3: Nullable<FloatArray>;
  31775. /**
  31776. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31777. */
  31778. uvs4: Nullable<FloatArray>;
  31779. /**
  31780. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31781. */
  31782. uvs5: Nullable<FloatArray>;
  31783. /**
  31784. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31785. */
  31786. uvs6: Nullable<FloatArray>;
  31787. /**
  31788. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  31789. */
  31790. colors: Nullable<FloatArray>;
  31791. /**
  31792. * 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).
  31793. */
  31794. matricesIndices: Nullable<FloatArray>;
  31795. /**
  31796. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  31797. */
  31798. matricesWeights: Nullable<FloatArray>;
  31799. /**
  31800. * An array extending the number of possible indices
  31801. */
  31802. matricesIndicesExtra: Nullable<FloatArray>;
  31803. /**
  31804. * An array extending the number of possible weights when the number of indices is extended
  31805. */
  31806. matricesWeightsExtra: Nullable<FloatArray>;
  31807. /**
  31808. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  31809. */
  31810. indices: Nullable<IndicesArray>;
  31811. /**
  31812. * Uses the passed data array to set the set the values for the specified kind of data
  31813. * @param data a linear array of floating numbers
  31814. * @param kind the type of data that is being set, eg positions, colors etc
  31815. */
  31816. set(data: FloatArray, kind: string): void;
  31817. /**
  31818. * Associates the vertexData to the passed Mesh.
  31819. * Sets it as updatable or not (default `false`)
  31820. * @param mesh the mesh the vertexData is applied to
  31821. * @param updatable when used and having the value true allows new data to update the vertexData
  31822. * @returns the VertexData
  31823. */
  31824. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  31825. /**
  31826. * Associates the vertexData to the passed Geometry.
  31827. * Sets it as updatable or not (default `false`)
  31828. * @param geometry the geometry the vertexData is applied to
  31829. * @param updatable when used and having the value true allows new data to update the vertexData
  31830. * @returns VertexData
  31831. */
  31832. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  31833. /**
  31834. * Updates the associated mesh
  31835. * @param mesh the mesh to be updated
  31836. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31837. * @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
  31838. * @returns VertexData
  31839. */
  31840. updateMesh(mesh: Mesh): VertexData;
  31841. /**
  31842. * Updates the associated geometry
  31843. * @param geometry the geometry to be updated
  31844. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31845. * @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
  31846. * @returns VertexData.
  31847. */
  31848. updateGeometry(geometry: Geometry): VertexData;
  31849. private _applyTo;
  31850. private _update;
  31851. /**
  31852. * Transforms each position and each normal of the vertexData according to the passed Matrix
  31853. * @param matrix the transforming matrix
  31854. * @returns the VertexData
  31855. */
  31856. transform(matrix: Matrix): VertexData;
  31857. /**
  31858. * Merges the passed VertexData into the current one
  31859. * @param other the VertexData to be merged into the current one
  31860. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  31861. * @returns the modified VertexData
  31862. */
  31863. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  31864. private _mergeElement;
  31865. private _validate;
  31866. /**
  31867. * Serializes the VertexData
  31868. * @returns a serialized object
  31869. */
  31870. serialize(): any;
  31871. /**
  31872. * Extracts the vertexData from a mesh
  31873. * @param mesh the mesh from which to extract the VertexData
  31874. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  31875. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31876. * @returns the object VertexData associated to the passed mesh
  31877. */
  31878. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31879. /**
  31880. * Extracts the vertexData from the geometry
  31881. * @param geometry the geometry from which to extract the VertexData
  31882. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  31883. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31884. * @returns the object VertexData associated to the passed mesh
  31885. */
  31886. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31887. private static _ExtractFrom;
  31888. /**
  31889. * Creates the VertexData for a Ribbon
  31890. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  31891. * * pathArray array of paths, each of which an array of successive Vector3
  31892. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  31893. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  31894. * * 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
  31895. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31896. * * 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)
  31897. * * 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)
  31898. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  31899. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  31900. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  31901. * @returns the VertexData of the ribbon
  31902. */
  31903. static CreateRibbon(options: {
  31904. pathArray: Vector3[][];
  31905. closeArray?: boolean;
  31906. closePath?: boolean;
  31907. offset?: number;
  31908. sideOrientation?: number;
  31909. frontUVs?: Vector4;
  31910. backUVs?: Vector4;
  31911. invertUV?: boolean;
  31912. uvs?: Vector2[];
  31913. colors?: Color4[];
  31914. }): VertexData;
  31915. /**
  31916. * Creates the VertexData for a box
  31917. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31918. * * size sets the width, height and depth of the box to the value of size, optional default 1
  31919. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  31920. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  31921. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  31922. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31923. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31924. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31925. * * 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)
  31926. * * 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)
  31927. * @returns the VertexData of the box
  31928. */
  31929. static CreateBox(options: {
  31930. size?: number;
  31931. width?: number;
  31932. height?: number;
  31933. depth?: number;
  31934. faceUV?: Vector4[];
  31935. faceColors?: Color4[];
  31936. sideOrientation?: number;
  31937. frontUVs?: Vector4;
  31938. backUVs?: Vector4;
  31939. }): VertexData;
  31940. /**
  31941. * Creates the VertexData for a tiled box
  31942. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31943. * * faceTiles sets the pattern, tile size and number of tiles for a face
  31944. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31945. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31946. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31947. * @returns the VertexData of the box
  31948. */
  31949. static CreateTiledBox(options: {
  31950. pattern?: number;
  31951. width?: number;
  31952. height?: number;
  31953. depth?: number;
  31954. tileSize?: number;
  31955. tileWidth?: number;
  31956. tileHeight?: number;
  31957. alignHorizontal?: number;
  31958. alignVertical?: number;
  31959. faceUV?: Vector4[];
  31960. faceColors?: Color4[];
  31961. sideOrientation?: number;
  31962. }): VertexData;
  31963. /**
  31964. * Creates the VertexData for a tiled plane
  31965. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31966. * * pattern a limited pattern arrangement depending on the number
  31967. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  31968. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  31969. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  31970. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31971. * * 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)
  31972. * * 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)
  31973. * @returns the VertexData of the tiled plane
  31974. */
  31975. static CreateTiledPlane(options: {
  31976. pattern?: number;
  31977. tileSize?: number;
  31978. tileWidth?: number;
  31979. tileHeight?: number;
  31980. size?: number;
  31981. width?: number;
  31982. height?: number;
  31983. alignHorizontal?: number;
  31984. alignVertical?: number;
  31985. sideOrientation?: number;
  31986. frontUVs?: Vector4;
  31987. backUVs?: Vector4;
  31988. }): VertexData;
  31989. /**
  31990. * Creates the VertexData for an ellipsoid, defaults to a sphere
  31991. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31992. * * segments sets the number of horizontal strips optional, default 32
  31993. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  31994. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  31995. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  31996. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  31997. * * 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
  31998. * * 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
  31999. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32000. * * 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)
  32001. * * 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)
  32002. * @returns the VertexData of the ellipsoid
  32003. */
  32004. static CreateSphere(options: {
  32005. segments?: number;
  32006. diameter?: number;
  32007. diameterX?: number;
  32008. diameterY?: number;
  32009. diameterZ?: number;
  32010. arc?: number;
  32011. slice?: number;
  32012. sideOrientation?: number;
  32013. frontUVs?: Vector4;
  32014. backUVs?: Vector4;
  32015. }): VertexData;
  32016. /**
  32017. * Creates the VertexData for a cylinder, cone or prism
  32018. * @param options an object used to set the following optional parameters for the box, required but can be empty
  32019. * * height sets the height (y direction) of the cylinder, optional, default 2
  32020. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  32021. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  32022. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  32023. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  32024. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  32025. * * 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
  32026. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  32027. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  32028. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  32029. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  32030. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32031. * * 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)
  32032. * * 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)
  32033. * @returns the VertexData of the cylinder, cone or prism
  32034. */
  32035. static CreateCylinder(options: {
  32036. height?: number;
  32037. diameterTop?: number;
  32038. diameterBottom?: number;
  32039. diameter?: number;
  32040. tessellation?: number;
  32041. subdivisions?: number;
  32042. arc?: number;
  32043. faceColors?: Color4[];
  32044. faceUV?: Vector4[];
  32045. hasRings?: boolean;
  32046. enclose?: boolean;
  32047. sideOrientation?: number;
  32048. frontUVs?: Vector4;
  32049. backUVs?: Vector4;
  32050. }): VertexData;
  32051. /**
  32052. * Creates the VertexData for a torus
  32053. * @param options an object used to set the following optional parameters for the box, required but can be empty
  32054. * * diameter the diameter of the torus, optional default 1
  32055. * * thickness the diameter of the tube forming the torus, optional default 0.5
  32056. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  32057. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32058. * * 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)
  32059. * * 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)
  32060. * @returns the VertexData of the torus
  32061. */
  32062. static CreateTorus(options: {
  32063. diameter?: number;
  32064. thickness?: number;
  32065. tessellation?: number;
  32066. sideOrientation?: number;
  32067. frontUVs?: Vector4;
  32068. backUVs?: Vector4;
  32069. }): VertexData;
  32070. /**
  32071. * Creates the VertexData of the LineSystem
  32072. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  32073. * - lines an array of lines, each line being an array of successive Vector3
  32074. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  32075. * @returns the VertexData of the LineSystem
  32076. */
  32077. static CreateLineSystem(options: {
  32078. lines: Vector3[][];
  32079. colors?: Nullable<Color4[][]>;
  32080. }): VertexData;
  32081. /**
  32082. * Create the VertexData for a DashedLines
  32083. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  32084. * - points an array successive Vector3
  32085. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  32086. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  32087. * - dashNb the intended total number of dashes, optional, default 200
  32088. * @returns the VertexData for the DashedLines
  32089. */
  32090. static CreateDashedLines(options: {
  32091. points: Vector3[];
  32092. dashSize?: number;
  32093. gapSize?: number;
  32094. dashNb?: number;
  32095. }): VertexData;
  32096. /**
  32097. * Creates the VertexData for a Ground
  32098. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  32099. * - width the width (x direction) of the ground, optional, default 1
  32100. * - height the height (z direction) of the ground, optional, default 1
  32101. * - subdivisions the number of subdivisions per side, optional, default 1
  32102. * @returns the VertexData of the Ground
  32103. */
  32104. static CreateGround(options: {
  32105. width?: number;
  32106. height?: number;
  32107. subdivisions?: number;
  32108. subdivisionsX?: number;
  32109. subdivisionsY?: number;
  32110. }): VertexData;
  32111. /**
  32112. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  32113. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  32114. * * xmin the ground minimum X coordinate, optional, default -1
  32115. * * zmin the ground minimum Z coordinate, optional, default -1
  32116. * * xmax the ground maximum X coordinate, optional, default 1
  32117. * * zmax the ground maximum Z coordinate, optional, default 1
  32118. * * 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}
  32119. * * 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}
  32120. * @returns the VertexData of the TiledGround
  32121. */
  32122. static CreateTiledGround(options: {
  32123. xmin: number;
  32124. zmin: number;
  32125. xmax: number;
  32126. zmax: number;
  32127. subdivisions?: {
  32128. w: number;
  32129. h: number;
  32130. };
  32131. precision?: {
  32132. w: number;
  32133. h: number;
  32134. };
  32135. }): VertexData;
  32136. /**
  32137. * Creates the VertexData of the Ground designed from a heightmap
  32138. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  32139. * * width the width (x direction) of the ground
  32140. * * height the height (z direction) of the ground
  32141. * * subdivisions the number of subdivisions per side
  32142. * * minHeight the minimum altitude on the ground, optional, default 0
  32143. * * maxHeight the maximum altitude on the ground, optional default 1
  32144. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  32145. * * buffer the array holding the image color data
  32146. * * bufferWidth the width of image
  32147. * * bufferHeight the height of image
  32148. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  32149. * @returns the VertexData of the Ground designed from a heightmap
  32150. */
  32151. static CreateGroundFromHeightMap(options: {
  32152. width: number;
  32153. height: number;
  32154. subdivisions: number;
  32155. minHeight: number;
  32156. maxHeight: number;
  32157. colorFilter: Color3;
  32158. buffer: Uint8Array;
  32159. bufferWidth: number;
  32160. bufferHeight: number;
  32161. alphaFilter: number;
  32162. }): VertexData;
  32163. /**
  32164. * Creates the VertexData for a Plane
  32165. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  32166. * * size sets the width and height of the plane to the value of size, optional default 1
  32167. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  32168. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  32169. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32170. * * 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)
  32171. * * 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)
  32172. * @returns the VertexData of the box
  32173. */
  32174. static CreatePlane(options: {
  32175. size?: number;
  32176. width?: number;
  32177. height?: number;
  32178. sideOrientation?: number;
  32179. frontUVs?: Vector4;
  32180. backUVs?: Vector4;
  32181. }): VertexData;
  32182. /**
  32183. * Creates the VertexData of the Disc or regular Polygon
  32184. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  32185. * * radius the radius of the disc, optional default 0.5
  32186. * * tessellation the number of polygon sides, optional, default 64
  32187. * * 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
  32188. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32189. * * 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)
  32190. * * 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)
  32191. * @returns the VertexData of the box
  32192. */
  32193. static CreateDisc(options: {
  32194. radius?: number;
  32195. tessellation?: number;
  32196. arc?: number;
  32197. sideOrientation?: number;
  32198. frontUVs?: Vector4;
  32199. backUVs?: Vector4;
  32200. }): VertexData;
  32201. /**
  32202. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  32203. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  32204. * @param polygon a mesh built from polygonTriangulation.build()
  32205. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32206. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  32207. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  32208. * @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)
  32209. * @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)
  32210. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  32211. * @returns the VertexData of the Polygon
  32212. */
  32213. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  32214. /**
  32215. * Creates the VertexData of the IcoSphere
  32216. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  32217. * * radius the radius of the IcoSphere, optional default 1
  32218. * * radiusX allows stretching in the x direction, optional, default radius
  32219. * * radiusY allows stretching in the y direction, optional, default radius
  32220. * * radiusZ allows stretching in the z direction, optional, default radius
  32221. * * flat when true creates a flat shaded mesh, optional, default true
  32222. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  32223. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32224. * * 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)
  32225. * * 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)
  32226. * @returns the VertexData of the IcoSphere
  32227. */
  32228. static CreateIcoSphere(options: {
  32229. radius?: number;
  32230. radiusX?: number;
  32231. radiusY?: number;
  32232. radiusZ?: number;
  32233. flat?: boolean;
  32234. subdivisions?: number;
  32235. sideOrientation?: number;
  32236. frontUVs?: Vector4;
  32237. backUVs?: Vector4;
  32238. }): VertexData;
  32239. /**
  32240. * Creates the VertexData for a Polyhedron
  32241. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  32242. * * type provided types are:
  32243. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  32244. * * 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)
  32245. * * size the size of the IcoSphere, optional default 1
  32246. * * sizeX allows stretching in the x direction, optional, default size
  32247. * * sizeY allows stretching in the y direction, optional, default size
  32248. * * sizeZ allows stretching in the z direction, optional, default size
  32249. * * 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
  32250. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  32251. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  32252. * * flat when true creates a flat shaded mesh, optional, default true
  32253. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  32254. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32255. * * 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)
  32256. * * 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)
  32257. * @returns the VertexData of the Polyhedron
  32258. */
  32259. static CreatePolyhedron(options: {
  32260. type?: number;
  32261. size?: number;
  32262. sizeX?: number;
  32263. sizeY?: number;
  32264. sizeZ?: number;
  32265. custom?: any;
  32266. faceUV?: Vector4[];
  32267. faceColors?: Color4[];
  32268. flat?: boolean;
  32269. sideOrientation?: number;
  32270. frontUVs?: Vector4;
  32271. backUVs?: Vector4;
  32272. }): VertexData;
  32273. /**
  32274. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  32275. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  32276. * @returns the VertexData of the Capsule
  32277. */
  32278. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  32279. /**
  32280. * Creates the VertexData for a TorusKnot
  32281. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  32282. * * radius the radius of the torus knot, optional, default 2
  32283. * * tube the thickness of the tube, optional, default 0.5
  32284. * * radialSegments the number of sides on each tube segments, optional, default 32
  32285. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  32286. * * p the number of windings around the z axis, optional, default 2
  32287. * * q the number of windings around the x axis, optional, default 3
  32288. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32289. * * 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)
  32290. * * 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)
  32291. * @returns the VertexData of the Torus Knot
  32292. */
  32293. static CreateTorusKnot(options: {
  32294. radius?: number;
  32295. tube?: number;
  32296. radialSegments?: number;
  32297. tubularSegments?: number;
  32298. p?: number;
  32299. q?: number;
  32300. sideOrientation?: number;
  32301. frontUVs?: Vector4;
  32302. backUVs?: Vector4;
  32303. }): VertexData;
  32304. /**
  32305. * Compute normals for given positions and indices
  32306. * @param positions an array of vertex positions, [...., x, y, z, ......]
  32307. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  32308. * @param normals an array of vertex normals, [...., x, y, z, ......]
  32309. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  32310. * * facetNormals : optional array of facet normals (vector3)
  32311. * * facetPositions : optional array of facet positions (vector3)
  32312. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  32313. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  32314. * * bInfo : optional bounding info, required for facetPartitioning computation
  32315. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  32316. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  32317. * * useRightHandedSystem: optional boolean to for right handed system computation
  32318. * * depthSort : optional boolean to enable the facet depth sort computation
  32319. * * distanceTo : optional Vector3 to compute the facet depth from this location
  32320. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  32321. */
  32322. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  32323. facetNormals?: any;
  32324. facetPositions?: any;
  32325. facetPartitioning?: any;
  32326. ratio?: number;
  32327. bInfo?: any;
  32328. bbSize?: Vector3;
  32329. subDiv?: any;
  32330. useRightHandedSystem?: boolean;
  32331. depthSort?: boolean;
  32332. distanceTo?: Vector3;
  32333. depthSortedFacets?: any;
  32334. }): void;
  32335. /** @hidden */
  32336. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  32337. /**
  32338. * Applies VertexData created from the imported parameters to the geometry
  32339. * @param parsedVertexData the parsed data from an imported file
  32340. * @param geometry the geometry to apply the VertexData to
  32341. */
  32342. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  32343. }
  32344. }
  32345. declare module "babylonjs/Morph/morphTarget" {
  32346. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  32347. import { Observable } from "babylonjs/Misc/observable";
  32348. import { Nullable, FloatArray } from "babylonjs/types";
  32349. import { Scene } from "babylonjs/scene";
  32350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32351. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32352. /**
  32353. * Defines a target to use with MorphTargetManager
  32354. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32355. */
  32356. export class MorphTarget implements IAnimatable {
  32357. /** defines the name of the target */
  32358. name: string;
  32359. /**
  32360. * Gets or sets the list of animations
  32361. */
  32362. animations: import("babylonjs/Animations/animation").Animation[];
  32363. private _scene;
  32364. private _positions;
  32365. private _normals;
  32366. private _tangents;
  32367. private _uvs;
  32368. private _influence;
  32369. private _uniqueId;
  32370. /**
  32371. * Observable raised when the influence changes
  32372. */
  32373. onInfluenceChanged: Observable<boolean>;
  32374. /** @hidden */
  32375. _onDataLayoutChanged: Observable<void>;
  32376. /**
  32377. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32378. */
  32379. get influence(): number;
  32380. set influence(influence: number);
  32381. /**
  32382. * Gets or sets the id of the morph Target
  32383. */
  32384. id: string;
  32385. private _animationPropertiesOverride;
  32386. /**
  32387. * Gets or sets the animation properties override
  32388. */
  32389. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32390. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32391. /**
  32392. * Creates a new MorphTarget
  32393. * @param name defines the name of the target
  32394. * @param influence defines the influence to use
  32395. * @param scene defines the scene the morphtarget belongs to
  32396. */
  32397. constructor(
  32398. /** defines the name of the target */
  32399. name: string, influence?: number, scene?: Nullable<Scene>);
  32400. /**
  32401. * Gets the unique ID of this manager
  32402. */
  32403. get uniqueId(): number;
  32404. /**
  32405. * Gets a boolean defining if the target contains position data
  32406. */
  32407. get hasPositions(): boolean;
  32408. /**
  32409. * Gets a boolean defining if the target contains normal data
  32410. */
  32411. get hasNormals(): boolean;
  32412. /**
  32413. * Gets a boolean defining if the target contains tangent data
  32414. */
  32415. get hasTangents(): boolean;
  32416. /**
  32417. * Gets a boolean defining if the target contains texture coordinates data
  32418. */
  32419. get hasUVs(): boolean;
  32420. /**
  32421. * Affects position data to this target
  32422. * @param data defines the position data to use
  32423. */
  32424. setPositions(data: Nullable<FloatArray>): void;
  32425. /**
  32426. * Gets the position data stored in this target
  32427. * @returns a FloatArray containing the position data (or null if not present)
  32428. */
  32429. getPositions(): Nullable<FloatArray>;
  32430. /**
  32431. * Affects normal data to this target
  32432. * @param data defines the normal data to use
  32433. */
  32434. setNormals(data: Nullable<FloatArray>): void;
  32435. /**
  32436. * Gets the normal data stored in this target
  32437. * @returns a FloatArray containing the normal data (or null if not present)
  32438. */
  32439. getNormals(): Nullable<FloatArray>;
  32440. /**
  32441. * Affects tangent data to this target
  32442. * @param data defines the tangent data to use
  32443. */
  32444. setTangents(data: Nullable<FloatArray>): void;
  32445. /**
  32446. * Gets the tangent data stored in this target
  32447. * @returns a FloatArray containing the tangent data (or null if not present)
  32448. */
  32449. getTangents(): Nullable<FloatArray>;
  32450. /**
  32451. * Affects texture coordinates data to this target
  32452. * @param data defines the texture coordinates data to use
  32453. */
  32454. setUVs(data: Nullable<FloatArray>): void;
  32455. /**
  32456. * Gets the texture coordinates data stored in this target
  32457. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32458. */
  32459. getUVs(): Nullable<FloatArray>;
  32460. /**
  32461. * Clone the current target
  32462. * @returns a new MorphTarget
  32463. */
  32464. clone(): MorphTarget;
  32465. /**
  32466. * Serializes the current target into a Serialization object
  32467. * @returns the serialized object
  32468. */
  32469. serialize(): any;
  32470. /**
  32471. * Returns the string "MorphTarget"
  32472. * @returns "MorphTarget"
  32473. */
  32474. getClassName(): string;
  32475. /**
  32476. * Creates a new target from serialized data
  32477. * @param serializationObject defines the serialized data to use
  32478. * @returns a new MorphTarget
  32479. */
  32480. static Parse(serializationObject: any): MorphTarget;
  32481. /**
  32482. * Creates a MorphTarget from mesh data
  32483. * @param mesh defines the source mesh
  32484. * @param name defines the name to use for the new target
  32485. * @param influence defines the influence to attach to the target
  32486. * @returns a new MorphTarget
  32487. */
  32488. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32489. }
  32490. }
  32491. declare module "babylonjs/Morph/morphTargetManager" {
  32492. import { Nullable } from "babylonjs/types";
  32493. import { Scene } from "babylonjs/scene";
  32494. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32495. /**
  32496. * This class is used to deform meshes using morphing between different targets
  32497. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32498. */
  32499. export class MorphTargetManager {
  32500. private _targets;
  32501. private _targetInfluenceChangedObservers;
  32502. private _targetDataLayoutChangedObservers;
  32503. private _activeTargets;
  32504. private _scene;
  32505. private _influences;
  32506. private _supportsNormals;
  32507. private _supportsTangents;
  32508. private _supportsUVs;
  32509. private _vertexCount;
  32510. private _uniqueId;
  32511. private _tempInfluences;
  32512. /**
  32513. * Gets or sets a boolean indicating if normals must be morphed
  32514. */
  32515. enableNormalMorphing: boolean;
  32516. /**
  32517. * Gets or sets a boolean indicating if tangents must be morphed
  32518. */
  32519. enableTangentMorphing: boolean;
  32520. /**
  32521. * Gets or sets a boolean indicating if UV must be morphed
  32522. */
  32523. enableUVMorphing: boolean;
  32524. /**
  32525. * Creates a new MorphTargetManager
  32526. * @param scene defines the current scene
  32527. */
  32528. constructor(scene?: Nullable<Scene>);
  32529. /**
  32530. * Gets the unique ID of this manager
  32531. */
  32532. get uniqueId(): number;
  32533. /**
  32534. * Gets the number of vertices handled by this manager
  32535. */
  32536. get vertexCount(): number;
  32537. /**
  32538. * Gets a boolean indicating if this manager supports morphing of normals
  32539. */
  32540. get supportsNormals(): boolean;
  32541. /**
  32542. * Gets a boolean indicating if this manager supports morphing of tangents
  32543. */
  32544. get supportsTangents(): boolean;
  32545. /**
  32546. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32547. */
  32548. get supportsUVs(): boolean;
  32549. /**
  32550. * Gets the number of targets stored in this manager
  32551. */
  32552. get numTargets(): number;
  32553. /**
  32554. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32555. */
  32556. get numInfluencers(): number;
  32557. /**
  32558. * Gets the list of influences (one per target)
  32559. */
  32560. get influences(): Float32Array;
  32561. /**
  32562. * Gets the active target at specified index. An active target is a target with an influence > 0
  32563. * @param index defines the index to check
  32564. * @returns the requested target
  32565. */
  32566. getActiveTarget(index: number): MorphTarget;
  32567. /**
  32568. * Gets the target at specified index
  32569. * @param index defines the index to check
  32570. * @returns the requested target
  32571. */
  32572. getTarget(index: number): MorphTarget;
  32573. /**
  32574. * Add a new target to this manager
  32575. * @param target defines the target to add
  32576. */
  32577. addTarget(target: MorphTarget): void;
  32578. /**
  32579. * Removes a target from the manager
  32580. * @param target defines the target to remove
  32581. */
  32582. removeTarget(target: MorphTarget): void;
  32583. /**
  32584. * Clone the current manager
  32585. * @returns a new MorphTargetManager
  32586. */
  32587. clone(): MorphTargetManager;
  32588. /**
  32589. * Serializes the current manager into a Serialization object
  32590. * @returns the serialized object
  32591. */
  32592. serialize(): any;
  32593. private _syncActiveTargets;
  32594. /**
  32595. * Syncrhonize the targets with all the meshes using this morph target manager
  32596. */
  32597. synchronize(): void;
  32598. /**
  32599. * Creates a new MorphTargetManager from serialized data
  32600. * @param serializationObject defines the serialized data
  32601. * @param scene defines the hosting scene
  32602. * @returns the new MorphTargetManager
  32603. */
  32604. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32605. }
  32606. }
  32607. declare module "babylonjs/Meshes/meshLODLevel" {
  32608. import { Mesh } from "babylonjs/Meshes/mesh";
  32609. import { Nullable } from "babylonjs/types";
  32610. /**
  32611. * Class used to represent a specific level of detail of a mesh
  32612. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32613. */
  32614. export class MeshLODLevel {
  32615. /** Defines the distance where this level should start being displayed */
  32616. distance: number;
  32617. /** Defines the mesh to use to render this level */
  32618. mesh: Nullable<Mesh>;
  32619. /**
  32620. * Creates a new LOD level
  32621. * @param distance defines the distance where this level should star being displayed
  32622. * @param mesh defines the mesh to use to render this level
  32623. */
  32624. constructor(
  32625. /** Defines the distance where this level should start being displayed */
  32626. distance: number,
  32627. /** Defines the mesh to use to render this level */
  32628. mesh: Nullable<Mesh>);
  32629. }
  32630. }
  32631. declare module "babylonjs/Misc/canvasGenerator" {
  32632. /**
  32633. * Helper class used to generate a canvas to manipulate images
  32634. */
  32635. export class CanvasGenerator {
  32636. /**
  32637. * Create a new canvas (or offscreen canvas depending on the context)
  32638. * @param width defines the expected width
  32639. * @param height defines the expected height
  32640. * @return a new canvas or offscreen canvas
  32641. */
  32642. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32643. }
  32644. }
  32645. declare module "babylonjs/Meshes/groundMesh" {
  32646. import { Scene } from "babylonjs/scene";
  32647. import { Vector3 } from "babylonjs/Maths/math.vector";
  32648. import { Mesh } from "babylonjs/Meshes/mesh";
  32649. /**
  32650. * Mesh representing the gorund
  32651. */
  32652. export class GroundMesh extends Mesh {
  32653. /** If octree should be generated */
  32654. generateOctree: boolean;
  32655. private _heightQuads;
  32656. /** @hidden */
  32657. _subdivisionsX: number;
  32658. /** @hidden */
  32659. _subdivisionsY: number;
  32660. /** @hidden */
  32661. _width: number;
  32662. /** @hidden */
  32663. _height: number;
  32664. /** @hidden */
  32665. _minX: number;
  32666. /** @hidden */
  32667. _maxX: number;
  32668. /** @hidden */
  32669. _minZ: number;
  32670. /** @hidden */
  32671. _maxZ: number;
  32672. constructor(name: string, scene: Scene);
  32673. /**
  32674. * "GroundMesh"
  32675. * @returns "GroundMesh"
  32676. */
  32677. getClassName(): string;
  32678. /**
  32679. * The minimum of x and y subdivisions
  32680. */
  32681. get subdivisions(): number;
  32682. /**
  32683. * X subdivisions
  32684. */
  32685. get subdivisionsX(): number;
  32686. /**
  32687. * Y subdivisions
  32688. */
  32689. get subdivisionsY(): number;
  32690. /**
  32691. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32692. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32693. * @param chunksCount the number of subdivisions for x and y
  32694. * @param octreeBlocksSize (Default: 32)
  32695. */
  32696. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32697. /**
  32698. * Returns a height (y) value in the Worl system :
  32699. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32700. * @param x x coordinate
  32701. * @param z z coordinate
  32702. * @returns the ground y position if (x, z) are outside the ground surface.
  32703. */
  32704. getHeightAtCoordinates(x: number, z: number): number;
  32705. /**
  32706. * Returns a normalized vector (Vector3) orthogonal to the ground
  32707. * at the ground coordinates (x, z) expressed in the World system.
  32708. * @param x x coordinate
  32709. * @param z z coordinate
  32710. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32711. */
  32712. getNormalAtCoordinates(x: number, z: number): Vector3;
  32713. /**
  32714. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32715. * at the ground coordinates (x, z) expressed in the World system.
  32716. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32717. * @param x x coordinate
  32718. * @param z z coordinate
  32719. * @param ref vector to store the result
  32720. * @returns the GroundMesh.
  32721. */
  32722. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32723. /**
  32724. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32725. * if the ground has been updated.
  32726. * This can be used in the render loop.
  32727. * @returns the GroundMesh.
  32728. */
  32729. updateCoordinateHeights(): GroundMesh;
  32730. private _getFacetAt;
  32731. private _initHeightQuads;
  32732. private _computeHeightQuads;
  32733. /**
  32734. * Serializes this ground mesh
  32735. * @param serializationObject object to write serialization to
  32736. */
  32737. serialize(serializationObject: any): void;
  32738. /**
  32739. * Parses a serialized ground mesh
  32740. * @param parsedMesh the serialized mesh
  32741. * @param scene the scene to create the ground mesh in
  32742. * @returns the created ground mesh
  32743. */
  32744. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32745. }
  32746. }
  32747. declare module "babylonjs/Physics/physicsJoint" {
  32748. import { Vector3 } from "babylonjs/Maths/math.vector";
  32749. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32750. /**
  32751. * Interface for Physics-Joint data
  32752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32753. */
  32754. export interface PhysicsJointData {
  32755. /**
  32756. * The main pivot of the joint
  32757. */
  32758. mainPivot?: Vector3;
  32759. /**
  32760. * The connected pivot of the joint
  32761. */
  32762. connectedPivot?: Vector3;
  32763. /**
  32764. * The main axis of the joint
  32765. */
  32766. mainAxis?: Vector3;
  32767. /**
  32768. * The connected axis of the joint
  32769. */
  32770. connectedAxis?: Vector3;
  32771. /**
  32772. * The collision of the joint
  32773. */
  32774. collision?: boolean;
  32775. /**
  32776. * Native Oimo/Cannon/Energy data
  32777. */
  32778. nativeParams?: any;
  32779. }
  32780. /**
  32781. * This is a holder class for the physics joint created by the physics plugin
  32782. * It holds a set of functions to control the underlying joint
  32783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32784. */
  32785. export class PhysicsJoint {
  32786. /**
  32787. * The type of the physics joint
  32788. */
  32789. type: number;
  32790. /**
  32791. * The data for the physics joint
  32792. */
  32793. jointData: PhysicsJointData;
  32794. private _physicsJoint;
  32795. protected _physicsPlugin: IPhysicsEnginePlugin;
  32796. /**
  32797. * Initializes the physics joint
  32798. * @param type The type of the physics joint
  32799. * @param jointData The data for the physics joint
  32800. */
  32801. constructor(
  32802. /**
  32803. * The type of the physics joint
  32804. */
  32805. type: number,
  32806. /**
  32807. * The data for the physics joint
  32808. */
  32809. jointData: PhysicsJointData);
  32810. /**
  32811. * Gets the physics joint
  32812. */
  32813. get physicsJoint(): any;
  32814. /**
  32815. * Sets the physics joint
  32816. */
  32817. set physicsJoint(newJoint: any);
  32818. /**
  32819. * Sets the physics plugin
  32820. */
  32821. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32822. /**
  32823. * Execute a function that is physics-plugin specific.
  32824. * @param {Function} func the function that will be executed.
  32825. * It accepts two parameters: the physics world and the physics joint
  32826. */
  32827. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32828. /**
  32829. * Distance-Joint type
  32830. */
  32831. static DistanceJoint: number;
  32832. /**
  32833. * Hinge-Joint type
  32834. */
  32835. static HingeJoint: number;
  32836. /**
  32837. * Ball-and-Socket joint type
  32838. */
  32839. static BallAndSocketJoint: number;
  32840. /**
  32841. * Wheel-Joint type
  32842. */
  32843. static WheelJoint: number;
  32844. /**
  32845. * Slider-Joint type
  32846. */
  32847. static SliderJoint: number;
  32848. /**
  32849. * Prismatic-Joint type
  32850. */
  32851. static PrismaticJoint: number;
  32852. /**
  32853. * Universal-Joint type
  32854. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32855. */
  32856. static UniversalJoint: number;
  32857. /**
  32858. * Hinge-Joint 2 type
  32859. */
  32860. static Hinge2Joint: number;
  32861. /**
  32862. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32863. */
  32864. static PointToPointJoint: number;
  32865. /**
  32866. * Spring-Joint type
  32867. */
  32868. static SpringJoint: number;
  32869. /**
  32870. * Lock-Joint type
  32871. */
  32872. static LockJoint: number;
  32873. }
  32874. /**
  32875. * A class representing a physics distance joint
  32876. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32877. */
  32878. export class DistanceJoint extends PhysicsJoint {
  32879. /**
  32880. *
  32881. * @param jointData The data for the Distance-Joint
  32882. */
  32883. constructor(jointData: DistanceJointData);
  32884. /**
  32885. * Update the predefined distance.
  32886. * @param maxDistance The maximum preferred distance
  32887. * @param minDistance The minimum preferred distance
  32888. */
  32889. updateDistance(maxDistance: number, minDistance?: number): void;
  32890. }
  32891. /**
  32892. * Represents a Motor-Enabled Joint
  32893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32894. */
  32895. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32896. /**
  32897. * Initializes the Motor-Enabled Joint
  32898. * @param type The type of the joint
  32899. * @param jointData The physica joint data for the joint
  32900. */
  32901. constructor(type: number, jointData: PhysicsJointData);
  32902. /**
  32903. * Set the motor values.
  32904. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32905. * @param force the force to apply
  32906. * @param maxForce max force for this motor.
  32907. */
  32908. setMotor(force?: number, maxForce?: number): void;
  32909. /**
  32910. * Set the motor's limits.
  32911. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32912. * @param upperLimit The upper limit of the motor
  32913. * @param lowerLimit The lower limit of the motor
  32914. */
  32915. setLimit(upperLimit: number, lowerLimit?: number): void;
  32916. }
  32917. /**
  32918. * This class represents a single physics Hinge-Joint
  32919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32920. */
  32921. export class HingeJoint extends MotorEnabledJoint {
  32922. /**
  32923. * Initializes the Hinge-Joint
  32924. * @param jointData The joint data for the Hinge-Joint
  32925. */
  32926. constructor(jointData: PhysicsJointData);
  32927. /**
  32928. * Set the motor values.
  32929. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32930. * @param {number} force the force to apply
  32931. * @param {number} maxForce max force for this motor.
  32932. */
  32933. setMotor(force?: number, maxForce?: number): void;
  32934. /**
  32935. * Set the motor's limits.
  32936. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32937. * @param upperLimit The upper limit of the motor
  32938. * @param lowerLimit The lower limit of the motor
  32939. */
  32940. setLimit(upperLimit: number, lowerLimit?: number): void;
  32941. }
  32942. /**
  32943. * This class represents a dual hinge physics joint (same as wheel joint)
  32944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32945. */
  32946. export class Hinge2Joint extends MotorEnabledJoint {
  32947. /**
  32948. * Initializes the Hinge2-Joint
  32949. * @param jointData The joint data for the Hinge2-Joint
  32950. */
  32951. constructor(jointData: PhysicsJointData);
  32952. /**
  32953. * Set the motor values.
  32954. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32955. * @param {number} targetSpeed the speed the motor is to reach
  32956. * @param {number} maxForce max force for this motor.
  32957. * @param {motorIndex} the motor's index, 0 or 1.
  32958. */
  32959. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32960. /**
  32961. * Set the motor limits.
  32962. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32963. * @param {number} upperLimit the upper limit
  32964. * @param {number} lowerLimit lower limit
  32965. * @param {motorIndex} the motor's index, 0 or 1.
  32966. */
  32967. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32968. }
  32969. /**
  32970. * Interface for a motor enabled joint
  32971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32972. */
  32973. export interface IMotorEnabledJoint {
  32974. /**
  32975. * Physics joint
  32976. */
  32977. physicsJoint: any;
  32978. /**
  32979. * Sets the motor of the motor-enabled joint
  32980. * @param force The force of the motor
  32981. * @param maxForce The maximum force of the motor
  32982. * @param motorIndex The index of the motor
  32983. */
  32984. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32985. /**
  32986. * Sets the limit of the motor
  32987. * @param upperLimit The upper limit of the motor
  32988. * @param lowerLimit The lower limit of the motor
  32989. * @param motorIndex The index of the motor
  32990. */
  32991. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32992. }
  32993. /**
  32994. * Joint data for a Distance-Joint
  32995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32996. */
  32997. export interface DistanceJointData extends PhysicsJointData {
  32998. /**
  32999. * Max distance the 2 joint objects can be apart
  33000. */
  33001. maxDistance: number;
  33002. }
  33003. /**
  33004. * Joint data from a spring joint
  33005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33006. */
  33007. export interface SpringJointData extends PhysicsJointData {
  33008. /**
  33009. * Length of the spring
  33010. */
  33011. length: number;
  33012. /**
  33013. * Stiffness of the spring
  33014. */
  33015. stiffness: number;
  33016. /**
  33017. * Damping of the spring
  33018. */
  33019. damping: number;
  33020. /** this callback will be called when applying the force to the impostors. */
  33021. forceApplicationCallback: () => void;
  33022. }
  33023. }
  33024. declare module "babylonjs/Physics/physicsRaycastResult" {
  33025. import { Vector3 } from "babylonjs/Maths/math.vector";
  33026. /**
  33027. * Holds the data for the raycast result
  33028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33029. */
  33030. export class PhysicsRaycastResult {
  33031. private _hasHit;
  33032. private _hitDistance;
  33033. private _hitNormalWorld;
  33034. private _hitPointWorld;
  33035. private _rayFromWorld;
  33036. private _rayToWorld;
  33037. /**
  33038. * Gets if there was a hit
  33039. */
  33040. get hasHit(): boolean;
  33041. /**
  33042. * Gets the distance from the hit
  33043. */
  33044. get hitDistance(): number;
  33045. /**
  33046. * Gets the hit normal/direction in the world
  33047. */
  33048. get hitNormalWorld(): Vector3;
  33049. /**
  33050. * Gets the hit point in the world
  33051. */
  33052. get hitPointWorld(): Vector3;
  33053. /**
  33054. * Gets the ray "start point" of the ray in the world
  33055. */
  33056. get rayFromWorld(): Vector3;
  33057. /**
  33058. * Gets the ray "end point" of the ray in the world
  33059. */
  33060. get rayToWorld(): Vector3;
  33061. /**
  33062. * Sets the hit data (normal & point in world space)
  33063. * @param hitNormalWorld defines the normal in world space
  33064. * @param hitPointWorld defines the point in world space
  33065. */
  33066. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  33067. /**
  33068. * Sets the distance from the start point to the hit point
  33069. * @param distance
  33070. */
  33071. setHitDistance(distance: number): void;
  33072. /**
  33073. * Calculates the distance manually
  33074. */
  33075. calculateHitDistance(): void;
  33076. /**
  33077. * Resets all the values to default
  33078. * @param from The from point on world space
  33079. * @param to The to point on world space
  33080. */
  33081. reset(from?: Vector3, to?: Vector3): void;
  33082. }
  33083. /**
  33084. * Interface for the size containing width and height
  33085. */
  33086. interface IXYZ {
  33087. /**
  33088. * X
  33089. */
  33090. x: number;
  33091. /**
  33092. * Y
  33093. */
  33094. y: number;
  33095. /**
  33096. * Z
  33097. */
  33098. z: number;
  33099. }
  33100. }
  33101. declare module "babylonjs/Physics/IPhysicsEngine" {
  33102. import { Nullable } from "babylonjs/types";
  33103. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  33104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33105. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33106. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  33107. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  33108. /**
  33109. * Interface used to describe a physics joint
  33110. */
  33111. export interface PhysicsImpostorJoint {
  33112. /** Defines the main impostor to which the joint is linked */
  33113. mainImpostor: PhysicsImpostor;
  33114. /** Defines the impostor that is connected to the main impostor using this joint */
  33115. connectedImpostor: PhysicsImpostor;
  33116. /** Defines the joint itself */
  33117. joint: PhysicsJoint;
  33118. }
  33119. /** @hidden */
  33120. export interface IPhysicsEnginePlugin {
  33121. world: any;
  33122. name: string;
  33123. setGravity(gravity: Vector3): void;
  33124. setTimeStep(timeStep: number): void;
  33125. getTimeStep(): number;
  33126. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33127. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33128. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33129. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33130. removePhysicsBody(impostor: PhysicsImpostor): void;
  33131. generateJoint(joint: PhysicsImpostorJoint): void;
  33132. removeJoint(joint: PhysicsImpostorJoint): void;
  33133. isSupported(): boolean;
  33134. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33135. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33136. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33137. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33138. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33139. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33140. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33141. getBodyMass(impostor: PhysicsImpostor): number;
  33142. getBodyFriction(impostor: PhysicsImpostor): number;
  33143. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33144. getBodyRestitution(impostor: PhysicsImpostor): number;
  33145. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33146. getBodyPressure?(impostor: PhysicsImpostor): number;
  33147. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  33148. getBodyStiffness?(impostor: PhysicsImpostor): number;
  33149. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  33150. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  33151. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  33152. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  33153. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  33154. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33155. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33156. sleepBody(impostor: PhysicsImpostor): void;
  33157. wakeUpBody(impostor: PhysicsImpostor): void;
  33158. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33159. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33160. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  33161. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33162. getRadius(impostor: PhysicsImpostor): number;
  33163. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33164. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33165. dispose(): void;
  33166. }
  33167. /**
  33168. * Interface used to define a physics engine
  33169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33170. */
  33171. export interface IPhysicsEngine {
  33172. /**
  33173. * Gets the gravity vector used by the simulation
  33174. */
  33175. gravity: Vector3;
  33176. /**
  33177. * Sets the gravity vector used by the simulation
  33178. * @param gravity defines the gravity vector to use
  33179. */
  33180. setGravity(gravity: Vector3): void;
  33181. /**
  33182. * Set the time step of the physics engine.
  33183. * Default is 1/60.
  33184. * To slow it down, enter 1/600 for example.
  33185. * To speed it up, 1/30
  33186. * @param newTimeStep the new timestep to apply to this world.
  33187. */
  33188. setTimeStep(newTimeStep: number): void;
  33189. /**
  33190. * Get the time step of the physics engine.
  33191. * @returns the current time step
  33192. */
  33193. getTimeStep(): number;
  33194. /**
  33195. * Set the sub time step of the physics engine.
  33196. * Default is 0 meaning there is no sub steps
  33197. * To increase physics resolution precision, set a small value (like 1 ms)
  33198. * @param subTimeStep defines the new sub timestep used for physics resolution.
  33199. */
  33200. setSubTimeStep(subTimeStep: number): void;
  33201. /**
  33202. * Get the sub time step of the physics engine.
  33203. * @returns the current sub time step
  33204. */
  33205. getSubTimeStep(): number;
  33206. /**
  33207. * Release all resources
  33208. */
  33209. dispose(): void;
  33210. /**
  33211. * Gets the name of the current physics plugin
  33212. * @returns the name of the plugin
  33213. */
  33214. getPhysicsPluginName(): string;
  33215. /**
  33216. * Adding a new impostor for the impostor tracking.
  33217. * This will be done by the impostor itself.
  33218. * @param impostor the impostor to add
  33219. */
  33220. addImpostor(impostor: PhysicsImpostor): void;
  33221. /**
  33222. * Remove an impostor from the engine.
  33223. * This impostor and its mesh will not longer be updated by the physics engine.
  33224. * @param impostor the impostor to remove
  33225. */
  33226. removeImpostor(impostor: PhysicsImpostor): void;
  33227. /**
  33228. * Add a joint to the physics engine
  33229. * @param mainImpostor defines the main impostor to which the joint is added.
  33230. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33231. * @param joint defines the joint that will connect both impostors.
  33232. */
  33233. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33234. /**
  33235. * Removes a joint from the simulation
  33236. * @param mainImpostor defines the impostor used with the joint
  33237. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33238. * @param joint defines the joint to remove
  33239. */
  33240. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33241. /**
  33242. * Gets the current plugin used to run the simulation
  33243. * @returns current plugin
  33244. */
  33245. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33246. /**
  33247. * Gets the list of physic impostors
  33248. * @returns an array of PhysicsImpostor
  33249. */
  33250. getImpostors(): Array<PhysicsImpostor>;
  33251. /**
  33252. * Gets the impostor for a physics enabled object
  33253. * @param object defines the object impersonated by the impostor
  33254. * @returns the PhysicsImpostor or null if not found
  33255. */
  33256. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33257. /**
  33258. * Gets the impostor for a physics body object
  33259. * @param body defines physics body used by the impostor
  33260. * @returns the PhysicsImpostor or null if not found
  33261. */
  33262. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33263. /**
  33264. * Does a raycast in the physics world
  33265. * @param from when should the ray start?
  33266. * @param to when should the ray end?
  33267. * @returns PhysicsRaycastResult
  33268. */
  33269. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33270. /**
  33271. * Called by the scene. No need to call it.
  33272. * @param delta defines the timespam between frames
  33273. */
  33274. _step(delta: number): void;
  33275. }
  33276. }
  33277. declare module "babylonjs/Physics/physicsImpostor" {
  33278. import { Nullable, IndicesArray } from "babylonjs/types";
  33279. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  33280. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33282. import { Scene } from "babylonjs/scene";
  33283. import { Bone } from "babylonjs/Bones/bone";
  33284. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33285. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  33286. import { Space } from "babylonjs/Maths/math.axis";
  33287. /**
  33288. * The interface for the physics imposter parameters
  33289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33290. */
  33291. export interface PhysicsImpostorParameters {
  33292. /**
  33293. * The mass of the physics imposter
  33294. */
  33295. mass: number;
  33296. /**
  33297. * The friction of the physics imposter
  33298. */
  33299. friction?: number;
  33300. /**
  33301. * The coefficient of restitution of the physics imposter
  33302. */
  33303. restitution?: number;
  33304. /**
  33305. * The native options of the physics imposter
  33306. */
  33307. nativeOptions?: any;
  33308. /**
  33309. * Specifies if the parent should be ignored
  33310. */
  33311. ignoreParent?: boolean;
  33312. /**
  33313. * Specifies if bi-directional transformations should be disabled
  33314. */
  33315. disableBidirectionalTransformation?: boolean;
  33316. /**
  33317. * The pressure inside the physics imposter, soft object only
  33318. */
  33319. pressure?: number;
  33320. /**
  33321. * The stiffness the physics imposter, soft object only
  33322. */
  33323. stiffness?: number;
  33324. /**
  33325. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  33326. */
  33327. velocityIterations?: number;
  33328. /**
  33329. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33330. */
  33331. positionIterations?: number;
  33332. /**
  33333. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33334. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33335. * Add to fix multiple points
  33336. */
  33337. fixedPoints?: number;
  33338. /**
  33339. * The collision margin around a soft object
  33340. */
  33341. margin?: number;
  33342. /**
  33343. * The collision margin around a soft object
  33344. */
  33345. damping?: number;
  33346. /**
  33347. * The path for a rope based on an extrusion
  33348. */
  33349. path?: any;
  33350. /**
  33351. * The shape of an extrusion used for a rope based on an extrusion
  33352. */
  33353. shape?: any;
  33354. }
  33355. /**
  33356. * Interface for a physics-enabled object
  33357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33358. */
  33359. export interface IPhysicsEnabledObject {
  33360. /**
  33361. * The position of the physics-enabled object
  33362. */
  33363. position: Vector3;
  33364. /**
  33365. * The rotation of the physics-enabled object
  33366. */
  33367. rotationQuaternion: Nullable<Quaternion>;
  33368. /**
  33369. * The scale of the physics-enabled object
  33370. */
  33371. scaling: Vector3;
  33372. /**
  33373. * The rotation of the physics-enabled object
  33374. */
  33375. rotation?: Vector3;
  33376. /**
  33377. * The parent of the physics-enabled object
  33378. */
  33379. parent?: any;
  33380. /**
  33381. * The bounding info of the physics-enabled object
  33382. * @returns The bounding info of the physics-enabled object
  33383. */
  33384. getBoundingInfo(): BoundingInfo;
  33385. /**
  33386. * Computes the world matrix
  33387. * @param force Specifies if the world matrix should be computed by force
  33388. * @returns A world matrix
  33389. */
  33390. computeWorldMatrix(force: boolean): Matrix;
  33391. /**
  33392. * Gets the world matrix
  33393. * @returns A world matrix
  33394. */
  33395. getWorldMatrix?(): Matrix;
  33396. /**
  33397. * Gets the child meshes
  33398. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33399. * @returns An array of abstract meshes
  33400. */
  33401. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33402. /**
  33403. * Gets the vertex data
  33404. * @param kind The type of vertex data
  33405. * @returns A nullable array of numbers, or a float32 array
  33406. */
  33407. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33408. /**
  33409. * Gets the indices from the mesh
  33410. * @returns A nullable array of index arrays
  33411. */
  33412. getIndices?(): Nullable<IndicesArray>;
  33413. /**
  33414. * Gets the scene from the mesh
  33415. * @returns the indices array or null
  33416. */
  33417. getScene?(): Scene;
  33418. /**
  33419. * Gets the absolute position from the mesh
  33420. * @returns the absolute position
  33421. */
  33422. getAbsolutePosition(): Vector3;
  33423. /**
  33424. * Gets the absolute pivot point from the mesh
  33425. * @returns the absolute pivot point
  33426. */
  33427. getAbsolutePivotPoint(): Vector3;
  33428. /**
  33429. * Rotates the mesh
  33430. * @param axis The axis of rotation
  33431. * @param amount The amount of rotation
  33432. * @param space The space of the rotation
  33433. * @returns The rotation transform node
  33434. */
  33435. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33436. /**
  33437. * Translates the mesh
  33438. * @param axis The axis of translation
  33439. * @param distance The distance of translation
  33440. * @param space The space of the translation
  33441. * @returns The transform node
  33442. */
  33443. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33444. /**
  33445. * Sets the absolute position of the mesh
  33446. * @param absolutePosition The absolute position of the mesh
  33447. * @returns The transform node
  33448. */
  33449. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33450. /**
  33451. * Gets the class name of the mesh
  33452. * @returns The class name
  33453. */
  33454. getClassName(): string;
  33455. }
  33456. /**
  33457. * Represents a physics imposter
  33458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33459. */
  33460. export class PhysicsImpostor {
  33461. /**
  33462. * The physics-enabled object used as the physics imposter
  33463. */
  33464. object: IPhysicsEnabledObject;
  33465. /**
  33466. * The type of the physics imposter
  33467. */
  33468. type: number;
  33469. private _options;
  33470. private _scene?;
  33471. /**
  33472. * The default object size of the imposter
  33473. */
  33474. static DEFAULT_OBJECT_SIZE: Vector3;
  33475. /**
  33476. * The identity quaternion of the imposter
  33477. */
  33478. static IDENTITY_QUATERNION: Quaternion;
  33479. /** @hidden */
  33480. _pluginData: any;
  33481. private _physicsEngine;
  33482. private _physicsBody;
  33483. private _bodyUpdateRequired;
  33484. private _onBeforePhysicsStepCallbacks;
  33485. private _onAfterPhysicsStepCallbacks;
  33486. /** @hidden */
  33487. _onPhysicsCollideCallbacks: Array<{
  33488. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33489. otherImpostors: Array<PhysicsImpostor>;
  33490. }>;
  33491. private _deltaPosition;
  33492. private _deltaRotation;
  33493. private _deltaRotationConjugated;
  33494. /** @hidden */
  33495. _isFromLine: boolean;
  33496. private _parent;
  33497. private _isDisposed;
  33498. private static _tmpVecs;
  33499. private static _tmpQuat;
  33500. /**
  33501. * Specifies if the physics imposter is disposed
  33502. */
  33503. get isDisposed(): boolean;
  33504. /**
  33505. * Gets the mass of the physics imposter
  33506. */
  33507. get mass(): number;
  33508. set mass(value: number);
  33509. /**
  33510. * Gets the coefficient of friction
  33511. */
  33512. get friction(): number;
  33513. /**
  33514. * Sets the coefficient of friction
  33515. */
  33516. set friction(value: number);
  33517. /**
  33518. * Gets the coefficient of restitution
  33519. */
  33520. get restitution(): number;
  33521. /**
  33522. * Sets the coefficient of restitution
  33523. */
  33524. set restitution(value: number);
  33525. /**
  33526. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33527. */
  33528. get pressure(): number;
  33529. /**
  33530. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33531. */
  33532. set pressure(value: number);
  33533. /**
  33534. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33535. */
  33536. get stiffness(): number;
  33537. /**
  33538. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33539. */
  33540. set stiffness(value: number);
  33541. /**
  33542. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33543. */
  33544. get velocityIterations(): number;
  33545. /**
  33546. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33547. */
  33548. set velocityIterations(value: number);
  33549. /**
  33550. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33551. */
  33552. get positionIterations(): number;
  33553. /**
  33554. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33555. */
  33556. set positionIterations(value: number);
  33557. /**
  33558. * The unique id of the physics imposter
  33559. * set by the physics engine when adding this impostor to the array
  33560. */
  33561. uniqueId: number;
  33562. /**
  33563. * @hidden
  33564. */
  33565. soft: boolean;
  33566. /**
  33567. * @hidden
  33568. */
  33569. segments: number;
  33570. private _joints;
  33571. /**
  33572. * Initializes the physics imposter
  33573. * @param object The physics-enabled object used as the physics imposter
  33574. * @param type The type of the physics imposter
  33575. * @param _options The options for the physics imposter
  33576. * @param _scene The Babylon scene
  33577. */
  33578. constructor(
  33579. /**
  33580. * The physics-enabled object used as the physics imposter
  33581. */
  33582. object: IPhysicsEnabledObject,
  33583. /**
  33584. * The type of the physics imposter
  33585. */
  33586. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33587. /**
  33588. * This function will completly initialize this impostor.
  33589. * It will create a new body - but only if this mesh has no parent.
  33590. * If it has, this impostor will not be used other than to define the impostor
  33591. * of the child mesh.
  33592. * @hidden
  33593. */
  33594. _init(): void;
  33595. private _getPhysicsParent;
  33596. /**
  33597. * Should a new body be generated.
  33598. * @returns boolean specifying if body initialization is required
  33599. */
  33600. isBodyInitRequired(): boolean;
  33601. /**
  33602. * Sets the updated scaling
  33603. * @param updated Specifies if the scaling is updated
  33604. */
  33605. setScalingUpdated(): void;
  33606. /**
  33607. * Force a regeneration of this or the parent's impostor's body.
  33608. * Use under cautious - This will remove all joints already implemented.
  33609. */
  33610. forceUpdate(): void;
  33611. /**
  33612. * Gets the body that holds this impostor. Either its own, or its parent.
  33613. */
  33614. get physicsBody(): any;
  33615. /**
  33616. * Get the parent of the physics imposter
  33617. * @returns Physics imposter or null
  33618. */
  33619. get parent(): Nullable<PhysicsImpostor>;
  33620. /**
  33621. * Sets the parent of the physics imposter
  33622. */
  33623. set parent(value: Nullable<PhysicsImpostor>);
  33624. /**
  33625. * Set the physics body. Used mainly by the physics engine/plugin
  33626. */
  33627. set physicsBody(physicsBody: any);
  33628. /**
  33629. * Resets the update flags
  33630. */
  33631. resetUpdateFlags(): void;
  33632. /**
  33633. * Gets the object extend size
  33634. * @returns the object extend size
  33635. */
  33636. getObjectExtendSize(): Vector3;
  33637. /**
  33638. * Gets the object center
  33639. * @returns The object center
  33640. */
  33641. getObjectCenter(): Vector3;
  33642. /**
  33643. * Get a specific parameter from the options parameters
  33644. * @param paramName The object parameter name
  33645. * @returns The object parameter
  33646. */
  33647. getParam(paramName: string): any;
  33648. /**
  33649. * Sets a specific parameter in the options given to the physics plugin
  33650. * @param paramName The parameter name
  33651. * @param value The value of the parameter
  33652. */
  33653. setParam(paramName: string, value: number): void;
  33654. /**
  33655. * Specifically change the body's mass option. Won't recreate the physics body object
  33656. * @param mass The mass of the physics imposter
  33657. */
  33658. setMass(mass: number): void;
  33659. /**
  33660. * Gets the linear velocity
  33661. * @returns linear velocity or null
  33662. */
  33663. getLinearVelocity(): Nullable<Vector3>;
  33664. /**
  33665. * Sets the linear velocity
  33666. * @param velocity linear velocity or null
  33667. */
  33668. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33669. /**
  33670. * Gets the angular velocity
  33671. * @returns angular velocity or null
  33672. */
  33673. getAngularVelocity(): Nullable<Vector3>;
  33674. /**
  33675. * Sets the angular velocity
  33676. * @param velocity The velocity or null
  33677. */
  33678. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33679. /**
  33680. * Execute a function with the physics plugin native code
  33681. * Provide a function the will have two variables - the world object and the physics body object
  33682. * @param func The function to execute with the physics plugin native code
  33683. */
  33684. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33685. /**
  33686. * Register a function that will be executed before the physics world is stepping forward
  33687. * @param func The function to execute before the physics world is stepped forward
  33688. */
  33689. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33690. /**
  33691. * Unregister a function that will be executed before the physics world is stepping forward
  33692. * @param func The function to execute before the physics world is stepped forward
  33693. */
  33694. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33695. /**
  33696. * Register a function that will be executed after the physics step
  33697. * @param func The function to execute after physics step
  33698. */
  33699. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33700. /**
  33701. * Unregisters a function that will be executed after the physics step
  33702. * @param func The function to execute after physics step
  33703. */
  33704. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33705. /**
  33706. * register a function that will be executed when this impostor collides against a different body
  33707. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33708. * @param func Callback that is executed on collision
  33709. */
  33710. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33711. /**
  33712. * Unregisters the physics imposter on contact
  33713. * @param collideAgainst The physics object to collide against
  33714. * @param func Callback to execute on collision
  33715. */
  33716. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33717. private _tmpQuat;
  33718. private _tmpQuat2;
  33719. /**
  33720. * Get the parent rotation
  33721. * @returns The parent rotation
  33722. */
  33723. getParentsRotation(): Quaternion;
  33724. /**
  33725. * this function is executed by the physics engine.
  33726. */
  33727. beforeStep: () => void;
  33728. /**
  33729. * this function is executed by the physics engine
  33730. */
  33731. afterStep: () => void;
  33732. /**
  33733. * Legacy collision detection event support
  33734. */
  33735. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33736. /**
  33737. * event and body object due to cannon's event-based architecture.
  33738. */
  33739. onCollide: (e: {
  33740. body: any;
  33741. point: Nullable<Vector3>;
  33742. }) => void;
  33743. /**
  33744. * Apply a force
  33745. * @param force The force to apply
  33746. * @param contactPoint The contact point for the force
  33747. * @returns The physics imposter
  33748. */
  33749. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33750. /**
  33751. * Apply an impulse
  33752. * @param force The impulse force
  33753. * @param contactPoint The contact point for the impulse force
  33754. * @returns The physics imposter
  33755. */
  33756. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33757. /**
  33758. * A help function to create a joint
  33759. * @param otherImpostor A physics imposter used to create a joint
  33760. * @param jointType The type of joint
  33761. * @param jointData The data for the joint
  33762. * @returns The physics imposter
  33763. */
  33764. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33765. /**
  33766. * Add a joint to this impostor with a different impostor
  33767. * @param otherImpostor A physics imposter used to add a joint
  33768. * @param joint The joint to add
  33769. * @returns The physics imposter
  33770. */
  33771. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33772. /**
  33773. * Add an anchor to a cloth impostor
  33774. * @param otherImpostor rigid impostor to anchor to
  33775. * @param width ratio across width from 0 to 1
  33776. * @param height ratio up height from 0 to 1
  33777. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33778. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33779. * @returns impostor the soft imposter
  33780. */
  33781. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33782. /**
  33783. * Add a hook to a rope impostor
  33784. * @param otherImpostor rigid impostor to anchor to
  33785. * @param length ratio across rope from 0 to 1
  33786. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33787. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33788. * @returns impostor the rope imposter
  33789. */
  33790. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33791. /**
  33792. * Will keep this body still, in a sleep mode.
  33793. * @returns the physics imposter
  33794. */
  33795. sleep(): PhysicsImpostor;
  33796. /**
  33797. * Wake the body up.
  33798. * @returns The physics imposter
  33799. */
  33800. wakeUp(): PhysicsImpostor;
  33801. /**
  33802. * Clones the physics imposter
  33803. * @param newObject The physics imposter clones to this physics-enabled object
  33804. * @returns A nullable physics imposter
  33805. */
  33806. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33807. /**
  33808. * Disposes the physics imposter
  33809. */
  33810. dispose(): void;
  33811. /**
  33812. * Sets the delta position
  33813. * @param position The delta position amount
  33814. */
  33815. setDeltaPosition(position: Vector3): void;
  33816. /**
  33817. * Sets the delta rotation
  33818. * @param rotation The delta rotation amount
  33819. */
  33820. setDeltaRotation(rotation: Quaternion): void;
  33821. /**
  33822. * Gets the box size of the physics imposter and stores the result in the input parameter
  33823. * @param result Stores the box size
  33824. * @returns The physics imposter
  33825. */
  33826. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33827. /**
  33828. * Gets the radius of the physics imposter
  33829. * @returns Radius of the physics imposter
  33830. */
  33831. getRadius(): number;
  33832. /**
  33833. * Sync a bone with this impostor
  33834. * @param bone The bone to sync to the impostor.
  33835. * @param boneMesh The mesh that the bone is influencing.
  33836. * @param jointPivot The pivot of the joint / bone in local space.
  33837. * @param distToJoint Optional distance from the impostor to the joint.
  33838. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33839. */
  33840. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33841. /**
  33842. * Sync impostor to a bone
  33843. * @param bone The bone that the impostor will be synced to.
  33844. * @param boneMesh The mesh that the bone is influencing.
  33845. * @param jointPivot The pivot of the joint / bone in local space.
  33846. * @param distToJoint Optional distance from the impostor to the joint.
  33847. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33848. * @param boneAxis Optional vector3 axis the bone is aligned with
  33849. */
  33850. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33851. /**
  33852. * No-Imposter type
  33853. */
  33854. static NoImpostor: number;
  33855. /**
  33856. * Sphere-Imposter type
  33857. */
  33858. static SphereImpostor: number;
  33859. /**
  33860. * Box-Imposter type
  33861. */
  33862. static BoxImpostor: number;
  33863. /**
  33864. * Plane-Imposter type
  33865. */
  33866. static PlaneImpostor: number;
  33867. /**
  33868. * Mesh-imposter type
  33869. */
  33870. static MeshImpostor: number;
  33871. /**
  33872. * Capsule-Impostor type (Ammo.js plugin only)
  33873. */
  33874. static CapsuleImpostor: number;
  33875. /**
  33876. * Cylinder-Imposter type
  33877. */
  33878. static CylinderImpostor: number;
  33879. /**
  33880. * Particle-Imposter type
  33881. */
  33882. static ParticleImpostor: number;
  33883. /**
  33884. * Heightmap-Imposter type
  33885. */
  33886. static HeightmapImpostor: number;
  33887. /**
  33888. * ConvexHull-Impostor type (Ammo.js plugin only)
  33889. */
  33890. static ConvexHullImpostor: number;
  33891. /**
  33892. * Custom-Imposter type (Ammo.js plugin only)
  33893. */
  33894. static CustomImpostor: number;
  33895. /**
  33896. * Rope-Imposter type
  33897. */
  33898. static RopeImpostor: number;
  33899. /**
  33900. * Cloth-Imposter type
  33901. */
  33902. static ClothImpostor: number;
  33903. /**
  33904. * Softbody-Imposter type
  33905. */
  33906. static SoftbodyImpostor: number;
  33907. }
  33908. }
  33909. declare module "babylonjs/Meshes/mesh" {
  33910. import { Observable } from "babylonjs/Misc/observable";
  33911. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33912. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33913. import { Camera } from "babylonjs/Cameras/camera";
  33914. import { Scene } from "babylonjs/scene";
  33915. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33916. import { Color4 } from "babylonjs/Maths/math.color";
  33917. import { Engine } from "babylonjs/Engines/engine";
  33918. import { Node } from "babylonjs/node";
  33919. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33920. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33921. import { Buffer } from "babylonjs/Meshes/buffer";
  33922. import { Geometry } from "babylonjs/Meshes/geometry";
  33923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33924. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33925. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33926. import { Effect } from "babylonjs/Materials/effect";
  33927. import { Material } from "babylonjs/Materials/material";
  33928. import { Skeleton } from "babylonjs/Bones/skeleton";
  33929. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33930. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33931. import { Path3D } from "babylonjs/Maths/math.path";
  33932. import { Plane } from "babylonjs/Maths/math.plane";
  33933. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33934. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33935. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33936. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33937. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33938. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33939. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33940. /**
  33941. * @hidden
  33942. **/
  33943. export class _CreationDataStorage {
  33944. closePath?: boolean;
  33945. closeArray?: boolean;
  33946. idx: number[];
  33947. dashSize: number;
  33948. gapSize: number;
  33949. path3D: Path3D;
  33950. pathArray: Vector3[][];
  33951. arc: number;
  33952. radius: number;
  33953. cap: number;
  33954. tessellation: number;
  33955. }
  33956. /**
  33957. * @hidden
  33958. **/
  33959. class _InstanceDataStorage {
  33960. visibleInstances: any;
  33961. batchCache: _InstancesBatch;
  33962. instancesBufferSize: number;
  33963. instancesBuffer: Nullable<Buffer>;
  33964. instancesData: Float32Array;
  33965. overridenInstanceCount: number;
  33966. isFrozen: boolean;
  33967. previousBatch: Nullable<_InstancesBatch>;
  33968. hardwareInstancedRendering: boolean;
  33969. sideOrientation: number;
  33970. manualUpdate: boolean;
  33971. previousRenderId: number;
  33972. }
  33973. /**
  33974. * @hidden
  33975. **/
  33976. export class _InstancesBatch {
  33977. mustReturn: boolean;
  33978. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33979. renderSelf: boolean[];
  33980. hardwareInstancedRendering: boolean[];
  33981. }
  33982. /**
  33983. * @hidden
  33984. **/
  33985. class _ThinInstanceDataStorage {
  33986. instancesCount: number;
  33987. matrixBuffer: Nullable<Buffer>;
  33988. matrixBufferSize: number;
  33989. matrixData: Nullable<Float32Array>;
  33990. boundingVectors: Array<Vector3>;
  33991. worldMatrices: Nullable<Matrix[]>;
  33992. }
  33993. /**
  33994. * Class used to represent renderable models
  33995. */
  33996. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33997. /**
  33998. * Mesh side orientation : usually the external or front surface
  33999. */
  34000. static readonly FRONTSIDE: number;
  34001. /**
  34002. * Mesh side orientation : usually the internal or back surface
  34003. */
  34004. static readonly BACKSIDE: number;
  34005. /**
  34006. * Mesh side orientation : both internal and external or front and back surfaces
  34007. */
  34008. static readonly DOUBLESIDE: number;
  34009. /**
  34010. * Mesh side orientation : by default, `FRONTSIDE`
  34011. */
  34012. static readonly DEFAULTSIDE: number;
  34013. /**
  34014. * Mesh cap setting : no cap
  34015. */
  34016. static readonly NO_CAP: number;
  34017. /**
  34018. * Mesh cap setting : one cap at the beginning of the mesh
  34019. */
  34020. static readonly CAP_START: number;
  34021. /**
  34022. * Mesh cap setting : one cap at the end of the mesh
  34023. */
  34024. static readonly CAP_END: number;
  34025. /**
  34026. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  34027. */
  34028. static readonly CAP_ALL: number;
  34029. /**
  34030. * Mesh pattern setting : no flip or rotate
  34031. */
  34032. static readonly NO_FLIP: number;
  34033. /**
  34034. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  34035. */
  34036. static readonly FLIP_TILE: number;
  34037. /**
  34038. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  34039. */
  34040. static readonly ROTATE_TILE: number;
  34041. /**
  34042. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  34043. */
  34044. static readonly FLIP_ROW: number;
  34045. /**
  34046. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  34047. */
  34048. static readonly ROTATE_ROW: number;
  34049. /**
  34050. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  34051. */
  34052. static readonly FLIP_N_ROTATE_TILE: number;
  34053. /**
  34054. * Mesh pattern setting : rotate pattern and rotate
  34055. */
  34056. static readonly FLIP_N_ROTATE_ROW: number;
  34057. /**
  34058. * Mesh tile positioning : part tiles same on left/right or top/bottom
  34059. */
  34060. static readonly CENTER: number;
  34061. /**
  34062. * Mesh tile positioning : part tiles on left
  34063. */
  34064. static readonly LEFT: number;
  34065. /**
  34066. * Mesh tile positioning : part tiles on right
  34067. */
  34068. static readonly RIGHT: number;
  34069. /**
  34070. * Mesh tile positioning : part tiles on top
  34071. */
  34072. static readonly TOP: number;
  34073. /**
  34074. * Mesh tile positioning : part tiles on bottom
  34075. */
  34076. static readonly BOTTOM: number;
  34077. /**
  34078. * Gets the default side orientation.
  34079. * @param orientation the orientation to value to attempt to get
  34080. * @returns the default orientation
  34081. * @hidden
  34082. */
  34083. static _GetDefaultSideOrientation(orientation?: number): number;
  34084. private _internalMeshDataInfo;
  34085. get computeBonesUsingShaders(): boolean;
  34086. set computeBonesUsingShaders(value: boolean);
  34087. /**
  34088. * An event triggered before rendering the mesh
  34089. */
  34090. get onBeforeRenderObservable(): Observable<Mesh>;
  34091. /**
  34092. * An event triggered before binding the mesh
  34093. */
  34094. get onBeforeBindObservable(): Observable<Mesh>;
  34095. /**
  34096. * An event triggered after rendering the mesh
  34097. */
  34098. get onAfterRenderObservable(): Observable<Mesh>;
  34099. /**
  34100. * An event triggered before drawing the mesh
  34101. */
  34102. get onBeforeDrawObservable(): Observable<Mesh>;
  34103. private _onBeforeDrawObserver;
  34104. /**
  34105. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  34106. */
  34107. set onBeforeDraw(callback: () => void);
  34108. get hasInstances(): boolean;
  34109. get hasThinInstances(): boolean;
  34110. /**
  34111. * Gets the delay loading state of the mesh (when delay loading is turned on)
  34112. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  34113. */
  34114. delayLoadState: number;
  34115. /**
  34116. * Gets the list of instances created from this mesh
  34117. * it is not supposed to be modified manually.
  34118. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  34119. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34120. */
  34121. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  34122. /**
  34123. * Gets the file containing delay loading data for this mesh
  34124. */
  34125. delayLoadingFile: string;
  34126. /** @hidden */
  34127. _binaryInfo: any;
  34128. /**
  34129. * User defined function used to change how LOD level selection is done
  34130. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34131. */
  34132. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  34133. /**
  34134. * Gets or sets the morph target manager
  34135. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  34136. */
  34137. get morphTargetManager(): Nullable<MorphTargetManager>;
  34138. set morphTargetManager(value: Nullable<MorphTargetManager>);
  34139. /** @hidden */
  34140. _creationDataStorage: Nullable<_CreationDataStorage>;
  34141. /** @hidden */
  34142. _geometry: Nullable<Geometry>;
  34143. /** @hidden */
  34144. _delayInfo: Array<string>;
  34145. /** @hidden */
  34146. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  34147. /** @hidden */
  34148. _instanceDataStorage: _InstanceDataStorage;
  34149. /** @hidden */
  34150. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  34151. private _effectiveMaterial;
  34152. /** @hidden */
  34153. _shouldGenerateFlatShading: boolean;
  34154. /** @hidden */
  34155. _originalBuilderSideOrientation: number;
  34156. /**
  34157. * Use this property to change the original side orientation defined at construction time
  34158. */
  34159. overrideMaterialSideOrientation: Nullable<number>;
  34160. /**
  34161. * Gets the source mesh (the one used to clone this one from)
  34162. */
  34163. get source(): Nullable<Mesh>;
  34164. /**
  34165. * Gets the list of clones of this mesh
  34166. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  34167. * Note that useClonedMeshMap=true is the default setting
  34168. */
  34169. get cloneMeshMap(): Nullable<{
  34170. [id: string]: Mesh | undefined;
  34171. }>;
  34172. /**
  34173. * Gets or sets a boolean indicating that this mesh does not use index buffer
  34174. */
  34175. get isUnIndexed(): boolean;
  34176. set isUnIndexed(value: boolean);
  34177. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  34178. get worldMatrixInstancedBuffer(): Float32Array;
  34179. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  34180. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  34181. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  34182. /**
  34183. * @constructor
  34184. * @param name The value used by scene.getMeshByName() to do a lookup.
  34185. * @param scene The scene to add this mesh to.
  34186. * @param parent The parent of this mesh, if it has one
  34187. * @param source An optional Mesh from which geometry is shared, cloned.
  34188. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  34189. * When false, achieved by calling a clone(), also passing False.
  34190. * This will make creation of children, recursive.
  34191. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  34192. */
  34193. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  34194. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  34195. doNotInstantiate: boolean;
  34196. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  34197. /**
  34198. * Gets the class name
  34199. * @returns the string "Mesh".
  34200. */
  34201. getClassName(): string;
  34202. /** @hidden */
  34203. get _isMesh(): boolean;
  34204. /**
  34205. * Returns a description of this mesh
  34206. * @param fullDetails define if full details about this mesh must be used
  34207. * @returns a descriptive string representing this mesh
  34208. */
  34209. toString(fullDetails?: boolean): string;
  34210. /** @hidden */
  34211. _unBindEffect(): void;
  34212. /**
  34213. * Gets a boolean indicating if this mesh has LOD
  34214. */
  34215. get hasLODLevels(): boolean;
  34216. /**
  34217. * Gets the list of MeshLODLevel associated with the current mesh
  34218. * @returns an array of MeshLODLevel
  34219. */
  34220. getLODLevels(): MeshLODLevel[];
  34221. private _sortLODLevels;
  34222. /**
  34223. * Add a mesh as LOD level triggered at the given distance.
  34224. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34225. * @param distance The distance from the center of the object to show this level
  34226. * @param mesh The mesh to be added as LOD level (can be null)
  34227. * @return This mesh (for chaining)
  34228. */
  34229. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  34230. /**
  34231. * Returns the LOD level mesh at the passed distance or null if not found.
  34232. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34233. * @param distance The distance from the center of the object to show this level
  34234. * @returns a Mesh or `null`
  34235. */
  34236. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  34237. /**
  34238. * Remove a mesh from the LOD array
  34239. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34240. * @param mesh defines the mesh to be removed
  34241. * @return This mesh (for chaining)
  34242. */
  34243. removeLODLevel(mesh: Mesh): Mesh;
  34244. /**
  34245. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  34246. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34247. * @param camera defines the camera to use to compute distance
  34248. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  34249. * @return This mesh (for chaining)
  34250. */
  34251. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  34252. /**
  34253. * Gets the mesh internal Geometry object
  34254. */
  34255. get geometry(): Nullable<Geometry>;
  34256. /**
  34257. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  34258. * @returns the total number of vertices
  34259. */
  34260. getTotalVertices(): number;
  34261. /**
  34262. * Returns the content of an associated vertex buffer
  34263. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34264. * - VertexBuffer.PositionKind
  34265. * - VertexBuffer.UVKind
  34266. * - VertexBuffer.UV2Kind
  34267. * - VertexBuffer.UV3Kind
  34268. * - VertexBuffer.UV4Kind
  34269. * - VertexBuffer.UV5Kind
  34270. * - VertexBuffer.UV6Kind
  34271. * - VertexBuffer.ColorKind
  34272. * - VertexBuffer.MatricesIndicesKind
  34273. * - VertexBuffer.MatricesIndicesExtraKind
  34274. * - VertexBuffer.MatricesWeightsKind
  34275. * - VertexBuffer.MatricesWeightsExtraKind
  34276. * @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
  34277. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  34278. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  34279. */
  34280. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34281. /**
  34282. * Returns the mesh VertexBuffer object from the requested `kind`
  34283. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34284. * - VertexBuffer.PositionKind
  34285. * - VertexBuffer.NormalKind
  34286. * - VertexBuffer.UVKind
  34287. * - VertexBuffer.UV2Kind
  34288. * - VertexBuffer.UV3Kind
  34289. * - VertexBuffer.UV4Kind
  34290. * - VertexBuffer.UV5Kind
  34291. * - VertexBuffer.UV6Kind
  34292. * - VertexBuffer.ColorKind
  34293. * - VertexBuffer.MatricesIndicesKind
  34294. * - VertexBuffer.MatricesIndicesExtraKind
  34295. * - VertexBuffer.MatricesWeightsKind
  34296. * - VertexBuffer.MatricesWeightsExtraKind
  34297. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  34298. */
  34299. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  34300. /**
  34301. * Tests if a specific vertex buffer is associated with this mesh
  34302. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34303. * - VertexBuffer.PositionKind
  34304. * - VertexBuffer.NormalKind
  34305. * - VertexBuffer.UVKind
  34306. * - VertexBuffer.UV2Kind
  34307. * - VertexBuffer.UV3Kind
  34308. * - VertexBuffer.UV4Kind
  34309. * - VertexBuffer.UV5Kind
  34310. * - VertexBuffer.UV6Kind
  34311. * - VertexBuffer.ColorKind
  34312. * - VertexBuffer.MatricesIndicesKind
  34313. * - VertexBuffer.MatricesIndicesExtraKind
  34314. * - VertexBuffer.MatricesWeightsKind
  34315. * - VertexBuffer.MatricesWeightsExtraKind
  34316. * @returns a boolean
  34317. */
  34318. isVerticesDataPresent(kind: string): boolean;
  34319. /**
  34320. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  34321. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34322. * - VertexBuffer.PositionKind
  34323. * - VertexBuffer.UVKind
  34324. * - VertexBuffer.UV2Kind
  34325. * - VertexBuffer.UV3Kind
  34326. * - VertexBuffer.UV4Kind
  34327. * - VertexBuffer.UV5Kind
  34328. * - VertexBuffer.UV6Kind
  34329. * - VertexBuffer.ColorKind
  34330. * - VertexBuffer.MatricesIndicesKind
  34331. * - VertexBuffer.MatricesIndicesExtraKind
  34332. * - VertexBuffer.MatricesWeightsKind
  34333. * - VertexBuffer.MatricesWeightsExtraKind
  34334. * @returns a boolean
  34335. */
  34336. isVertexBufferUpdatable(kind: string): boolean;
  34337. /**
  34338. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  34339. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34340. * - VertexBuffer.PositionKind
  34341. * - VertexBuffer.NormalKind
  34342. * - VertexBuffer.UVKind
  34343. * - VertexBuffer.UV2Kind
  34344. * - VertexBuffer.UV3Kind
  34345. * - VertexBuffer.UV4Kind
  34346. * - VertexBuffer.UV5Kind
  34347. * - VertexBuffer.UV6Kind
  34348. * - VertexBuffer.ColorKind
  34349. * - VertexBuffer.MatricesIndicesKind
  34350. * - VertexBuffer.MatricesIndicesExtraKind
  34351. * - VertexBuffer.MatricesWeightsKind
  34352. * - VertexBuffer.MatricesWeightsExtraKind
  34353. * @returns an array of strings
  34354. */
  34355. getVerticesDataKinds(): string[];
  34356. /**
  34357. * Returns a positive integer : the total number of indices in this mesh geometry.
  34358. * @returns the numner of indices or zero if the mesh has no geometry.
  34359. */
  34360. getTotalIndices(): number;
  34361. /**
  34362. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34363. * @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.
  34364. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34365. * @returns the indices array or an empty array if the mesh has no geometry
  34366. */
  34367. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34368. get isBlocked(): boolean;
  34369. /**
  34370. * Determine if the current mesh is ready to be rendered
  34371. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34372. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34373. * @returns true if all associated assets are ready (material, textures, shaders)
  34374. */
  34375. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34376. /**
  34377. * 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.
  34378. */
  34379. get areNormalsFrozen(): boolean;
  34380. /**
  34381. * 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.
  34382. * @returns the current mesh
  34383. */
  34384. freezeNormals(): Mesh;
  34385. /**
  34386. * 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
  34387. * @returns the current mesh
  34388. */
  34389. unfreezeNormals(): Mesh;
  34390. /**
  34391. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34392. */
  34393. set overridenInstanceCount(count: number);
  34394. /** @hidden */
  34395. _preActivate(): Mesh;
  34396. /** @hidden */
  34397. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34398. /** @hidden */
  34399. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34400. protected _afterComputeWorldMatrix(): void;
  34401. /** @hidden */
  34402. _postActivate(): void;
  34403. /**
  34404. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34405. * This means the mesh underlying bounding box and sphere are recomputed.
  34406. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34407. * @returns the current mesh
  34408. */
  34409. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34410. /** @hidden */
  34411. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34412. /**
  34413. * This function will subdivide the mesh into multiple submeshes
  34414. * @param count defines the expected number of submeshes
  34415. */
  34416. subdivide(count: number): void;
  34417. /**
  34418. * Copy a FloatArray into a specific associated vertex buffer
  34419. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34420. * - VertexBuffer.PositionKind
  34421. * - VertexBuffer.UVKind
  34422. * - VertexBuffer.UV2Kind
  34423. * - VertexBuffer.UV3Kind
  34424. * - VertexBuffer.UV4Kind
  34425. * - VertexBuffer.UV5Kind
  34426. * - VertexBuffer.UV6Kind
  34427. * - VertexBuffer.ColorKind
  34428. * - VertexBuffer.MatricesIndicesKind
  34429. * - VertexBuffer.MatricesIndicesExtraKind
  34430. * - VertexBuffer.MatricesWeightsKind
  34431. * - VertexBuffer.MatricesWeightsExtraKind
  34432. * @param data defines the data source
  34433. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34434. * @param stride defines the data stride size (can be null)
  34435. * @returns the current mesh
  34436. */
  34437. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34438. /**
  34439. * Delete a vertex buffer associated with this mesh
  34440. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34441. * - VertexBuffer.PositionKind
  34442. * - VertexBuffer.UVKind
  34443. * - VertexBuffer.UV2Kind
  34444. * - VertexBuffer.UV3Kind
  34445. * - VertexBuffer.UV4Kind
  34446. * - VertexBuffer.UV5Kind
  34447. * - VertexBuffer.UV6Kind
  34448. * - VertexBuffer.ColorKind
  34449. * - VertexBuffer.MatricesIndicesKind
  34450. * - VertexBuffer.MatricesIndicesExtraKind
  34451. * - VertexBuffer.MatricesWeightsKind
  34452. * - VertexBuffer.MatricesWeightsExtraKind
  34453. */
  34454. removeVerticesData(kind: string): void;
  34455. /**
  34456. * Flags an associated vertex buffer as updatable
  34457. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34458. * - VertexBuffer.PositionKind
  34459. * - VertexBuffer.UVKind
  34460. * - VertexBuffer.UV2Kind
  34461. * - VertexBuffer.UV3Kind
  34462. * - VertexBuffer.UV4Kind
  34463. * - VertexBuffer.UV5Kind
  34464. * - VertexBuffer.UV6Kind
  34465. * - VertexBuffer.ColorKind
  34466. * - VertexBuffer.MatricesIndicesKind
  34467. * - VertexBuffer.MatricesIndicesExtraKind
  34468. * - VertexBuffer.MatricesWeightsKind
  34469. * - VertexBuffer.MatricesWeightsExtraKind
  34470. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34471. */
  34472. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34473. /**
  34474. * Sets the mesh global Vertex Buffer
  34475. * @param buffer defines the buffer to use
  34476. * @returns the current mesh
  34477. */
  34478. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34479. /**
  34480. * Update a specific associated vertex buffer
  34481. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34482. * - VertexBuffer.PositionKind
  34483. * - VertexBuffer.UVKind
  34484. * - VertexBuffer.UV2Kind
  34485. * - VertexBuffer.UV3Kind
  34486. * - VertexBuffer.UV4Kind
  34487. * - VertexBuffer.UV5Kind
  34488. * - VertexBuffer.UV6Kind
  34489. * - VertexBuffer.ColorKind
  34490. * - VertexBuffer.MatricesIndicesKind
  34491. * - VertexBuffer.MatricesIndicesExtraKind
  34492. * - VertexBuffer.MatricesWeightsKind
  34493. * - VertexBuffer.MatricesWeightsExtraKind
  34494. * @param data defines the data source
  34495. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34496. * @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)
  34497. * @returns the current mesh
  34498. */
  34499. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34500. /**
  34501. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34502. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34503. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34504. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34505. * @returns the current mesh
  34506. */
  34507. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34508. /**
  34509. * Creates a un-shared specific occurence of the geometry for the mesh.
  34510. * @returns the current mesh
  34511. */
  34512. makeGeometryUnique(): Mesh;
  34513. /**
  34514. * Set the index buffer of this mesh
  34515. * @param indices defines the source data
  34516. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34517. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34518. * @returns the current mesh
  34519. */
  34520. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34521. /**
  34522. * Update the current index buffer
  34523. * @param indices defines the source data
  34524. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34525. * @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)
  34526. * @returns the current mesh
  34527. */
  34528. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34529. /**
  34530. * Invert the geometry to move from a right handed system to a left handed one.
  34531. * @returns the current mesh
  34532. */
  34533. toLeftHanded(): Mesh;
  34534. /** @hidden */
  34535. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34536. /** @hidden */
  34537. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34538. /**
  34539. * Registers for this mesh a javascript function called just before the rendering process
  34540. * @param func defines the function to call before rendering this mesh
  34541. * @returns the current mesh
  34542. */
  34543. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34544. /**
  34545. * Disposes a previously registered javascript function called before the rendering
  34546. * @param func defines the function to remove
  34547. * @returns the current mesh
  34548. */
  34549. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34550. /**
  34551. * Registers for this mesh a javascript function called just after the rendering is complete
  34552. * @param func defines the function to call after rendering this mesh
  34553. * @returns the current mesh
  34554. */
  34555. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34556. /**
  34557. * Disposes a previously registered javascript function called after the rendering.
  34558. * @param func defines the function to remove
  34559. * @returns the current mesh
  34560. */
  34561. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34562. /** @hidden */
  34563. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34564. /** @hidden */
  34565. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34566. /** @hidden */
  34567. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34568. /** @hidden */
  34569. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34570. /** @hidden */
  34571. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34572. /** @hidden */
  34573. _rebuild(): void;
  34574. /** @hidden */
  34575. _freeze(): void;
  34576. /** @hidden */
  34577. _unFreeze(): void;
  34578. /**
  34579. * 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
  34580. * @param subMesh defines the subMesh to render
  34581. * @param enableAlphaMode defines if alpha mode can be changed
  34582. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34583. * @returns the current mesh
  34584. */
  34585. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34586. private _onBeforeDraw;
  34587. /**
  34588. * Renormalize the mesh and patch it up if there are no weights
  34589. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34590. * However in the case of zero weights then we set just a single influence to 1.
  34591. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34592. */
  34593. cleanMatrixWeights(): void;
  34594. private normalizeSkinFourWeights;
  34595. private normalizeSkinWeightsAndExtra;
  34596. /**
  34597. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34598. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34599. * the user know there was an issue with importing the mesh
  34600. * @returns a validation object with skinned, valid and report string
  34601. */
  34602. validateSkinning(): {
  34603. skinned: boolean;
  34604. valid: boolean;
  34605. report: string;
  34606. };
  34607. /** @hidden */
  34608. _checkDelayState(): Mesh;
  34609. private _queueLoad;
  34610. /**
  34611. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34612. * A mesh is in the frustum if its bounding box intersects the frustum
  34613. * @param frustumPlanes defines the frustum to test
  34614. * @returns true if the mesh is in the frustum planes
  34615. */
  34616. isInFrustum(frustumPlanes: Plane[]): boolean;
  34617. /**
  34618. * Sets the mesh material by the material or multiMaterial `id` property
  34619. * @param id is a string identifying the material or the multiMaterial
  34620. * @returns the current mesh
  34621. */
  34622. setMaterialByID(id: string): Mesh;
  34623. /**
  34624. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34625. * @returns an array of IAnimatable
  34626. */
  34627. getAnimatables(): IAnimatable[];
  34628. /**
  34629. * Modifies the mesh geometry according to the passed transformation matrix.
  34630. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34631. * The mesh normals are modified using the same transformation.
  34632. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34633. * @param transform defines the transform matrix to use
  34634. * @see https://doc.babylonjs.com/resources/baking_transformations
  34635. * @returns the current mesh
  34636. */
  34637. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34638. /**
  34639. * Modifies the mesh geometry according to its own current World Matrix.
  34640. * The mesh World Matrix is then reset.
  34641. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34642. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34643. * @see https://doc.babylonjs.com/resources/baking_transformations
  34644. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34645. * @returns the current mesh
  34646. */
  34647. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34648. /** @hidden */
  34649. get _positions(): Nullable<Vector3[]>;
  34650. /** @hidden */
  34651. _resetPointsArrayCache(): Mesh;
  34652. /** @hidden */
  34653. _generatePointsArray(): boolean;
  34654. /**
  34655. * Returns a new Mesh object generated from the current mesh properties.
  34656. * This method must not get confused with createInstance()
  34657. * @param name is a string, the name given to the new mesh
  34658. * @param newParent can be any Node object (default `null`)
  34659. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34660. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34661. * @returns a new mesh
  34662. */
  34663. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34664. /**
  34665. * Releases resources associated with this mesh.
  34666. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34667. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34668. */
  34669. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34670. /** @hidden */
  34671. _disposeInstanceSpecificData(): void;
  34672. /** @hidden */
  34673. _disposeThinInstanceSpecificData(): void;
  34674. /**
  34675. * Modifies the mesh geometry according to a displacement map.
  34676. * 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.
  34677. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34678. * @param url is a string, the URL from the image file is to be downloaded.
  34679. * @param minHeight is the lower limit of the displacement.
  34680. * @param maxHeight is the upper limit of the displacement.
  34681. * @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.
  34682. * @param uvOffset is an optional vector2 used to offset UV.
  34683. * @param uvScale is an optional vector2 used to scale UV.
  34684. * @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.
  34685. * @returns the Mesh.
  34686. */
  34687. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34688. /**
  34689. * Modifies the mesh geometry according to a displacementMap buffer.
  34690. * 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.
  34691. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34692. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34693. * @param heightMapWidth is the width of the buffer image.
  34694. * @param heightMapHeight is the height of the buffer image.
  34695. * @param minHeight is the lower limit of the displacement.
  34696. * @param maxHeight is the upper limit of the displacement.
  34697. * @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.
  34698. * @param uvOffset is an optional vector2 used to offset UV.
  34699. * @param uvScale is an optional vector2 used to scale UV.
  34700. * @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.
  34701. * @returns the Mesh.
  34702. */
  34703. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34704. /**
  34705. * Modify the mesh to get a flat shading rendering.
  34706. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34707. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34708. * @returns current mesh
  34709. */
  34710. convertToFlatShadedMesh(): Mesh;
  34711. /**
  34712. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34713. * In other words, more vertices, no more indices and a single bigger VBO.
  34714. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34715. * @returns current mesh
  34716. */
  34717. convertToUnIndexedMesh(): Mesh;
  34718. /**
  34719. * Inverses facet orientations.
  34720. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34721. * @param flipNormals will also inverts the normals
  34722. * @returns current mesh
  34723. */
  34724. flipFaces(flipNormals?: boolean): Mesh;
  34725. /**
  34726. * Increase the number of facets and hence vertices in a mesh
  34727. * Vertex normals are interpolated from existing vertex normals
  34728. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34729. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34730. */
  34731. increaseVertices(numberPerEdge: number): void;
  34732. /**
  34733. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34734. * This will undo any application of covertToFlatShadedMesh
  34735. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34736. */
  34737. forceSharedVertices(): void;
  34738. /** @hidden */
  34739. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34740. /** @hidden */
  34741. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34742. /**
  34743. * Creates a new InstancedMesh object from the mesh model.
  34744. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34745. * @param name defines the name of the new instance
  34746. * @returns a new InstancedMesh
  34747. */
  34748. createInstance(name: string): InstancedMesh;
  34749. /**
  34750. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34751. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34752. * @returns the current mesh
  34753. */
  34754. synchronizeInstances(): Mesh;
  34755. /**
  34756. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34757. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34758. * This should be used together with the simplification to avoid disappearing triangles.
  34759. * @param successCallback an optional success callback to be called after the optimization finished.
  34760. * @returns the current mesh
  34761. */
  34762. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34763. /**
  34764. * Serialize current mesh
  34765. * @param serializationObject defines the object which will receive the serialization data
  34766. */
  34767. serialize(serializationObject: any): void;
  34768. /** @hidden */
  34769. _syncGeometryWithMorphTargetManager(): void;
  34770. /** @hidden */
  34771. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34772. /**
  34773. * Returns a new Mesh object parsed from the source provided.
  34774. * @param parsedMesh is the source
  34775. * @param scene defines the hosting scene
  34776. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34777. * @returns a new Mesh
  34778. */
  34779. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34780. /**
  34781. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34782. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34783. * @param name defines the name of the mesh to create
  34784. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34785. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34786. * @param closePath creates a seam between the first and the last points of each path of the path array
  34787. * @param offset is taken in account only if the `pathArray` is containing a single path
  34788. * @param scene defines the hosting scene
  34789. * @param updatable defines if the mesh must be flagged as updatable
  34790. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34791. * @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)
  34792. * @returns a new Mesh
  34793. */
  34794. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34795. /**
  34796. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34797. * @param name defines the name of the mesh to create
  34798. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34799. * @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
  34800. * @param scene defines the hosting scene
  34801. * @param updatable defines if the mesh must be flagged as updatable
  34802. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34803. * @returns a new Mesh
  34804. */
  34805. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34806. /**
  34807. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34808. * @param name defines the name of the mesh to create
  34809. * @param size sets the size (float) of each box side (default 1)
  34810. * @param scene defines the hosting scene
  34811. * @param updatable defines if the mesh must be flagged as updatable
  34812. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34813. * @returns a new Mesh
  34814. */
  34815. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34816. /**
  34817. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34818. * @param name defines the name of the mesh to create
  34819. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34820. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34821. * @param scene defines the hosting scene
  34822. * @param updatable defines if the mesh must be flagged as updatable
  34823. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34824. * @returns a new Mesh
  34825. */
  34826. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34827. /**
  34828. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34829. * @param name defines the name of the mesh to create
  34830. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34831. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34832. * @param scene defines the hosting scene
  34833. * @returns a new Mesh
  34834. */
  34835. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34836. /**
  34837. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34838. * @param name defines the name of the mesh to create
  34839. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34840. * @param diameterTop set the top cap diameter (floats, default 1)
  34841. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34842. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34843. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34844. * @param scene defines the hosting scene
  34845. * @param updatable defines if the mesh must be flagged as updatable
  34846. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34847. * @returns a new Mesh
  34848. */
  34849. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34850. /**
  34851. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34852. * @param name defines the name of the mesh to create
  34853. * @param diameter sets the diameter size (float) of the torus (default 1)
  34854. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34855. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34856. * @param scene defines the hosting scene
  34857. * @param updatable defines if the mesh must be flagged as updatable
  34858. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34859. * @returns a new Mesh
  34860. */
  34861. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34862. /**
  34863. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34864. * @param name defines the name of the mesh to create
  34865. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34866. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34867. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34868. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34869. * @param p the number of windings on X axis (positive integers, default 2)
  34870. * @param q the number of windings on Y axis (positive integers, default 3)
  34871. * @param scene defines the hosting scene
  34872. * @param updatable defines if the mesh must be flagged as updatable
  34873. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34874. * @returns a new Mesh
  34875. */
  34876. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34877. /**
  34878. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34879. * @param name defines the name of the mesh to create
  34880. * @param points is an array successive Vector3
  34881. * @param scene defines the hosting scene
  34882. * @param updatable defines if the mesh must be flagged as updatable
  34883. * @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).
  34884. * @returns a new Mesh
  34885. */
  34886. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34887. /**
  34888. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34889. * @param name defines the name of the mesh to create
  34890. * @param points is an array successive Vector3
  34891. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34892. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34893. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34894. * @param scene defines the hosting scene
  34895. * @param updatable defines if the mesh must be flagged as updatable
  34896. * @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)
  34897. * @returns a new Mesh
  34898. */
  34899. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34900. /**
  34901. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34902. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34903. * 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.
  34904. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34905. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34906. * Remember you can only change the shape positions, not their number when updating a polygon.
  34907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34908. * @param name defines the name of the mesh to create
  34909. * @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
  34910. * @param scene defines the hosting scene
  34911. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34912. * @param updatable defines if the mesh must be flagged as updatable
  34913. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34914. * @param earcutInjection can be used to inject your own earcut reference
  34915. * @returns a new Mesh
  34916. */
  34917. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34918. /**
  34919. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34920. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34921. * @param name defines the name of the mesh to create
  34922. * @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
  34923. * @param depth defines the height of extrusion
  34924. * @param scene defines the hosting scene
  34925. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34926. * @param updatable defines if the mesh must be flagged as updatable
  34927. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34928. * @param earcutInjection can be used to inject your own earcut reference
  34929. * @returns a new Mesh
  34930. */
  34931. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34932. /**
  34933. * Creates an extruded shape mesh.
  34934. * 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
  34935. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34937. * @param name defines the name of the mesh to create
  34938. * @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
  34939. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34940. * @param scale is the value to scale the shape
  34941. * @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
  34942. * @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
  34943. * @param scene defines the hosting scene
  34944. * @param updatable defines if the mesh must be flagged as updatable
  34945. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34946. * @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)
  34947. * @returns a new Mesh
  34948. */
  34949. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34950. /**
  34951. * Creates an custom extruded shape mesh.
  34952. * The custom extrusion is a parametric shape.
  34953. * It has no predefined shape. Its final shape will depend on the input parameters.
  34954. * Please consider using the same method from the MeshBuilder class instead
  34955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34956. * @param name defines the name of the mesh to create
  34957. * @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
  34958. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34959. * @param scaleFunction is a custom Javascript function called on each path point
  34960. * @param rotationFunction is a custom Javascript function called on each path point
  34961. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34962. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34963. * @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
  34964. * @param scene defines the hosting scene
  34965. * @param updatable defines if the mesh must be flagged as updatable
  34966. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34967. * @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)
  34968. * @returns a new Mesh
  34969. */
  34970. 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;
  34971. /**
  34972. * Creates lathe mesh.
  34973. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34974. * Please consider using the same method from the MeshBuilder class instead
  34975. * @param name defines the name of the mesh to create
  34976. * @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
  34977. * @param radius is the radius value of the lathe
  34978. * @param tessellation is the side number of the lathe.
  34979. * @param scene defines the hosting scene
  34980. * @param updatable defines if the mesh must be flagged as updatable
  34981. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34982. * @returns a new Mesh
  34983. */
  34984. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34985. /**
  34986. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34987. * @param name defines the name of the mesh to create
  34988. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34989. * @param scene defines the hosting scene
  34990. * @param updatable defines if the mesh must be flagged as updatable
  34991. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34992. * @returns a new Mesh
  34993. */
  34994. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34995. /**
  34996. * Creates a ground mesh.
  34997. * Please consider using the same method from the MeshBuilder class instead
  34998. * @param name defines the name of the mesh to create
  34999. * @param width set the width of the ground
  35000. * @param height set the height of the ground
  35001. * @param subdivisions sets the number of subdivisions per side
  35002. * @param scene defines the hosting scene
  35003. * @param updatable defines if the mesh must be flagged as updatable
  35004. * @returns a new Mesh
  35005. */
  35006. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  35007. /**
  35008. * Creates a tiled ground mesh.
  35009. * Please consider using the same method from the MeshBuilder class instead
  35010. * @param name defines the name of the mesh to create
  35011. * @param xmin set the ground minimum X coordinate
  35012. * @param zmin set the ground minimum Y coordinate
  35013. * @param xmax set the ground maximum X coordinate
  35014. * @param zmax set the ground maximum Z coordinate
  35015. * @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
  35016. * @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
  35017. * @param scene defines the hosting scene
  35018. * @param updatable defines if the mesh must be flagged as updatable
  35019. * @returns a new Mesh
  35020. */
  35021. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  35022. w: number;
  35023. h: number;
  35024. }, precision: {
  35025. w: number;
  35026. h: number;
  35027. }, scene: Scene, updatable?: boolean): Mesh;
  35028. /**
  35029. * Creates a ground mesh from a height map.
  35030. * Please consider using the same method from the MeshBuilder class instead
  35031. * @see https://doc.babylonjs.com/babylon101/height_map
  35032. * @param name defines the name of the mesh to create
  35033. * @param url sets the URL of the height map image resource
  35034. * @param width set the ground width size
  35035. * @param height set the ground height size
  35036. * @param subdivisions sets the number of subdivision per side
  35037. * @param minHeight is the minimum altitude on the ground
  35038. * @param maxHeight is the maximum altitude on the ground
  35039. * @param scene defines the hosting scene
  35040. * @param updatable defines if the mesh must be flagged as updatable
  35041. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  35042. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  35043. * @returns a new Mesh
  35044. */
  35045. 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;
  35046. /**
  35047. * Creates a tube mesh.
  35048. * The tube is a parametric shape.
  35049. * It has no predefined shape. Its final shape will depend on the input parameters.
  35050. * Please consider using the same method from the MeshBuilder class instead
  35051. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35052. * @param name defines the name of the mesh to create
  35053. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  35054. * @param radius sets the tube radius size
  35055. * @param tessellation is the number of sides on the tubular surface
  35056. * @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
  35057. * @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
  35058. * @param scene defines the hosting scene
  35059. * @param updatable defines if the mesh must be flagged as updatable
  35060. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35061. * @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)
  35062. * @returns a new Mesh
  35063. */
  35064. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  35065. (i: number, distance: number): number;
  35066. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35067. /**
  35068. * Creates a polyhedron mesh.
  35069. * Please consider using the same method from the MeshBuilder class instead.
  35070. * * 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
  35071. * * The parameter `size` (positive float, default 1) sets the polygon size
  35072. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  35073. * * 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`
  35074. * * 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
  35075. * * 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)`)
  35076. * * 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
  35077. * * 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
  35078. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35081. * @param name defines the name of the mesh to create
  35082. * @param options defines the options used to create the mesh
  35083. * @param scene defines the hosting scene
  35084. * @returns a new Mesh
  35085. */
  35086. static CreatePolyhedron(name: string, options: {
  35087. type?: number;
  35088. size?: number;
  35089. sizeX?: number;
  35090. sizeY?: number;
  35091. sizeZ?: number;
  35092. custom?: any;
  35093. faceUV?: Vector4[];
  35094. faceColors?: Color4[];
  35095. updatable?: boolean;
  35096. sideOrientation?: number;
  35097. }, scene: Scene): Mesh;
  35098. /**
  35099. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  35100. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  35101. * * 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`)
  35102. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  35103. * * 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
  35104. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35107. * @param name defines the name of the mesh
  35108. * @param options defines the options used to create the mesh
  35109. * @param scene defines the hosting scene
  35110. * @returns a new Mesh
  35111. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  35112. */
  35113. static CreateIcoSphere(name: string, options: {
  35114. radius?: number;
  35115. flat?: boolean;
  35116. subdivisions?: number;
  35117. sideOrientation?: number;
  35118. updatable?: boolean;
  35119. }, scene: Scene): Mesh;
  35120. /**
  35121. * Creates a decal mesh.
  35122. * Please consider using the same method from the MeshBuilder class instead.
  35123. * A decal is a mesh usually applied as a model onto the surface of another mesh
  35124. * @param name defines the name of the mesh
  35125. * @param sourceMesh defines the mesh receiving the decal
  35126. * @param position sets the position of the decal in world coordinates
  35127. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  35128. * @param size sets the decal scaling
  35129. * @param angle sets the angle to rotate the decal
  35130. * @returns a new Mesh
  35131. */
  35132. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  35133. /** Creates a Capsule Mesh
  35134. * @param name defines the name of the mesh.
  35135. * @param options the constructors options used to shape the mesh.
  35136. * @param scene defines the scene the mesh is scoped to.
  35137. * @returns the capsule mesh
  35138. * @see https://doc.babylonjs.com/how_to/capsule_shape
  35139. */
  35140. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  35141. /**
  35142. * Prepare internal position array for software CPU skinning
  35143. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  35144. */
  35145. setPositionsForCPUSkinning(): Float32Array;
  35146. /**
  35147. * Prepare internal normal array for software CPU skinning
  35148. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  35149. */
  35150. setNormalsForCPUSkinning(): Float32Array;
  35151. /**
  35152. * Updates the vertex buffer by applying transformation from the bones
  35153. * @param skeleton defines the skeleton to apply to current mesh
  35154. * @returns the current mesh
  35155. */
  35156. applySkeleton(skeleton: Skeleton): Mesh;
  35157. /**
  35158. * 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
  35159. * @param meshes defines the list of meshes to scan
  35160. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  35161. */
  35162. static MinMax(meshes: AbstractMesh[]): {
  35163. min: Vector3;
  35164. max: Vector3;
  35165. };
  35166. /**
  35167. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  35168. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  35169. * @returns a vector3
  35170. */
  35171. static Center(meshesOrMinMaxVector: {
  35172. min: Vector3;
  35173. max: Vector3;
  35174. } | AbstractMesh[]): Vector3;
  35175. /**
  35176. * Merge the array of meshes into a single mesh for performance reasons.
  35177. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  35178. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  35179. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  35180. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  35181. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  35182. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  35183. * @returns a new mesh
  35184. */
  35185. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  35186. /** @hidden */
  35187. addInstance(instance: InstancedMesh): void;
  35188. /** @hidden */
  35189. removeInstance(instance: InstancedMesh): void;
  35190. }
  35191. }
  35192. declare module "babylonjs/Cameras/camera" {
  35193. import { SmartArray } from "babylonjs/Misc/smartArray";
  35194. import { Observable } from "babylonjs/Misc/observable";
  35195. import { Nullable } from "babylonjs/types";
  35196. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35197. import { Scene } from "babylonjs/scene";
  35198. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  35199. import { Node } from "babylonjs/node";
  35200. import { Mesh } from "babylonjs/Meshes/mesh";
  35201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35202. import { ICullable } from "babylonjs/Culling/boundingInfo";
  35203. import { Viewport } from "babylonjs/Maths/math.viewport";
  35204. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35205. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35206. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  35207. import { Ray } from "babylonjs/Culling/ray";
  35208. /**
  35209. * This is the base class of all the camera used in the application.
  35210. * @see https://doc.babylonjs.com/features/cameras
  35211. */
  35212. export class Camera extends Node {
  35213. /** @hidden */
  35214. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  35215. /**
  35216. * This is the default projection mode used by the cameras.
  35217. * It helps recreating a feeling of perspective and better appreciate depth.
  35218. * This is the best way to simulate real life cameras.
  35219. */
  35220. static readonly PERSPECTIVE_CAMERA: number;
  35221. /**
  35222. * This helps creating camera with an orthographic mode.
  35223. * 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.
  35224. */
  35225. static readonly ORTHOGRAPHIC_CAMERA: number;
  35226. /**
  35227. * This is the default FOV mode for perspective cameras.
  35228. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  35229. */
  35230. static readonly FOVMODE_VERTICAL_FIXED: number;
  35231. /**
  35232. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  35233. */
  35234. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  35235. /**
  35236. * This specifies ther is no need for a camera rig.
  35237. * Basically only one eye is rendered corresponding to the camera.
  35238. */
  35239. static readonly RIG_MODE_NONE: number;
  35240. /**
  35241. * Simulates a camera Rig with one blue eye and one red eye.
  35242. * This can be use with 3d blue and red glasses.
  35243. */
  35244. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  35245. /**
  35246. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  35247. */
  35248. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  35249. /**
  35250. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  35251. */
  35252. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  35253. /**
  35254. * Defines that both eyes of the camera will be rendered over under each other.
  35255. */
  35256. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  35257. /**
  35258. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  35259. */
  35260. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  35261. /**
  35262. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  35263. */
  35264. static readonly RIG_MODE_VR: number;
  35265. /**
  35266. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  35267. */
  35268. static readonly RIG_MODE_WEBVR: number;
  35269. /**
  35270. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  35271. */
  35272. static readonly RIG_MODE_CUSTOM: number;
  35273. /**
  35274. * Defines if by default attaching controls should prevent the default javascript event to continue.
  35275. */
  35276. static ForceAttachControlToAlwaysPreventDefault: boolean;
  35277. /**
  35278. * Define the input manager associated with the camera.
  35279. */
  35280. inputs: CameraInputsManager<Camera>;
  35281. /** @hidden */
  35282. _position: Vector3;
  35283. /**
  35284. * Define the current local position of the camera in the scene
  35285. */
  35286. get position(): Vector3;
  35287. set position(newPosition: Vector3);
  35288. protected _upVector: Vector3;
  35289. /**
  35290. * The vector the camera should consider as up.
  35291. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  35292. */
  35293. set upVector(vec: Vector3);
  35294. get upVector(): Vector3;
  35295. /**
  35296. * Define the current limit on the left side for an orthographic camera
  35297. * In scene unit
  35298. */
  35299. orthoLeft: Nullable<number>;
  35300. /**
  35301. * Define the current limit on the right side for an orthographic camera
  35302. * In scene unit
  35303. */
  35304. orthoRight: Nullable<number>;
  35305. /**
  35306. * Define the current limit on the bottom side for an orthographic camera
  35307. * In scene unit
  35308. */
  35309. orthoBottom: Nullable<number>;
  35310. /**
  35311. * Define the current limit on the top side for an orthographic camera
  35312. * In scene unit
  35313. */
  35314. orthoTop: Nullable<number>;
  35315. /**
  35316. * Field Of View is set in Radians. (default is 0.8)
  35317. */
  35318. fov: number;
  35319. /**
  35320. * Define the minimum distance the camera can see from.
  35321. * This is important to note that the depth buffer are not infinite and the closer it starts
  35322. * the more your scene might encounter depth fighting issue.
  35323. */
  35324. minZ: number;
  35325. /**
  35326. * Define the maximum distance the camera can see to.
  35327. * This is important to note that the depth buffer are not infinite and the further it end
  35328. * the more your scene might encounter depth fighting issue.
  35329. */
  35330. maxZ: number;
  35331. /**
  35332. * Define the default inertia of the camera.
  35333. * This helps giving a smooth feeling to the camera movement.
  35334. */
  35335. inertia: number;
  35336. /**
  35337. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  35338. */
  35339. mode: number;
  35340. /**
  35341. * Define whether the camera is intermediate.
  35342. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  35343. */
  35344. isIntermediate: boolean;
  35345. /**
  35346. * Define the viewport of the camera.
  35347. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  35348. */
  35349. viewport: Viewport;
  35350. /**
  35351. * Restricts the camera to viewing objects with the same layerMask.
  35352. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  35353. */
  35354. layerMask: number;
  35355. /**
  35356. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  35357. */
  35358. fovMode: number;
  35359. /**
  35360. * Rig mode of the camera.
  35361. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  35362. * This is normally controlled byt the camera themselves as internal use.
  35363. */
  35364. cameraRigMode: number;
  35365. /**
  35366. * Defines the distance between both "eyes" in case of a RIG
  35367. */
  35368. interaxialDistance: number;
  35369. /**
  35370. * Defines if stereoscopic rendering is done side by side or over under.
  35371. */
  35372. isStereoscopicSideBySide: boolean;
  35373. /**
  35374. * 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
  35375. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  35376. * else in the scene. (Eg. security camera)
  35377. *
  35378. * 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)
  35379. */
  35380. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  35381. /**
  35382. * When set, the camera will render to this render target instead of the default canvas
  35383. *
  35384. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  35385. */
  35386. outputRenderTarget: Nullable<RenderTargetTexture>;
  35387. /**
  35388. * Observable triggered when the camera view matrix has changed.
  35389. */
  35390. onViewMatrixChangedObservable: Observable<Camera>;
  35391. /**
  35392. * Observable triggered when the camera Projection matrix has changed.
  35393. */
  35394. onProjectionMatrixChangedObservable: Observable<Camera>;
  35395. /**
  35396. * Observable triggered when the inputs have been processed.
  35397. */
  35398. onAfterCheckInputsObservable: Observable<Camera>;
  35399. /**
  35400. * Observable triggered when reset has been called and applied to the camera.
  35401. */
  35402. onRestoreStateObservable: Observable<Camera>;
  35403. /**
  35404. * Is this camera a part of a rig system?
  35405. */
  35406. isRigCamera: boolean;
  35407. /**
  35408. * If isRigCamera set to true this will be set with the parent camera.
  35409. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  35410. */
  35411. rigParent?: Camera;
  35412. /** @hidden */
  35413. _cameraRigParams: any;
  35414. /** @hidden */
  35415. _rigCameras: Camera[];
  35416. /** @hidden */
  35417. _rigPostProcess: Nullable<PostProcess>;
  35418. protected _webvrViewMatrix: Matrix;
  35419. /** @hidden */
  35420. _skipRendering: boolean;
  35421. /** @hidden */
  35422. _projectionMatrix: Matrix;
  35423. /** @hidden */
  35424. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  35425. /** @hidden */
  35426. _activeMeshes: SmartArray<AbstractMesh>;
  35427. protected _globalPosition: Vector3;
  35428. /** @hidden */
  35429. _computedViewMatrix: Matrix;
  35430. private _doNotComputeProjectionMatrix;
  35431. private _transformMatrix;
  35432. private _frustumPlanes;
  35433. private _refreshFrustumPlanes;
  35434. private _storedFov;
  35435. private _stateStored;
  35436. /**
  35437. * Instantiates a new camera object.
  35438. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  35439. * @see https://doc.babylonjs.com/features/cameras
  35440. * @param name Defines the name of the camera in the scene
  35441. * @param position Defines the position of the camera
  35442. * @param scene Defines the scene the camera belongs too
  35443. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  35444. */
  35445. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35446. /**
  35447. * Store current camera state (fov, position, etc..)
  35448. * @returns the camera
  35449. */
  35450. storeState(): Camera;
  35451. /**
  35452. * Restores the camera state values if it has been stored. You must call storeState() first
  35453. */
  35454. protected _restoreStateValues(): boolean;
  35455. /**
  35456. * Restored camera state. You must call storeState() first.
  35457. * @returns true if restored and false otherwise
  35458. */
  35459. restoreState(): boolean;
  35460. /**
  35461. * Gets the class name of the camera.
  35462. * @returns the class name
  35463. */
  35464. getClassName(): string;
  35465. /** @hidden */
  35466. readonly _isCamera: boolean;
  35467. /**
  35468. * Gets a string representation of the camera useful for debug purpose.
  35469. * @param fullDetails Defines that a more verboe level of logging is required
  35470. * @returns the string representation
  35471. */
  35472. toString(fullDetails?: boolean): string;
  35473. /**
  35474. * Gets the current world space position of the camera.
  35475. */
  35476. get globalPosition(): Vector3;
  35477. /**
  35478. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  35479. * @returns the active meshe list
  35480. */
  35481. getActiveMeshes(): SmartArray<AbstractMesh>;
  35482. /**
  35483. * Check whether a mesh is part of the current active mesh list of the camera
  35484. * @param mesh Defines the mesh to check
  35485. * @returns true if active, false otherwise
  35486. */
  35487. isActiveMesh(mesh: Mesh): boolean;
  35488. /**
  35489. * Is this camera ready to be used/rendered
  35490. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  35491. * @return true if the camera is ready
  35492. */
  35493. isReady(completeCheck?: boolean): boolean;
  35494. /** @hidden */
  35495. _initCache(): void;
  35496. /** @hidden */
  35497. _updateCache(ignoreParentClass?: boolean): void;
  35498. /** @hidden */
  35499. _isSynchronized(): boolean;
  35500. /** @hidden */
  35501. _isSynchronizedViewMatrix(): boolean;
  35502. /** @hidden */
  35503. _isSynchronizedProjectionMatrix(): boolean;
  35504. /**
  35505. * Attach the input controls to a specific dom element to get the input from.
  35506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35507. */
  35508. attachControl(noPreventDefault?: boolean): void;
  35509. /**
  35510. * Detach the current controls from the specified dom element.
  35511. */
  35512. detachControl(): void;
  35513. /**
  35514. * Update the camera state according to the different inputs gathered during the frame.
  35515. */
  35516. update(): void;
  35517. /** @hidden */
  35518. _checkInputs(): void;
  35519. /** @hidden */
  35520. get rigCameras(): Camera[];
  35521. /**
  35522. * Gets the post process used by the rig cameras
  35523. */
  35524. get rigPostProcess(): Nullable<PostProcess>;
  35525. /**
  35526. * Internal, gets the first post proces.
  35527. * @returns the first post process to be run on this camera.
  35528. */
  35529. _getFirstPostProcess(): Nullable<PostProcess>;
  35530. private _cascadePostProcessesToRigCams;
  35531. /**
  35532. * Attach a post process to the camera.
  35533. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35534. * @param postProcess The post process to attach to the camera
  35535. * @param insertAt The position of the post process in case several of them are in use in the scene
  35536. * @returns the position the post process has been inserted at
  35537. */
  35538. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  35539. /**
  35540. * Detach a post process to the camera.
  35541. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35542. * @param postProcess The post process to detach from the camera
  35543. */
  35544. detachPostProcess(postProcess: PostProcess): void;
  35545. /**
  35546. * Gets the current world matrix of the camera
  35547. */
  35548. getWorldMatrix(): Matrix;
  35549. /** @hidden */
  35550. _getViewMatrix(): Matrix;
  35551. /**
  35552. * Gets the current view matrix of the camera.
  35553. * @param force forces the camera to recompute the matrix without looking at the cached state
  35554. * @returns the view matrix
  35555. */
  35556. getViewMatrix(force?: boolean): Matrix;
  35557. /**
  35558. * Freeze the projection matrix.
  35559. * It will prevent the cache check of the camera projection compute and can speed up perf
  35560. * if no parameter of the camera are meant to change
  35561. * @param projection Defines manually a projection if necessary
  35562. */
  35563. freezeProjectionMatrix(projection?: Matrix): void;
  35564. /**
  35565. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  35566. */
  35567. unfreezeProjectionMatrix(): void;
  35568. /**
  35569. * Gets the current projection matrix of the camera.
  35570. * @param force forces the camera to recompute the matrix without looking at the cached state
  35571. * @returns the projection matrix
  35572. */
  35573. getProjectionMatrix(force?: boolean): Matrix;
  35574. /**
  35575. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  35576. * @returns a Matrix
  35577. */
  35578. getTransformationMatrix(): Matrix;
  35579. private _updateFrustumPlanes;
  35580. /**
  35581. * Checks if a cullable object (mesh...) is in the camera frustum
  35582. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  35583. * @param target The object to check
  35584. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  35585. * @returns true if the object is in frustum otherwise false
  35586. */
  35587. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  35588. /**
  35589. * Checks if a cullable object (mesh...) is in the camera frustum
  35590. * Unlike isInFrustum this cheks the full bounding box
  35591. * @param target The object to check
  35592. * @returns true if the object is in frustum otherwise false
  35593. */
  35594. isCompletelyInFrustum(target: ICullable): boolean;
  35595. /**
  35596. * Gets a ray in the forward direction from the camera.
  35597. * @param length Defines the length of the ray to create
  35598. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35599. * @param origin Defines the start point of the ray which defaults to the camera position
  35600. * @returns the forward ray
  35601. */
  35602. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35603. /**
  35604. * Gets a ray in the forward direction from the camera.
  35605. * @param refRay the ray to (re)use when setting the values
  35606. * @param length Defines the length of the ray to create
  35607. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35608. * @param origin Defines the start point of the ray which defaults to the camera position
  35609. * @returns the forward ray
  35610. */
  35611. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35612. /**
  35613. * Releases resources associated with this node.
  35614. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35615. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35616. */
  35617. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35618. /** @hidden */
  35619. _isLeftCamera: boolean;
  35620. /**
  35621. * Gets the left camera of a rig setup in case of Rigged Camera
  35622. */
  35623. get isLeftCamera(): boolean;
  35624. /** @hidden */
  35625. _isRightCamera: boolean;
  35626. /**
  35627. * Gets the right camera of a rig setup in case of Rigged Camera
  35628. */
  35629. get isRightCamera(): boolean;
  35630. /**
  35631. * Gets the left camera of a rig setup in case of Rigged Camera
  35632. */
  35633. get leftCamera(): Nullable<FreeCamera>;
  35634. /**
  35635. * Gets the right camera of a rig setup in case of Rigged Camera
  35636. */
  35637. get rightCamera(): Nullable<FreeCamera>;
  35638. /**
  35639. * Gets the left camera target of a rig setup in case of Rigged Camera
  35640. * @returns the target position
  35641. */
  35642. getLeftTarget(): Nullable<Vector3>;
  35643. /**
  35644. * Gets the right camera target of a rig setup in case of Rigged Camera
  35645. * @returns the target position
  35646. */
  35647. getRightTarget(): Nullable<Vector3>;
  35648. /**
  35649. * @hidden
  35650. */
  35651. setCameraRigMode(mode: number, rigParams: any): void;
  35652. /** @hidden */
  35653. static _setStereoscopicRigMode(camera: Camera): void;
  35654. /** @hidden */
  35655. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  35656. /** @hidden */
  35657. static _setVRRigMode(camera: Camera, rigParams: any): void;
  35658. /** @hidden */
  35659. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  35660. /** @hidden */
  35661. _getVRProjectionMatrix(): Matrix;
  35662. protected _updateCameraRotationMatrix(): void;
  35663. protected _updateWebVRCameraRotationMatrix(): void;
  35664. /**
  35665. * This function MUST be overwritten by the different WebVR cameras available.
  35666. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35667. * @hidden
  35668. */
  35669. _getWebVRProjectionMatrix(): Matrix;
  35670. /**
  35671. * This function MUST be overwritten by the different WebVR cameras available.
  35672. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35673. * @hidden
  35674. */
  35675. _getWebVRViewMatrix(): Matrix;
  35676. /** @hidden */
  35677. setCameraRigParameter(name: string, value: any): void;
  35678. /**
  35679. * needs to be overridden by children so sub has required properties to be copied
  35680. * @hidden
  35681. */
  35682. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  35683. /**
  35684. * May need to be overridden by children
  35685. * @hidden
  35686. */
  35687. _updateRigCameras(): void;
  35688. /** @hidden */
  35689. _setupInputs(): void;
  35690. /**
  35691. * Serialiaze the camera setup to a json represention
  35692. * @returns the JSON representation
  35693. */
  35694. serialize(): any;
  35695. /**
  35696. * Clones the current camera.
  35697. * @param name The cloned camera name
  35698. * @returns the cloned camera
  35699. */
  35700. clone(name: string): Camera;
  35701. /**
  35702. * Gets the direction of the camera relative to a given local axis.
  35703. * @param localAxis Defines the reference axis to provide a relative direction.
  35704. * @return the direction
  35705. */
  35706. getDirection(localAxis: Vector3): Vector3;
  35707. /**
  35708. * Returns the current camera absolute rotation
  35709. */
  35710. get absoluteRotation(): Quaternion;
  35711. /**
  35712. * Gets the direction of the camera relative to a given local axis into a passed vector.
  35713. * @param localAxis Defines the reference axis to provide a relative direction.
  35714. * @param result Defines the vector to store the result in
  35715. */
  35716. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  35717. /**
  35718. * Gets a camera constructor for a given camera type
  35719. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  35720. * @param name The name of the camera the result will be able to instantiate
  35721. * @param scene The scene the result will construct the camera in
  35722. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  35723. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  35724. * @returns a factory method to construc the camera
  35725. */
  35726. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  35727. /**
  35728. * Compute the world matrix of the camera.
  35729. * @returns the camera world matrix
  35730. */
  35731. computeWorldMatrix(): Matrix;
  35732. /**
  35733. * Parse a JSON and creates the camera from the parsed information
  35734. * @param parsedCamera The JSON to parse
  35735. * @param scene The scene to instantiate the camera in
  35736. * @returns the newly constructed camera
  35737. */
  35738. static Parse(parsedCamera: any, scene: Scene): Camera;
  35739. }
  35740. }
  35741. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35742. import { Nullable } from "babylonjs/types";
  35743. import { Scene } from "babylonjs/scene";
  35744. import { Vector4 } from "babylonjs/Maths/math.vector";
  35745. import { Mesh } from "babylonjs/Meshes/mesh";
  35746. /**
  35747. * Class containing static functions to help procedurally build meshes
  35748. */
  35749. export class DiscBuilder {
  35750. /**
  35751. * Creates a plane polygonal mesh. By default, this is a disc
  35752. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35753. * * 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
  35754. * * 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
  35755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35756. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35758. * @param name defines the name of the mesh
  35759. * @param options defines the options used to create the mesh
  35760. * @param scene defines the hosting scene
  35761. * @returns the plane polygonal mesh
  35762. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35763. */
  35764. static CreateDisc(name: string, options: {
  35765. radius?: number;
  35766. tessellation?: number;
  35767. arc?: number;
  35768. updatable?: boolean;
  35769. sideOrientation?: number;
  35770. frontUVs?: Vector4;
  35771. backUVs?: Vector4;
  35772. }, scene?: Nullable<Scene>): Mesh;
  35773. }
  35774. }
  35775. declare module "babylonjs/Particles/solidParticleSystem" {
  35776. import { Nullable } from "babylonjs/types";
  35777. import { Mesh } from "babylonjs/Meshes/mesh";
  35778. import { Scene, IDisposable } from "babylonjs/scene";
  35779. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35780. import { Material } from "babylonjs/Materials/material";
  35781. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35782. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35783. /**
  35784. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35785. *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.
  35786. * The SPS is also a particle system. It provides some methods to manage the particles.
  35787. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35788. *
  35789. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35790. */
  35791. export class SolidParticleSystem implements IDisposable {
  35792. /**
  35793. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35794. * Example : var p = SPS.particles[i];
  35795. */
  35796. particles: SolidParticle[];
  35797. /**
  35798. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35799. */
  35800. nbParticles: number;
  35801. /**
  35802. * If the particles must ever face the camera (default false). Useful for planar particles.
  35803. */
  35804. billboard: boolean;
  35805. /**
  35806. * Recompute normals when adding a shape
  35807. */
  35808. recomputeNormals: boolean;
  35809. /**
  35810. * This a counter ofr your own usage. It's not set by any SPS functions.
  35811. */
  35812. counter: number;
  35813. /**
  35814. * The SPS name. This name is also given to the underlying mesh.
  35815. */
  35816. name: string;
  35817. /**
  35818. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35819. */
  35820. mesh: Mesh;
  35821. /**
  35822. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35823. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35824. */
  35825. vars: any;
  35826. /**
  35827. * This array is populated when the SPS is set as 'pickable'.
  35828. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35829. * Each element of this array is an object `{idx: int, faceId: int}`.
  35830. * `idx` is the picked particle index in the `SPS.particles` array
  35831. * `faceId` is the picked face index counted within this particle.
  35832. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35833. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35834. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35835. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35836. */
  35837. pickedParticles: {
  35838. idx: number;
  35839. faceId: number;
  35840. }[];
  35841. /**
  35842. * This array is populated when the SPS is set as 'pickable'
  35843. * Each key of this array is a submesh index.
  35844. * Each element of this array is a second array defined like this :
  35845. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35846. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35847. * `idx` is the picked particle index in the `SPS.particles` array
  35848. * `faceId` is the picked face index counted within this particle.
  35849. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35850. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35851. */
  35852. pickedBySubMesh: {
  35853. idx: number;
  35854. faceId: number;
  35855. }[][];
  35856. /**
  35857. * This array is populated when `enableDepthSort` is set to true.
  35858. * Each element of this array is an instance of the class DepthSortedParticle.
  35859. */
  35860. depthSortedParticles: DepthSortedParticle[];
  35861. /**
  35862. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35863. * @hidden
  35864. */
  35865. _bSphereOnly: boolean;
  35866. /**
  35867. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35868. * @hidden
  35869. */
  35870. _bSphereRadiusFactor: number;
  35871. private _scene;
  35872. private _positions;
  35873. private _indices;
  35874. private _normals;
  35875. private _colors;
  35876. private _uvs;
  35877. private _indices32;
  35878. private _positions32;
  35879. private _normals32;
  35880. private _fixedNormal32;
  35881. private _colors32;
  35882. private _uvs32;
  35883. private _index;
  35884. private _updatable;
  35885. private _pickable;
  35886. private _isVisibilityBoxLocked;
  35887. private _alwaysVisible;
  35888. private _depthSort;
  35889. private _expandable;
  35890. private _shapeCounter;
  35891. private _copy;
  35892. private _color;
  35893. private _computeParticleColor;
  35894. private _computeParticleTexture;
  35895. private _computeParticleRotation;
  35896. private _computeParticleVertex;
  35897. private _computeBoundingBox;
  35898. private _depthSortParticles;
  35899. private _camera;
  35900. private _mustUnrotateFixedNormals;
  35901. private _particlesIntersect;
  35902. private _needs32Bits;
  35903. private _isNotBuilt;
  35904. private _lastParticleId;
  35905. private _idxOfId;
  35906. private _multimaterialEnabled;
  35907. private _useModelMaterial;
  35908. private _indicesByMaterial;
  35909. private _materialIndexes;
  35910. private _depthSortFunction;
  35911. private _materialSortFunction;
  35912. private _materials;
  35913. private _multimaterial;
  35914. private _materialIndexesById;
  35915. private _defaultMaterial;
  35916. private _autoUpdateSubMeshes;
  35917. private _tmpVertex;
  35918. /**
  35919. * Creates a SPS (Solid Particle System) object.
  35920. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35921. * @param scene (Scene) is the scene in which the SPS is added.
  35922. * @param options defines the options of the sps e.g.
  35923. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35924. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35925. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35926. * * 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.
  35927. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35928. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35929. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35930. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35931. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35932. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35933. */
  35934. constructor(name: string, scene: Scene, options?: {
  35935. updatable?: boolean;
  35936. isPickable?: boolean;
  35937. enableDepthSort?: boolean;
  35938. particleIntersection?: boolean;
  35939. boundingSphereOnly?: boolean;
  35940. bSphereRadiusFactor?: number;
  35941. expandable?: boolean;
  35942. useModelMaterial?: boolean;
  35943. enableMultiMaterial?: boolean;
  35944. });
  35945. /**
  35946. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35947. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35948. * @returns the created mesh
  35949. */
  35950. buildMesh(): Mesh;
  35951. /**
  35952. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35953. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35954. * Thus the particles generated from `digest()` have their property `position` set yet.
  35955. * @param mesh ( Mesh ) is the mesh to be digested
  35956. * @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
  35957. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35958. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35959. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35960. * @returns the current SPS
  35961. */
  35962. digest(mesh: Mesh, options?: {
  35963. facetNb?: number;
  35964. number?: number;
  35965. delta?: number;
  35966. storage?: [];
  35967. }): SolidParticleSystem;
  35968. /**
  35969. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35970. * @hidden
  35971. */
  35972. private _unrotateFixedNormals;
  35973. /**
  35974. * Resets the temporary working copy particle
  35975. * @hidden
  35976. */
  35977. private _resetCopy;
  35978. /**
  35979. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35980. * @param p the current index in the positions array to be updated
  35981. * @param ind the current index in the indices array
  35982. * @param shape a Vector3 array, the shape geometry
  35983. * @param positions the positions array to be updated
  35984. * @param meshInd the shape indices array
  35985. * @param indices the indices array to be updated
  35986. * @param meshUV the shape uv array
  35987. * @param uvs the uv array to be updated
  35988. * @param meshCol the shape color array
  35989. * @param colors the color array to be updated
  35990. * @param meshNor the shape normals array
  35991. * @param normals the normals array to be updated
  35992. * @param idx the particle index
  35993. * @param idxInShape the particle index in its shape
  35994. * @param options the addShape() method passed options
  35995. * @model the particle model
  35996. * @hidden
  35997. */
  35998. private _meshBuilder;
  35999. /**
  36000. * Returns a shape Vector3 array from positions float array
  36001. * @param positions float array
  36002. * @returns a vector3 array
  36003. * @hidden
  36004. */
  36005. private _posToShape;
  36006. /**
  36007. * Returns a shapeUV array from a float uvs (array deep copy)
  36008. * @param uvs as a float array
  36009. * @returns a shapeUV array
  36010. * @hidden
  36011. */
  36012. private _uvsToShapeUV;
  36013. /**
  36014. * Adds a new particle object in the particles array
  36015. * @param idx particle index in particles array
  36016. * @param id particle id
  36017. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  36018. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  36019. * @param model particle ModelShape object
  36020. * @param shapeId model shape identifier
  36021. * @param idxInShape index of the particle in the current model
  36022. * @param bInfo model bounding info object
  36023. * @param storage target storage array, if any
  36024. * @hidden
  36025. */
  36026. private _addParticle;
  36027. /**
  36028. * Adds some particles to the SPS from the model shape. Returns the shape id.
  36029. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  36030. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  36031. * @param nb (positive integer) the number of particles to be created from this model
  36032. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  36033. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  36034. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  36035. * @returns the number of shapes in the system
  36036. */
  36037. addShape(mesh: Mesh, nb: number, options?: {
  36038. positionFunction?: any;
  36039. vertexFunction?: any;
  36040. storage?: [];
  36041. }): number;
  36042. /**
  36043. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  36044. * @hidden
  36045. */
  36046. private _rebuildParticle;
  36047. /**
  36048. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  36049. * @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.
  36050. * @returns the SPS.
  36051. */
  36052. rebuildMesh(reset?: boolean): SolidParticleSystem;
  36053. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  36054. * Returns an array with the removed particles.
  36055. * 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.
  36056. * The SPS can't be empty so at least one particle needs to remain in place.
  36057. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  36058. * @param start index of the first particle to remove
  36059. * @param end index of the last particle to remove (included)
  36060. * @returns an array populated with the removed particles
  36061. */
  36062. removeParticles(start: number, end: number): SolidParticle[];
  36063. /**
  36064. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  36065. * @param solidParticleArray an array populated with Solid Particles objects
  36066. * @returns the SPS
  36067. */
  36068. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  36069. /**
  36070. * Creates a new particle and modifies the SPS mesh geometry :
  36071. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  36072. * - calls _addParticle() to populate the particle array
  36073. * factorized code from addShape() and insertParticlesFromArray()
  36074. * @param idx particle index in the particles array
  36075. * @param i particle index in its shape
  36076. * @param modelShape particle ModelShape object
  36077. * @param shape shape vertex array
  36078. * @param meshInd shape indices array
  36079. * @param meshUV shape uv array
  36080. * @param meshCol shape color array
  36081. * @param meshNor shape normals array
  36082. * @param bbInfo shape bounding info
  36083. * @param storage target particle storage
  36084. * @options addShape() passed options
  36085. * @hidden
  36086. */
  36087. private _insertNewParticle;
  36088. /**
  36089. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  36090. * This method calls `updateParticle()` for each particle of the SPS.
  36091. * For an animated SPS, it is usually called within the render loop.
  36092. * 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.
  36093. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  36094. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  36095. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  36096. * @returns the SPS.
  36097. */
  36098. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  36099. /**
  36100. * Disposes the SPS.
  36101. */
  36102. dispose(): void;
  36103. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  36104. * idx is the particle index in the SPS
  36105. * faceId is the picked face index counted within this particle.
  36106. * Returns null if the pickInfo can't identify a picked particle.
  36107. * @param pickingInfo (PickingInfo object)
  36108. * @returns {idx: number, faceId: number} or null
  36109. */
  36110. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  36111. idx: number;
  36112. faceId: number;
  36113. }>;
  36114. /**
  36115. * Returns a SolidParticle object from its identifier : particle.id
  36116. * @param id (integer) the particle Id
  36117. * @returns the searched particle or null if not found in the SPS.
  36118. */
  36119. getParticleById(id: number): Nullable<SolidParticle>;
  36120. /**
  36121. * Returns a new array populated with the particles having the passed shapeId.
  36122. * @param shapeId (integer) the shape identifier
  36123. * @returns a new solid particle array
  36124. */
  36125. getParticlesByShapeId(shapeId: number): SolidParticle[];
  36126. /**
  36127. * Populates the passed array "ref" with the particles having the passed shapeId.
  36128. * @param shapeId the shape identifier
  36129. * @returns the SPS
  36130. * @param ref
  36131. */
  36132. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  36133. /**
  36134. * Computes the required SubMeshes according the materials assigned to the particles.
  36135. * @returns the solid particle system.
  36136. * Does nothing if called before the SPS mesh is built.
  36137. */
  36138. computeSubMeshes(): SolidParticleSystem;
  36139. /**
  36140. * Sorts the solid particles by material when MultiMaterial is enabled.
  36141. * Updates the indices32 array.
  36142. * Updates the indicesByMaterial array.
  36143. * Updates the mesh indices array.
  36144. * @returns the SPS
  36145. * @hidden
  36146. */
  36147. private _sortParticlesByMaterial;
  36148. /**
  36149. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  36150. * @hidden
  36151. */
  36152. private _setMaterialIndexesById;
  36153. /**
  36154. * Returns an array with unique values of Materials from the passed array
  36155. * @param array the material array to be checked and filtered
  36156. * @hidden
  36157. */
  36158. private _filterUniqueMaterialId;
  36159. /**
  36160. * Sets a new Standard Material as _defaultMaterial if not already set.
  36161. * @hidden
  36162. */
  36163. private _setDefaultMaterial;
  36164. /**
  36165. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  36166. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36167. * @returns the SPS.
  36168. */
  36169. refreshVisibleSize(): SolidParticleSystem;
  36170. /**
  36171. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  36172. * @param size the size (float) of the visibility box
  36173. * note : this doesn't lock the SPS mesh bounding box.
  36174. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36175. */
  36176. setVisibilityBox(size: number): void;
  36177. /**
  36178. * Gets whether the SPS as always visible or not
  36179. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36180. */
  36181. get isAlwaysVisible(): boolean;
  36182. /**
  36183. * Sets the SPS as always visible or not
  36184. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36185. */
  36186. set isAlwaysVisible(val: boolean);
  36187. /**
  36188. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36189. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36190. */
  36191. set isVisibilityBoxLocked(val: boolean);
  36192. /**
  36193. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36194. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36195. */
  36196. get isVisibilityBoxLocked(): boolean;
  36197. /**
  36198. * Tells to `setParticles()` to compute the particle rotations or not.
  36199. * Default value : true. The SPS is faster when it's set to false.
  36200. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36201. */
  36202. set computeParticleRotation(val: boolean);
  36203. /**
  36204. * Tells to `setParticles()` to compute the particle colors or not.
  36205. * Default value : true. The SPS is faster when it's set to false.
  36206. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36207. */
  36208. set computeParticleColor(val: boolean);
  36209. set computeParticleTexture(val: boolean);
  36210. /**
  36211. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  36212. * Default value : false. The SPS is faster when it's set to false.
  36213. * Note : the particle custom vertex positions aren't stored values.
  36214. */
  36215. set computeParticleVertex(val: boolean);
  36216. /**
  36217. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  36218. */
  36219. set computeBoundingBox(val: boolean);
  36220. /**
  36221. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  36222. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36223. * Default : `true`
  36224. */
  36225. set depthSortParticles(val: boolean);
  36226. /**
  36227. * Gets if `setParticles()` computes the particle rotations or not.
  36228. * Default value : true. The SPS is faster when it's set to false.
  36229. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36230. */
  36231. get computeParticleRotation(): boolean;
  36232. /**
  36233. * Gets if `setParticles()` computes the particle colors or not.
  36234. * Default value : true. The SPS is faster when it's set to false.
  36235. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36236. */
  36237. get computeParticleColor(): boolean;
  36238. /**
  36239. * Gets if `setParticles()` computes the particle textures or not.
  36240. * Default value : true. The SPS is faster when it's set to false.
  36241. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  36242. */
  36243. get computeParticleTexture(): boolean;
  36244. /**
  36245. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  36246. * Default value : false. The SPS is faster when it's set to false.
  36247. * Note : the particle custom vertex positions aren't stored values.
  36248. */
  36249. get computeParticleVertex(): boolean;
  36250. /**
  36251. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  36252. */
  36253. get computeBoundingBox(): boolean;
  36254. /**
  36255. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  36256. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36257. * Default : `true`
  36258. */
  36259. get depthSortParticles(): boolean;
  36260. /**
  36261. * Gets if the SPS is created as expandable at construction time.
  36262. * Default : `false`
  36263. */
  36264. get expandable(): boolean;
  36265. /**
  36266. * Gets if the SPS supports the Multi Materials
  36267. */
  36268. get multimaterialEnabled(): boolean;
  36269. /**
  36270. * Gets if the SPS uses the model materials for its own multimaterial.
  36271. */
  36272. get useModelMaterial(): boolean;
  36273. /**
  36274. * The SPS used material array.
  36275. */
  36276. get materials(): Material[];
  36277. /**
  36278. * Sets the SPS MultiMaterial from the passed materials.
  36279. * Note : the passed array is internally copied and not used then by reference.
  36280. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  36281. */
  36282. setMultiMaterial(materials: Material[]): void;
  36283. /**
  36284. * The SPS computed multimaterial object
  36285. */
  36286. get multimaterial(): MultiMaterial;
  36287. set multimaterial(mm: MultiMaterial);
  36288. /**
  36289. * If the subMeshes must be updated on the next call to setParticles()
  36290. */
  36291. get autoUpdateSubMeshes(): boolean;
  36292. set autoUpdateSubMeshes(val: boolean);
  36293. /**
  36294. * This function does nothing. It may be overwritten to set all the particle first values.
  36295. * The SPS doesn't call this function, you may have to call it by your own.
  36296. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36297. */
  36298. initParticles(): void;
  36299. /**
  36300. * This function does nothing. It may be overwritten to recycle a particle.
  36301. * The SPS doesn't call this function, you may have to call it by your own.
  36302. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36303. * @param particle The particle to recycle
  36304. * @returns the recycled particle
  36305. */
  36306. recycleParticle(particle: SolidParticle): SolidParticle;
  36307. /**
  36308. * Updates a particle : this function should be overwritten by the user.
  36309. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36310. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36311. * @example : just set a particle position or velocity and recycle conditions
  36312. * @param particle The particle to update
  36313. * @returns the updated particle
  36314. */
  36315. updateParticle(particle: SolidParticle): SolidParticle;
  36316. /**
  36317. * Updates a vertex of a particle : it can be overwritten by the user.
  36318. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36319. * @param particle the current particle
  36320. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36321. * @param pt the index of the current vertex in the particle shape
  36322. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36323. * @example : just set a vertex particle position or color
  36324. * @returns the sps
  36325. */
  36326. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36327. /**
  36328. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36329. * This does nothing and may be overwritten by the user.
  36330. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36331. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36332. * @param update the boolean update value actually passed to setParticles()
  36333. */
  36334. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36335. /**
  36336. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36337. * This will be passed three parameters.
  36338. * This does nothing and may be overwritten by the user.
  36339. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36340. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36341. * @param update the boolean update value actually passed to setParticles()
  36342. */
  36343. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36344. }
  36345. }
  36346. declare module "babylonjs/Particles/solidParticle" {
  36347. import { Nullable } from "babylonjs/types";
  36348. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36349. import { Color4 } from "babylonjs/Maths/math.color";
  36350. import { Mesh } from "babylonjs/Meshes/mesh";
  36351. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36352. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36353. import { Plane } from "babylonjs/Maths/math.plane";
  36354. import { Material } from "babylonjs/Materials/material";
  36355. /**
  36356. * Represents one particle of a solid particle system.
  36357. */
  36358. export class SolidParticle {
  36359. /**
  36360. * particle global index
  36361. */
  36362. idx: number;
  36363. /**
  36364. * particle identifier
  36365. */
  36366. id: number;
  36367. /**
  36368. * The color of the particle
  36369. */
  36370. color: Nullable<Color4>;
  36371. /**
  36372. * The world space position of the particle.
  36373. */
  36374. position: Vector3;
  36375. /**
  36376. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36377. */
  36378. rotation: Vector3;
  36379. /**
  36380. * The world space rotation quaternion of the particle.
  36381. */
  36382. rotationQuaternion: Nullable<Quaternion>;
  36383. /**
  36384. * The scaling of the particle.
  36385. */
  36386. scaling: Vector3;
  36387. /**
  36388. * The uvs of the particle.
  36389. */
  36390. uvs: Vector4;
  36391. /**
  36392. * The current speed of the particle.
  36393. */
  36394. velocity: Vector3;
  36395. /**
  36396. * The pivot point in the particle local space.
  36397. */
  36398. pivot: Vector3;
  36399. /**
  36400. * Must the particle be translated from its pivot point in its local space ?
  36401. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36402. * Default : false
  36403. */
  36404. translateFromPivot: boolean;
  36405. /**
  36406. * Is the particle active or not ?
  36407. */
  36408. alive: boolean;
  36409. /**
  36410. * Is the particle visible or not ?
  36411. */
  36412. isVisible: boolean;
  36413. /**
  36414. * Index of this particle in the global "positions" array (Internal use)
  36415. * @hidden
  36416. */
  36417. _pos: number;
  36418. /**
  36419. * @hidden Index of this particle in the global "indices" array (Internal use)
  36420. */
  36421. _ind: number;
  36422. /**
  36423. * @hidden ModelShape of this particle (Internal use)
  36424. */
  36425. _model: ModelShape;
  36426. /**
  36427. * ModelShape id of this particle
  36428. */
  36429. shapeId: number;
  36430. /**
  36431. * Index of the particle in its shape id
  36432. */
  36433. idxInShape: number;
  36434. /**
  36435. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36436. */
  36437. _modelBoundingInfo: BoundingInfo;
  36438. /**
  36439. * @hidden Particle BoundingInfo object (Internal use)
  36440. */
  36441. _boundingInfo: BoundingInfo;
  36442. /**
  36443. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36444. */
  36445. _sps: SolidParticleSystem;
  36446. /**
  36447. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36448. */
  36449. _stillInvisible: boolean;
  36450. /**
  36451. * @hidden Last computed particle rotation matrix
  36452. */
  36453. _rotationMatrix: number[];
  36454. /**
  36455. * Parent particle Id, if any.
  36456. * Default null.
  36457. */
  36458. parentId: Nullable<number>;
  36459. /**
  36460. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36461. */
  36462. materialIndex: Nullable<number>;
  36463. /**
  36464. * Custom object or properties.
  36465. */
  36466. props: Nullable<any>;
  36467. /**
  36468. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36469. * The possible values are :
  36470. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36471. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36472. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36473. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36474. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36475. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36476. * */
  36477. cullingStrategy: number;
  36478. /**
  36479. * @hidden Internal global position in the SPS.
  36480. */
  36481. _globalPosition: Vector3;
  36482. /**
  36483. * Creates a Solid Particle object.
  36484. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36485. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36486. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36487. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36488. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36489. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36490. * @param shapeId (integer) is the model shape identifier in the SPS.
  36491. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36492. * @param sps defines the sps it is associated to
  36493. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36494. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36495. */
  36496. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36497. /**
  36498. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36499. * @param target the particle target
  36500. * @returns the current particle
  36501. */
  36502. copyToRef(target: SolidParticle): SolidParticle;
  36503. /**
  36504. * Legacy support, changed scale to scaling
  36505. */
  36506. get scale(): Vector3;
  36507. /**
  36508. * Legacy support, changed scale to scaling
  36509. */
  36510. set scale(scale: Vector3);
  36511. /**
  36512. * Legacy support, changed quaternion to rotationQuaternion
  36513. */
  36514. get quaternion(): Nullable<Quaternion>;
  36515. /**
  36516. * Legacy support, changed quaternion to rotationQuaternion
  36517. */
  36518. set quaternion(q: Nullable<Quaternion>);
  36519. /**
  36520. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36521. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36522. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36523. * @returns true if it intersects
  36524. */
  36525. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36526. /**
  36527. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36528. * A particle is in the frustum if its bounding box intersects the frustum
  36529. * @param frustumPlanes defines the frustum to test
  36530. * @returns true if the particle is in the frustum planes
  36531. */
  36532. isInFrustum(frustumPlanes: Plane[]): boolean;
  36533. /**
  36534. * get the rotation matrix of the particle
  36535. * @hidden
  36536. */
  36537. getRotationMatrix(m: Matrix): void;
  36538. }
  36539. /**
  36540. * Represents the shape of the model used by one particle of a solid particle system.
  36541. * SPS internal tool, don't use it manually.
  36542. */
  36543. export class ModelShape {
  36544. /**
  36545. * The shape id
  36546. * @hidden
  36547. */
  36548. shapeID: number;
  36549. /**
  36550. * flat array of model positions (internal use)
  36551. * @hidden
  36552. */
  36553. _shape: Vector3[];
  36554. /**
  36555. * flat array of model UVs (internal use)
  36556. * @hidden
  36557. */
  36558. _shapeUV: number[];
  36559. /**
  36560. * color array of the model
  36561. * @hidden
  36562. */
  36563. _shapeColors: number[];
  36564. /**
  36565. * indices array of the model
  36566. * @hidden
  36567. */
  36568. _indices: number[];
  36569. /**
  36570. * normals array of the model
  36571. * @hidden
  36572. */
  36573. _normals: number[];
  36574. /**
  36575. * length of the shape in the model indices array (internal use)
  36576. * @hidden
  36577. */
  36578. _indicesLength: number;
  36579. /**
  36580. * Custom position function (internal use)
  36581. * @hidden
  36582. */
  36583. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36584. /**
  36585. * Custom vertex function (internal use)
  36586. * @hidden
  36587. */
  36588. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36589. /**
  36590. * Model material (internal use)
  36591. * @hidden
  36592. */
  36593. _material: Nullable<Material>;
  36594. /**
  36595. * 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.
  36596. * SPS internal tool, don't use it manually.
  36597. * @hidden
  36598. */
  36599. 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>);
  36600. }
  36601. /**
  36602. * Represents a Depth Sorted Particle in the solid particle system.
  36603. * @hidden
  36604. */
  36605. export class DepthSortedParticle {
  36606. /**
  36607. * Particle index
  36608. */
  36609. idx: number;
  36610. /**
  36611. * Index of the particle in the "indices" array
  36612. */
  36613. ind: number;
  36614. /**
  36615. * Length of the particle shape in the "indices" array
  36616. */
  36617. indicesLength: number;
  36618. /**
  36619. * Squared distance from the particle to the camera
  36620. */
  36621. sqDistance: number;
  36622. /**
  36623. * Material index when used with MultiMaterials
  36624. */
  36625. materialIndex: number;
  36626. /**
  36627. * Creates a new sorted particle
  36628. * @param materialIndex
  36629. */
  36630. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36631. }
  36632. /**
  36633. * Represents a solid particle vertex
  36634. */
  36635. export class SolidParticleVertex {
  36636. /**
  36637. * Vertex position
  36638. */
  36639. position: Vector3;
  36640. /**
  36641. * Vertex color
  36642. */
  36643. color: Color4;
  36644. /**
  36645. * Vertex UV
  36646. */
  36647. uv: Vector2;
  36648. /**
  36649. * Creates a new solid particle vertex
  36650. */
  36651. constructor();
  36652. /** Vertex x coordinate */
  36653. get x(): number;
  36654. set x(val: number);
  36655. /** Vertex y coordinate */
  36656. get y(): number;
  36657. set y(val: number);
  36658. /** Vertex z coordinate */
  36659. get z(): number;
  36660. set z(val: number);
  36661. }
  36662. }
  36663. declare module "babylonjs/Collisions/meshCollisionData" {
  36664. import { Collider } from "babylonjs/Collisions/collider";
  36665. import { Vector3 } from "babylonjs/Maths/math.vector";
  36666. import { Nullable } from "babylonjs/types";
  36667. import { Observer } from "babylonjs/Misc/observable";
  36668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36669. /**
  36670. * @hidden
  36671. */
  36672. export class _MeshCollisionData {
  36673. _checkCollisions: boolean;
  36674. _collisionMask: number;
  36675. _collisionGroup: number;
  36676. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36677. _collider: Nullable<Collider>;
  36678. _oldPositionForCollisions: Vector3;
  36679. _diffPositionForCollisions: Vector3;
  36680. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36681. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36682. _collisionResponse: boolean;
  36683. }
  36684. }
  36685. declare module "babylonjs/Meshes/abstractMesh" {
  36686. import { Observable } from "babylonjs/Misc/observable";
  36687. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36688. import { Camera } from "babylonjs/Cameras/camera";
  36689. import { Scene, IDisposable } from "babylonjs/scene";
  36690. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36691. import { Node } from "babylonjs/node";
  36692. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36693. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36694. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36695. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36696. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36697. import { Material } from "babylonjs/Materials/material";
  36698. import { Light } from "babylonjs/Lights/light";
  36699. import { Skeleton } from "babylonjs/Bones/skeleton";
  36700. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36701. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36702. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36703. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36704. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36705. import { Plane } from "babylonjs/Maths/math.plane";
  36706. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36707. import { Ray } from "babylonjs/Culling/ray";
  36708. import { Collider } from "babylonjs/Collisions/collider";
  36709. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36710. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36711. /** @hidden */
  36712. class _FacetDataStorage {
  36713. facetPositions: Vector3[];
  36714. facetNormals: Vector3[];
  36715. facetPartitioning: number[][];
  36716. facetNb: number;
  36717. partitioningSubdivisions: number;
  36718. partitioningBBoxRatio: number;
  36719. facetDataEnabled: boolean;
  36720. facetParameters: any;
  36721. bbSize: Vector3;
  36722. subDiv: {
  36723. max: number;
  36724. X: number;
  36725. Y: number;
  36726. Z: number;
  36727. };
  36728. facetDepthSort: boolean;
  36729. facetDepthSortEnabled: boolean;
  36730. depthSortedIndices: IndicesArray;
  36731. depthSortedFacets: {
  36732. ind: number;
  36733. sqDistance: number;
  36734. }[];
  36735. facetDepthSortFunction: (f1: {
  36736. ind: number;
  36737. sqDistance: number;
  36738. }, f2: {
  36739. ind: number;
  36740. sqDistance: number;
  36741. }) => number;
  36742. facetDepthSortFrom: Vector3;
  36743. facetDepthSortOrigin: Vector3;
  36744. invertedMatrix: Matrix;
  36745. }
  36746. /**
  36747. * @hidden
  36748. **/
  36749. class _InternalAbstractMeshDataInfo {
  36750. _hasVertexAlpha: boolean;
  36751. _useVertexColors: boolean;
  36752. _numBoneInfluencers: number;
  36753. _applyFog: boolean;
  36754. _receiveShadows: boolean;
  36755. _facetData: _FacetDataStorage;
  36756. _visibility: number;
  36757. _skeleton: Nullable<Skeleton>;
  36758. _layerMask: number;
  36759. _computeBonesUsingShaders: boolean;
  36760. _isActive: boolean;
  36761. _onlyForInstances: boolean;
  36762. _isActiveIntermediate: boolean;
  36763. _onlyForInstancesIntermediate: boolean;
  36764. _actAsRegularMesh: boolean;
  36765. _currentLOD: Nullable<AbstractMesh>;
  36766. }
  36767. /**
  36768. * Class used to store all common mesh properties
  36769. */
  36770. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36771. /** No occlusion */
  36772. static OCCLUSION_TYPE_NONE: number;
  36773. /** Occlusion set to optimisitic */
  36774. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36775. /** Occlusion set to strict */
  36776. static OCCLUSION_TYPE_STRICT: number;
  36777. /** Use an accurante occlusion algorithm */
  36778. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36779. /** Use a conservative occlusion algorithm */
  36780. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36781. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36782. * Test order :
  36783. * Is the bounding sphere outside the frustum ?
  36784. * If not, are the bounding box vertices outside the frustum ?
  36785. * It not, then the cullable object is in the frustum.
  36786. */
  36787. static readonly CULLINGSTRATEGY_STANDARD: number;
  36788. /** Culling strategy : Bounding Sphere Only.
  36789. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36790. * It's also less accurate than the standard because some not visible objects can still be selected.
  36791. * Test : is the bounding sphere outside the frustum ?
  36792. * If not, then the cullable object is in the frustum.
  36793. */
  36794. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36795. /** Culling strategy : Optimistic Inclusion.
  36796. * This in an inclusion test first, then the standard exclusion test.
  36797. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36798. * 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.
  36799. * Anyway, it's as accurate as the standard strategy.
  36800. * Test :
  36801. * Is the cullable object bounding sphere center in the frustum ?
  36802. * If not, apply the default culling strategy.
  36803. */
  36804. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36805. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36806. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36807. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36808. * 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.
  36809. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36810. * Test :
  36811. * Is the cullable object bounding sphere center in the frustum ?
  36812. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36813. */
  36814. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36815. /**
  36816. * No billboard
  36817. */
  36818. static get BILLBOARDMODE_NONE(): number;
  36819. /** Billboard on X axis */
  36820. static get BILLBOARDMODE_X(): number;
  36821. /** Billboard on Y axis */
  36822. static get BILLBOARDMODE_Y(): number;
  36823. /** Billboard on Z axis */
  36824. static get BILLBOARDMODE_Z(): number;
  36825. /** Billboard on all axes */
  36826. static get BILLBOARDMODE_ALL(): number;
  36827. /** Billboard on using position instead of orientation */
  36828. static get BILLBOARDMODE_USE_POSITION(): number;
  36829. /** @hidden */
  36830. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36831. /**
  36832. * The culling strategy to use to check whether the mesh must be rendered or not.
  36833. * This value can be changed at any time and will be used on the next render mesh selection.
  36834. * The possible values are :
  36835. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36836. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36837. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36838. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36839. * Please read each static variable documentation to get details about the culling process.
  36840. * */
  36841. cullingStrategy: number;
  36842. /**
  36843. * Gets the number of facets in the mesh
  36844. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36845. */
  36846. get facetNb(): number;
  36847. /**
  36848. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36849. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36850. */
  36851. get partitioningSubdivisions(): number;
  36852. set partitioningSubdivisions(nb: number);
  36853. /**
  36854. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36855. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36856. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36857. */
  36858. get partitioningBBoxRatio(): number;
  36859. set partitioningBBoxRatio(ratio: number);
  36860. /**
  36861. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36862. * Works only for updatable meshes.
  36863. * Doesn't work with multi-materials
  36864. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36865. */
  36866. get mustDepthSortFacets(): boolean;
  36867. set mustDepthSortFacets(sort: boolean);
  36868. /**
  36869. * The location (Vector3) where the facet depth sort must be computed from.
  36870. * By default, the active camera position.
  36871. * Used only when facet depth sort is enabled
  36872. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36873. */
  36874. get facetDepthSortFrom(): Vector3;
  36875. set facetDepthSortFrom(location: Vector3);
  36876. /**
  36877. * gets a boolean indicating if facetData is enabled
  36878. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36879. */
  36880. get isFacetDataEnabled(): boolean;
  36881. /** @hidden */
  36882. _updateNonUniformScalingState(value: boolean): boolean;
  36883. /**
  36884. * An event triggered when this mesh collides with another one
  36885. */
  36886. onCollideObservable: Observable<AbstractMesh>;
  36887. /** Set a function to call when this mesh collides with another one */
  36888. set onCollide(callback: () => void);
  36889. /**
  36890. * An event triggered when the collision's position changes
  36891. */
  36892. onCollisionPositionChangeObservable: Observable<Vector3>;
  36893. /** Set a function to call when the collision's position changes */
  36894. set onCollisionPositionChange(callback: () => void);
  36895. /**
  36896. * An event triggered when material is changed
  36897. */
  36898. onMaterialChangedObservable: Observable<AbstractMesh>;
  36899. /**
  36900. * Gets or sets the orientation for POV movement & rotation
  36901. */
  36902. definedFacingForward: boolean;
  36903. /** @hidden */
  36904. _occlusionQuery: Nullable<WebGLQuery>;
  36905. /** @hidden */
  36906. _renderingGroup: Nullable<RenderingGroup>;
  36907. /**
  36908. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36909. */
  36910. get visibility(): number;
  36911. /**
  36912. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36913. */
  36914. set visibility(value: number);
  36915. /** Gets or sets the alpha index used to sort transparent meshes
  36916. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36917. */
  36918. alphaIndex: number;
  36919. /**
  36920. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36921. */
  36922. isVisible: boolean;
  36923. /**
  36924. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36925. */
  36926. isPickable: boolean;
  36927. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36928. showSubMeshesBoundingBox: boolean;
  36929. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36930. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36931. */
  36932. isBlocker: boolean;
  36933. /**
  36934. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36935. */
  36936. enablePointerMoveEvents: boolean;
  36937. private _renderingGroupId;
  36938. /**
  36939. * Specifies the rendering group id for this mesh (0 by default)
  36940. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36941. */
  36942. get renderingGroupId(): number;
  36943. set renderingGroupId(value: number);
  36944. private _material;
  36945. /** Gets or sets current material */
  36946. get material(): Nullable<Material>;
  36947. set material(value: Nullable<Material>);
  36948. /**
  36949. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36950. * @see https://doc.babylonjs.com/babylon101/shadows
  36951. */
  36952. get receiveShadows(): boolean;
  36953. set receiveShadows(value: boolean);
  36954. /** Defines color to use when rendering outline */
  36955. outlineColor: Color3;
  36956. /** Define width to use when rendering outline */
  36957. outlineWidth: number;
  36958. /** Defines color to use when rendering overlay */
  36959. overlayColor: Color3;
  36960. /** Defines alpha to use when rendering overlay */
  36961. overlayAlpha: number;
  36962. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36963. get hasVertexAlpha(): boolean;
  36964. set hasVertexAlpha(value: boolean);
  36965. /** 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) */
  36966. get useVertexColors(): boolean;
  36967. set useVertexColors(value: boolean);
  36968. /**
  36969. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36970. */
  36971. get computeBonesUsingShaders(): boolean;
  36972. set computeBonesUsingShaders(value: boolean);
  36973. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36974. get numBoneInfluencers(): number;
  36975. set numBoneInfluencers(value: number);
  36976. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36977. get applyFog(): boolean;
  36978. set applyFog(value: boolean);
  36979. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36980. useOctreeForRenderingSelection: boolean;
  36981. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36982. useOctreeForPicking: boolean;
  36983. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36984. useOctreeForCollisions: boolean;
  36985. /**
  36986. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36987. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36988. */
  36989. get layerMask(): number;
  36990. set layerMask(value: number);
  36991. /**
  36992. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36993. */
  36994. alwaysSelectAsActiveMesh: boolean;
  36995. /**
  36996. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36997. */
  36998. doNotSyncBoundingInfo: boolean;
  36999. /**
  37000. * Gets or sets the current action manager
  37001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37002. */
  37003. actionManager: Nullable<AbstractActionManager>;
  37004. private _meshCollisionData;
  37005. /**
  37006. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  37007. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37008. */
  37009. ellipsoid: Vector3;
  37010. /**
  37011. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  37012. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37013. */
  37014. ellipsoidOffset: Vector3;
  37015. /**
  37016. * Gets or sets a collision mask used to mask collisions (default is -1).
  37017. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37018. */
  37019. get collisionMask(): number;
  37020. set collisionMask(mask: number);
  37021. /**
  37022. * Gets or sets a collision response flag (default is true).
  37023. * when collisionResponse is false, events are still triggered but colliding entity has no response
  37024. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  37025. * to respond to the collision.
  37026. */
  37027. get collisionResponse(): boolean;
  37028. set collisionResponse(response: boolean);
  37029. /**
  37030. * Gets or sets the current collision group mask (-1 by default).
  37031. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37032. */
  37033. get collisionGroup(): number;
  37034. set collisionGroup(mask: number);
  37035. /**
  37036. * Gets or sets current surrounding meshes (null by default).
  37037. *
  37038. * By default collision detection is tested against every mesh in the scene.
  37039. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  37040. * meshes will be tested for the collision.
  37041. *
  37042. * Note: if set to an empty array no collision will happen when this mesh is moved.
  37043. */
  37044. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  37045. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  37046. /**
  37047. * Defines edge width used when edgesRenderer is enabled
  37048. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37049. */
  37050. edgesWidth: number;
  37051. /**
  37052. * Defines edge color used when edgesRenderer is enabled
  37053. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37054. */
  37055. edgesColor: Color4;
  37056. /** @hidden */
  37057. _edgesRenderer: Nullable<IEdgesRenderer>;
  37058. /** @hidden */
  37059. _masterMesh: Nullable<AbstractMesh>;
  37060. /** @hidden */
  37061. _boundingInfo: Nullable<BoundingInfo>;
  37062. /** @hidden */
  37063. _renderId: number;
  37064. /**
  37065. * Gets or sets the list of subMeshes
  37066. * @see https://doc.babylonjs.com/how_to/multi_materials
  37067. */
  37068. subMeshes: SubMesh[];
  37069. /** @hidden */
  37070. _intersectionsInProgress: AbstractMesh[];
  37071. /** @hidden */
  37072. _unIndexed: boolean;
  37073. /** @hidden */
  37074. _lightSources: Light[];
  37075. /** Gets the list of lights affecting that mesh */
  37076. get lightSources(): Light[];
  37077. /** @hidden */
  37078. get _positions(): Nullable<Vector3[]>;
  37079. /** @hidden */
  37080. _waitingData: {
  37081. lods: Nullable<any>;
  37082. actions: Nullable<any>;
  37083. freezeWorldMatrix: Nullable<boolean>;
  37084. };
  37085. /** @hidden */
  37086. _bonesTransformMatrices: Nullable<Float32Array>;
  37087. /** @hidden */
  37088. _transformMatrixTexture: Nullable<RawTexture>;
  37089. /**
  37090. * Gets or sets a skeleton to apply skining transformations
  37091. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37092. */
  37093. set skeleton(value: Nullable<Skeleton>);
  37094. get skeleton(): Nullable<Skeleton>;
  37095. /**
  37096. * An event triggered when the mesh is rebuilt.
  37097. */
  37098. onRebuildObservable: Observable<AbstractMesh>;
  37099. /**
  37100. * Creates a new AbstractMesh
  37101. * @param name defines the name of the mesh
  37102. * @param scene defines the hosting scene
  37103. */
  37104. constructor(name: string, scene?: Nullable<Scene>);
  37105. /**
  37106. * Returns the string "AbstractMesh"
  37107. * @returns "AbstractMesh"
  37108. */
  37109. getClassName(): string;
  37110. /**
  37111. * Gets a string representation of the current mesh
  37112. * @param fullDetails defines a boolean indicating if full details must be included
  37113. * @returns a string representation of the current mesh
  37114. */
  37115. toString(fullDetails?: boolean): string;
  37116. /**
  37117. * @hidden
  37118. */
  37119. protected _getEffectiveParent(): Nullable<Node>;
  37120. /** @hidden */
  37121. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37122. /** @hidden */
  37123. _rebuild(): void;
  37124. /** @hidden */
  37125. _resyncLightSources(): void;
  37126. /** @hidden */
  37127. _resyncLightSource(light: Light): void;
  37128. /** @hidden */
  37129. _unBindEffect(): void;
  37130. /** @hidden */
  37131. _removeLightSource(light: Light, dispose: boolean): void;
  37132. private _markSubMeshesAsDirty;
  37133. /** @hidden */
  37134. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  37135. /** @hidden */
  37136. _markSubMeshesAsAttributesDirty(): void;
  37137. /** @hidden */
  37138. _markSubMeshesAsMiscDirty(): void;
  37139. /**
  37140. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  37141. */
  37142. get scaling(): Vector3;
  37143. set scaling(newScaling: Vector3);
  37144. /**
  37145. * Returns true if the mesh is blocked. Implemented by child classes
  37146. */
  37147. get isBlocked(): boolean;
  37148. /**
  37149. * Returns the mesh itself by default. Implemented by child classes
  37150. * @param camera defines the camera to use to pick the right LOD level
  37151. * @returns the currentAbstractMesh
  37152. */
  37153. getLOD(camera: Camera): Nullable<AbstractMesh>;
  37154. /**
  37155. * Returns 0 by default. Implemented by child classes
  37156. * @returns an integer
  37157. */
  37158. getTotalVertices(): number;
  37159. /**
  37160. * Returns a positive integer : the total number of indices in this mesh geometry.
  37161. * @returns the numner of indices or zero if the mesh has no geometry.
  37162. */
  37163. getTotalIndices(): number;
  37164. /**
  37165. * Returns null by default. Implemented by child classes
  37166. * @returns null
  37167. */
  37168. getIndices(): Nullable<IndicesArray>;
  37169. /**
  37170. * Returns the array of the requested vertex data kind. Implemented by child classes
  37171. * @param kind defines the vertex data kind to use
  37172. * @returns null
  37173. */
  37174. getVerticesData(kind: string): Nullable<FloatArray>;
  37175. /**
  37176. * Sets the vertex data of the mesh geometry for the requested `kind`.
  37177. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  37178. * Note that a new underlying VertexBuffer object is created each call.
  37179. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  37180. * @param kind defines vertex data kind:
  37181. * * VertexBuffer.PositionKind
  37182. * * VertexBuffer.UVKind
  37183. * * VertexBuffer.UV2Kind
  37184. * * VertexBuffer.UV3Kind
  37185. * * VertexBuffer.UV4Kind
  37186. * * VertexBuffer.UV5Kind
  37187. * * VertexBuffer.UV6Kind
  37188. * * VertexBuffer.ColorKind
  37189. * * VertexBuffer.MatricesIndicesKind
  37190. * * VertexBuffer.MatricesIndicesExtraKind
  37191. * * VertexBuffer.MatricesWeightsKind
  37192. * * VertexBuffer.MatricesWeightsExtraKind
  37193. * @param data defines the data source
  37194. * @param updatable defines if the data must be flagged as updatable (or static)
  37195. * @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
  37196. * @returns the current mesh
  37197. */
  37198. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  37199. /**
  37200. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  37201. * If the mesh has no geometry, it is simply returned as it is.
  37202. * @param kind defines vertex data kind:
  37203. * * VertexBuffer.PositionKind
  37204. * * VertexBuffer.UVKind
  37205. * * VertexBuffer.UV2Kind
  37206. * * VertexBuffer.UV3Kind
  37207. * * VertexBuffer.UV4Kind
  37208. * * VertexBuffer.UV5Kind
  37209. * * VertexBuffer.UV6Kind
  37210. * * VertexBuffer.ColorKind
  37211. * * VertexBuffer.MatricesIndicesKind
  37212. * * VertexBuffer.MatricesIndicesExtraKind
  37213. * * VertexBuffer.MatricesWeightsKind
  37214. * * VertexBuffer.MatricesWeightsExtraKind
  37215. * @param data defines the data source
  37216. * @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
  37217. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  37218. * @returns the current mesh
  37219. */
  37220. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  37221. /**
  37222. * Sets the mesh indices,
  37223. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  37224. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  37225. * @param totalVertices Defines the total number of vertices
  37226. * @returns the current mesh
  37227. */
  37228. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  37229. /**
  37230. * Gets a boolean indicating if specific vertex data is present
  37231. * @param kind defines the vertex data kind to use
  37232. * @returns true is data kind is present
  37233. */
  37234. isVerticesDataPresent(kind: string): boolean;
  37235. /**
  37236. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  37237. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  37238. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  37239. * @returns a BoundingInfo
  37240. */
  37241. getBoundingInfo(): BoundingInfo;
  37242. /**
  37243. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  37244. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  37245. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  37246. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  37247. * @returns the current mesh
  37248. */
  37249. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  37250. /**
  37251. * Overwrite the current bounding info
  37252. * @param boundingInfo defines the new bounding info
  37253. * @returns the current mesh
  37254. */
  37255. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  37256. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  37257. get useBones(): boolean;
  37258. /** @hidden */
  37259. _preActivate(): void;
  37260. /** @hidden */
  37261. _preActivateForIntermediateRendering(renderId: number): void;
  37262. /** @hidden */
  37263. _activate(renderId: number, intermediateRendering: boolean): boolean;
  37264. /** @hidden */
  37265. _postActivate(): void;
  37266. /** @hidden */
  37267. _freeze(): void;
  37268. /** @hidden */
  37269. _unFreeze(): void;
  37270. /**
  37271. * Gets the current world matrix
  37272. * @returns a Matrix
  37273. */
  37274. getWorldMatrix(): Matrix;
  37275. /** @hidden */
  37276. _getWorldMatrixDeterminant(): number;
  37277. /**
  37278. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  37279. */
  37280. get isAnInstance(): boolean;
  37281. /**
  37282. * Gets a boolean indicating if this mesh has instances
  37283. */
  37284. get hasInstances(): boolean;
  37285. /**
  37286. * Gets a boolean indicating if this mesh has thin instances
  37287. */
  37288. get hasThinInstances(): boolean;
  37289. /**
  37290. * Perform relative position change from the point of view of behind the front of the mesh.
  37291. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37292. * Supports definition of mesh facing forward or backward
  37293. * @param amountRight defines the distance on the right axis
  37294. * @param amountUp defines the distance on the up axis
  37295. * @param amountForward defines the distance on the forward axis
  37296. * @returns the current mesh
  37297. */
  37298. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37299. /**
  37300. * Calculate relative position change from the point of view of behind the front of the mesh.
  37301. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37302. * Supports definition of mesh facing forward or backward
  37303. * @param amountRight defines the distance on the right axis
  37304. * @param amountUp defines the distance on the up axis
  37305. * @param amountForward defines the distance on the forward axis
  37306. * @returns the new displacement vector
  37307. */
  37308. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37309. /**
  37310. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37311. * Supports definition of mesh facing forward or backward
  37312. * @param flipBack defines the flip
  37313. * @param twirlClockwise defines the twirl
  37314. * @param tiltRight defines the tilt
  37315. * @returns the current mesh
  37316. */
  37317. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37318. /**
  37319. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37320. * Supports definition of mesh facing forward or backward.
  37321. * @param flipBack defines the flip
  37322. * @param twirlClockwise defines the twirl
  37323. * @param tiltRight defines the tilt
  37324. * @returns the new rotation vector
  37325. */
  37326. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37327. /**
  37328. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37329. * This means the mesh underlying bounding box and sphere are recomputed.
  37330. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37331. * @returns the current mesh
  37332. */
  37333. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37334. /** @hidden */
  37335. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37336. /** @hidden */
  37337. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37338. /** @hidden */
  37339. _updateBoundingInfo(): AbstractMesh;
  37340. /** @hidden */
  37341. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37342. /** @hidden */
  37343. protected _afterComputeWorldMatrix(): void;
  37344. /** @hidden */
  37345. get _effectiveMesh(): AbstractMesh;
  37346. /**
  37347. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37348. * A mesh is in the frustum if its bounding box intersects the frustum
  37349. * @param frustumPlanes defines the frustum to test
  37350. * @returns true if the mesh is in the frustum planes
  37351. */
  37352. isInFrustum(frustumPlanes: Plane[]): boolean;
  37353. /**
  37354. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37355. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37356. * @param frustumPlanes defines the frustum to test
  37357. * @returns true if the mesh is completely in the frustum planes
  37358. */
  37359. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37360. /**
  37361. * True if the mesh intersects another mesh or a SolidParticle object
  37362. * @param mesh defines a target mesh or SolidParticle to test
  37363. * @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)
  37364. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37365. * @returns true if there is an intersection
  37366. */
  37367. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37368. /**
  37369. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37370. * @param point defines the point to test
  37371. * @returns true if there is an intersection
  37372. */
  37373. intersectsPoint(point: Vector3): boolean;
  37374. /**
  37375. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37376. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37377. */
  37378. get checkCollisions(): boolean;
  37379. set checkCollisions(collisionEnabled: boolean);
  37380. /**
  37381. * Gets Collider object used to compute collisions (not physics)
  37382. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37383. */
  37384. get collider(): Nullable<Collider>;
  37385. /**
  37386. * Move the mesh using collision engine
  37387. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37388. * @param displacement defines the requested displacement vector
  37389. * @returns the current mesh
  37390. */
  37391. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37392. private _onCollisionPositionChange;
  37393. /** @hidden */
  37394. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37395. /** @hidden */
  37396. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37397. /** @hidden */
  37398. _checkCollision(collider: Collider): AbstractMesh;
  37399. /** @hidden */
  37400. _generatePointsArray(): boolean;
  37401. /**
  37402. * Checks if the passed Ray intersects with the mesh
  37403. * @param ray defines the ray to use
  37404. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37405. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37406. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37407. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37408. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  37409. * @returns the picking info
  37410. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37411. */
  37412. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  37413. /**
  37414. * Clones the current mesh
  37415. * @param name defines the mesh name
  37416. * @param newParent defines the new mesh parent
  37417. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37418. * @returns the new mesh
  37419. */
  37420. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37421. /**
  37422. * Disposes all the submeshes of the current meshnp
  37423. * @returns the current mesh
  37424. */
  37425. releaseSubMeshes(): AbstractMesh;
  37426. /**
  37427. * Releases resources associated with this abstract mesh.
  37428. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37429. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37430. */
  37431. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37432. /**
  37433. * Adds the passed mesh as a child to the current mesh
  37434. * @param mesh defines the child mesh
  37435. * @returns the current mesh
  37436. */
  37437. addChild(mesh: AbstractMesh): AbstractMesh;
  37438. /**
  37439. * Removes the passed mesh from the current mesh children list
  37440. * @param mesh defines the child mesh
  37441. * @returns the current mesh
  37442. */
  37443. removeChild(mesh: AbstractMesh): AbstractMesh;
  37444. /** @hidden */
  37445. private _initFacetData;
  37446. /**
  37447. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37448. * This method can be called within the render loop.
  37449. * 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
  37450. * @returns the current mesh
  37451. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37452. */
  37453. updateFacetData(): AbstractMesh;
  37454. /**
  37455. * Returns the facetLocalNormals array.
  37456. * The normals are expressed in the mesh local spac
  37457. * @returns an array of Vector3
  37458. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37459. */
  37460. getFacetLocalNormals(): Vector3[];
  37461. /**
  37462. * Returns the facetLocalPositions array.
  37463. * The facet positions are expressed in the mesh local space
  37464. * @returns an array of Vector3
  37465. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37466. */
  37467. getFacetLocalPositions(): Vector3[];
  37468. /**
  37469. * Returns the facetLocalPartioning array
  37470. * @returns an array of array of numbers
  37471. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37472. */
  37473. getFacetLocalPartitioning(): number[][];
  37474. /**
  37475. * Returns the i-th facet position in the world system.
  37476. * This method allocates a new Vector3 per call
  37477. * @param i defines the facet index
  37478. * @returns a new Vector3
  37479. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37480. */
  37481. getFacetPosition(i: number): Vector3;
  37482. /**
  37483. * Sets the reference Vector3 with the i-th facet position in the world system
  37484. * @param i defines the facet index
  37485. * @param ref defines the target vector
  37486. * @returns the current mesh
  37487. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37488. */
  37489. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37490. /**
  37491. * Returns the i-th facet normal in the world system.
  37492. * This method allocates a new Vector3 per call
  37493. * @param i defines the facet index
  37494. * @returns a new Vector3
  37495. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37496. */
  37497. getFacetNormal(i: number): Vector3;
  37498. /**
  37499. * Sets the reference Vector3 with the i-th facet normal in the world system
  37500. * @param i defines the facet index
  37501. * @param ref defines the target vector
  37502. * @returns the current mesh
  37503. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37504. */
  37505. getFacetNormalToRef(i: number, ref: Vector3): this;
  37506. /**
  37507. * 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)
  37508. * @param x defines x coordinate
  37509. * @param y defines y coordinate
  37510. * @param z defines z coordinate
  37511. * @returns the array of facet indexes
  37512. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37513. */
  37514. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37515. /**
  37516. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37517. * @param projected sets as the (x,y,z) world projection on the facet
  37518. * @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
  37519. * @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
  37520. * @param x defines x coordinate
  37521. * @param y defines y coordinate
  37522. * @param z defines z coordinate
  37523. * @returns the face index if found (or null instead)
  37524. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37525. */
  37526. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37527. /**
  37528. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37529. * @param projected sets as the (x,y,z) local projection on the facet
  37530. * @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
  37531. * @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
  37532. * @param x defines x coordinate
  37533. * @param y defines y coordinate
  37534. * @param z defines z coordinate
  37535. * @returns the face index if found (or null instead)
  37536. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37537. */
  37538. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37539. /**
  37540. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37541. * @returns the parameters
  37542. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37543. */
  37544. getFacetDataParameters(): any;
  37545. /**
  37546. * Disables the feature FacetData and frees the related memory
  37547. * @returns the current mesh
  37548. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37549. */
  37550. disableFacetData(): AbstractMesh;
  37551. /**
  37552. * Updates the AbstractMesh indices array
  37553. * @param indices defines the data source
  37554. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37555. * @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)
  37556. * @returns the current mesh
  37557. */
  37558. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37559. /**
  37560. * Creates new normals data for the mesh
  37561. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37562. * @returns the current mesh
  37563. */
  37564. createNormals(updatable: boolean): AbstractMesh;
  37565. /**
  37566. * Align the mesh with a normal
  37567. * @param normal defines the normal to use
  37568. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37569. * @returns the current mesh
  37570. */
  37571. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37572. /** @hidden */
  37573. _checkOcclusionQuery(): boolean;
  37574. /**
  37575. * Disables the mesh edge rendering mode
  37576. * @returns the currentAbstractMesh
  37577. */
  37578. disableEdgesRendering(): AbstractMesh;
  37579. /**
  37580. * Enables the edge rendering mode on the mesh.
  37581. * This mode makes the mesh edges visible
  37582. * @param epsilon defines the maximal distance between two angles to detect a face
  37583. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37584. * @returns the currentAbstractMesh
  37585. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37586. */
  37587. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  37588. /**
  37589. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37590. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37591. */
  37592. getConnectedParticleSystems(): IParticleSystem[];
  37593. }
  37594. }
  37595. declare module "babylonjs/Actions/actionEvent" {
  37596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37597. import { Nullable } from "babylonjs/types";
  37598. import { Sprite } from "babylonjs/Sprites/sprite";
  37599. import { Scene } from "babylonjs/scene";
  37600. import { Vector2 } from "babylonjs/Maths/math.vector";
  37601. /**
  37602. * Interface used to define ActionEvent
  37603. */
  37604. export interface IActionEvent {
  37605. /** The mesh or sprite that triggered the action */
  37606. source: any;
  37607. /** The X mouse cursor position at the time of the event */
  37608. pointerX: number;
  37609. /** The Y mouse cursor position at the time of the event */
  37610. pointerY: number;
  37611. /** The mesh that is currently pointed at (can be null) */
  37612. meshUnderPointer: Nullable<AbstractMesh>;
  37613. /** the original (browser) event that triggered the ActionEvent */
  37614. sourceEvent?: any;
  37615. /** additional data for the event */
  37616. additionalData?: any;
  37617. }
  37618. /**
  37619. * ActionEvent is the event being sent when an action is triggered.
  37620. */
  37621. export class ActionEvent implements IActionEvent {
  37622. /** The mesh or sprite that triggered the action */
  37623. source: any;
  37624. /** The X mouse cursor position at the time of the event */
  37625. pointerX: number;
  37626. /** The Y mouse cursor position at the time of the event */
  37627. pointerY: number;
  37628. /** The mesh that is currently pointed at (can be null) */
  37629. meshUnderPointer: Nullable<AbstractMesh>;
  37630. /** the original (browser) event that triggered the ActionEvent */
  37631. sourceEvent?: any;
  37632. /** additional data for the event */
  37633. additionalData?: any;
  37634. /**
  37635. * Creates a new ActionEvent
  37636. * @param source The mesh or sprite that triggered the action
  37637. * @param pointerX The X mouse cursor position at the time of the event
  37638. * @param pointerY The Y mouse cursor position at the time of the event
  37639. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37640. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37641. * @param additionalData additional data for the event
  37642. */
  37643. constructor(
  37644. /** The mesh or sprite that triggered the action */
  37645. source: any,
  37646. /** The X mouse cursor position at the time of the event */
  37647. pointerX: number,
  37648. /** The Y mouse cursor position at the time of the event */
  37649. pointerY: number,
  37650. /** The mesh that is currently pointed at (can be null) */
  37651. meshUnderPointer: Nullable<AbstractMesh>,
  37652. /** the original (browser) event that triggered the ActionEvent */
  37653. sourceEvent?: any,
  37654. /** additional data for the event */
  37655. additionalData?: any);
  37656. /**
  37657. * Helper function to auto-create an ActionEvent from a source mesh.
  37658. * @param source The source mesh that triggered the event
  37659. * @param evt The original (browser) event
  37660. * @param additionalData additional data for the event
  37661. * @returns the new ActionEvent
  37662. */
  37663. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37664. /**
  37665. * Helper function to auto-create an ActionEvent from a source sprite
  37666. * @param source The source sprite that triggered the event
  37667. * @param scene Scene associated with the sprite
  37668. * @param evt The original (browser) event
  37669. * @param additionalData additional data for the event
  37670. * @returns the new ActionEvent
  37671. */
  37672. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37673. /**
  37674. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37675. * @param scene the scene where the event occurred
  37676. * @param evt The original (browser) event
  37677. * @returns the new ActionEvent
  37678. */
  37679. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37680. /**
  37681. * Helper function to auto-create an ActionEvent from a primitive
  37682. * @param prim defines the target primitive
  37683. * @param pointerPos defines the pointer position
  37684. * @param evt The original (browser) event
  37685. * @param additionalData additional data for the event
  37686. * @returns the new ActionEvent
  37687. */
  37688. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37689. }
  37690. }
  37691. declare module "babylonjs/Actions/abstractActionManager" {
  37692. import { IDisposable } from "babylonjs/scene";
  37693. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37694. import { IAction } from "babylonjs/Actions/action";
  37695. import { Nullable } from "babylonjs/types";
  37696. /**
  37697. * Abstract class used to decouple action Manager from scene and meshes.
  37698. * Do not instantiate.
  37699. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37700. */
  37701. export abstract class AbstractActionManager implements IDisposable {
  37702. /** Gets the list of active triggers */
  37703. static Triggers: {
  37704. [key: string]: number;
  37705. };
  37706. /** Gets the cursor to use when hovering items */
  37707. hoverCursor: string;
  37708. /** Gets the list of actions */
  37709. actions: IAction[];
  37710. /**
  37711. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37712. */
  37713. isRecursive: boolean;
  37714. /**
  37715. * Releases all associated resources
  37716. */
  37717. abstract dispose(): void;
  37718. /**
  37719. * Does this action manager has pointer triggers
  37720. */
  37721. abstract get hasPointerTriggers(): boolean;
  37722. /**
  37723. * Does this action manager has pick triggers
  37724. */
  37725. abstract get hasPickTriggers(): boolean;
  37726. /**
  37727. * Process a specific trigger
  37728. * @param trigger defines the trigger to process
  37729. * @param evt defines the event details to be processed
  37730. */
  37731. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37732. /**
  37733. * Does this action manager handles actions of any of the given triggers
  37734. * @param triggers defines the triggers to be tested
  37735. * @return a boolean indicating whether one (or more) of the triggers is handled
  37736. */
  37737. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37738. /**
  37739. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37740. * speed.
  37741. * @param triggerA defines the trigger to be tested
  37742. * @param triggerB defines the trigger to be tested
  37743. * @return a boolean indicating whether one (or more) of the triggers is handled
  37744. */
  37745. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37746. /**
  37747. * Does this action manager handles actions of a given trigger
  37748. * @param trigger defines the trigger to be tested
  37749. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37750. * @return whether the trigger is handled
  37751. */
  37752. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37753. /**
  37754. * Serialize this manager to a JSON object
  37755. * @param name defines the property name to store this manager
  37756. * @returns a JSON representation of this manager
  37757. */
  37758. abstract serialize(name: string): any;
  37759. /**
  37760. * Registers an action to this action manager
  37761. * @param action defines the action to be registered
  37762. * @return the action amended (prepared) after registration
  37763. */
  37764. abstract registerAction(action: IAction): Nullable<IAction>;
  37765. /**
  37766. * Unregisters an action to this action manager
  37767. * @param action defines the action to be unregistered
  37768. * @return a boolean indicating whether the action has been unregistered
  37769. */
  37770. abstract unregisterAction(action: IAction): Boolean;
  37771. /**
  37772. * Does exist one action manager with at least one trigger
  37773. **/
  37774. static get HasTriggers(): boolean;
  37775. /**
  37776. * Does exist one action manager with at least one pick trigger
  37777. **/
  37778. static get HasPickTriggers(): boolean;
  37779. /**
  37780. * Does exist one action manager that handles actions of a given trigger
  37781. * @param trigger defines the trigger to be tested
  37782. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37783. **/
  37784. static HasSpecificTrigger(trigger: number): boolean;
  37785. }
  37786. }
  37787. declare module "babylonjs/node" {
  37788. import { Scene } from "babylonjs/scene";
  37789. import { Nullable } from "babylonjs/types";
  37790. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37791. import { Engine } from "babylonjs/Engines/engine";
  37792. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37793. import { Observable } from "babylonjs/Misc/observable";
  37794. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37795. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37796. import { Animatable } from "babylonjs/Animations/animatable";
  37797. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37798. import { Animation } from "babylonjs/Animations/animation";
  37799. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37801. /**
  37802. * Defines how a node can be built from a string name.
  37803. */
  37804. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37805. /**
  37806. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37807. */
  37808. export class Node implements IBehaviorAware<Node> {
  37809. /** @hidden */
  37810. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37811. private static _NodeConstructors;
  37812. /**
  37813. * Add a new node constructor
  37814. * @param type defines the type name of the node to construct
  37815. * @param constructorFunc defines the constructor function
  37816. */
  37817. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37818. /**
  37819. * Returns a node constructor based on type name
  37820. * @param type defines the type name
  37821. * @param name defines the new node name
  37822. * @param scene defines the hosting scene
  37823. * @param options defines optional options to transmit to constructors
  37824. * @returns the new constructor or null
  37825. */
  37826. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37827. /**
  37828. * Gets or sets the name of the node
  37829. */
  37830. name: string;
  37831. /**
  37832. * Gets or sets the id of the node
  37833. */
  37834. id: string;
  37835. /**
  37836. * Gets or sets the unique id of the node
  37837. */
  37838. uniqueId: number;
  37839. /**
  37840. * Gets or sets a string used to store user defined state for the node
  37841. */
  37842. state: string;
  37843. /**
  37844. * Gets or sets an object used to store user defined information for the node
  37845. */
  37846. metadata: any;
  37847. /**
  37848. * For internal use only. Please do not use.
  37849. */
  37850. reservedDataStore: any;
  37851. /**
  37852. * List of inspectable custom properties (used by the Inspector)
  37853. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37854. */
  37855. inspectableCustomProperties: IInspectable[];
  37856. private _doNotSerialize;
  37857. /**
  37858. * Gets or sets a boolean used to define if the node must be serialized
  37859. */
  37860. get doNotSerialize(): boolean;
  37861. set doNotSerialize(value: boolean);
  37862. /** @hidden */
  37863. _isDisposed: boolean;
  37864. /**
  37865. * Gets a list of Animations associated with the node
  37866. */
  37867. animations: import("babylonjs/Animations/animation").Animation[];
  37868. protected _ranges: {
  37869. [name: string]: Nullable<AnimationRange>;
  37870. };
  37871. /**
  37872. * Callback raised when the node is ready to be used
  37873. */
  37874. onReady: Nullable<(node: Node) => void>;
  37875. private _isEnabled;
  37876. private _isParentEnabled;
  37877. private _isReady;
  37878. /** @hidden */
  37879. _currentRenderId: number;
  37880. private _parentUpdateId;
  37881. /** @hidden */
  37882. _childUpdateId: number;
  37883. /** @hidden */
  37884. _waitingParentId: Nullable<string>;
  37885. /** @hidden */
  37886. _scene: Scene;
  37887. /** @hidden */
  37888. _cache: any;
  37889. private _parentNode;
  37890. private _children;
  37891. /** @hidden */
  37892. _worldMatrix: Matrix;
  37893. /** @hidden */
  37894. _worldMatrixDeterminant: number;
  37895. /** @hidden */
  37896. _worldMatrixDeterminantIsDirty: boolean;
  37897. /** @hidden */
  37898. private _sceneRootNodesIndex;
  37899. /**
  37900. * Gets a boolean indicating if the node has been disposed
  37901. * @returns true if the node was disposed
  37902. */
  37903. isDisposed(): boolean;
  37904. /**
  37905. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37906. * @see https://doc.babylonjs.com/how_to/parenting
  37907. */
  37908. set parent(parent: Nullable<Node>);
  37909. get parent(): Nullable<Node>;
  37910. /** @hidden */
  37911. _addToSceneRootNodes(): void;
  37912. /** @hidden */
  37913. _removeFromSceneRootNodes(): void;
  37914. private _animationPropertiesOverride;
  37915. /**
  37916. * Gets or sets the animation properties override
  37917. */
  37918. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37919. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37920. /**
  37921. * Gets a string identifying the name of the class
  37922. * @returns "Node" string
  37923. */
  37924. getClassName(): string;
  37925. /** @hidden */
  37926. readonly _isNode: boolean;
  37927. /**
  37928. * An event triggered when the mesh is disposed
  37929. */
  37930. onDisposeObservable: Observable<Node>;
  37931. private _onDisposeObserver;
  37932. /**
  37933. * Sets a callback that will be raised when the node will be disposed
  37934. */
  37935. set onDispose(callback: () => void);
  37936. /**
  37937. * Creates a new Node
  37938. * @param name the name and id to be given to this node
  37939. * @param scene the scene this node will be added to
  37940. */
  37941. constructor(name: string, scene?: Nullable<Scene>);
  37942. /**
  37943. * Gets the scene of the node
  37944. * @returns a scene
  37945. */
  37946. getScene(): Scene;
  37947. /**
  37948. * Gets the engine of the node
  37949. * @returns a Engine
  37950. */
  37951. getEngine(): Engine;
  37952. private _behaviors;
  37953. /**
  37954. * Attach a behavior to the node
  37955. * @see https://doc.babylonjs.com/features/behaviour
  37956. * @param behavior defines the behavior to attach
  37957. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37958. * @returns the current Node
  37959. */
  37960. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37961. /**
  37962. * Remove an attached behavior
  37963. * @see https://doc.babylonjs.com/features/behaviour
  37964. * @param behavior defines the behavior to attach
  37965. * @returns the current Node
  37966. */
  37967. removeBehavior(behavior: Behavior<Node>): Node;
  37968. /**
  37969. * Gets the list of attached behaviors
  37970. * @see https://doc.babylonjs.com/features/behaviour
  37971. */
  37972. get behaviors(): Behavior<Node>[];
  37973. /**
  37974. * Gets an attached behavior by name
  37975. * @param name defines the name of the behavior to look for
  37976. * @see https://doc.babylonjs.com/features/behaviour
  37977. * @returns null if behavior was not found else the requested behavior
  37978. */
  37979. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37980. /**
  37981. * Returns the latest update of the World matrix
  37982. * @returns a Matrix
  37983. */
  37984. getWorldMatrix(): Matrix;
  37985. /** @hidden */
  37986. _getWorldMatrixDeterminant(): number;
  37987. /**
  37988. * Returns directly the latest state of the mesh World matrix.
  37989. * A Matrix is returned.
  37990. */
  37991. get worldMatrixFromCache(): Matrix;
  37992. /** @hidden */
  37993. _initCache(): void;
  37994. /** @hidden */
  37995. updateCache(force?: boolean): void;
  37996. /** @hidden */
  37997. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37998. /** @hidden */
  37999. _updateCache(ignoreParentClass?: boolean): void;
  38000. /** @hidden */
  38001. _isSynchronized(): boolean;
  38002. /** @hidden */
  38003. _markSyncedWithParent(): void;
  38004. /** @hidden */
  38005. isSynchronizedWithParent(): boolean;
  38006. /** @hidden */
  38007. isSynchronized(): boolean;
  38008. /**
  38009. * Is this node ready to be used/rendered
  38010. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  38011. * @return true if the node is ready
  38012. */
  38013. isReady(completeCheck?: boolean): boolean;
  38014. /**
  38015. * Is this node enabled?
  38016. * 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
  38017. * @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
  38018. * @return whether this node (and its parent) is enabled
  38019. */
  38020. isEnabled(checkAncestors?: boolean): boolean;
  38021. /** @hidden */
  38022. protected _syncParentEnabledState(): void;
  38023. /**
  38024. * Set the enabled state of this node
  38025. * @param value defines the new enabled state
  38026. */
  38027. setEnabled(value: boolean): void;
  38028. /**
  38029. * Is this node a descendant of the given node?
  38030. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  38031. * @param ancestor defines the parent node to inspect
  38032. * @returns a boolean indicating if this node is a descendant of the given node
  38033. */
  38034. isDescendantOf(ancestor: Node): boolean;
  38035. /** @hidden */
  38036. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  38037. /**
  38038. * Will return all nodes that have this node as ascendant
  38039. * @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
  38040. * @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
  38041. * @return all children nodes of all types
  38042. */
  38043. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  38044. /**
  38045. * Get all child-meshes of this node
  38046. * @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)
  38047. * @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
  38048. * @returns an array of AbstractMesh
  38049. */
  38050. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  38051. /**
  38052. * Get all direct children of this node
  38053. * @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
  38054. * @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)
  38055. * @returns an array of Node
  38056. */
  38057. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  38058. /** @hidden */
  38059. _setReady(state: boolean): void;
  38060. /**
  38061. * Get an animation by name
  38062. * @param name defines the name of the animation to look for
  38063. * @returns null if not found else the requested animation
  38064. */
  38065. getAnimationByName(name: string): Nullable<Animation>;
  38066. /**
  38067. * Creates an animation range for this node
  38068. * @param name defines the name of the range
  38069. * @param from defines the starting key
  38070. * @param to defines the end key
  38071. */
  38072. createAnimationRange(name: string, from: number, to: number): void;
  38073. /**
  38074. * Delete a specific animation range
  38075. * @param name defines the name of the range to delete
  38076. * @param deleteFrames defines if animation frames from the range must be deleted as well
  38077. */
  38078. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  38079. /**
  38080. * Get an animation range by name
  38081. * @param name defines the name of the animation range to look for
  38082. * @returns null if not found else the requested animation range
  38083. */
  38084. getAnimationRange(name: string): Nullable<AnimationRange>;
  38085. /**
  38086. * Gets the list of all animation ranges defined on this node
  38087. * @returns an array
  38088. */
  38089. getAnimationRanges(): Nullable<AnimationRange>[];
  38090. /**
  38091. * Will start the animation sequence
  38092. * @param name defines the range frames for animation sequence
  38093. * @param loop defines if the animation should loop (false by default)
  38094. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  38095. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  38096. * @returns the object created for this animation. If range does not exist, it will return null
  38097. */
  38098. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  38099. /**
  38100. * Serialize animation ranges into a JSON compatible object
  38101. * @returns serialization object
  38102. */
  38103. serializeAnimationRanges(): any;
  38104. /**
  38105. * Computes the world matrix of the node
  38106. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  38107. * @returns the world matrix
  38108. */
  38109. computeWorldMatrix(force?: boolean): Matrix;
  38110. /**
  38111. * Releases resources associated with this node.
  38112. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38113. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38114. */
  38115. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38116. /**
  38117. * Parse animation range data from a serialization object and store them into a given node
  38118. * @param node defines where to store the animation ranges
  38119. * @param parsedNode defines the serialization object to read data from
  38120. * @param scene defines the hosting scene
  38121. */
  38122. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  38123. /**
  38124. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  38125. * @param includeDescendants Include bounding info from descendants as well (true by default)
  38126. * @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
  38127. * @returns the new bounding vectors
  38128. */
  38129. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  38130. min: Vector3;
  38131. max: Vector3;
  38132. };
  38133. }
  38134. }
  38135. declare module "babylonjs/Animations/animation" {
  38136. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  38137. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  38138. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  38139. import { Nullable } from "babylonjs/types";
  38140. import { Scene } from "babylonjs/scene";
  38141. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  38142. import { AnimationRange } from "babylonjs/Animations/animationRange";
  38143. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  38144. import { Node } from "babylonjs/node";
  38145. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38146. import { Size } from "babylonjs/Maths/math.size";
  38147. import { Animatable } from "babylonjs/Animations/animatable";
  38148. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  38149. /**
  38150. * @hidden
  38151. */
  38152. export class _IAnimationState {
  38153. key: number;
  38154. repeatCount: number;
  38155. workValue?: any;
  38156. loopMode?: number;
  38157. offsetValue?: any;
  38158. highLimitValue?: any;
  38159. }
  38160. /**
  38161. * Class used to store any kind of animation
  38162. */
  38163. export class Animation {
  38164. /**Name of the animation */
  38165. name: string;
  38166. /**Property to animate */
  38167. targetProperty: string;
  38168. /**The frames per second of the animation */
  38169. framePerSecond: number;
  38170. /**The data type of the animation */
  38171. dataType: number;
  38172. /**The loop mode of the animation */
  38173. loopMode?: number | undefined;
  38174. /**Specifies if blending should be enabled */
  38175. enableBlending?: boolean | undefined;
  38176. /**
  38177. * Use matrix interpolation instead of using direct key value when animating matrices
  38178. */
  38179. static AllowMatricesInterpolation: boolean;
  38180. /**
  38181. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  38182. */
  38183. static AllowMatrixDecomposeForInterpolation: boolean;
  38184. /** Define the Url to load snippets */
  38185. static SnippetUrl: string;
  38186. /** Snippet ID if the animation was created from the snippet server */
  38187. snippetId: string;
  38188. /**
  38189. * Stores the key frames of the animation
  38190. */
  38191. private _keys;
  38192. /**
  38193. * Stores the easing function of the animation
  38194. */
  38195. private _easingFunction;
  38196. /**
  38197. * @hidden Internal use only
  38198. */
  38199. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  38200. /**
  38201. * The set of event that will be linked to this animation
  38202. */
  38203. private _events;
  38204. /**
  38205. * Stores an array of target property paths
  38206. */
  38207. targetPropertyPath: string[];
  38208. /**
  38209. * Stores the blending speed of the animation
  38210. */
  38211. blendingSpeed: number;
  38212. /**
  38213. * Stores the animation ranges for the animation
  38214. */
  38215. private _ranges;
  38216. /**
  38217. * @hidden Internal use
  38218. */
  38219. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  38220. /**
  38221. * Sets up an animation
  38222. * @param property The property to animate
  38223. * @param animationType The animation type to apply
  38224. * @param framePerSecond The frames per second of the animation
  38225. * @param easingFunction The easing function used in the animation
  38226. * @returns The created animation
  38227. */
  38228. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  38229. /**
  38230. * Create and start an animation on a node
  38231. * @param name defines the name of the global animation that will be run on all nodes
  38232. * @param node defines the root node where the animation will take place
  38233. * @param targetProperty defines property to animate
  38234. * @param framePerSecond defines the number of frame per second yo use
  38235. * @param totalFrame defines the number of frames in total
  38236. * @param from defines the initial value
  38237. * @param to defines the final value
  38238. * @param loopMode defines which loop mode you want to use (off by default)
  38239. * @param easingFunction defines the easing function to use (linear by default)
  38240. * @param onAnimationEnd defines the callback to call when animation end
  38241. * @returns the animatable created for this animation
  38242. */
  38243. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38244. /**
  38245. * Create and start an animation on a node and its descendants
  38246. * @param name defines the name of the global animation that will be run on all nodes
  38247. * @param node defines the root node where the animation will take place
  38248. * @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
  38249. * @param targetProperty defines property to animate
  38250. * @param framePerSecond defines the number of frame per second to use
  38251. * @param totalFrame defines the number of frames in total
  38252. * @param from defines the initial value
  38253. * @param to defines the final value
  38254. * @param loopMode defines which loop mode you want to use (off by default)
  38255. * @param easingFunction defines the easing function to use (linear by default)
  38256. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  38257. * @returns the list of animatables created for all nodes
  38258. * @example https://www.babylonjs-playground.com/#MH0VLI
  38259. */
  38260. 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[]>;
  38261. /**
  38262. * Creates a new animation, merges it with the existing animations and starts it
  38263. * @param name Name of the animation
  38264. * @param node Node which contains the scene that begins the animations
  38265. * @param targetProperty Specifies which property to animate
  38266. * @param framePerSecond The frames per second of the animation
  38267. * @param totalFrame The total number of frames
  38268. * @param from The frame at the beginning of the animation
  38269. * @param to The frame at the end of the animation
  38270. * @param loopMode Specifies the loop mode of the animation
  38271. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  38272. * @param onAnimationEnd Callback to run once the animation is complete
  38273. * @returns Nullable animation
  38274. */
  38275. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38276. /**
  38277. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38278. * @param sourceAnimation defines the Animation containing keyframes to convert
  38279. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38280. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  38281. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  38282. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  38283. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  38284. */
  38285. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  38286. /**
  38287. * Transition property of an host to the target Value
  38288. * @param property The property to transition
  38289. * @param targetValue The target Value of the property
  38290. * @param host The object where the property to animate belongs
  38291. * @param scene Scene used to run the animation
  38292. * @param frameRate Framerate (in frame/s) to use
  38293. * @param transition The transition type we want to use
  38294. * @param duration The duration of the animation, in milliseconds
  38295. * @param onAnimationEnd Callback trigger at the end of the animation
  38296. * @returns Nullable animation
  38297. */
  38298. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38299. /**
  38300. * Return the array of runtime animations currently using this animation
  38301. */
  38302. get runtimeAnimations(): RuntimeAnimation[];
  38303. /**
  38304. * Specifies if any of the runtime animations are currently running
  38305. */
  38306. get hasRunningRuntimeAnimations(): boolean;
  38307. /**
  38308. * Initializes the animation
  38309. * @param name Name of the animation
  38310. * @param targetProperty Property to animate
  38311. * @param framePerSecond The frames per second of the animation
  38312. * @param dataType The data type of the animation
  38313. * @param loopMode The loop mode of the animation
  38314. * @param enableBlending Specifies if blending should be enabled
  38315. */
  38316. constructor(
  38317. /**Name of the animation */
  38318. name: string,
  38319. /**Property to animate */
  38320. targetProperty: string,
  38321. /**The frames per second of the animation */
  38322. framePerSecond: number,
  38323. /**The data type of the animation */
  38324. dataType: number,
  38325. /**The loop mode of the animation */
  38326. loopMode?: number | undefined,
  38327. /**Specifies if blending should be enabled */
  38328. enableBlending?: boolean | undefined);
  38329. /**
  38330. * Converts the animation to a string
  38331. * @param fullDetails support for multiple levels of logging within scene loading
  38332. * @returns String form of the animation
  38333. */
  38334. toString(fullDetails?: boolean): string;
  38335. /**
  38336. * Add an event to this animation
  38337. * @param event Event to add
  38338. */
  38339. addEvent(event: AnimationEvent): void;
  38340. /**
  38341. * Remove all events found at the given frame
  38342. * @param frame The frame to remove events from
  38343. */
  38344. removeEvents(frame: number): void;
  38345. /**
  38346. * Retrieves all the events from the animation
  38347. * @returns Events from the animation
  38348. */
  38349. getEvents(): AnimationEvent[];
  38350. /**
  38351. * Creates an animation range
  38352. * @param name Name of the animation range
  38353. * @param from Starting frame of the animation range
  38354. * @param to Ending frame of the animation
  38355. */
  38356. createRange(name: string, from: number, to: number): void;
  38357. /**
  38358. * Deletes an animation range by name
  38359. * @param name Name of the animation range to delete
  38360. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38361. */
  38362. deleteRange(name: string, deleteFrames?: boolean): void;
  38363. /**
  38364. * Gets the animation range by name, or null if not defined
  38365. * @param name Name of the animation range
  38366. * @returns Nullable animation range
  38367. */
  38368. getRange(name: string): Nullable<AnimationRange>;
  38369. /**
  38370. * Gets the key frames from the animation
  38371. * @returns The key frames of the animation
  38372. */
  38373. getKeys(): Array<IAnimationKey>;
  38374. /**
  38375. * Gets the highest frame rate of the animation
  38376. * @returns Highest frame rate of the animation
  38377. */
  38378. getHighestFrame(): number;
  38379. /**
  38380. * Gets the easing function of the animation
  38381. * @returns Easing function of the animation
  38382. */
  38383. getEasingFunction(): IEasingFunction;
  38384. /**
  38385. * Sets the easing function of the animation
  38386. * @param easingFunction A custom mathematical formula for animation
  38387. */
  38388. setEasingFunction(easingFunction: EasingFunction): void;
  38389. /**
  38390. * Interpolates a scalar linearly
  38391. * @param startValue Start value of the animation curve
  38392. * @param endValue End value of the animation curve
  38393. * @param gradient Scalar amount to interpolate
  38394. * @returns Interpolated scalar value
  38395. */
  38396. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38397. /**
  38398. * Interpolates a scalar cubically
  38399. * @param startValue Start value of the animation curve
  38400. * @param outTangent End tangent of the animation
  38401. * @param endValue End value of the animation curve
  38402. * @param inTangent Start tangent of the animation curve
  38403. * @param gradient Scalar amount to interpolate
  38404. * @returns Interpolated scalar value
  38405. */
  38406. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38407. /**
  38408. * Interpolates a quaternion using a spherical linear interpolation
  38409. * @param startValue Start value of the animation curve
  38410. * @param endValue End value of the animation curve
  38411. * @param gradient Scalar amount to interpolate
  38412. * @returns Interpolated quaternion value
  38413. */
  38414. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38415. /**
  38416. * Interpolates a quaternion cubically
  38417. * @param startValue Start value of the animation curve
  38418. * @param outTangent End tangent of the animation curve
  38419. * @param endValue End value of the animation curve
  38420. * @param inTangent Start tangent of the animation curve
  38421. * @param gradient Scalar amount to interpolate
  38422. * @returns Interpolated quaternion value
  38423. */
  38424. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38425. /**
  38426. * Interpolates a Vector3 linearl
  38427. * @param startValue Start value of the animation curve
  38428. * @param endValue End value of the animation curve
  38429. * @param gradient Scalar amount to interpolate
  38430. * @returns Interpolated scalar value
  38431. */
  38432. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38433. /**
  38434. * Interpolates a Vector3 cubically
  38435. * @param startValue Start value of the animation curve
  38436. * @param outTangent End tangent of the animation
  38437. * @param endValue End value of the animation curve
  38438. * @param inTangent Start tangent of the animation curve
  38439. * @param gradient Scalar amount to interpolate
  38440. * @returns InterpolatedVector3 value
  38441. */
  38442. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38443. /**
  38444. * Interpolates a Vector2 linearly
  38445. * @param startValue Start value of the animation curve
  38446. * @param endValue End value of the animation curve
  38447. * @param gradient Scalar amount to interpolate
  38448. * @returns Interpolated Vector2 value
  38449. */
  38450. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38451. /**
  38452. * Interpolates a Vector2 cubically
  38453. * @param startValue Start value of the animation curve
  38454. * @param outTangent End tangent of the animation
  38455. * @param endValue End value of the animation curve
  38456. * @param inTangent Start tangent of the animation curve
  38457. * @param gradient Scalar amount to interpolate
  38458. * @returns Interpolated Vector2 value
  38459. */
  38460. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38461. /**
  38462. * Interpolates a size linearly
  38463. * @param startValue Start value of the animation curve
  38464. * @param endValue End value of the animation curve
  38465. * @param gradient Scalar amount to interpolate
  38466. * @returns Interpolated Size value
  38467. */
  38468. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38469. /**
  38470. * Interpolates a Color3 linearly
  38471. * @param startValue Start value of the animation curve
  38472. * @param endValue End value of the animation curve
  38473. * @param gradient Scalar amount to interpolate
  38474. * @returns Interpolated Color3 value
  38475. */
  38476. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38477. /**
  38478. * Interpolates a Color4 linearly
  38479. * @param startValue Start value of the animation curve
  38480. * @param endValue End value of the animation curve
  38481. * @param gradient Scalar amount to interpolate
  38482. * @returns Interpolated Color3 value
  38483. */
  38484. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38485. /**
  38486. * @hidden Internal use only
  38487. */
  38488. _getKeyValue(value: any): any;
  38489. /**
  38490. * @hidden Internal use only
  38491. */
  38492. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38493. /**
  38494. * Defines the function to use to interpolate matrices
  38495. * @param startValue defines the start matrix
  38496. * @param endValue defines the end matrix
  38497. * @param gradient defines the gradient between both matrices
  38498. * @param result defines an optional target matrix where to store the interpolation
  38499. * @returns the interpolated matrix
  38500. */
  38501. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38502. /**
  38503. * Makes a copy of the animation
  38504. * @returns Cloned animation
  38505. */
  38506. clone(): Animation;
  38507. /**
  38508. * Sets the key frames of the animation
  38509. * @param values The animation key frames to set
  38510. */
  38511. setKeys(values: Array<IAnimationKey>): void;
  38512. /**
  38513. * Serializes the animation to an object
  38514. * @returns Serialized object
  38515. */
  38516. serialize(): any;
  38517. /**
  38518. * Float animation type
  38519. */
  38520. static readonly ANIMATIONTYPE_FLOAT: number;
  38521. /**
  38522. * Vector3 animation type
  38523. */
  38524. static readonly ANIMATIONTYPE_VECTOR3: number;
  38525. /**
  38526. * Quaternion animation type
  38527. */
  38528. static readonly ANIMATIONTYPE_QUATERNION: number;
  38529. /**
  38530. * Matrix animation type
  38531. */
  38532. static readonly ANIMATIONTYPE_MATRIX: number;
  38533. /**
  38534. * Color3 animation type
  38535. */
  38536. static readonly ANIMATIONTYPE_COLOR3: number;
  38537. /**
  38538. * Color3 animation type
  38539. */
  38540. static readonly ANIMATIONTYPE_COLOR4: number;
  38541. /**
  38542. * Vector2 animation type
  38543. */
  38544. static readonly ANIMATIONTYPE_VECTOR2: number;
  38545. /**
  38546. * Size animation type
  38547. */
  38548. static readonly ANIMATIONTYPE_SIZE: number;
  38549. /**
  38550. * Relative Loop Mode
  38551. */
  38552. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38553. /**
  38554. * Cycle Loop Mode
  38555. */
  38556. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38557. /**
  38558. * Constant Loop Mode
  38559. */
  38560. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38561. /** @hidden */
  38562. static _UniversalLerp(left: any, right: any, amount: number): any;
  38563. /**
  38564. * Parses an animation object and creates an animation
  38565. * @param parsedAnimation Parsed animation object
  38566. * @returns Animation object
  38567. */
  38568. static Parse(parsedAnimation: any): Animation;
  38569. /**
  38570. * Appends the serialized animations from the source animations
  38571. * @param source Source containing the animations
  38572. * @param destination Target to store the animations
  38573. */
  38574. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38575. /**
  38576. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38577. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38578. * @param url defines the url to load from
  38579. * @returns a promise that will resolve to the new animation or an array of animations
  38580. */
  38581. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38582. /**
  38583. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38584. * @param snippetId defines the snippet to load
  38585. * @returns a promise that will resolve to the new animation or a new array of animations
  38586. */
  38587. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38588. }
  38589. }
  38590. declare module "babylonjs/Animations/animatable.interface" {
  38591. import { Nullable } from "babylonjs/types";
  38592. import { Animation } from "babylonjs/Animations/animation";
  38593. /**
  38594. * Interface containing an array of animations
  38595. */
  38596. export interface IAnimatable {
  38597. /**
  38598. * Array of animations
  38599. */
  38600. animations: Nullable<Array<Animation>>;
  38601. }
  38602. }
  38603. declare module "babylonjs/Misc/decorators" {
  38604. import { Nullable } from "babylonjs/types";
  38605. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38606. import { Scene } from "babylonjs/scene";
  38607. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38608. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38609. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38610. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38611. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38612. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38613. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38614. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38615. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38616. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38617. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38618. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38619. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38620. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38621. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38622. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38623. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38624. /**
  38625. * Decorator used to define property that can be serialized as reference to a camera
  38626. * @param sourceName defines the name of the property to decorate
  38627. */
  38628. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38629. /**
  38630. * Class used to help serialization objects
  38631. */
  38632. export class SerializationHelper {
  38633. /** @hidden */
  38634. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38635. /** @hidden */
  38636. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38637. /** @hidden */
  38638. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38639. /** @hidden */
  38640. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38641. /**
  38642. * Appends the serialized animations from the source animations
  38643. * @param source Source containing the animations
  38644. * @param destination Target to store the animations
  38645. */
  38646. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38647. /**
  38648. * Static function used to serialized a specific entity
  38649. * @param entity defines the entity to serialize
  38650. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38651. * @returns a JSON compatible object representing the serialization of the entity
  38652. */
  38653. static Serialize<T>(entity: T, serializationObject?: any): any;
  38654. /**
  38655. * Creates a new entity from a serialization data object
  38656. * @param creationFunction defines a function used to instanciated the new entity
  38657. * @param source defines the source serialization data
  38658. * @param scene defines the hosting scene
  38659. * @param rootUrl defines the root url for resources
  38660. * @returns a new entity
  38661. */
  38662. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38663. /**
  38664. * Clones an object
  38665. * @param creationFunction defines the function used to instanciate the new object
  38666. * @param source defines the source object
  38667. * @returns the cloned object
  38668. */
  38669. static Clone<T>(creationFunction: () => T, source: T): T;
  38670. /**
  38671. * Instanciates a new object based on a source one (some data will be shared between both object)
  38672. * @param creationFunction defines the function used to instanciate the new object
  38673. * @param source defines the source object
  38674. * @returns the new object
  38675. */
  38676. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38677. }
  38678. }
  38679. declare module "babylonjs/Materials/Textures/baseTexture" {
  38680. import { Observable } from "babylonjs/Misc/observable";
  38681. import { Nullable } from "babylonjs/types";
  38682. import { Scene } from "babylonjs/scene";
  38683. import { Matrix } from "babylonjs/Maths/math.vector";
  38684. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38685. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38686. import { ISize } from "babylonjs/Maths/math.size";
  38687. import "babylonjs/Misc/fileTools";
  38688. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38689. /**
  38690. * Base class of all the textures in babylon.
  38691. * It groups all the common properties the materials, post process, lights... might need
  38692. * in order to make a correct use of the texture.
  38693. */
  38694. export class BaseTexture implements IAnimatable {
  38695. /**
  38696. * Default anisotropic filtering level for the application.
  38697. * It is set to 4 as a good tradeoff between perf and quality.
  38698. */
  38699. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  38700. /**
  38701. * Gets or sets the unique id of the texture
  38702. */
  38703. uniqueId: number;
  38704. /**
  38705. * Define the name of the texture.
  38706. */
  38707. name: string;
  38708. /**
  38709. * Gets or sets an object used to store user defined information.
  38710. */
  38711. metadata: any;
  38712. /**
  38713. * For internal use only. Please do not use.
  38714. */
  38715. reservedDataStore: any;
  38716. private _hasAlpha;
  38717. /**
  38718. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  38719. */
  38720. set hasAlpha(value: boolean);
  38721. get hasAlpha(): boolean;
  38722. /**
  38723. * Defines if the alpha value should be determined via the rgb values.
  38724. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  38725. */
  38726. getAlphaFromRGB: boolean;
  38727. /**
  38728. * Intensity or strength of the texture.
  38729. * It is commonly used by materials to fine tune the intensity of the texture
  38730. */
  38731. level: number;
  38732. /**
  38733. * Define the UV chanel to use starting from 0 and defaulting to 0.
  38734. * This is part of the texture as textures usually maps to one uv set.
  38735. */
  38736. coordinatesIndex: number;
  38737. protected _coordinatesMode: number;
  38738. /**
  38739. * How a texture is mapped.
  38740. *
  38741. * | Value | Type | Description |
  38742. * | ----- | ----------------------------------- | ----------- |
  38743. * | 0 | EXPLICIT_MODE | |
  38744. * | 1 | SPHERICAL_MODE | |
  38745. * | 2 | PLANAR_MODE | |
  38746. * | 3 | CUBIC_MODE | |
  38747. * | 4 | PROJECTION_MODE | |
  38748. * | 5 | SKYBOX_MODE | |
  38749. * | 6 | INVCUBIC_MODE | |
  38750. * | 7 | EQUIRECTANGULAR_MODE | |
  38751. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  38752. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  38753. */
  38754. set coordinatesMode(value: number);
  38755. get coordinatesMode(): number;
  38756. private _wrapU;
  38757. /**
  38758. * | Value | Type | Description |
  38759. * | ----- | ------------------ | ----------- |
  38760. * | 0 | CLAMP_ADDRESSMODE | |
  38761. * | 1 | WRAP_ADDRESSMODE | |
  38762. * | 2 | MIRROR_ADDRESSMODE | |
  38763. */
  38764. get wrapU(): number;
  38765. set wrapU(value: number);
  38766. private _wrapV;
  38767. /**
  38768. * | Value | Type | Description |
  38769. * | ----- | ------------------ | ----------- |
  38770. * | 0 | CLAMP_ADDRESSMODE | |
  38771. * | 1 | WRAP_ADDRESSMODE | |
  38772. * | 2 | MIRROR_ADDRESSMODE | |
  38773. */
  38774. get wrapV(): number;
  38775. set wrapV(value: number);
  38776. /**
  38777. * | Value | Type | Description |
  38778. * | ----- | ------------------ | ----------- |
  38779. * | 0 | CLAMP_ADDRESSMODE | |
  38780. * | 1 | WRAP_ADDRESSMODE | |
  38781. * | 2 | MIRROR_ADDRESSMODE | |
  38782. */
  38783. wrapR: number;
  38784. /**
  38785. * With compliant hardware and browser (supporting anisotropic filtering)
  38786. * this defines the level of anisotropic filtering in the texture.
  38787. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  38788. */
  38789. anisotropicFilteringLevel: number;
  38790. /**
  38791. * Define if the texture is a cube texture or if false a 2d texture.
  38792. */
  38793. get isCube(): boolean;
  38794. set isCube(value: boolean);
  38795. /**
  38796. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  38797. */
  38798. get is3D(): boolean;
  38799. set is3D(value: boolean);
  38800. /**
  38801. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  38802. */
  38803. get is2DArray(): boolean;
  38804. set is2DArray(value: boolean);
  38805. private _gammaSpace;
  38806. /**
  38807. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  38808. * HDR texture are usually stored in linear space.
  38809. * This only impacts the PBR and Background materials
  38810. */
  38811. get gammaSpace(): boolean;
  38812. set gammaSpace(gamma: boolean);
  38813. /**
  38814. * Gets or sets whether or not the texture contains RGBD data.
  38815. */
  38816. get isRGBD(): boolean;
  38817. set isRGBD(value: boolean);
  38818. /**
  38819. * Is Z inverted in the texture (useful in a cube texture).
  38820. */
  38821. invertZ: boolean;
  38822. /**
  38823. * Are mip maps generated for this texture or not.
  38824. */
  38825. get noMipmap(): boolean;
  38826. /**
  38827. * @hidden
  38828. */
  38829. lodLevelInAlpha: boolean;
  38830. /**
  38831. * With prefiltered texture, defined the offset used during the prefiltering steps.
  38832. */
  38833. get lodGenerationOffset(): number;
  38834. set lodGenerationOffset(value: number);
  38835. /**
  38836. * With prefiltered texture, defined the scale used during the prefiltering steps.
  38837. */
  38838. get lodGenerationScale(): number;
  38839. set lodGenerationScale(value: number);
  38840. /**
  38841. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  38842. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  38843. * average roughness values.
  38844. */
  38845. get linearSpecularLOD(): boolean;
  38846. set linearSpecularLOD(value: boolean);
  38847. /**
  38848. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  38849. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  38850. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  38851. */
  38852. get irradianceTexture(): Nullable<BaseTexture>;
  38853. set irradianceTexture(value: Nullable<BaseTexture>);
  38854. /**
  38855. * Define if the texture is a render target.
  38856. */
  38857. isRenderTarget: boolean;
  38858. /**
  38859. * Define the unique id of the texture in the scene.
  38860. */
  38861. get uid(): string;
  38862. /** @hidden */
  38863. _prefiltered: boolean;
  38864. /**
  38865. * Return a string representation of the texture.
  38866. * @returns the texture as a string
  38867. */
  38868. toString(): string;
  38869. /**
  38870. * Get the class name of the texture.
  38871. * @returns "BaseTexture"
  38872. */
  38873. getClassName(): string;
  38874. /**
  38875. * Define the list of animation attached to the texture.
  38876. */
  38877. animations: import("babylonjs/Animations/animation").Animation[];
  38878. /**
  38879. * An event triggered when the texture is disposed.
  38880. */
  38881. onDisposeObservable: Observable<BaseTexture>;
  38882. private _onDisposeObserver;
  38883. /**
  38884. * Callback triggered when the texture has been disposed.
  38885. * Kept for back compatibility, you can use the onDisposeObservable instead.
  38886. */
  38887. set onDispose(callback: () => void);
  38888. /**
  38889. * Define the current state of the loading sequence when in delayed load mode.
  38890. */
  38891. delayLoadState: number;
  38892. protected _scene: Nullable<Scene>;
  38893. protected _engine: Nullable<ThinEngine>;
  38894. /** @hidden */
  38895. _texture: Nullable<InternalTexture>;
  38896. private _uid;
  38897. /**
  38898. * Define if the texture is preventinga material to render or not.
  38899. * If not and the texture is not ready, the engine will use a default black texture instead.
  38900. */
  38901. get isBlocking(): boolean;
  38902. /**
  38903. * Instantiates a new BaseTexture.
  38904. * Base class of all the textures in babylon.
  38905. * It groups all the common properties the materials, post process, lights... might need
  38906. * in order to make a correct use of the texture.
  38907. * @param sceneOrEngine Define the scene or engine the texture blongs to
  38908. */
  38909. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  38910. /**
  38911. * Get the scene the texture belongs to.
  38912. * @returns the scene or null if undefined
  38913. */
  38914. getScene(): Nullable<Scene>;
  38915. /** @hidden */
  38916. protected _getEngine(): Nullable<ThinEngine>;
  38917. /**
  38918. * Checks if the texture has the same transform matrix than another texture
  38919. * @param texture texture to check against
  38920. * @returns true if the transforms are the same, else false
  38921. */
  38922. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  38923. /**
  38924. * Get the texture transform matrix used to offset tile the texture for istance.
  38925. * @returns the transformation matrix
  38926. */
  38927. getTextureMatrix(): Matrix;
  38928. /**
  38929. * Get the texture reflection matrix used to rotate/transform the reflection.
  38930. * @returns the reflection matrix
  38931. */
  38932. getReflectionTextureMatrix(): Matrix;
  38933. /**
  38934. * Get the underlying lower level texture from Babylon.
  38935. * @returns the insternal texture
  38936. */
  38937. getInternalTexture(): Nullable<InternalTexture>;
  38938. /**
  38939. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  38940. * @returns true if ready or not blocking
  38941. */
  38942. isReadyOrNotBlocking(): boolean;
  38943. /**
  38944. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  38945. * @returns true if fully ready
  38946. */
  38947. isReady(): boolean;
  38948. private _cachedSize;
  38949. /**
  38950. * Get the size of the texture.
  38951. * @returns the texture size.
  38952. */
  38953. getSize(): ISize;
  38954. /**
  38955. * Get the base size of the texture.
  38956. * It can be different from the size if the texture has been resized for POT for instance
  38957. * @returns the base size
  38958. */
  38959. getBaseSize(): ISize;
  38960. /**
  38961. * Update the sampling mode of the texture.
  38962. * Default is Trilinear mode.
  38963. *
  38964. * | Value | Type | Description |
  38965. * | ----- | ------------------ | ----------- |
  38966. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  38967. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  38968. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  38969. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  38970. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  38971. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  38972. * | 7 | NEAREST_LINEAR | |
  38973. * | 8 | NEAREST_NEAREST | |
  38974. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  38975. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  38976. * | 11 | LINEAR_LINEAR | |
  38977. * | 12 | LINEAR_NEAREST | |
  38978. *
  38979. * > _mag_: magnification filter (close to the viewer)
  38980. * > _min_: minification filter (far from the viewer)
  38981. * > _mip_: filter used between mip map levels
  38982. *@param samplingMode Define the new sampling mode of the texture
  38983. */
  38984. updateSamplingMode(samplingMode: number): void;
  38985. /**
  38986. * Scales the texture if is `canRescale()`
  38987. * @param ratio the resize factor we want to use to rescale
  38988. */
  38989. scale(ratio: number): void;
  38990. /**
  38991. * Get if the texture can rescale.
  38992. */
  38993. get canRescale(): boolean;
  38994. /** @hidden */
  38995. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  38996. /** @hidden */
  38997. _rebuild(): void;
  38998. /**
  38999. * Triggers the load sequence in delayed load mode.
  39000. */
  39001. delayLoad(): void;
  39002. /**
  39003. * Clones the texture.
  39004. * @returns the cloned texture
  39005. */
  39006. clone(): Nullable<BaseTexture>;
  39007. /**
  39008. * Get the texture underlying type (INT, FLOAT...)
  39009. */
  39010. get textureType(): number;
  39011. /**
  39012. * Get the texture underlying format (RGB, RGBA...)
  39013. */
  39014. get textureFormat(): number;
  39015. /**
  39016. * Indicates that textures need to be re-calculated for all materials
  39017. */
  39018. protected _markAllSubMeshesAsTexturesDirty(): void;
  39019. /**
  39020. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  39021. * This will returns an RGBA array buffer containing either in values (0-255) or
  39022. * float values (0-1) depending of the underlying buffer type.
  39023. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  39024. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  39025. * @param buffer defines a user defined buffer to fill with data (can be null)
  39026. * @returns The Array buffer containing the pixels data.
  39027. */
  39028. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  39029. /**
  39030. * Release and destroy the underlying lower level texture aka internalTexture.
  39031. */
  39032. releaseInternalTexture(): void;
  39033. /** @hidden */
  39034. get _lodTextureHigh(): Nullable<BaseTexture>;
  39035. /** @hidden */
  39036. get _lodTextureMid(): Nullable<BaseTexture>;
  39037. /** @hidden */
  39038. get _lodTextureLow(): Nullable<BaseTexture>;
  39039. /**
  39040. * Dispose the texture and release its associated resources.
  39041. */
  39042. dispose(): void;
  39043. /**
  39044. * Serialize the texture into a JSON representation that can be parsed later on.
  39045. * @returns the JSON representation of the texture
  39046. */
  39047. serialize(): any;
  39048. /**
  39049. * Helper function to be called back once a list of texture contains only ready textures.
  39050. * @param textures Define the list of textures to wait for
  39051. * @param callback Define the callback triggered once the entire list will be ready
  39052. */
  39053. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  39054. private static _isScene;
  39055. }
  39056. }
  39057. declare module "babylonjs/Materials/effect" {
  39058. import { Observable } from "babylonjs/Misc/observable";
  39059. import { Nullable } from "babylonjs/types";
  39060. import { IDisposable } from "babylonjs/scene";
  39061. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39062. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39063. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  39064. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  39065. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39066. import { Engine } from "babylonjs/Engines/engine";
  39067. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39068. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39069. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39070. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39071. /**
  39072. * Options to be used when creating an effect.
  39073. */
  39074. export interface IEffectCreationOptions {
  39075. /**
  39076. * Atrributes that will be used in the shader.
  39077. */
  39078. attributes: string[];
  39079. /**
  39080. * Uniform varible names that will be set in the shader.
  39081. */
  39082. uniformsNames: string[];
  39083. /**
  39084. * Uniform buffer variable names that will be set in the shader.
  39085. */
  39086. uniformBuffersNames: string[];
  39087. /**
  39088. * Sampler texture variable names that will be set in the shader.
  39089. */
  39090. samplers: string[];
  39091. /**
  39092. * Define statements that will be set in the shader.
  39093. */
  39094. defines: any;
  39095. /**
  39096. * Possible fallbacks for this effect to improve performance when needed.
  39097. */
  39098. fallbacks: Nullable<IEffectFallbacks>;
  39099. /**
  39100. * Callback that will be called when the shader is compiled.
  39101. */
  39102. onCompiled: Nullable<(effect: Effect) => void>;
  39103. /**
  39104. * Callback that will be called if an error occurs during shader compilation.
  39105. */
  39106. onError: Nullable<(effect: Effect, errors: string) => void>;
  39107. /**
  39108. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39109. */
  39110. indexParameters?: any;
  39111. /**
  39112. * Max number of lights that can be used in the shader.
  39113. */
  39114. maxSimultaneousLights?: number;
  39115. /**
  39116. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39117. */
  39118. transformFeedbackVaryings?: Nullable<string[]>;
  39119. /**
  39120. * 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
  39121. */
  39122. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39123. /**
  39124. * Is this effect rendering to several color attachments ?
  39125. */
  39126. multiTarget?: boolean;
  39127. }
  39128. /**
  39129. * Effect containing vertex and fragment shader that can be executed on an object.
  39130. */
  39131. export class Effect implements IDisposable {
  39132. /**
  39133. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39134. */
  39135. static ShadersRepository: string;
  39136. /**
  39137. * Enable logging of the shader code when a compilation error occurs
  39138. */
  39139. static LogShaderCodeOnCompilationError: boolean;
  39140. /**
  39141. * Name of the effect.
  39142. */
  39143. name: any;
  39144. /**
  39145. * String container all the define statements that should be set on the shader.
  39146. */
  39147. defines: string;
  39148. /**
  39149. * Callback that will be called when the shader is compiled.
  39150. */
  39151. onCompiled: Nullable<(effect: Effect) => void>;
  39152. /**
  39153. * Callback that will be called if an error occurs during shader compilation.
  39154. */
  39155. onError: Nullable<(effect: Effect, errors: string) => void>;
  39156. /**
  39157. * Callback that will be called when effect is bound.
  39158. */
  39159. onBind: Nullable<(effect: Effect) => void>;
  39160. /**
  39161. * Unique ID of the effect.
  39162. */
  39163. uniqueId: number;
  39164. /**
  39165. * Observable that will be called when the shader is compiled.
  39166. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39167. */
  39168. onCompileObservable: Observable<Effect>;
  39169. /**
  39170. * Observable that will be called if an error occurs during shader compilation.
  39171. */
  39172. onErrorObservable: Observable<Effect>;
  39173. /** @hidden */
  39174. _onBindObservable: Nullable<Observable<Effect>>;
  39175. /**
  39176. * @hidden
  39177. * Specifies if the effect was previously ready
  39178. */
  39179. _wasPreviouslyReady: boolean;
  39180. /**
  39181. * Observable that will be called when effect is bound.
  39182. */
  39183. get onBindObservable(): Observable<Effect>;
  39184. /** @hidden */
  39185. _bonesComputationForcedToCPU: boolean;
  39186. /** @hidden */
  39187. _multiTarget: boolean;
  39188. private static _uniqueIdSeed;
  39189. private _engine;
  39190. private _uniformBuffersNames;
  39191. private _uniformBuffersNamesList;
  39192. private _uniformsNames;
  39193. private _samplerList;
  39194. private _samplers;
  39195. private _isReady;
  39196. private _compilationError;
  39197. private _allFallbacksProcessed;
  39198. private _attributesNames;
  39199. private _attributes;
  39200. private _attributeLocationByName;
  39201. private _uniforms;
  39202. /**
  39203. * Key for the effect.
  39204. * @hidden
  39205. */
  39206. _key: string;
  39207. private _indexParameters;
  39208. private _fallbacks;
  39209. private _vertexSourceCode;
  39210. private _fragmentSourceCode;
  39211. private _vertexSourceCodeOverride;
  39212. private _fragmentSourceCodeOverride;
  39213. private _transformFeedbackVaryings;
  39214. /**
  39215. * Compiled shader to webGL program.
  39216. * @hidden
  39217. */
  39218. _pipelineContext: Nullable<IPipelineContext>;
  39219. private _valueCache;
  39220. private static _baseCache;
  39221. /**
  39222. * Instantiates an effect.
  39223. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39224. * @param baseName Name of the effect.
  39225. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39226. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39227. * @param samplers List of sampler variables that will be passed to the shader.
  39228. * @param engine Engine to be used to render the effect
  39229. * @param defines Define statements to be added to the shader.
  39230. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39231. * @param onCompiled Callback that will be called when the shader is compiled.
  39232. * @param onError Callback that will be called if an error occurs during shader compilation.
  39233. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39234. */
  39235. 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);
  39236. private _useFinalCode;
  39237. /**
  39238. * Unique key for this effect
  39239. */
  39240. get key(): string;
  39241. /**
  39242. * If the effect has been compiled and prepared.
  39243. * @returns if the effect is compiled and prepared.
  39244. */
  39245. isReady(): boolean;
  39246. private _isReadyInternal;
  39247. /**
  39248. * The engine the effect was initialized with.
  39249. * @returns the engine.
  39250. */
  39251. getEngine(): Engine;
  39252. /**
  39253. * The pipeline context for this effect
  39254. * @returns the associated pipeline context
  39255. */
  39256. getPipelineContext(): Nullable<IPipelineContext>;
  39257. /**
  39258. * The set of names of attribute variables for the shader.
  39259. * @returns An array of attribute names.
  39260. */
  39261. getAttributesNames(): string[];
  39262. /**
  39263. * Returns the attribute at the given index.
  39264. * @param index The index of the attribute.
  39265. * @returns The location of the attribute.
  39266. */
  39267. getAttributeLocation(index: number): number;
  39268. /**
  39269. * Returns the attribute based on the name of the variable.
  39270. * @param name of the attribute to look up.
  39271. * @returns the attribute location.
  39272. */
  39273. getAttributeLocationByName(name: string): number;
  39274. /**
  39275. * The number of attributes.
  39276. * @returns the numnber of attributes.
  39277. */
  39278. getAttributesCount(): number;
  39279. /**
  39280. * Gets the index of a uniform variable.
  39281. * @param uniformName of the uniform to look up.
  39282. * @returns the index.
  39283. */
  39284. getUniformIndex(uniformName: string): number;
  39285. /**
  39286. * Returns the attribute based on the name of the variable.
  39287. * @param uniformName of the uniform to look up.
  39288. * @returns the location of the uniform.
  39289. */
  39290. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39291. /**
  39292. * Returns an array of sampler variable names
  39293. * @returns The array of sampler variable names.
  39294. */
  39295. getSamplers(): string[];
  39296. /**
  39297. * Returns an array of uniform variable names
  39298. * @returns The array of uniform variable names.
  39299. */
  39300. getUniformNames(): string[];
  39301. /**
  39302. * Returns an array of uniform buffer variable names
  39303. * @returns The array of uniform buffer variable names.
  39304. */
  39305. getUniformBuffersNames(): string[];
  39306. /**
  39307. * Returns the index parameters used to create the effect
  39308. * @returns The index parameters object
  39309. */
  39310. getIndexParameters(): any;
  39311. /**
  39312. * The error from the last compilation.
  39313. * @returns the error string.
  39314. */
  39315. getCompilationError(): string;
  39316. /**
  39317. * Gets a boolean indicating that all fallbacks were used during compilation
  39318. * @returns true if all fallbacks were used
  39319. */
  39320. allFallbacksProcessed(): boolean;
  39321. /**
  39322. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39323. * @param func The callback to be used.
  39324. */
  39325. executeWhenCompiled(func: (effect: Effect) => void): void;
  39326. private _checkIsReady;
  39327. private _loadShader;
  39328. /**
  39329. * Gets the vertex shader source code of this effect
  39330. */
  39331. get vertexSourceCode(): string;
  39332. /**
  39333. * Gets the fragment shader source code of this effect
  39334. */
  39335. get fragmentSourceCode(): string;
  39336. /**
  39337. * Recompiles the webGL program
  39338. * @param vertexSourceCode The source code for the vertex shader.
  39339. * @param fragmentSourceCode The source code for the fragment shader.
  39340. * @param onCompiled Callback called when completed.
  39341. * @param onError Callback called on error.
  39342. * @hidden
  39343. */
  39344. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39345. /**
  39346. * Prepares the effect
  39347. * @hidden
  39348. */
  39349. _prepareEffect(): void;
  39350. private _getShaderCodeAndErrorLine;
  39351. private _processCompilationErrors;
  39352. /**
  39353. * Checks if the effect is supported. (Must be called after compilation)
  39354. */
  39355. get isSupported(): boolean;
  39356. /**
  39357. * Binds a texture to the engine to be used as output of the shader.
  39358. * @param channel Name of the output variable.
  39359. * @param texture Texture to bind.
  39360. * @hidden
  39361. */
  39362. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39363. /**
  39364. * Sets a texture on the engine to be used in the shader.
  39365. * @param channel Name of the sampler variable.
  39366. * @param texture Texture to set.
  39367. */
  39368. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  39369. /**
  39370. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39371. * @param channel Name of the sampler variable.
  39372. * @param texture Texture to set.
  39373. */
  39374. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39375. /**
  39376. * Sets an array of textures on the engine to be used in the shader.
  39377. * @param channel Name of the variable.
  39378. * @param textures Textures to set.
  39379. */
  39380. setTextureArray(channel: string, textures: BaseTexture[]): void;
  39381. /**
  39382. * 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)
  39383. * @param channel Name of the sampler variable.
  39384. * @param postProcess Post process to get the input texture from.
  39385. */
  39386. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39387. /**
  39388. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39389. * 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)
  39390. * @param channel Name of the sampler variable.
  39391. * @param postProcess Post process to get the output texture from.
  39392. */
  39393. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39394. /** @hidden */
  39395. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39396. /** @hidden */
  39397. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39398. /** @hidden */
  39399. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39400. /** @hidden */
  39401. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39402. /**
  39403. * Binds a buffer to a uniform.
  39404. * @param buffer Buffer to bind.
  39405. * @param name Name of the uniform variable to bind to.
  39406. */
  39407. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39408. /**
  39409. * Binds block to a uniform.
  39410. * @param blockName Name of the block to bind.
  39411. * @param index Index to bind.
  39412. */
  39413. bindUniformBlock(blockName: string, index: number): void;
  39414. /**
  39415. * Sets an interger value on a uniform variable.
  39416. * @param uniformName Name of the variable.
  39417. * @param value Value to be set.
  39418. * @returns this effect.
  39419. */
  39420. setInt(uniformName: string, value: number): Effect;
  39421. /**
  39422. * Sets an int array on a uniform variable.
  39423. * @param uniformName Name of the variable.
  39424. * @param array array to be set.
  39425. * @returns this effect.
  39426. */
  39427. setIntArray(uniformName: string, array: Int32Array): Effect;
  39428. /**
  39429. * 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)
  39430. * @param uniformName Name of the variable.
  39431. * @param array array to be set.
  39432. * @returns this effect.
  39433. */
  39434. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39435. /**
  39436. * 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)
  39437. * @param uniformName Name of the variable.
  39438. * @param array array to be set.
  39439. * @returns this effect.
  39440. */
  39441. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39442. /**
  39443. * 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)
  39444. * @param uniformName Name of the variable.
  39445. * @param array array to be set.
  39446. * @returns this effect.
  39447. */
  39448. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39449. /**
  39450. * Sets an float array on a uniform variable.
  39451. * @param uniformName Name of the variable.
  39452. * @param array array to be set.
  39453. * @returns this effect.
  39454. */
  39455. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39456. /**
  39457. * 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)
  39458. * @param uniformName Name of the variable.
  39459. * @param array array to be set.
  39460. * @returns this effect.
  39461. */
  39462. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39463. /**
  39464. * 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)
  39465. * @param uniformName Name of the variable.
  39466. * @param array array to be set.
  39467. * @returns this effect.
  39468. */
  39469. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39470. /**
  39471. * 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)
  39472. * @param uniformName Name of the variable.
  39473. * @param array array to be set.
  39474. * @returns this effect.
  39475. */
  39476. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39477. /**
  39478. * Sets an array on a uniform variable.
  39479. * @param uniformName Name of the variable.
  39480. * @param array array to be set.
  39481. * @returns this effect.
  39482. */
  39483. setArray(uniformName: string, array: number[]): Effect;
  39484. /**
  39485. * 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)
  39486. * @param uniformName Name of the variable.
  39487. * @param array array to be set.
  39488. * @returns this effect.
  39489. */
  39490. setArray2(uniformName: string, array: number[]): Effect;
  39491. /**
  39492. * 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)
  39493. * @param uniformName Name of the variable.
  39494. * @param array array to be set.
  39495. * @returns this effect.
  39496. */
  39497. setArray3(uniformName: string, array: number[]): Effect;
  39498. /**
  39499. * 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)
  39500. * @param uniformName Name of the variable.
  39501. * @param array array to be set.
  39502. * @returns this effect.
  39503. */
  39504. setArray4(uniformName: string, array: number[]): Effect;
  39505. /**
  39506. * Sets matrices on a uniform variable.
  39507. * @param uniformName Name of the variable.
  39508. * @param matrices matrices to be set.
  39509. * @returns this effect.
  39510. */
  39511. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39512. /**
  39513. * Sets matrix on a uniform variable.
  39514. * @param uniformName Name of the variable.
  39515. * @param matrix matrix to be set.
  39516. * @returns this effect.
  39517. */
  39518. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39519. /**
  39520. * 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)
  39521. * @param uniformName Name of the variable.
  39522. * @param matrix matrix to be set.
  39523. * @returns this effect.
  39524. */
  39525. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39526. /**
  39527. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39528. * @param uniformName Name of the variable.
  39529. * @param matrix matrix to be set.
  39530. * @returns this effect.
  39531. */
  39532. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39533. /**
  39534. * Sets a float on a uniform variable.
  39535. * @param uniformName Name of the variable.
  39536. * @param value value to be set.
  39537. * @returns this effect.
  39538. */
  39539. setFloat(uniformName: string, value: number): Effect;
  39540. /**
  39541. * Sets a boolean on a uniform variable.
  39542. * @param uniformName Name of the variable.
  39543. * @param bool value to be set.
  39544. * @returns this effect.
  39545. */
  39546. setBool(uniformName: string, bool: boolean): Effect;
  39547. /**
  39548. * Sets a Vector2 on a uniform variable.
  39549. * @param uniformName Name of the variable.
  39550. * @param vector2 vector2 to be set.
  39551. * @returns this effect.
  39552. */
  39553. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39554. /**
  39555. * Sets a float2 on a uniform variable.
  39556. * @param uniformName Name of the variable.
  39557. * @param x First float in float2.
  39558. * @param y Second float in float2.
  39559. * @returns this effect.
  39560. */
  39561. setFloat2(uniformName: string, x: number, y: number): Effect;
  39562. /**
  39563. * Sets a Vector3 on a uniform variable.
  39564. * @param uniformName Name of the variable.
  39565. * @param vector3 Value to be set.
  39566. * @returns this effect.
  39567. */
  39568. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39569. /**
  39570. * Sets a float3 on a uniform variable.
  39571. * @param uniformName Name of the variable.
  39572. * @param x First float in float3.
  39573. * @param y Second float in float3.
  39574. * @param z Third float in float3.
  39575. * @returns this effect.
  39576. */
  39577. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39578. /**
  39579. * Sets a Vector4 on a uniform variable.
  39580. * @param uniformName Name of the variable.
  39581. * @param vector4 Value to be set.
  39582. * @returns this effect.
  39583. */
  39584. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39585. /**
  39586. * Sets a float4 on a uniform variable.
  39587. * @param uniformName Name of the variable.
  39588. * @param x First float in float4.
  39589. * @param y Second float in float4.
  39590. * @param z Third float in float4.
  39591. * @param w Fourth float in float4.
  39592. * @returns this effect.
  39593. */
  39594. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39595. /**
  39596. * Sets a Color3 on a uniform variable.
  39597. * @param uniformName Name of the variable.
  39598. * @param color3 Value to be set.
  39599. * @returns this effect.
  39600. */
  39601. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39602. /**
  39603. * Sets a Color4 on a uniform variable.
  39604. * @param uniformName Name of the variable.
  39605. * @param color3 Value to be set.
  39606. * @param alpha Alpha value to be set.
  39607. * @returns this effect.
  39608. */
  39609. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39610. /**
  39611. * Sets a Color4 on a uniform variable
  39612. * @param uniformName defines the name of the variable
  39613. * @param color4 defines the value to be set
  39614. * @returns this effect.
  39615. */
  39616. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39617. /** Release all associated resources */
  39618. dispose(): void;
  39619. /**
  39620. * This function will add a new shader to the shader store
  39621. * @param name the name of the shader
  39622. * @param pixelShader optional pixel shader content
  39623. * @param vertexShader optional vertex shader content
  39624. */
  39625. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39626. /**
  39627. * Store of each shader (The can be looked up using effect.key)
  39628. */
  39629. static ShadersStore: {
  39630. [key: string]: string;
  39631. };
  39632. /**
  39633. * Store of each included file for a shader (The can be looked up using effect.key)
  39634. */
  39635. static IncludesShadersStore: {
  39636. [key: string]: string;
  39637. };
  39638. /**
  39639. * Resets the cache of effects.
  39640. */
  39641. static ResetCache(): void;
  39642. }
  39643. }
  39644. declare module "babylonjs/Engines/engineCapabilities" {
  39645. /**
  39646. * Interface used to describe the capabilities of the engine relatively to the current browser
  39647. */
  39648. export interface EngineCapabilities {
  39649. /** Maximum textures units per fragment shader */
  39650. maxTexturesImageUnits: number;
  39651. /** Maximum texture units per vertex shader */
  39652. maxVertexTextureImageUnits: number;
  39653. /** Maximum textures units in the entire pipeline */
  39654. maxCombinedTexturesImageUnits: number;
  39655. /** Maximum texture size */
  39656. maxTextureSize: number;
  39657. /** Maximum texture samples */
  39658. maxSamples?: number;
  39659. /** Maximum cube texture size */
  39660. maxCubemapTextureSize: number;
  39661. /** Maximum render texture size */
  39662. maxRenderTextureSize: number;
  39663. /** Maximum number of vertex attributes */
  39664. maxVertexAttribs: number;
  39665. /** Maximum number of varyings */
  39666. maxVaryingVectors: number;
  39667. /** Maximum number of uniforms per vertex shader */
  39668. maxVertexUniformVectors: number;
  39669. /** Maximum number of uniforms per fragment shader */
  39670. maxFragmentUniformVectors: number;
  39671. /** Defines if standard derivates (dx/dy) are supported */
  39672. standardDerivatives: boolean;
  39673. /** Defines if s3tc texture compression is supported */
  39674. s3tc?: WEBGL_compressed_texture_s3tc;
  39675. /** Defines if pvrtc texture compression is supported */
  39676. pvrtc: any;
  39677. /** Defines if etc1 texture compression is supported */
  39678. etc1: any;
  39679. /** Defines if etc2 texture compression is supported */
  39680. etc2: any;
  39681. /** Defines if astc texture compression is supported */
  39682. astc: any;
  39683. /** Defines if bptc texture compression is supported */
  39684. bptc: any;
  39685. /** Defines if float textures are supported */
  39686. textureFloat: boolean;
  39687. /** Defines if vertex array objects are supported */
  39688. vertexArrayObject: boolean;
  39689. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39690. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39691. /** Gets the maximum level of anisotropy supported */
  39692. maxAnisotropy: number;
  39693. /** Defines if instancing is supported */
  39694. instancedArrays: boolean;
  39695. /** Defines if 32 bits indices are supported */
  39696. uintIndices: boolean;
  39697. /** Defines if high precision shaders are supported */
  39698. highPrecisionShaderSupported: boolean;
  39699. /** Defines if depth reading in the fragment shader is supported */
  39700. fragmentDepthSupported: boolean;
  39701. /** Defines if float texture linear filtering is supported*/
  39702. textureFloatLinearFiltering: boolean;
  39703. /** Defines if rendering to float textures is supported */
  39704. textureFloatRender: boolean;
  39705. /** Defines if half float textures are supported*/
  39706. textureHalfFloat: boolean;
  39707. /** Defines if half float texture linear filtering is supported*/
  39708. textureHalfFloatLinearFiltering: boolean;
  39709. /** Defines if rendering to half float textures is supported */
  39710. textureHalfFloatRender: boolean;
  39711. /** Defines if textureLOD shader command is supported */
  39712. textureLOD: boolean;
  39713. /** Defines if draw buffers extension is supported */
  39714. drawBuffersExtension: boolean;
  39715. /** Defines if depth textures are supported */
  39716. depthTextureExtension: boolean;
  39717. /** Defines if float color buffer are supported */
  39718. colorBufferFloat: boolean;
  39719. /** Gets disjoint timer query extension (null if not supported) */
  39720. timerQuery?: EXT_disjoint_timer_query;
  39721. /** Defines if timestamp can be used with timer query */
  39722. canUseTimestampForTimerQuery: boolean;
  39723. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39724. multiview?: any;
  39725. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39726. oculusMultiview?: any;
  39727. /** Function used to let the system compiles shaders in background */
  39728. parallelShaderCompile?: {
  39729. COMPLETION_STATUS_KHR: number;
  39730. };
  39731. /** Max number of texture samples for MSAA */
  39732. maxMSAASamples: number;
  39733. /** Defines if the blend min max extension is supported */
  39734. blendMinMax: boolean;
  39735. }
  39736. }
  39737. declare module "babylonjs/States/depthCullingState" {
  39738. import { Nullable } from "babylonjs/types";
  39739. /**
  39740. * @hidden
  39741. **/
  39742. export class DepthCullingState {
  39743. private _isDepthTestDirty;
  39744. private _isDepthMaskDirty;
  39745. private _isDepthFuncDirty;
  39746. private _isCullFaceDirty;
  39747. private _isCullDirty;
  39748. private _isZOffsetDirty;
  39749. private _isFrontFaceDirty;
  39750. private _depthTest;
  39751. private _depthMask;
  39752. private _depthFunc;
  39753. private _cull;
  39754. private _cullFace;
  39755. private _zOffset;
  39756. private _frontFace;
  39757. /**
  39758. * Initializes the state.
  39759. */
  39760. constructor();
  39761. get isDirty(): boolean;
  39762. get zOffset(): number;
  39763. set zOffset(value: number);
  39764. get cullFace(): Nullable<number>;
  39765. set cullFace(value: Nullable<number>);
  39766. get cull(): Nullable<boolean>;
  39767. set cull(value: Nullable<boolean>);
  39768. get depthFunc(): Nullable<number>;
  39769. set depthFunc(value: Nullable<number>);
  39770. get depthMask(): boolean;
  39771. set depthMask(value: boolean);
  39772. get depthTest(): boolean;
  39773. set depthTest(value: boolean);
  39774. get frontFace(): Nullable<number>;
  39775. set frontFace(value: Nullable<number>);
  39776. reset(): void;
  39777. apply(gl: WebGLRenderingContext): void;
  39778. }
  39779. }
  39780. declare module "babylonjs/States/stencilState" {
  39781. /**
  39782. * @hidden
  39783. **/
  39784. export class StencilState {
  39785. /** 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 */
  39786. static readonly ALWAYS: number;
  39787. /** Passed to stencilOperation to specify that stencil value must be kept */
  39788. static readonly KEEP: number;
  39789. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39790. static readonly REPLACE: number;
  39791. private _isStencilTestDirty;
  39792. private _isStencilMaskDirty;
  39793. private _isStencilFuncDirty;
  39794. private _isStencilOpDirty;
  39795. private _stencilTest;
  39796. private _stencilMask;
  39797. private _stencilFunc;
  39798. private _stencilFuncRef;
  39799. private _stencilFuncMask;
  39800. private _stencilOpStencilFail;
  39801. private _stencilOpDepthFail;
  39802. private _stencilOpStencilDepthPass;
  39803. get isDirty(): boolean;
  39804. get stencilFunc(): number;
  39805. set stencilFunc(value: number);
  39806. get stencilFuncRef(): number;
  39807. set stencilFuncRef(value: number);
  39808. get stencilFuncMask(): number;
  39809. set stencilFuncMask(value: number);
  39810. get stencilOpStencilFail(): number;
  39811. set stencilOpStencilFail(value: number);
  39812. get stencilOpDepthFail(): number;
  39813. set stencilOpDepthFail(value: number);
  39814. get stencilOpStencilDepthPass(): number;
  39815. set stencilOpStencilDepthPass(value: number);
  39816. get stencilMask(): number;
  39817. set stencilMask(value: number);
  39818. get stencilTest(): boolean;
  39819. set stencilTest(value: boolean);
  39820. constructor();
  39821. reset(): void;
  39822. apply(gl: WebGLRenderingContext): void;
  39823. }
  39824. }
  39825. declare module "babylonjs/States/alphaCullingState" {
  39826. /**
  39827. * @hidden
  39828. **/
  39829. export class AlphaState {
  39830. private _isAlphaBlendDirty;
  39831. private _isBlendFunctionParametersDirty;
  39832. private _isBlendEquationParametersDirty;
  39833. private _isBlendConstantsDirty;
  39834. private _alphaBlend;
  39835. private _blendFunctionParameters;
  39836. private _blendEquationParameters;
  39837. private _blendConstants;
  39838. /**
  39839. * Initializes the state.
  39840. */
  39841. constructor();
  39842. get isDirty(): boolean;
  39843. get alphaBlend(): boolean;
  39844. set alphaBlend(value: boolean);
  39845. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39846. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39847. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39848. reset(): void;
  39849. apply(gl: WebGLRenderingContext): void;
  39850. }
  39851. }
  39852. declare module "babylonjs/Engines/WebGL/webGLShaderProcessors" {
  39853. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39854. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  39855. /** @hidden */
  39856. export class WebGLShaderProcessor implements IShaderProcessor {
  39857. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  39858. }
  39859. }
  39860. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  39861. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39862. /** @hidden */
  39863. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39864. attributeProcessor(attribute: string): string;
  39865. varyingProcessor(varying: string, isFragment: boolean): string;
  39866. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  39867. }
  39868. }
  39869. declare module "babylonjs/Engines/instancingAttributeInfo" {
  39870. /**
  39871. * Interface for attribute information associated with buffer instanciation
  39872. */
  39873. export interface InstancingAttributeInfo {
  39874. /**
  39875. * Name of the GLSL attribute
  39876. * if attribute index is not specified, this is used to retrieve the index from the effect
  39877. */
  39878. attributeName: string;
  39879. /**
  39880. * Index/offset of the attribute in the vertex shader
  39881. * if not specified, this will be computes from the name.
  39882. */
  39883. index?: number;
  39884. /**
  39885. * size of the attribute, 1, 2, 3 or 4
  39886. */
  39887. attributeSize: number;
  39888. /**
  39889. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39890. */
  39891. offset: number;
  39892. /**
  39893. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39894. * default to 1
  39895. */
  39896. divisor?: number;
  39897. /**
  39898. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39899. * default is FLOAT
  39900. */
  39901. attributeType?: number;
  39902. /**
  39903. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39904. */
  39905. normalized?: boolean;
  39906. }
  39907. }
  39908. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  39909. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39910. import { Nullable } from "babylonjs/types";
  39911. module "babylonjs/Engines/thinEngine" {
  39912. interface ThinEngine {
  39913. /**
  39914. * Update a video texture
  39915. * @param texture defines the texture to update
  39916. * @param video defines the video element to use
  39917. * @param invertY defines if data must be stored with Y axis inverted
  39918. */
  39919. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39920. }
  39921. }
  39922. }
  39923. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  39924. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39925. import { Nullable } from "babylonjs/types";
  39926. module "babylonjs/Engines/thinEngine" {
  39927. interface ThinEngine {
  39928. /**
  39929. * Creates a dynamic texture
  39930. * @param width defines the width of the texture
  39931. * @param height defines the height of the texture
  39932. * @param generateMipMaps defines if the engine should generate the mip levels
  39933. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39934. * @returns the dynamic texture inside an InternalTexture
  39935. */
  39936. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39937. /**
  39938. * Update the content of a dynamic texture
  39939. * @param texture defines the texture to update
  39940. * @param canvas defines the canvas containing the source
  39941. * @param invertY defines if data must be stored with Y axis inverted
  39942. * @param premulAlpha defines if alpha is stored as premultiplied
  39943. * @param format defines the format of the data
  39944. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39945. */
  39946. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39947. }
  39948. }
  39949. }
  39950. declare module "babylonjs/Materials/Textures/videoTexture" {
  39951. import { Observable } from "babylonjs/Misc/observable";
  39952. import { Nullable } from "babylonjs/types";
  39953. import { Scene } from "babylonjs/scene";
  39954. import { Texture } from "babylonjs/Materials/Textures/texture";
  39955. import "babylonjs/Engines/Extensions/engine.videoTexture";
  39956. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  39957. /**
  39958. * Settings for finer control over video usage
  39959. */
  39960. export interface VideoTextureSettings {
  39961. /**
  39962. * Applies `autoplay` to video, if specified
  39963. */
  39964. autoPlay?: boolean;
  39965. /**
  39966. * Applies `muted` to video, if specified
  39967. */
  39968. muted?: boolean;
  39969. /**
  39970. * Applies `loop` to video, if specified
  39971. */
  39972. loop?: boolean;
  39973. /**
  39974. * Automatically updates internal texture from video at every frame in the render loop
  39975. */
  39976. autoUpdateTexture: boolean;
  39977. /**
  39978. * Image src displayed during the video loading or until the user interacts with the video.
  39979. */
  39980. poster?: string;
  39981. }
  39982. /**
  39983. * If you want to display a video in your scene, this is the special texture for that.
  39984. * This special texture works similar to other textures, with the exception of a few parameters.
  39985. * @see https://doc.babylonjs.com/how_to/video_texture
  39986. */
  39987. export class VideoTexture extends Texture {
  39988. /**
  39989. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39990. */
  39991. readonly autoUpdateTexture: boolean;
  39992. /**
  39993. * The video instance used by the texture internally
  39994. */
  39995. readonly video: HTMLVideoElement;
  39996. private _onUserActionRequestedObservable;
  39997. /**
  39998. * Event triggerd when a dom action is required by the user to play the video.
  39999. * This happens due to recent changes in browser policies preventing video to auto start.
  40000. */
  40001. get onUserActionRequestedObservable(): Observable<Texture>;
  40002. private _generateMipMaps;
  40003. private _stillImageCaptured;
  40004. private _displayingPosterTexture;
  40005. private _settings;
  40006. private _createInternalTextureOnEvent;
  40007. private _frameId;
  40008. private _currentSrc;
  40009. /**
  40010. * Creates a video texture.
  40011. * If you want to display a video in your scene, this is the special texture for that.
  40012. * This special texture works similar to other textures, with the exception of a few parameters.
  40013. * @see https://doc.babylonjs.com/how_to/video_texture
  40014. * @param name optional name, will detect from video source, if not defined
  40015. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40016. * @param scene is obviously the current scene.
  40017. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40018. * @param invertY is false by default but can be used to invert video on Y axis
  40019. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40020. * @param settings allows finer control over video usage
  40021. */
  40022. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40023. private _getName;
  40024. private _getVideo;
  40025. private _createInternalTexture;
  40026. private reset;
  40027. /**
  40028. * @hidden Internal method to initiate `update`.
  40029. */
  40030. _rebuild(): void;
  40031. /**
  40032. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40033. */
  40034. update(): void;
  40035. /**
  40036. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40037. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  40038. */
  40039. updateTexture(isVisible: boolean): void;
  40040. protected _updateInternalTexture: () => void;
  40041. /**
  40042. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40043. * @param url New url.
  40044. */
  40045. updateURL(url: string): void;
  40046. /**
  40047. * Clones the texture.
  40048. * @returns the cloned texture
  40049. */
  40050. clone(): VideoTexture;
  40051. /**
  40052. * Dispose the texture and release its associated resources.
  40053. */
  40054. dispose(): void;
  40055. /**
  40056. * Creates a video texture straight from a stream.
  40057. * @param scene Define the scene the texture should be created in
  40058. * @param stream Define the stream the texture should be created from
  40059. * @returns The created video texture as a promise
  40060. */
  40061. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40062. /**
  40063. * Creates a video texture straight from your WebCam video feed.
  40064. * @param scene Define the scene the texture should be created in
  40065. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40066. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40067. * @returns The created video texture as a promise
  40068. */
  40069. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40070. minWidth: number;
  40071. maxWidth: number;
  40072. minHeight: number;
  40073. maxHeight: number;
  40074. deviceId: string;
  40075. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40076. /**
  40077. * Creates a video texture straight from your WebCam video feed.
  40078. * @param scene Define the scene the texture should be created in
  40079. * @param onReady Define a callback to triggered once the texture will be ready
  40080. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40081. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40082. */
  40083. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40084. minWidth: number;
  40085. maxWidth: number;
  40086. minHeight: number;
  40087. maxHeight: number;
  40088. deviceId: string;
  40089. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40090. }
  40091. }
  40092. declare module "babylonjs/Engines/thinEngine" {
  40093. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  40094. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  40095. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40096. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40097. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  40098. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  40099. import { Observable } from "babylonjs/Misc/observable";
  40100. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  40101. import { StencilState } from "babylonjs/States/stencilState";
  40102. import { AlphaState } from "babylonjs/States/alphaCullingState";
  40103. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40104. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  40105. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  40106. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40107. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  40108. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  40109. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  40110. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  40111. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40112. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40113. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  40114. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  40115. import { WebRequest } from "babylonjs/Misc/webRequest";
  40116. import { LoadFileError } from "babylonjs/Misc/fileTools";
  40117. /**
  40118. * Defines the interface used by objects working like Scene
  40119. * @hidden
  40120. */
  40121. export interface ISceneLike {
  40122. _addPendingData(data: any): void;
  40123. _removePendingData(data: any): void;
  40124. offlineProvider: IOfflineProvider;
  40125. }
  40126. /**
  40127. * Information about the current host
  40128. */
  40129. export interface HostInformation {
  40130. /**
  40131. * Defines if the current host is a mobile
  40132. */
  40133. isMobile: boolean;
  40134. }
  40135. /** Interface defining initialization parameters for Engine class */
  40136. export interface EngineOptions extends WebGLContextAttributes {
  40137. /**
  40138. * Defines if the engine should no exceed a specified device ratio
  40139. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40140. */
  40141. limitDeviceRatio?: number;
  40142. /**
  40143. * Defines if webvr should be enabled automatically
  40144. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40145. */
  40146. autoEnableWebVR?: boolean;
  40147. /**
  40148. * Defines if webgl2 should be turned off even if supported
  40149. * @see https://doc.babylonjs.com/features/webgl2
  40150. */
  40151. disableWebGL2Support?: boolean;
  40152. /**
  40153. * Defines if webaudio should be initialized as well
  40154. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40155. */
  40156. audioEngine?: boolean;
  40157. /**
  40158. * Defines if animations should run using a deterministic lock step
  40159. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40160. */
  40161. deterministicLockstep?: boolean;
  40162. /** Defines the maximum steps to use with deterministic lock step mode */
  40163. lockstepMaxSteps?: number;
  40164. /** Defines the seconds between each deterministic lock step */
  40165. timeStep?: number;
  40166. /**
  40167. * Defines that engine should ignore context lost events
  40168. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40169. */
  40170. doNotHandleContextLost?: boolean;
  40171. /**
  40172. * Defines that engine should ignore modifying touch action attribute and style
  40173. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40174. */
  40175. doNotHandleTouchAction?: boolean;
  40176. /**
  40177. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40178. */
  40179. useHighPrecisionFloats?: boolean;
  40180. /**
  40181. * Make the canvas XR Compatible for XR sessions
  40182. */
  40183. xrCompatible?: boolean;
  40184. /**
  40185. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40186. */
  40187. useHighPrecisionMatrix?: boolean;
  40188. /**
  40189. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40190. */
  40191. failIfMajorPerformanceCaveat?: boolean;
  40192. }
  40193. /**
  40194. * The base engine class (root of all engines)
  40195. */
  40196. export class ThinEngine {
  40197. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40198. static ExceptionList: ({
  40199. key: string;
  40200. capture: string;
  40201. captureConstraint: number;
  40202. targets: string[];
  40203. } | {
  40204. key: string;
  40205. capture: null;
  40206. captureConstraint: null;
  40207. targets: string[];
  40208. })[];
  40209. /** @hidden */
  40210. static _TextureLoaders: IInternalTextureLoader[];
  40211. /**
  40212. * Returns the current npm package of the sdk
  40213. */
  40214. static get NpmPackage(): string;
  40215. /**
  40216. * Returns the current version of the framework
  40217. */
  40218. static get Version(): string;
  40219. /**
  40220. * Returns a string describing the current engine
  40221. */
  40222. get description(): string;
  40223. /**
  40224. * Gets or sets the epsilon value used by collision engine
  40225. */
  40226. static CollisionsEpsilon: number;
  40227. /**
  40228. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40229. */
  40230. static get ShadersRepository(): string;
  40231. static set ShadersRepository(value: string);
  40232. /** @hidden */
  40233. _shaderProcessor: IShaderProcessor;
  40234. /**
  40235. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40236. */
  40237. forcePOTTextures: boolean;
  40238. /**
  40239. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40240. */
  40241. isFullscreen: boolean;
  40242. /**
  40243. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40244. */
  40245. cullBackFaces: boolean;
  40246. /**
  40247. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40248. */
  40249. renderEvenInBackground: boolean;
  40250. /**
  40251. * Gets or sets a boolean indicating that cache can be kept between frames
  40252. */
  40253. preventCacheWipeBetweenFrames: boolean;
  40254. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40255. validateShaderPrograms: boolean;
  40256. /**
  40257. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40258. * This can provide greater z depth for distant objects.
  40259. */
  40260. useReverseDepthBuffer: boolean;
  40261. /**
  40262. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40263. */
  40264. disableUniformBuffers: boolean;
  40265. /** @hidden */
  40266. _uniformBuffers: UniformBuffer[];
  40267. /**
  40268. * Gets a boolean indicating that the engine supports uniform buffers
  40269. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40270. */
  40271. get supportsUniformBuffers(): boolean;
  40272. /** @hidden */
  40273. _gl: WebGLRenderingContext;
  40274. /** @hidden */
  40275. _webGLVersion: number;
  40276. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40277. protected _windowIsBackground: boolean;
  40278. protected _creationOptions: EngineOptions;
  40279. protected _highPrecisionShadersAllowed: boolean;
  40280. /** @hidden */
  40281. get _shouldUseHighPrecisionShader(): boolean;
  40282. /**
  40283. * Gets a boolean indicating that only power of 2 textures are supported
  40284. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40285. */
  40286. get needPOTTextures(): boolean;
  40287. /** @hidden */
  40288. _badOS: boolean;
  40289. /** @hidden */
  40290. _badDesktopOS: boolean;
  40291. private _hardwareScalingLevel;
  40292. /** @hidden */
  40293. _caps: EngineCapabilities;
  40294. private _isStencilEnable;
  40295. private _glVersion;
  40296. private _glRenderer;
  40297. private _glVendor;
  40298. /** @hidden */
  40299. _videoTextureSupported: boolean;
  40300. protected _renderingQueueLaunched: boolean;
  40301. protected _activeRenderLoops: (() => void)[];
  40302. /**
  40303. * Observable signaled when a context lost event is raised
  40304. */
  40305. onContextLostObservable: Observable<ThinEngine>;
  40306. /**
  40307. * Observable signaled when a context restored event is raised
  40308. */
  40309. onContextRestoredObservable: Observable<ThinEngine>;
  40310. private _onContextLost;
  40311. private _onContextRestored;
  40312. protected _contextWasLost: boolean;
  40313. /** @hidden */
  40314. _doNotHandleContextLost: boolean;
  40315. /**
  40316. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40317. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40318. */
  40319. get doNotHandleContextLost(): boolean;
  40320. set doNotHandleContextLost(value: boolean);
  40321. /**
  40322. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40323. */
  40324. disableVertexArrayObjects: boolean;
  40325. /** @hidden */
  40326. protected _colorWrite: boolean;
  40327. /** @hidden */
  40328. protected _colorWriteChanged: boolean;
  40329. /** @hidden */
  40330. protected _depthCullingState: DepthCullingState;
  40331. /** @hidden */
  40332. protected _stencilState: StencilState;
  40333. /** @hidden */
  40334. _alphaState: AlphaState;
  40335. /** @hidden */
  40336. _alphaMode: number;
  40337. /** @hidden */
  40338. _alphaEquation: number;
  40339. /** @hidden */
  40340. _internalTexturesCache: InternalTexture[];
  40341. /** @hidden */
  40342. protected _activeChannel: number;
  40343. private _currentTextureChannel;
  40344. /** @hidden */
  40345. protected _boundTexturesCache: {
  40346. [key: string]: Nullable<InternalTexture>;
  40347. };
  40348. /** @hidden */
  40349. protected _currentEffect: Nullable<Effect>;
  40350. /** @hidden */
  40351. protected _currentProgram: Nullable<WebGLProgram>;
  40352. private _compiledEffects;
  40353. private _vertexAttribArraysEnabled;
  40354. /** @hidden */
  40355. protected _cachedViewport: Nullable<IViewportLike>;
  40356. private _cachedVertexArrayObject;
  40357. /** @hidden */
  40358. protected _cachedVertexBuffers: any;
  40359. /** @hidden */
  40360. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40361. /** @hidden */
  40362. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40363. /** @hidden */
  40364. _currentRenderTarget: Nullable<InternalTexture>;
  40365. private _uintIndicesCurrentlySet;
  40366. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40367. /** @hidden */
  40368. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40369. /** @hidden */
  40370. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40371. private _currentBufferPointers;
  40372. private _currentInstanceLocations;
  40373. private _currentInstanceBuffers;
  40374. private _textureUnits;
  40375. /** @hidden */
  40376. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40377. /** @hidden */
  40378. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40379. /** @hidden */
  40380. _boundRenderFunction: any;
  40381. private _vaoRecordInProgress;
  40382. private _mustWipeVertexAttributes;
  40383. private _emptyTexture;
  40384. private _emptyCubeTexture;
  40385. private _emptyTexture3D;
  40386. private _emptyTexture2DArray;
  40387. /** @hidden */
  40388. _frameHandler: number;
  40389. private _nextFreeTextureSlots;
  40390. private _maxSimultaneousTextures;
  40391. private _activeRequests;
  40392. /** @hidden */
  40393. _transformTextureUrl: Nullable<(url: string) => string>;
  40394. /**
  40395. * Gets information about the current host
  40396. */
  40397. hostInformation: HostInformation;
  40398. protected get _supportsHardwareTextureRescaling(): boolean;
  40399. private _framebufferDimensionsObject;
  40400. /**
  40401. * sets the object from which width and height will be taken from when getting render width and height
  40402. * Will fallback to the gl object
  40403. * @param dimensions the framebuffer width and height that will be used.
  40404. */
  40405. set framebufferDimensionsObject(dimensions: Nullable<{
  40406. framebufferWidth: number;
  40407. framebufferHeight: number;
  40408. }>);
  40409. /**
  40410. * Gets the current viewport
  40411. */
  40412. get currentViewport(): Nullable<IViewportLike>;
  40413. /**
  40414. * Gets the default empty texture
  40415. */
  40416. get emptyTexture(): InternalTexture;
  40417. /**
  40418. * Gets the default empty 3D texture
  40419. */
  40420. get emptyTexture3D(): InternalTexture;
  40421. /**
  40422. * Gets the default empty 2D array texture
  40423. */
  40424. get emptyTexture2DArray(): InternalTexture;
  40425. /**
  40426. * Gets the default empty cube texture
  40427. */
  40428. get emptyCubeTexture(): InternalTexture;
  40429. /**
  40430. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40431. */
  40432. readonly premultipliedAlpha: boolean;
  40433. /**
  40434. * Observable event triggered before each texture is initialized
  40435. */
  40436. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40437. /**
  40438. * Creates a new engine
  40439. * @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
  40440. * @param antialias defines enable antialiasing (default: false)
  40441. * @param options defines further options to be sent to the getContext() function
  40442. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40443. */
  40444. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40445. private _rebuildInternalTextures;
  40446. private _rebuildEffects;
  40447. /**
  40448. * Gets a boolean indicating if all created effects are ready
  40449. * @returns true if all effects are ready
  40450. */
  40451. areAllEffectsReady(): boolean;
  40452. protected _rebuildBuffers(): void;
  40453. protected _initGLContext(): void;
  40454. /**
  40455. * Gets version of the current webGL context
  40456. */
  40457. get webGLVersion(): number;
  40458. /**
  40459. * Gets a string identifying the name of the class
  40460. * @returns "Engine" string
  40461. */
  40462. getClassName(): string;
  40463. /**
  40464. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40465. */
  40466. get isStencilEnable(): boolean;
  40467. /** @hidden */
  40468. _prepareWorkingCanvas(): void;
  40469. /**
  40470. * Reset the texture cache to empty state
  40471. */
  40472. resetTextureCache(): void;
  40473. /**
  40474. * Gets an object containing information about the current webGL context
  40475. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40476. */
  40477. getGlInfo(): {
  40478. vendor: string;
  40479. renderer: string;
  40480. version: string;
  40481. };
  40482. /**
  40483. * Defines the hardware scaling level.
  40484. * By default the hardware scaling level is computed from the window device ratio.
  40485. * 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.
  40486. * @param level defines the level to use
  40487. */
  40488. setHardwareScalingLevel(level: number): void;
  40489. /**
  40490. * Gets the current hardware scaling level.
  40491. * By default the hardware scaling level is computed from the window device ratio.
  40492. * 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.
  40493. * @returns a number indicating the current hardware scaling level
  40494. */
  40495. getHardwareScalingLevel(): number;
  40496. /**
  40497. * Gets the list of loaded textures
  40498. * @returns an array containing all loaded textures
  40499. */
  40500. getLoadedTexturesCache(): InternalTexture[];
  40501. /**
  40502. * Gets the object containing all engine capabilities
  40503. * @returns the EngineCapabilities object
  40504. */
  40505. getCaps(): EngineCapabilities;
  40506. /**
  40507. * stop executing a render loop function and remove it from the execution array
  40508. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40509. */
  40510. stopRenderLoop(renderFunction?: () => void): void;
  40511. /** @hidden */
  40512. _renderLoop(): void;
  40513. /**
  40514. * Gets the HTML canvas attached with the current webGL context
  40515. * @returns a HTML canvas
  40516. */
  40517. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40518. /**
  40519. * Gets host window
  40520. * @returns the host window object
  40521. */
  40522. getHostWindow(): Nullable<Window>;
  40523. /**
  40524. * Gets the current render width
  40525. * @param useScreen defines if screen size must be used (or the current render target if any)
  40526. * @returns a number defining the current render width
  40527. */
  40528. getRenderWidth(useScreen?: boolean): number;
  40529. /**
  40530. * Gets the current render height
  40531. * @param useScreen defines if screen size must be used (or the current render target if any)
  40532. * @returns a number defining the current render height
  40533. */
  40534. getRenderHeight(useScreen?: boolean): number;
  40535. /**
  40536. * Can be used to override the current requestAnimationFrame requester.
  40537. * @hidden
  40538. */
  40539. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40540. /**
  40541. * Register and execute a render loop. The engine can have more than one render function
  40542. * @param renderFunction defines the function to continuously execute
  40543. */
  40544. runRenderLoop(renderFunction: () => void): void;
  40545. /**
  40546. * Clear the current render buffer or the current render target (if any is set up)
  40547. * @param color defines the color to use
  40548. * @param backBuffer defines if the back buffer must be cleared
  40549. * @param depth defines if the depth buffer must be cleared
  40550. * @param stencil defines if the stencil buffer must be cleared
  40551. */
  40552. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40553. private _viewportCached;
  40554. /** @hidden */
  40555. _viewport(x: number, y: number, width: number, height: number): void;
  40556. /**
  40557. * Set the WebGL's viewport
  40558. * @param viewport defines the viewport element to be used
  40559. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40560. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40561. */
  40562. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40563. /**
  40564. * Begin a new frame
  40565. */
  40566. beginFrame(): void;
  40567. /**
  40568. * Enf the current frame
  40569. */
  40570. endFrame(): void;
  40571. /**
  40572. * Resize the view according to the canvas' size
  40573. */
  40574. resize(): void;
  40575. /**
  40576. * Force a specific size of the canvas
  40577. * @param width defines the new canvas' width
  40578. * @param height defines the new canvas' height
  40579. * @returns true if the size was changed
  40580. */
  40581. setSize(width: number, height: number): boolean;
  40582. /**
  40583. * Binds the frame buffer to the specified texture.
  40584. * @param texture The texture to render to or null for the default canvas
  40585. * @param faceIndex The face of the texture to render to in case of cube texture
  40586. * @param requiredWidth The width of the target to render to
  40587. * @param requiredHeight The height of the target to render to
  40588. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40589. * @param lodLevel defines the lod level to bind to the frame buffer
  40590. * @param layer defines the 2d array index to bind to frame buffer to
  40591. */
  40592. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40593. /** @hidden */
  40594. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40595. /**
  40596. * Unbind the current render target texture from the webGL context
  40597. * @param texture defines the render target texture to unbind
  40598. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40599. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40600. */
  40601. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40602. /**
  40603. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40604. */
  40605. flushFramebuffer(): void;
  40606. /**
  40607. * Unbind the current render target and bind the default framebuffer
  40608. */
  40609. restoreDefaultFramebuffer(): void;
  40610. /** @hidden */
  40611. protected _resetVertexBufferBinding(): void;
  40612. /**
  40613. * Creates a vertex buffer
  40614. * @param data the data for the vertex buffer
  40615. * @returns the new WebGL static buffer
  40616. */
  40617. createVertexBuffer(data: DataArray): DataBuffer;
  40618. private _createVertexBuffer;
  40619. /**
  40620. * Creates a dynamic vertex buffer
  40621. * @param data the data for the dynamic vertex buffer
  40622. * @returns the new WebGL dynamic buffer
  40623. */
  40624. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40625. protected _resetIndexBufferBinding(): void;
  40626. /**
  40627. * Creates a new index buffer
  40628. * @param indices defines the content of the index buffer
  40629. * @param updatable defines if the index buffer must be updatable
  40630. * @returns a new webGL buffer
  40631. */
  40632. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40633. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40634. /**
  40635. * Bind a webGL buffer to the webGL context
  40636. * @param buffer defines the buffer to bind
  40637. */
  40638. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40639. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40640. private bindBuffer;
  40641. /**
  40642. * update the bound buffer with the given data
  40643. * @param data defines the data to update
  40644. */
  40645. updateArrayBuffer(data: Float32Array): void;
  40646. private _vertexAttribPointer;
  40647. /** @hidden */
  40648. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40649. private _bindVertexBuffersAttributes;
  40650. /**
  40651. * Records a vertex array object
  40652. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40653. * @param vertexBuffers defines the list of vertex buffers to store
  40654. * @param indexBuffer defines the index buffer to store
  40655. * @param effect defines the effect to store
  40656. * @returns the new vertex array object
  40657. */
  40658. recordVertexArrayObject(vertexBuffers: {
  40659. [key: string]: VertexBuffer;
  40660. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40661. /**
  40662. * Bind a specific vertex array object
  40663. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40664. * @param vertexArrayObject defines the vertex array object to bind
  40665. * @param indexBuffer defines the index buffer to bind
  40666. */
  40667. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40668. /**
  40669. * Bind webGl buffers directly to the webGL context
  40670. * @param vertexBuffer defines the vertex buffer to bind
  40671. * @param indexBuffer defines the index buffer to bind
  40672. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40673. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40674. * @param effect defines the effect associated with the vertex buffer
  40675. */
  40676. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40677. private _unbindVertexArrayObject;
  40678. /**
  40679. * Bind a list of vertex buffers to the webGL context
  40680. * @param vertexBuffers defines the list of vertex buffers to bind
  40681. * @param indexBuffer defines the index buffer to bind
  40682. * @param effect defines the effect associated with the vertex buffers
  40683. */
  40684. bindBuffers(vertexBuffers: {
  40685. [key: string]: Nullable<VertexBuffer>;
  40686. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40687. /**
  40688. * Unbind all instance attributes
  40689. */
  40690. unbindInstanceAttributes(): void;
  40691. /**
  40692. * Release and free the memory of a vertex array object
  40693. * @param vao defines the vertex array object to delete
  40694. */
  40695. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40696. /** @hidden */
  40697. _releaseBuffer(buffer: DataBuffer): boolean;
  40698. protected _deleteBuffer(buffer: DataBuffer): void;
  40699. /**
  40700. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40701. * @param instancesBuffer defines the webGL buffer to update and bind
  40702. * @param data defines the data to store in the buffer
  40703. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40704. */
  40705. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40706. /**
  40707. * Bind the content of a webGL buffer used with instantiation
  40708. * @param instancesBuffer defines the webGL buffer to bind
  40709. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40710. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40711. */
  40712. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40713. /**
  40714. * Disable the instance attribute corresponding to the name in parameter
  40715. * @param name defines the name of the attribute to disable
  40716. */
  40717. disableInstanceAttributeByName(name: string): void;
  40718. /**
  40719. * Disable the instance attribute corresponding to the location in parameter
  40720. * @param attributeLocation defines the attribute location of the attribute to disable
  40721. */
  40722. disableInstanceAttribute(attributeLocation: number): void;
  40723. /**
  40724. * Disable the attribute corresponding to the location in parameter
  40725. * @param attributeLocation defines the attribute location of the attribute to disable
  40726. */
  40727. disableAttributeByIndex(attributeLocation: number): void;
  40728. /**
  40729. * Send a draw order
  40730. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40731. * @param indexStart defines the starting index
  40732. * @param indexCount defines the number of index to draw
  40733. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40734. */
  40735. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40736. /**
  40737. * Draw a list of points
  40738. * @param verticesStart defines the index of first vertex to draw
  40739. * @param verticesCount defines the count of vertices to draw
  40740. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40741. */
  40742. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40743. /**
  40744. * Draw a list of unindexed primitives
  40745. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40746. * @param verticesStart defines the index of first vertex to draw
  40747. * @param verticesCount defines the count of vertices to draw
  40748. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40749. */
  40750. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40751. /**
  40752. * Draw a list of indexed primitives
  40753. * @param fillMode defines the primitive to use
  40754. * @param indexStart defines the starting index
  40755. * @param indexCount defines the number of index to draw
  40756. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40757. */
  40758. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40759. /**
  40760. * Draw a list of unindexed primitives
  40761. * @param fillMode defines the primitive to use
  40762. * @param verticesStart defines the index of first vertex to draw
  40763. * @param verticesCount defines the count of vertices to draw
  40764. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40765. */
  40766. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40767. private _drawMode;
  40768. /** @hidden */
  40769. protected _reportDrawCall(): void;
  40770. /** @hidden */
  40771. _releaseEffect(effect: Effect): void;
  40772. /** @hidden */
  40773. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40774. /**
  40775. * Create a new effect (used to store vertex/fragment shaders)
  40776. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40777. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40778. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40779. * @param samplers defines an array of string used to represent textures
  40780. * @param defines defines the string containing the defines to use to compile the shaders
  40781. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40782. * @param onCompiled defines a function to call when the effect creation is successful
  40783. * @param onError defines a function to call when the effect creation has failed
  40784. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40785. * @returns the new Effect
  40786. */
  40787. 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;
  40788. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40789. private _compileShader;
  40790. private _compileRawShader;
  40791. /** @hidden */
  40792. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40793. /**
  40794. * Directly creates a webGL program
  40795. * @param pipelineContext defines the pipeline context to attach to
  40796. * @param vertexCode defines the vertex shader code to use
  40797. * @param fragmentCode defines the fragment shader code to use
  40798. * @param context defines the webGL context to use (if not set, the current one will be used)
  40799. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40800. * @returns the new webGL program
  40801. */
  40802. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40803. /**
  40804. * Creates a webGL program
  40805. * @param pipelineContext defines the pipeline context to attach to
  40806. * @param vertexCode defines the vertex shader code to use
  40807. * @param fragmentCode defines the fragment shader code to use
  40808. * @param defines defines the string containing the defines to use to compile the shaders
  40809. * @param context defines the webGL context to use (if not set, the current one will be used)
  40810. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40811. * @returns the new webGL program
  40812. */
  40813. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40814. /**
  40815. * Creates a new pipeline context
  40816. * @returns the new pipeline
  40817. */
  40818. createPipelineContext(): IPipelineContext;
  40819. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40820. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40821. /** @hidden */
  40822. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  40823. /** @hidden */
  40824. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40825. /** @hidden */
  40826. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40827. /**
  40828. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40829. * @param pipelineContext defines the pipeline context to use
  40830. * @param uniformsNames defines the list of uniform names
  40831. * @returns an array of webGL uniform locations
  40832. */
  40833. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40834. /**
  40835. * Gets the lsit of active attributes for a given webGL program
  40836. * @param pipelineContext defines the pipeline context to use
  40837. * @param attributesNames defines the list of attribute names to get
  40838. * @returns an array of indices indicating the offset of each attribute
  40839. */
  40840. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40841. /**
  40842. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40843. * @param effect defines the effect to activate
  40844. */
  40845. enableEffect(effect: Nullable<Effect>): void;
  40846. /**
  40847. * Set the value of an uniform to a number (int)
  40848. * @param uniform defines the webGL uniform location where to store the value
  40849. * @param value defines the int number to store
  40850. * @returns true if the value was set
  40851. */
  40852. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40853. /**
  40854. * Set the value of an uniform to an array of int32
  40855. * @param uniform defines the webGL uniform location where to store the value
  40856. * @param array defines the array of int32 to store
  40857. * @returns true if the value was set
  40858. */
  40859. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40860. /**
  40861. * Set the value of an uniform to an array of int32 (stored as vec2)
  40862. * @param uniform defines the webGL uniform location where to store the value
  40863. * @param array defines the array of int32 to store
  40864. * @returns true if the value was set
  40865. */
  40866. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40867. /**
  40868. * Set the value of an uniform to an array of int32 (stored as vec3)
  40869. * @param uniform defines the webGL uniform location where to store the value
  40870. * @param array defines the array of int32 to store
  40871. * @returns true if the value was set
  40872. */
  40873. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40874. /**
  40875. * Set the value of an uniform to an array of int32 (stored as vec4)
  40876. * @param uniform defines the webGL uniform location where to store the value
  40877. * @param array defines the array of int32 to store
  40878. * @returns true if the value was set
  40879. */
  40880. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40881. /**
  40882. * Set the value of an uniform to an array of number
  40883. * @param uniform defines the webGL uniform location where to store the value
  40884. * @param array defines the array of number to store
  40885. * @returns true if the value was set
  40886. */
  40887. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40888. /**
  40889. * Set the value of an uniform to an array of number (stored as vec2)
  40890. * @param uniform defines the webGL uniform location where to store the value
  40891. * @param array defines the array of number to store
  40892. * @returns true if the value was set
  40893. */
  40894. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40895. /**
  40896. * Set the value of an uniform to an array of number (stored as vec3)
  40897. * @param uniform defines the webGL uniform location where to store the value
  40898. * @param array defines the array of number to store
  40899. * @returns true if the value was set
  40900. */
  40901. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40902. /**
  40903. * Set the value of an uniform to an array of number (stored as vec4)
  40904. * @param uniform defines the webGL uniform location where to store the value
  40905. * @param array defines the array of number to store
  40906. * @returns true if the value was set
  40907. */
  40908. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40909. /**
  40910. * Set the value of an uniform to an array of float32 (stored as matrices)
  40911. * @param uniform defines the webGL uniform location where to store the value
  40912. * @param matrices defines the array of float32 to store
  40913. * @returns true if the value was set
  40914. */
  40915. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40916. /**
  40917. * Set the value of an uniform to a matrix (3x3)
  40918. * @param uniform defines the webGL uniform location where to store the value
  40919. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40920. * @returns true if the value was set
  40921. */
  40922. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40923. /**
  40924. * Set the value of an uniform to a matrix (2x2)
  40925. * @param uniform defines the webGL uniform location where to store the value
  40926. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40927. * @returns true if the value was set
  40928. */
  40929. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40930. /**
  40931. * Set the value of an uniform to a number (float)
  40932. * @param uniform defines the webGL uniform location where to store the value
  40933. * @param value defines the float number to store
  40934. * @returns true if the value was transfered
  40935. */
  40936. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40937. /**
  40938. * Set the value of an uniform to a vec2
  40939. * @param uniform defines the webGL uniform location where to store the value
  40940. * @param x defines the 1st component of the value
  40941. * @param y defines the 2nd component of the value
  40942. * @returns true if the value was set
  40943. */
  40944. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40945. /**
  40946. * Set the value of an uniform to a vec3
  40947. * @param uniform defines the webGL uniform location where to store the value
  40948. * @param x defines the 1st component of the value
  40949. * @param y defines the 2nd component of the value
  40950. * @param z defines the 3rd component of the value
  40951. * @returns true if the value was set
  40952. */
  40953. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40954. /**
  40955. * Set the value of an uniform to a vec4
  40956. * @param uniform defines the webGL uniform location where to store the value
  40957. * @param x defines the 1st component of the value
  40958. * @param y defines the 2nd component of the value
  40959. * @param z defines the 3rd component of the value
  40960. * @param w defines the 4th component of the value
  40961. * @returns true if the value was set
  40962. */
  40963. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40964. /**
  40965. * Apply all cached states (depth, culling, stencil and alpha)
  40966. */
  40967. applyStates(): void;
  40968. /**
  40969. * Enable or disable color writing
  40970. * @param enable defines the state to set
  40971. */
  40972. setColorWrite(enable: boolean): void;
  40973. /**
  40974. * Gets a boolean indicating if color writing is enabled
  40975. * @returns the current color writing state
  40976. */
  40977. getColorWrite(): boolean;
  40978. /**
  40979. * Gets the depth culling state manager
  40980. */
  40981. get depthCullingState(): DepthCullingState;
  40982. /**
  40983. * Gets the alpha state manager
  40984. */
  40985. get alphaState(): AlphaState;
  40986. /**
  40987. * Gets the stencil state manager
  40988. */
  40989. get stencilState(): StencilState;
  40990. /**
  40991. * Clears the list of texture accessible through engine.
  40992. * This can help preventing texture load conflict due to name collision.
  40993. */
  40994. clearInternalTexturesCache(): void;
  40995. /**
  40996. * Force the entire cache to be cleared
  40997. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40998. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40999. */
  41000. wipeCaches(bruteForce?: boolean): void;
  41001. /** @hidden */
  41002. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41003. min: number;
  41004. mag: number;
  41005. };
  41006. /** @hidden */
  41007. _createTexture(): WebGLTexture;
  41008. /**
  41009. * Usually called from Texture.ts.
  41010. * Passed information to create a WebGLTexture
  41011. * @param url defines a value which contains one of the following:
  41012. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41013. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41014. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41015. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41016. * @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)
  41017. * @param scene needed for loading to the correct scene
  41018. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41019. * @param onLoad optional callback to be called upon successful completion
  41020. * @param onError optional callback to be called upon failure
  41021. * @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
  41022. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41023. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41024. * @param forcedExtension defines the extension to use to pick the right loader
  41025. * @param mimeType defines an optional mime type
  41026. * @param loaderOptions options to be passed to the loader
  41027. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41028. */
  41029. 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;
  41030. /**
  41031. * Loads an image as an HTMLImageElement.
  41032. * @param input url string, ArrayBuffer, or Blob to load
  41033. * @param onLoad callback called when the image successfully loads
  41034. * @param onError callback called when the image fails to load
  41035. * @param offlineProvider offline provider for caching
  41036. * @param mimeType optional mime type
  41037. * @returns the HTMLImageElement of the loaded image
  41038. * @hidden
  41039. */
  41040. 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>;
  41041. /**
  41042. * @hidden
  41043. */
  41044. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41045. private _unpackFlipYCached;
  41046. /**
  41047. * In case you are sharing the context with other applications, it might
  41048. * be interested to not cache the unpack flip y state to ensure a consistent
  41049. * value would be set.
  41050. */
  41051. enableUnpackFlipYCached: boolean;
  41052. /** @hidden */
  41053. _unpackFlipY(value: boolean): void;
  41054. /** @hidden */
  41055. _getUnpackAlignement(): number;
  41056. private _getTextureTarget;
  41057. /**
  41058. * Update the sampling mode of a given texture
  41059. * @param samplingMode defines the required sampling mode
  41060. * @param texture defines the texture to update
  41061. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41062. */
  41063. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41064. /**
  41065. * Update the sampling mode of a given texture
  41066. * @param texture defines the texture to update
  41067. * @param wrapU defines the texture wrap mode of the u coordinates
  41068. * @param wrapV defines the texture wrap mode of the v coordinates
  41069. * @param wrapR defines the texture wrap mode of the r coordinates
  41070. */
  41071. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41072. /** @hidden */
  41073. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41074. width: number;
  41075. height: number;
  41076. layers?: number;
  41077. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  41078. /** @hidden */
  41079. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41080. /** @hidden */
  41081. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41082. /**
  41083. * Update a portion of an internal texture
  41084. * @param texture defines the texture to update
  41085. * @param imageData defines the data to store into the texture
  41086. * @param xOffset defines the x coordinates of the update rectangle
  41087. * @param yOffset defines the y coordinates of the update rectangle
  41088. * @param width defines the width of the update rectangle
  41089. * @param height defines the height of the update rectangle
  41090. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41091. * @param lod defines the lod level to update (0 by default)
  41092. */
  41093. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41094. /** @hidden */
  41095. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41096. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41097. private _prepareWebGLTexture;
  41098. /** @hidden */
  41099. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41100. private _getDepthStencilBuffer;
  41101. /** @hidden */
  41102. _releaseFramebufferObjects(texture: InternalTexture): void;
  41103. /** @hidden */
  41104. _releaseTexture(texture: InternalTexture): void;
  41105. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41106. protected _setProgram(program: WebGLProgram): void;
  41107. protected _boundUniforms: {
  41108. [key: number]: WebGLUniformLocation;
  41109. };
  41110. /**
  41111. * Binds an effect to the webGL context
  41112. * @param effect defines the effect to bind
  41113. */
  41114. bindSamplers(effect: Effect): void;
  41115. private _activateCurrentTexture;
  41116. /** @hidden */
  41117. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41118. /** @hidden */
  41119. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  41120. /**
  41121. * Unbind all textures from the webGL context
  41122. */
  41123. unbindAllTextures(): void;
  41124. /**
  41125. * Sets a texture to the according uniform.
  41126. * @param channel The texture channel
  41127. * @param uniform The uniform to set
  41128. * @param texture The texture to apply
  41129. */
  41130. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  41131. private _bindSamplerUniformToChannel;
  41132. private _getTextureWrapMode;
  41133. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  41134. /**
  41135. * Sets an array of texture to the webGL context
  41136. * @param channel defines the channel where the texture array must be set
  41137. * @param uniform defines the associated uniform location
  41138. * @param textures defines the array of textures to bind
  41139. */
  41140. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  41141. /** @hidden */
  41142. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41143. private _setTextureParameterFloat;
  41144. private _setTextureParameterInteger;
  41145. /**
  41146. * Unbind all vertex attributes from the webGL context
  41147. */
  41148. unbindAllAttributes(): void;
  41149. /**
  41150. * 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
  41151. */
  41152. releaseEffects(): void;
  41153. /**
  41154. * Dispose and release all associated resources
  41155. */
  41156. dispose(): void;
  41157. /**
  41158. * Attach a new callback raised when context lost event is fired
  41159. * @param callback defines the callback to call
  41160. */
  41161. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41162. /**
  41163. * Attach a new callback raised when context restored event is fired
  41164. * @param callback defines the callback to call
  41165. */
  41166. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41167. /**
  41168. * Get the current error code of the webGL context
  41169. * @returns the error code
  41170. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41171. */
  41172. getError(): number;
  41173. private _canRenderToFloatFramebuffer;
  41174. private _canRenderToHalfFloatFramebuffer;
  41175. private _canRenderToFramebuffer;
  41176. /** @hidden */
  41177. _getWebGLTextureType(type: number): number;
  41178. /** @hidden */
  41179. _getInternalFormat(format: number): number;
  41180. /** @hidden */
  41181. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41182. /** @hidden */
  41183. _getRGBAMultiSampleBufferFormat(type: number): number;
  41184. /** @hidden */
  41185. _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;
  41186. /**
  41187. * Loads a file from a url
  41188. * @param url url to load
  41189. * @param onSuccess callback called when the file successfully loads
  41190. * @param onProgress callback called while file is loading (if the server supports this mode)
  41191. * @param offlineProvider defines the offline provider for caching
  41192. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41193. * @param onError callback called when the file fails to load
  41194. * @returns a file request object
  41195. * @hidden
  41196. */
  41197. 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;
  41198. /**
  41199. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41200. * @param x defines the x coordinate of the rectangle where pixels must be read
  41201. * @param y defines the y coordinate of the rectangle where pixels must be read
  41202. * @param width defines the width of the rectangle where pixels must be read
  41203. * @param height defines the height of the rectangle where pixels must be read
  41204. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41205. * @returns a Uint8Array containing RGBA colors
  41206. */
  41207. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  41208. private static _IsSupported;
  41209. private static _HasMajorPerformanceCaveat;
  41210. /**
  41211. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41212. */
  41213. static get IsSupported(): boolean;
  41214. /**
  41215. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41216. * @returns true if the engine can be created
  41217. * @ignorenaming
  41218. */
  41219. static isSupported(): boolean;
  41220. /**
  41221. * 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)
  41222. */
  41223. static get HasMajorPerformanceCaveat(): boolean;
  41224. /**
  41225. * Find the next highest power of two.
  41226. * @param x Number to start search from.
  41227. * @return Next highest power of two.
  41228. */
  41229. static CeilingPOT(x: number): number;
  41230. /**
  41231. * Find the next lowest power of two.
  41232. * @param x Number to start search from.
  41233. * @return Next lowest power of two.
  41234. */
  41235. static FloorPOT(x: number): number;
  41236. /**
  41237. * Find the nearest power of two.
  41238. * @param x Number to start search from.
  41239. * @return Next nearest power of two.
  41240. */
  41241. static NearestPOT(x: number): number;
  41242. /**
  41243. * Get the closest exponent of two
  41244. * @param value defines the value to approximate
  41245. * @param max defines the maximum value to return
  41246. * @param mode defines how to define the closest value
  41247. * @returns closest exponent of two of the given value
  41248. */
  41249. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41250. /**
  41251. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41252. * @param func - the function to be called
  41253. * @param requester - the object that will request the next frame. Falls back to window.
  41254. * @returns frame number
  41255. */
  41256. static QueueNewFrame(func: () => void, requester?: any): number;
  41257. /**
  41258. * Gets host document
  41259. * @returns the host document object
  41260. */
  41261. getHostDocument(): Nullable<Document>;
  41262. }
  41263. }
  41264. declare module "babylonjs/Materials/Textures/internalTexture" {
  41265. import { Observable } from "babylonjs/Misc/observable";
  41266. import { Nullable, int } from "babylonjs/types";
  41267. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41268. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41269. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  41270. /**
  41271. * Defines the source of the internal texture
  41272. */
  41273. export enum InternalTextureSource {
  41274. /**
  41275. * The source of the texture data is unknown
  41276. */
  41277. Unknown = 0,
  41278. /**
  41279. * Texture data comes from an URL
  41280. */
  41281. Url = 1,
  41282. /**
  41283. * Texture data is only used for temporary storage
  41284. */
  41285. Temp = 2,
  41286. /**
  41287. * Texture data comes from raw data (ArrayBuffer)
  41288. */
  41289. Raw = 3,
  41290. /**
  41291. * Texture content is dynamic (video or dynamic texture)
  41292. */
  41293. Dynamic = 4,
  41294. /**
  41295. * Texture content is generated by rendering to it
  41296. */
  41297. RenderTarget = 5,
  41298. /**
  41299. * Texture content is part of a multi render target process
  41300. */
  41301. MultiRenderTarget = 6,
  41302. /**
  41303. * Texture data comes from a cube data file
  41304. */
  41305. Cube = 7,
  41306. /**
  41307. * Texture data comes from a raw cube data
  41308. */
  41309. CubeRaw = 8,
  41310. /**
  41311. * Texture data come from a prefiltered cube data file
  41312. */
  41313. CubePrefiltered = 9,
  41314. /**
  41315. * Texture content is raw 3D data
  41316. */
  41317. Raw3D = 10,
  41318. /**
  41319. * Texture content is raw 2D array data
  41320. */
  41321. Raw2DArray = 11,
  41322. /**
  41323. * Texture content is a depth texture
  41324. */
  41325. Depth = 12,
  41326. /**
  41327. * Texture data comes from a raw cube data encoded with RGBD
  41328. */
  41329. CubeRawRGBD = 13
  41330. }
  41331. /**
  41332. * Class used to store data associated with WebGL texture data for the engine
  41333. * This class should not be used directly
  41334. */
  41335. export class InternalTexture {
  41336. /** @hidden */
  41337. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41338. /**
  41339. * Defines if the texture is ready
  41340. */
  41341. isReady: boolean;
  41342. /**
  41343. * Defines if the texture is a cube texture
  41344. */
  41345. isCube: boolean;
  41346. /**
  41347. * Defines if the texture contains 3D data
  41348. */
  41349. is3D: boolean;
  41350. /**
  41351. * Defines if the texture contains 2D array data
  41352. */
  41353. is2DArray: boolean;
  41354. /**
  41355. * Defines if the texture contains multiview data
  41356. */
  41357. isMultiview: boolean;
  41358. /**
  41359. * Gets the URL used to load this texture
  41360. */
  41361. url: string;
  41362. /**
  41363. * Gets the sampling mode of the texture
  41364. */
  41365. samplingMode: number;
  41366. /**
  41367. * Gets a boolean indicating if the texture needs mipmaps generation
  41368. */
  41369. generateMipMaps: boolean;
  41370. /**
  41371. * Gets the number of samples used by the texture (WebGL2+ only)
  41372. */
  41373. samples: number;
  41374. /**
  41375. * Gets the type of the texture (int, float...)
  41376. */
  41377. type: number;
  41378. /**
  41379. * Gets the format of the texture (RGB, RGBA...)
  41380. */
  41381. format: number;
  41382. /**
  41383. * Observable called when the texture is loaded
  41384. */
  41385. onLoadedObservable: Observable<InternalTexture>;
  41386. /**
  41387. * Gets the width of the texture
  41388. */
  41389. width: number;
  41390. /**
  41391. * Gets the height of the texture
  41392. */
  41393. height: number;
  41394. /**
  41395. * Gets the depth of the texture
  41396. */
  41397. depth: number;
  41398. /**
  41399. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41400. */
  41401. baseWidth: number;
  41402. /**
  41403. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41404. */
  41405. baseHeight: number;
  41406. /**
  41407. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41408. */
  41409. baseDepth: number;
  41410. /**
  41411. * Gets a boolean indicating if the texture is inverted on Y axis
  41412. */
  41413. invertY: boolean;
  41414. /** @hidden */
  41415. _invertVScale: boolean;
  41416. /** @hidden */
  41417. _associatedChannel: number;
  41418. /** @hidden */
  41419. _source: InternalTextureSource;
  41420. /** @hidden */
  41421. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41422. /** @hidden */
  41423. _bufferView: Nullable<ArrayBufferView>;
  41424. /** @hidden */
  41425. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41426. /** @hidden */
  41427. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41428. /** @hidden */
  41429. _size: number;
  41430. /** @hidden */
  41431. _extension: string;
  41432. /** @hidden */
  41433. _files: Nullable<string[]>;
  41434. /** @hidden */
  41435. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41436. /** @hidden */
  41437. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41438. /** @hidden */
  41439. _framebuffer: Nullable<WebGLFramebuffer>;
  41440. /** @hidden */
  41441. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41442. /** @hidden */
  41443. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41444. /** @hidden */
  41445. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41446. /** @hidden */
  41447. _attachments: Nullable<number[]>;
  41448. /** @hidden */
  41449. _textureArray: Nullable<InternalTexture[]>;
  41450. /** @hidden */
  41451. _cachedCoordinatesMode: Nullable<number>;
  41452. /** @hidden */
  41453. _cachedWrapU: Nullable<number>;
  41454. /** @hidden */
  41455. _cachedWrapV: Nullable<number>;
  41456. /** @hidden */
  41457. _cachedWrapR: Nullable<number>;
  41458. /** @hidden */
  41459. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41460. /** @hidden */
  41461. _isDisabled: boolean;
  41462. /** @hidden */
  41463. _compression: Nullable<string>;
  41464. /** @hidden */
  41465. _generateStencilBuffer: boolean;
  41466. /** @hidden */
  41467. _generateDepthBuffer: boolean;
  41468. /** @hidden */
  41469. _comparisonFunction: number;
  41470. /** @hidden */
  41471. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41472. /** @hidden */
  41473. _lodGenerationScale: number;
  41474. /** @hidden */
  41475. _lodGenerationOffset: number;
  41476. /** @hidden */
  41477. _depthStencilTexture: Nullable<InternalTexture>;
  41478. /** @hidden */
  41479. _colorTextureArray: Nullable<WebGLTexture>;
  41480. /** @hidden */
  41481. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41482. /** @hidden */
  41483. _lodTextureHigh: Nullable<BaseTexture>;
  41484. /** @hidden */
  41485. _lodTextureMid: Nullable<BaseTexture>;
  41486. /** @hidden */
  41487. _lodTextureLow: Nullable<BaseTexture>;
  41488. /** @hidden */
  41489. _isRGBD: boolean;
  41490. /** @hidden */
  41491. _linearSpecularLOD: boolean;
  41492. /** @hidden */
  41493. _irradianceTexture: Nullable<BaseTexture>;
  41494. /** @hidden */
  41495. _webGLTexture: Nullable<WebGLTexture>;
  41496. /** @hidden */
  41497. _references: number;
  41498. /** @hidden */
  41499. _gammaSpace: Nullable<boolean>;
  41500. private _engine;
  41501. /**
  41502. * Gets the Engine the texture belongs to.
  41503. * @returns The babylon engine
  41504. */
  41505. getEngine(): ThinEngine;
  41506. /**
  41507. * Gets the data source type of the texture
  41508. */
  41509. get source(): InternalTextureSource;
  41510. /**
  41511. * Creates a new InternalTexture
  41512. * @param engine defines the engine to use
  41513. * @param source defines the type of data that will be used
  41514. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41515. */
  41516. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41517. /**
  41518. * Increments the number of references (ie. the number of Texture that point to it)
  41519. */
  41520. incrementReferences(): void;
  41521. /**
  41522. * Change the size of the texture (not the size of the content)
  41523. * @param width defines the new width
  41524. * @param height defines the new height
  41525. * @param depth defines the new depth (1 by default)
  41526. */
  41527. updateSize(width: int, height: int, depth?: int): void;
  41528. /** @hidden */
  41529. _rebuild(): void;
  41530. /** @hidden */
  41531. _swapAndDie(target: InternalTexture): void;
  41532. /**
  41533. * Dispose the current allocated resources
  41534. */
  41535. dispose(): void;
  41536. }
  41537. }
  41538. declare module "babylonjs/Loading/loadingScreen" {
  41539. /**
  41540. * Interface used to present a loading screen while loading a scene
  41541. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41542. */
  41543. export interface ILoadingScreen {
  41544. /**
  41545. * Function called to display the loading screen
  41546. */
  41547. displayLoadingUI: () => void;
  41548. /**
  41549. * Function called to hide the loading screen
  41550. */
  41551. hideLoadingUI: () => void;
  41552. /**
  41553. * Gets or sets the color to use for the background
  41554. */
  41555. loadingUIBackgroundColor: string;
  41556. /**
  41557. * Gets or sets the text to display while loading
  41558. */
  41559. loadingUIText: string;
  41560. }
  41561. /**
  41562. * Class used for the default loading screen
  41563. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41564. */
  41565. export class DefaultLoadingScreen implements ILoadingScreen {
  41566. private _renderingCanvas;
  41567. private _loadingText;
  41568. private _loadingDivBackgroundColor;
  41569. private _loadingDiv;
  41570. private _loadingTextDiv;
  41571. /** Gets or sets the logo url to use for the default loading screen */
  41572. static DefaultLogoUrl: string;
  41573. /** Gets or sets the spinner url to use for the default loading screen */
  41574. static DefaultSpinnerUrl: string;
  41575. /**
  41576. * Creates a new default loading screen
  41577. * @param _renderingCanvas defines the canvas used to render the scene
  41578. * @param _loadingText defines the default text to display
  41579. * @param _loadingDivBackgroundColor defines the default background color
  41580. */
  41581. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41582. /**
  41583. * Function called to display the loading screen
  41584. */
  41585. displayLoadingUI(): void;
  41586. /**
  41587. * Function called to hide the loading screen
  41588. */
  41589. hideLoadingUI(): void;
  41590. /**
  41591. * Gets or sets the text to display while loading
  41592. */
  41593. set loadingUIText(text: string);
  41594. get loadingUIText(): string;
  41595. /**
  41596. * Gets or sets the color to use for the background
  41597. */
  41598. get loadingUIBackgroundColor(): string;
  41599. set loadingUIBackgroundColor(color: string);
  41600. private _resizeLoadingUI;
  41601. }
  41602. }
  41603. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41604. /**
  41605. * Interface for any object that can request an animation frame
  41606. */
  41607. export interface ICustomAnimationFrameRequester {
  41608. /**
  41609. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41610. */
  41611. renderFunction?: Function;
  41612. /**
  41613. * Called to request the next frame to render to
  41614. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41615. */
  41616. requestAnimationFrame: Function;
  41617. /**
  41618. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41619. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41620. */
  41621. requestID?: number;
  41622. }
  41623. }
  41624. declare module "babylonjs/Misc/performanceMonitor" {
  41625. /**
  41626. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41627. */
  41628. export class PerformanceMonitor {
  41629. private _enabled;
  41630. private _rollingFrameTime;
  41631. private _lastFrameTimeMs;
  41632. /**
  41633. * constructor
  41634. * @param frameSampleSize The number of samples required to saturate the sliding window
  41635. */
  41636. constructor(frameSampleSize?: number);
  41637. /**
  41638. * Samples current frame
  41639. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41640. */
  41641. sampleFrame(timeMs?: number): void;
  41642. /**
  41643. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41644. */
  41645. get averageFrameTime(): number;
  41646. /**
  41647. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41648. */
  41649. get averageFrameTimeVariance(): number;
  41650. /**
  41651. * Returns the frame time of the most recent frame
  41652. */
  41653. get instantaneousFrameTime(): number;
  41654. /**
  41655. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41656. */
  41657. get averageFPS(): number;
  41658. /**
  41659. * Returns the average framerate in frames per second using the most recent frame time
  41660. */
  41661. get instantaneousFPS(): number;
  41662. /**
  41663. * Returns true if enough samples have been taken to completely fill the sliding window
  41664. */
  41665. get isSaturated(): boolean;
  41666. /**
  41667. * Enables contributions to the sliding window sample set
  41668. */
  41669. enable(): void;
  41670. /**
  41671. * Disables contributions to the sliding window sample set
  41672. * Samples will not be interpolated over the disabled period
  41673. */
  41674. disable(): void;
  41675. /**
  41676. * Returns true if sampling is enabled
  41677. */
  41678. get isEnabled(): boolean;
  41679. /**
  41680. * Resets performance monitor
  41681. */
  41682. reset(): void;
  41683. }
  41684. /**
  41685. * RollingAverage
  41686. *
  41687. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41688. */
  41689. export class RollingAverage {
  41690. /**
  41691. * Current average
  41692. */
  41693. average: number;
  41694. /**
  41695. * Current variance
  41696. */
  41697. variance: number;
  41698. protected _samples: Array<number>;
  41699. protected _sampleCount: number;
  41700. protected _pos: number;
  41701. protected _m2: number;
  41702. /**
  41703. * constructor
  41704. * @param length The number of samples required to saturate the sliding window
  41705. */
  41706. constructor(length: number);
  41707. /**
  41708. * Adds a sample to the sample set
  41709. * @param v The sample value
  41710. */
  41711. add(v: number): void;
  41712. /**
  41713. * Returns previously added values or null if outside of history or outside the sliding window domain
  41714. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41715. * @return Value previously recorded with add() or null if outside of range
  41716. */
  41717. history(i: number): number;
  41718. /**
  41719. * Returns true if enough samples have been taken to completely fill the sliding window
  41720. * @return true if sample-set saturated
  41721. */
  41722. isSaturated(): boolean;
  41723. /**
  41724. * Resets the rolling average (equivalent to 0 samples taken so far)
  41725. */
  41726. reset(): void;
  41727. /**
  41728. * Wraps a value around the sample range boundaries
  41729. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41730. * @return Wrapped position in sample range
  41731. */
  41732. protected _wrapPosition(i: number): number;
  41733. }
  41734. }
  41735. declare module "babylonjs/Misc/perfCounter" {
  41736. /**
  41737. * This class is used to track a performance counter which is number based.
  41738. * The user has access to many properties which give statistics of different nature.
  41739. *
  41740. * The implementer can track two kinds of Performance Counter: time and count.
  41741. * 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.
  41742. * 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.
  41743. */
  41744. export class PerfCounter {
  41745. /**
  41746. * Gets or sets a global boolean to turn on and off all the counters
  41747. */
  41748. static Enabled: boolean;
  41749. /**
  41750. * Returns the smallest value ever
  41751. */
  41752. get min(): number;
  41753. /**
  41754. * Returns the biggest value ever
  41755. */
  41756. get max(): number;
  41757. /**
  41758. * Returns the average value since the performance counter is running
  41759. */
  41760. get average(): number;
  41761. /**
  41762. * Returns the average value of the last second the counter was monitored
  41763. */
  41764. get lastSecAverage(): number;
  41765. /**
  41766. * Returns the current value
  41767. */
  41768. get current(): number;
  41769. /**
  41770. * Gets the accumulated total
  41771. */
  41772. get total(): number;
  41773. /**
  41774. * Gets the total value count
  41775. */
  41776. get count(): number;
  41777. /**
  41778. * Creates a new counter
  41779. */
  41780. constructor();
  41781. /**
  41782. * Call this method to start monitoring a new frame.
  41783. * 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.
  41784. */
  41785. fetchNewFrame(): void;
  41786. /**
  41787. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41788. * @param newCount the count value to add to the monitored count
  41789. * @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.
  41790. */
  41791. addCount(newCount: number, fetchResult: boolean): void;
  41792. /**
  41793. * Start monitoring this performance counter
  41794. */
  41795. beginMonitoring(): void;
  41796. /**
  41797. * Compute the time lapsed since the previous beginMonitoring() call.
  41798. * @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
  41799. */
  41800. endMonitoring(newFrame?: boolean): void;
  41801. private _fetchResult;
  41802. private _startMonitoringTime;
  41803. private _min;
  41804. private _max;
  41805. private _average;
  41806. private _current;
  41807. private _totalValueCount;
  41808. private _totalAccumulated;
  41809. private _lastSecAverage;
  41810. private _lastSecAccumulated;
  41811. private _lastSecTime;
  41812. private _lastSecValueCount;
  41813. }
  41814. }
  41815. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  41816. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41817. import { Nullable } from "babylonjs/types";
  41818. module "babylonjs/Engines/thinEngine" {
  41819. interface ThinEngine {
  41820. /** @hidden */
  41821. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  41822. }
  41823. }
  41824. }
  41825. declare module "babylonjs/Audio/analyser" {
  41826. import { Scene } from "babylonjs/scene";
  41827. /**
  41828. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41829. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41830. */
  41831. export class Analyser {
  41832. /**
  41833. * Gets or sets the smoothing
  41834. * @ignorenaming
  41835. */
  41836. SMOOTHING: number;
  41837. /**
  41838. * Gets or sets the FFT table size
  41839. * @ignorenaming
  41840. */
  41841. FFT_SIZE: number;
  41842. /**
  41843. * Gets or sets the bar graph amplitude
  41844. * @ignorenaming
  41845. */
  41846. BARGRAPHAMPLITUDE: number;
  41847. /**
  41848. * Gets or sets the position of the debug canvas
  41849. * @ignorenaming
  41850. */
  41851. DEBUGCANVASPOS: {
  41852. x: number;
  41853. y: number;
  41854. };
  41855. /**
  41856. * Gets or sets the debug canvas size
  41857. * @ignorenaming
  41858. */
  41859. DEBUGCANVASSIZE: {
  41860. width: number;
  41861. height: number;
  41862. };
  41863. private _byteFreqs;
  41864. private _byteTime;
  41865. private _floatFreqs;
  41866. private _webAudioAnalyser;
  41867. private _debugCanvas;
  41868. private _debugCanvasContext;
  41869. private _scene;
  41870. private _registerFunc;
  41871. private _audioEngine;
  41872. /**
  41873. * Creates a new analyser
  41874. * @param scene defines hosting scene
  41875. */
  41876. constructor(scene: Scene);
  41877. /**
  41878. * Get the number of data values you will have to play with for the visualization
  41879. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41880. * @returns a number
  41881. */
  41882. getFrequencyBinCount(): number;
  41883. /**
  41884. * Gets the current frequency data as a byte array
  41885. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41886. * @returns a Uint8Array
  41887. */
  41888. getByteFrequencyData(): Uint8Array;
  41889. /**
  41890. * Gets the current waveform as a byte array
  41891. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41892. * @returns a Uint8Array
  41893. */
  41894. getByteTimeDomainData(): Uint8Array;
  41895. /**
  41896. * Gets the current frequency data as a float array
  41897. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41898. * @returns a Float32Array
  41899. */
  41900. getFloatFrequencyData(): Float32Array;
  41901. /**
  41902. * Renders the debug canvas
  41903. */
  41904. drawDebugCanvas(): void;
  41905. /**
  41906. * Stops rendering the debug canvas and removes it
  41907. */
  41908. stopDebugCanvas(): void;
  41909. /**
  41910. * Connects two audio nodes
  41911. * @param inputAudioNode defines first node to connect
  41912. * @param outputAudioNode defines second node to connect
  41913. */
  41914. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41915. /**
  41916. * Releases all associated resources
  41917. */
  41918. dispose(): void;
  41919. }
  41920. }
  41921. declare module "babylonjs/Audio/Interfaces/IAudioEngine" {
  41922. import { Observable } from "babylonjs/Misc/observable";
  41923. import { IDisposable } from "babylonjs/scene";
  41924. import { Nullable } from "babylonjs/types";
  41925. import { Analyser } from "babylonjs/Audio/analyser";
  41926. /**
  41927. * This represents an audio engine and it is responsible
  41928. * to play, synchronize and analyse sounds throughout the application.
  41929. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41930. */
  41931. export interface IAudioEngine extends IDisposable {
  41932. /**
  41933. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41934. */
  41935. readonly canUseWebAudio: boolean;
  41936. /**
  41937. * Gets the current AudioContext if available.
  41938. */
  41939. readonly audioContext: Nullable<AudioContext>;
  41940. /**
  41941. * The master gain node defines the global audio volume of your audio engine.
  41942. */
  41943. readonly masterGain: GainNode;
  41944. /**
  41945. * Gets whether or not mp3 are supported by your browser.
  41946. */
  41947. readonly isMP3supported: boolean;
  41948. /**
  41949. * Gets whether or not ogg are supported by your browser.
  41950. */
  41951. readonly isOGGsupported: boolean;
  41952. /**
  41953. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41954. * @ignoreNaming
  41955. */
  41956. WarnedWebAudioUnsupported: boolean;
  41957. /**
  41958. * Defines if the audio engine relies on a custom unlocked button.
  41959. * In this case, the embedded button will not be displayed.
  41960. */
  41961. useCustomUnlockedButton: boolean;
  41962. /**
  41963. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41964. */
  41965. readonly unlocked: boolean;
  41966. /**
  41967. * Event raised when audio has been unlocked on the browser.
  41968. */
  41969. onAudioUnlockedObservable: Observable<IAudioEngine>;
  41970. /**
  41971. * Event raised when audio has been locked on the browser.
  41972. */
  41973. onAudioLockedObservable: Observable<IAudioEngine>;
  41974. /**
  41975. * Flags the audio engine in Locked state.
  41976. * This happens due to new browser policies preventing audio to autoplay.
  41977. */
  41978. lock(): void;
  41979. /**
  41980. * Unlocks the audio engine once a user action has been done on the dom.
  41981. * This is helpful to resume play once browser policies have been satisfied.
  41982. */
  41983. unlock(): void;
  41984. /**
  41985. * Gets the global volume sets on the master gain.
  41986. * @returns the global volume if set or -1 otherwise
  41987. */
  41988. getGlobalVolume(): number;
  41989. /**
  41990. * Sets the global volume of your experience (sets on the master gain).
  41991. * @param newVolume Defines the new global volume of the application
  41992. */
  41993. setGlobalVolume(newVolume: number): void;
  41994. /**
  41995. * Connect the audio engine to an audio analyser allowing some amazing
  41996. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41997. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41998. * @param analyser The analyser to connect to the engine
  41999. */
  42000. connectToAnalyser(analyser: Analyser): void;
  42001. }
  42002. }
  42003. declare module "babylonjs/Engines/engine" {
  42004. import { Observable } from "babylonjs/Misc/observable";
  42005. import { Nullable } from "babylonjs/types";
  42006. import { Scene } from "babylonjs/scene";
  42007. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42008. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42009. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  42010. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  42011. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42012. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  42013. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  42014. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  42015. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42016. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  42017. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42018. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  42019. import "babylonjs/Engines/Extensions/engine.alpha";
  42020. import "babylonjs/Engines/Extensions/engine.readTexture";
  42021. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  42022. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  42023. import { Material } from "babylonjs/Materials/material";
  42024. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42025. /**
  42026. * Defines the interface used by display changed events
  42027. */
  42028. export interface IDisplayChangedEventArgs {
  42029. /** Gets the vrDisplay object (if any) */
  42030. vrDisplay: Nullable<any>;
  42031. /** Gets a boolean indicating if webVR is supported */
  42032. vrSupported: boolean;
  42033. }
  42034. /**
  42035. * Defines the interface used by objects containing a viewport (like a camera)
  42036. */
  42037. interface IViewportOwnerLike {
  42038. /**
  42039. * Gets or sets the viewport
  42040. */
  42041. viewport: IViewportLike;
  42042. }
  42043. /**
  42044. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42045. */
  42046. export class Engine extends ThinEngine {
  42047. /** Defines that alpha blending is disabled */
  42048. static readonly ALPHA_DISABLE: number;
  42049. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42050. static readonly ALPHA_ADD: number;
  42051. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42052. static readonly ALPHA_COMBINE: number;
  42053. /** Defines that alpha blending to DEST - SRC * DEST */
  42054. static readonly ALPHA_SUBTRACT: number;
  42055. /** Defines that alpha blending to SRC * DEST */
  42056. static readonly ALPHA_MULTIPLY: number;
  42057. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42058. static readonly ALPHA_MAXIMIZED: number;
  42059. /** Defines that alpha blending to SRC + DEST */
  42060. static readonly ALPHA_ONEONE: number;
  42061. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42062. static readonly ALPHA_PREMULTIPLIED: number;
  42063. /**
  42064. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42065. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42066. */
  42067. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42068. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42069. static readonly ALPHA_INTERPOLATE: number;
  42070. /**
  42071. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42072. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42073. */
  42074. static readonly ALPHA_SCREENMODE: number;
  42075. /** Defines that the ressource is not delayed*/
  42076. static readonly DELAYLOADSTATE_NONE: number;
  42077. /** Defines that the ressource was successfully delay loaded */
  42078. static readonly DELAYLOADSTATE_LOADED: number;
  42079. /** Defines that the ressource is currently delay loading */
  42080. static readonly DELAYLOADSTATE_LOADING: number;
  42081. /** Defines that the ressource is delayed and has not started loading */
  42082. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42083. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42084. static readonly NEVER: number;
  42085. /** 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 */
  42086. static readonly ALWAYS: number;
  42087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42088. static readonly LESS: number;
  42089. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42090. static readonly EQUAL: number;
  42091. /** 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 */
  42092. static readonly LEQUAL: number;
  42093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42094. static readonly GREATER: number;
  42095. /** 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 */
  42096. static readonly GEQUAL: number;
  42097. /** 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 */
  42098. static readonly NOTEQUAL: number;
  42099. /** Passed to stencilOperation to specify that stencil value must be kept */
  42100. static readonly KEEP: number;
  42101. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42102. static readonly REPLACE: number;
  42103. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42104. static readonly INCR: number;
  42105. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42106. static readonly DECR: number;
  42107. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42108. static readonly INVERT: number;
  42109. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42110. static readonly INCR_WRAP: number;
  42111. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42112. static readonly DECR_WRAP: number;
  42113. /** Texture is not repeating outside of 0..1 UVs */
  42114. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42115. /** Texture is repeating outside of 0..1 UVs */
  42116. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42117. /** Texture is repeating and mirrored */
  42118. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42119. /** ALPHA */
  42120. static readonly TEXTUREFORMAT_ALPHA: number;
  42121. /** LUMINANCE */
  42122. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42123. /** LUMINANCE_ALPHA */
  42124. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42125. /** RGB */
  42126. static readonly TEXTUREFORMAT_RGB: number;
  42127. /** RGBA */
  42128. static readonly TEXTUREFORMAT_RGBA: number;
  42129. /** RED */
  42130. static readonly TEXTUREFORMAT_RED: number;
  42131. /** RED (2nd reference) */
  42132. static readonly TEXTUREFORMAT_R: number;
  42133. /** RG */
  42134. static readonly TEXTUREFORMAT_RG: number;
  42135. /** RED_INTEGER */
  42136. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42137. /** RED_INTEGER (2nd reference) */
  42138. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42139. /** RG_INTEGER */
  42140. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42141. /** RGB_INTEGER */
  42142. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42143. /** RGBA_INTEGER */
  42144. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42145. /** UNSIGNED_BYTE */
  42146. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42147. /** UNSIGNED_BYTE (2nd reference) */
  42148. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42149. /** FLOAT */
  42150. static readonly TEXTURETYPE_FLOAT: number;
  42151. /** HALF_FLOAT */
  42152. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42153. /** BYTE */
  42154. static readonly TEXTURETYPE_BYTE: number;
  42155. /** SHORT */
  42156. static readonly TEXTURETYPE_SHORT: number;
  42157. /** UNSIGNED_SHORT */
  42158. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42159. /** INT */
  42160. static readonly TEXTURETYPE_INT: number;
  42161. /** UNSIGNED_INT */
  42162. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42163. /** UNSIGNED_SHORT_4_4_4_4 */
  42164. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42165. /** UNSIGNED_SHORT_5_5_5_1 */
  42166. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42167. /** UNSIGNED_SHORT_5_6_5 */
  42168. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42169. /** UNSIGNED_INT_2_10_10_10_REV */
  42170. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42171. /** UNSIGNED_INT_24_8 */
  42172. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42173. /** UNSIGNED_INT_10F_11F_11F_REV */
  42174. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42175. /** UNSIGNED_INT_5_9_9_9_REV */
  42176. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42177. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42178. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42179. /** nearest is mag = nearest and min = nearest and mip = linear */
  42180. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42181. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42182. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42183. /** Trilinear is mag = linear and min = linear and mip = linear */
  42184. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42185. /** nearest is mag = nearest and min = nearest and mip = linear */
  42186. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42187. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42188. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42189. /** Trilinear is mag = linear and min = linear and mip = linear */
  42190. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42191. /** mag = nearest and min = nearest and mip = nearest */
  42192. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42193. /** mag = nearest and min = linear and mip = nearest */
  42194. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42195. /** mag = nearest and min = linear and mip = linear */
  42196. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42197. /** mag = nearest and min = linear and mip = none */
  42198. static readonly TEXTURE_NEAREST_LINEAR: number;
  42199. /** mag = nearest and min = nearest and mip = none */
  42200. static readonly TEXTURE_NEAREST_NEAREST: number;
  42201. /** mag = linear and min = nearest and mip = nearest */
  42202. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42203. /** mag = linear and min = nearest and mip = linear */
  42204. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42205. /** mag = linear and min = linear and mip = none */
  42206. static readonly TEXTURE_LINEAR_LINEAR: number;
  42207. /** mag = linear and min = nearest and mip = none */
  42208. static readonly TEXTURE_LINEAR_NEAREST: number;
  42209. /** Explicit coordinates mode */
  42210. static readonly TEXTURE_EXPLICIT_MODE: number;
  42211. /** Spherical coordinates mode */
  42212. static readonly TEXTURE_SPHERICAL_MODE: number;
  42213. /** Planar coordinates mode */
  42214. static readonly TEXTURE_PLANAR_MODE: number;
  42215. /** Cubic coordinates mode */
  42216. static readonly TEXTURE_CUBIC_MODE: number;
  42217. /** Projection coordinates mode */
  42218. static readonly TEXTURE_PROJECTION_MODE: number;
  42219. /** Skybox coordinates mode */
  42220. static readonly TEXTURE_SKYBOX_MODE: number;
  42221. /** Inverse Cubic coordinates mode */
  42222. static readonly TEXTURE_INVCUBIC_MODE: number;
  42223. /** Equirectangular coordinates mode */
  42224. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42225. /** Equirectangular Fixed coordinates mode */
  42226. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42227. /** Equirectangular Fixed Mirrored coordinates mode */
  42228. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42229. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42230. static readonly SCALEMODE_FLOOR: number;
  42231. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42232. static readonly SCALEMODE_NEAREST: number;
  42233. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42234. static readonly SCALEMODE_CEILING: number;
  42235. /**
  42236. * Returns the current npm package of the sdk
  42237. */
  42238. static get NpmPackage(): string;
  42239. /**
  42240. * Returns the current version of the framework
  42241. */
  42242. static get Version(): string;
  42243. /** Gets the list of created engines */
  42244. static get Instances(): Engine[];
  42245. /**
  42246. * Gets the latest created engine
  42247. */
  42248. static get LastCreatedEngine(): Nullable<Engine>;
  42249. /**
  42250. * Gets the latest created scene
  42251. */
  42252. static get LastCreatedScene(): Nullable<Scene>;
  42253. /**
  42254. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42255. * @param flag defines which part of the materials must be marked as dirty
  42256. * @param predicate defines a predicate used to filter which materials should be affected
  42257. */
  42258. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42259. /**
  42260. * Method called to create the default loading screen.
  42261. * This can be overriden in your own app.
  42262. * @param canvas The rendering canvas element
  42263. * @returns The loading screen
  42264. */
  42265. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42266. /**
  42267. * Method called to create the default rescale post process on each engine.
  42268. */
  42269. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42270. /**
  42271. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42272. **/
  42273. enableOfflineSupport: boolean;
  42274. /**
  42275. * 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)
  42276. **/
  42277. disableManifestCheck: boolean;
  42278. /**
  42279. * Gets the list of created scenes
  42280. */
  42281. scenes: Scene[];
  42282. /**
  42283. * Event raised when a new scene is created
  42284. */
  42285. onNewSceneAddedObservable: Observable<Scene>;
  42286. /**
  42287. * Gets the list of created postprocesses
  42288. */
  42289. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42290. /**
  42291. * Gets a boolean indicating if the pointer is currently locked
  42292. */
  42293. isPointerLock: boolean;
  42294. /**
  42295. * Observable event triggered each time the rendering canvas is resized
  42296. */
  42297. onResizeObservable: Observable<Engine>;
  42298. /**
  42299. * Observable event triggered each time the canvas loses focus
  42300. */
  42301. onCanvasBlurObservable: Observable<Engine>;
  42302. /**
  42303. * Observable event triggered each time the canvas gains focus
  42304. */
  42305. onCanvasFocusObservable: Observable<Engine>;
  42306. /**
  42307. * Observable event triggered each time the canvas receives pointerout event
  42308. */
  42309. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42310. /**
  42311. * Observable raised when the engine begins a new frame
  42312. */
  42313. onBeginFrameObservable: Observable<Engine>;
  42314. /**
  42315. * If set, will be used to request the next animation frame for the render loop
  42316. */
  42317. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42318. /**
  42319. * Observable raised when the engine ends the current frame
  42320. */
  42321. onEndFrameObservable: Observable<Engine>;
  42322. /**
  42323. * Observable raised when the engine is about to compile a shader
  42324. */
  42325. onBeforeShaderCompilationObservable: Observable<Engine>;
  42326. /**
  42327. * Observable raised when the engine has jsut compiled a shader
  42328. */
  42329. onAfterShaderCompilationObservable: Observable<Engine>;
  42330. /**
  42331. * Gets the audio engine
  42332. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42333. * @ignorenaming
  42334. */
  42335. static audioEngine: IAudioEngine;
  42336. /**
  42337. * Default AudioEngine factory responsible of creating the Audio Engine.
  42338. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42339. */
  42340. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42341. /**
  42342. * Default offline support factory responsible of creating a tool used to store data locally.
  42343. * By default, this will create a Database object if the workload has been embedded.
  42344. */
  42345. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42346. private _loadingScreen;
  42347. private _pointerLockRequested;
  42348. private _rescalePostProcess;
  42349. private _deterministicLockstep;
  42350. private _lockstepMaxSteps;
  42351. private _timeStep;
  42352. protected get _supportsHardwareTextureRescaling(): boolean;
  42353. private _fps;
  42354. private _deltaTime;
  42355. /** @hidden */
  42356. _drawCalls: PerfCounter;
  42357. /** 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 */
  42358. canvasTabIndex: number;
  42359. /**
  42360. * Turn this value on if you want to pause FPS computation when in background
  42361. */
  42362. disablePerformanceMonitorInBackground: boolean;
  42363. private _performanceMonitor;
  42364. /**
  42365. * Gets the performance monitor attached to this engine
  42366. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42367. */
  42368. get performanceMonitor(): PerformanceMonitor;
  42369. private _onFocus;
  42370. private _onBlur;
  42371. private _onCanvasPointerOut;
  42372. private _onCanvasBlur;
  42373. private _onCanvasFocus;
  42374. private _onFullscreenChange;
  42375. private _onPointerLockChange;
  42376. /**
  42377. * Gets the HTML element used to attach event listeners
  42378. * @returns a HTML element
  42379. */
  42380. getInputElement(): Nullable<HTMLElement>;
  42381. /**
  42382. * Creates a new engine
  42383. * @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
  42384. * @param antialias defines enable antialiasing (default: false)
  42385. * @param options defines further options to be sent to the getContext() function
  42386. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42387. */
  42388. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42389. /**
  42390. * Gets current aspect ratio
  42391. * @param viewportOwner defines the camera to use to get the aspect ratio
  42392. * @param useScreen defines if screen size must be used (or the current render target if any)
  42393. * @returns a number defining the aspect ratio
  42394. */
  42395. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42396. /**
  42397. * Gets current screen aspect ratio
  42398. * @returns a number defining the aspect ratio
  42399. */
  42400. getScreenAspectRatio(): number;
  42401. /**
  42402. * Gets the client rect of the HTML canvas attached with the current webGL context
  42403. * @returns a client rectanglee
  42404. */
  42405. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42406. /**
  42407. * Gets the client rect of the HTML element used for events
  42408. * @returns a client rectanglee
  42409. */
  42410. getInputElementClientRect(): Nullable<ClientRect>;
  42411. /**
  42412. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42413. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42414. * @returns true if engine is in deterministic lock step mode
  42415. */
  42416. isDeterministicLockStep(): boolean;
  42417. /**
  42418. * Gets the max steps when engine is running in deterministic lock step
  42419. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42420. * @returns the max steps
  42421. */
  42422. getLockstepMaxSteps(): number;
  42423. /**
  42424. * Returns the time in ms between steps when using deterministic lock step.
  42425. * @returns time step in (ms)
  42426. */
  42427. getTimeStep(): number;
  42428. /**
  42429. * Force the mipmap generation for the given render target texture
  42430. * @param texture defines the render target texture to use
  42431. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42432. */
  42433. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42434. /** States */
  42435. /**
  42436. * Set various states to the webGL context
  42437. * @param culling defines backface culling state
  42438. * @param zOffset defines the value to apply to zOffset (0 by default)
  42439. * @param force defines if states must be applied even if cache is up to date
  42440. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42441. */
  42442. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42443. /**
  42444. * Set the z offset to apply to current rendering
  42445. * @param value defines the offset to apply
  42446. */
  42447. setZOffset(value: number): void;
  42448. /**
  42449. * Gets the current value of the zOffset
  42450. * @returns the current zOffset state
  42451. */
  42452. getZOffset(): number;
  42453. /**
  42454. * Enable or disable depth buffering
  42455. * @param enable defines the state to set
  42456. */
  42457. setDepthBuffer(enable: boolean): void;
  42458. /**
  42459. * Gets a boolean indicating if depth writing is enabled
  42460. * @returns the current depth writing state
  42461. */
  42462. getDepthWrite(): boolean;
  42463. /**
  42464. * Enable or disable depth writing
  42465. * @param enable defines the state to set
  42466. */
  42467. setDepthWrite(enable: boolean): void;
  42468. /**
  42469. * Gets a boolean indicating if stencil buffer is enabled
  42470. * @returns the current stencil buffer state
  42471. */
  42472. getStencilBuffer(): boolean;
  42473. /**
  42474. * Enable or disable the stencil buffer
  42475. * @param enable defines if the stencil buffer must be enabled or disabled
  42476. */
  42477. setStencilBuffer(enable: boolean): void;
  42478. /**
  42479. * Gets the current stencil mask
  42480. * @returns a number defining the new stencil mask to use
  42481. */
  42482. getStencilMask(): number;
  42483. /**
  42484. * Sets the current stencil mask
  42485. * @param mask defines the new stencil mask to use
  42486. */
  42487. setStencilMask(mask: number): void;
  42488. /**
  42489. * Gets the current stencil function
  42490. * @returns a number defining the stencil function to use
  42491. */
  42492. getStencilFunction(): number;
  42493. /**
  42494. * Gets the current stencil reference value
  42495. * @returns a number defining the stencil reference value to use
  42496. */
  42497. getStencilFunctionReference(): number;
  42498. /**
  42499. * Gets the current stencil mask
  42500. * @returns a number defining the stencil mask to use
  42501. */
  42502. getStencilFunctionMask(): number;
  42503. /**
  42504. * Sets the current stencil function
  42505. * @param stencilFunc defines the new stencil function to use
  42506. */
  42507. setStencilFunction(stencilFunc: number): void;
  42508. /**
  42509. * Sets the current stencil reference
  42510. * @param reference defines the new stencil reference to use
  42511. */
  42512. setStencilFunctionReference(reference: number): void;
  42513. /**
  42514. * Sets the current stencil mask
  42515. * @param mask defines the new stencil mask to use
  42516. */
  42517. setStencilFunctionMask(mask: number): void;
  42518. /**
  42519. * Gets the current stencil operation when stencil fails
  42520. * @returns a number defining stencil operation to use when stencil fails
  42521. */
  42522. getStencilOperationFail(): number;
  42523. /**
  42524. * Gets the current stencil operation when depth fails
  42525. * @returns a number defining stencil operation to use when depth fails
  42526. */
  42527. getStencilOperationDepthFail(): number;
  42528. /**
  42529. * Gets the current stencil operation when stencil passes
  42530. * @returns a number defining stencil operation to use when stencil passes
  42531. */
  42532. getStencilOperationPass(): number;
  42533. /**
  42534. * Sets the stencil operation to use when stencil fails
  42535. * @param operation defines the stencil operation to use when stencil fails
  42536. */
  42537. setStencilOperationFail(operation: number): void;
  42538. /**
  42539. * Sets the stencil operation to use when depth fails
  42540. * @param operation defines the stencil operation to use when depth fails
  42541. */
  42542. setStencilOperationDepthFail(operation: number): void;
  42543. /**
  42544. * Sets the stencil operation to use when stencil passes
  42545. * @param operation defines the stencil operation to use when stencil passes
  42546. */
  42547. setStencilOperationPass(operation: number): void;
  42548. /**
  42549. * Sets a boolean indicating if the dithering state is enabled or disabled
  42550. * @param value defines the dithering state
  42551. */
  42552. setDitheringState(value: boolean): void;
  42553. /**
  42554. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42555. * @param value defines the rasterizer state
  42556. */
  42557. setRasterizerState(value: boolean): void;
  42558. /**
  42559. * Gets the current depth function
  42560. * @returns a number defining the depth function
  42561. */
  42562. getDepthFunction(): Nullable<number>;
  42563. /**
  42564. * Sets the current depth function
  42565. * @param depthFunc defines the function to use
  42566. */
  42567. setDepthFunction(depthFunc: number): void;
  42568. /**
  42569. * Sets the current depth function to GREATER
  42570. */
  42571. setDepthFunctionToGreater(): void;
  42572. /**
  42573. * Sets the current depth function to GEQUAL
  42574. */
  42575. setDepthFunctionToGreaterOrEqual(): void;
  42576. /**
  42577. * Sets the current depth function to LESS
  42578. */
  42579. setDepthFunctionToLess(): void;
  42580. /**
  42581. * Sets the current depth function to LEQUAL
  42582. */
  42583. setDepthFunctionToLessOrEqual(): void;
  42584. private _cachedStencilBuffer;
  42585. private _cachedStencilFunction;
  42586. private _cachedStencilMask;
  42587. private _cachedStencilOperationPass;
  42588. private _cachedStencilOperationFail;
  42589. private _cachedStencilOperationDepthFail;
  42590. private _cachedStencilReference;
  42591. /**
  42592. * Caches the the state of the stencil buffer
  42593. */
  42594. cacheStencilState(): void;
  42595. /**
  42596. * Restores the state of the stencil buffer
  42597. */
  42598. restoreStencilState(): void;
  42599. /**
  42600. * Directly set the WebGL Viewport
  42601. * @param x defines the x coordinate of the viewport (in screen space)
  42602. * @param y defines the y coordinate of the viewport (in screen space)
  42603. * @param width defines the width of the viewport (in screen space)
  42604. * @param height defines the height of the viewport (in screen space)
  42605. * @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
  42606. */
  42607. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42608. /**
  42609. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42610. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42611. * @param y defines the y-coordinate of the corner of the clear rectangle
  42612. * @param width defines the width of the clear rectangle
  42613. * @param height defines the height of the clear rectangle
  42614. * @param clearColor defines the clear color
  42615. */
  42616. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42617. /**
  42618. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42619. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42620. * @param y defines the y-coordinate of the corner of the clear rectangle
  42621. * @param width defines the width of the clear rectangle
  42622. * @param height defines the height of the clear rectangle
  42623. */
  42624. enableScissor(x: number, y: number, width: number, height: number): void;
  42625. /**
  42626. * Disable previously set scissor test rectangle
  42627. */
  42628. disableScissor(): void;
  42629. protected _reportDrawCall(): void;
  42630. /**
  42631. * Initializes a webVR display and starts listening to display change events
  42632. * The onVRDisplayChangedObservable will be notified upon these changes
  42633. * @returns The onVRDisplayChangedObservable
  42634. */
  42635. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42636. /** @hidden */
  42637. _prepareVRComponent(): void;
  42638. /** @hidden */
  42639. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42640. /** @hidden */
  42641. _submitVRFrame(): void;
  42642. /**
  42643. * Call this function to leave webVR mode
  42644. * Will do nothing if webVR is not supported or if there is no webVR device
  42645. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42646. */
  42647. disableVR(): void;
  42648. /**
  42649. * Gets a boolean indicating that the system is in VR mode and is presenting
  42650. * @returns true if VR mode is engaged
  42651. */
  42652. isVRPresenting(): boolean;
  42653. /** @hidden */
  42654. _requestVRFrame(): void;
  42655. /** @hidden */
  42656. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42657. /**
  42658. * Gets the source code of the vertex shader associated with a specific webGL program
  42659. * @param program defines the program to use
  42660. * @returns a string containing the source code of the vertex shader associated with the program
  42661. */
  42662. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42663. /**
  42664. * Gets the source code of the fragment shader associated with a specific webGL program
  42665. * @param program defines the program to use
  42666. * @returns a string containing the source code of the fragment shader associated with the program
  42667. */
  42668. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42669. /**
  42670. * Sets a depth stencil texture from a render target to the according uniform.
  42671. * @param channel The texture channel
  42672. * @param uniform The uniform to set
  42673. * @param texture The render target texture containing the depth stencil texture to apply
  42674. */
  42675. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  42676. /**
  42677. * Sets a texture to the webGL context from a postprocess
  42678. * @param channel defines the channel to use
  42679. * @param postProcess defines the source postprocess
  42680. */
  42681. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  42682. /**
  42683. * Binds the output of the passed in post process to the texture channel specified
  42684. * @param channel The channel the texture should be bound to
  42685. * @param postProcess The post process which's output should be bound
  42686. */
  42687. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  42688. protected _rebuildBuffers(): void;
  42689. /** @hidden */
  42690. _renderFrame(): void;
  42691. _renderLoop(): void;
  42692. /** @hidden */
  42693. _renderViews(): boolean;
  42694. /**
  42695. * Toggle full screen mode
  42696. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42697. */
  42698. switchFullscreen(requestPointerLock: boolean): void;
  42699. /**
  42700. * Enters full screen mode
  42701. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42702. */
  42703. enterFullscreen(requestPointerLock: boolean): void;
  42704. /**
  42705. * Exits full screen mode
  42706. */
  42707. exitFullscreen(): void;
  42708. /**
  42709. * Enters Pointerlock mode
  42710. */
  42711. enterPointerlock(): void;
  42712. /**
  42713. * Exits Pointerlock mode
  42714. */
  42715. exitPointerlock(): void;
  42716. /**
  42717. * Begin a new frame
  42718. */
  42719. beginFrame(): void;
  42720. /**
  42721. * Enf the current frame
  42722. */
  42723. endFrame(): void;
  42724. resize(): void;
  42725. /**
  42726. * Force a specific size of the canvas
  42727. * @param width defines the new canvas' width
  42728. * @param height defines the new canvas' height
  42729. * @returns true if the size was changed
  42730. */
  42731. setSize(width: number, height: number): boolean;
  42732. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42733. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42734. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42735. _releaseTexture(texture: InternalTexture): void;
  42736. /**
  42737. * @hidden
  42738. * Rescales a texture
  42739. * @param source input texutre
  42740. * @param destination destination texture
  42741. * @param scene scene to use to render the resize
  42742. * @param internalFormat format to use when resizing
  42743. * @param onComplete callback to be called when resize has completed
  42744. */
  42745. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42746. /**
  42747. * Gets the current framerate
  42748. * @returns a number representing the framerate
  42749. */
  42750. getFps(): number;
  42751. /**
  42752. * Gets the time spent between current and previous frame
  42753. * @returns a number representing the delta time in ms
  42754. */
  42755. getDeltaTime(): number;
  42756. private _measureFps;
  42757. /** @hidden */
  42758. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42759. /**
  42760. * Updates the sample count of a render target texture
  42761. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42762. * @param texture defines the texture to update
  42763. * @param samples defines the sample count to set
  42764. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42765. */
  42766. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42767. /**
  42768. * Updates a depth texture Comparison Mode and Function.
  42769. * If the comparison Function is equal to 0, the mode will be set to none.
  42770. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42771. * @param texture The texture to set the comparison function for
  42772. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42773. */
  42774. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42775. /**
  42776. * Creates a webGL buffer to use with instanciation
  42777. * @param capacity defines the size of the buffer
  42778. * @returns the webGL buffer
  42779. */
  42780. createInstancesBuffer(capacity: number): DataBuffer;
  42781. /**
  42782. * Delete a webGL buffer used with instanciation
  42783. * @param buffer defines the webGL buffer to delete
  42784. */
  42785. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42786. private _clientWaitAsync;
  42787. /** @hidden */
  42788. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  42789. dispose(): void;
  42790. private _disableTouchAction;
  42791. /**
  42792. * Display the loading screen
  42793. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42794. */
  42795. displayLoadingUI(): void;
  42796. /**
  42797. * Hide the loading screen
  42798. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42799. */
  42800. hideLoadingUI(): void;
  42801. /**
  42802. * Gets the current loading screen object
  42803. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42804. */
  42805. get loadingScreen(): ILoadingScreen;
  42806. /**
  42807. * Sets the current loading screen object
  42808. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42809. */
  42810. set loadingScreen(loadingScreen: ILoadingScreen);
  42811. /**
  42812. * Sets the current loading screen text
  42813. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42814. */
  42815. set loadingUIText(text: string);
  42816. /**
  42817. * Sets the current loading screen background color
  42818. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42819. */
  42820. set loadingUIBackgroundColor(color: string);
  42821. /** Pointerlock and fullscreen */
  42822. /**
  42823. * Ask the browser to promote the current element to pointerlock mode
  42824. * @param element defines the DOM element to promote
  42825. */
  42826. static _RequestPointerlock(element: HTMLElement): void;
  42827. /**
  42828. * Asks the browser to exit pointerlock mode
  42829. */
  42830. static _ExitPointerlock(): void;
  42831. /**
  42832. * Ask the browser to promote the current element to fullscreen rendering mode
  42833. * @param element defines the DOM element to promote
  42834. */
  42835. static _RequestFullscreen(element: HTMLElement): void;
  42836. /**
  42837. * Asks the browser to exit fullscreen mode
  42838. */
  42839. static _ExitFullscreen(): void;
  42840. }
  42841. }
  42842. declare module "babylonjs/Engines/engineStore" {
  42843. import { Nullable } from "babylonjs/types";
  42844. import { Engine } from "babylonjs/Engines/engine";
  42845. import { Scene } from "babylonjs/scene";
  42846. /**
  42847. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42848. * during the life time of the application.
  42849. */
  42850. export class EngineStore {
  42851. /** Gets the list of created engines */
  42852. static Instances: import("babylonjs/Engines/engine").Engine[];
  42853. /** @hidden */
  42854. static _LastCreatedScene: Nullable<Scene>;
  42855. /**
  42856. * Gets the latest created engine
  42857. */
  42858. static get LastCreatedEngine(): Nullable<Engine>;
  42859. /**
  42860. * Gets the latest created scene
  42861. */
  42862. static get LastCreatedScene(): Nullable<Scene>;
  42863. /**
  42864. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42865. * @ignorenaming
  42866. */
  42867. static UseFallbackTexture: boolean;
  42868. /**
  42869. * Texture content used if a texture cannot loaded
  42870. * @ignorenaming
  42871. */
  42872. static FallbackTexture: string;
  42873. }
  42874. }
  42875. declare module "babylonjs/Misc/promise" {
  42876. /**
  42877. * Helper class that provides a small promise polyfill
  42878. */
  42879. export class PromisePolyfill {
  42880. /**
  42881. * Static function used to check if the polyfill is required
  42882. * If this is the case then the function will inject the polyfill to window.Promise
  42883. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42884. */
  42885. static Apply(force?: boolean): void;
  42886. }
  42887. }
  42888. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  42889. /**
  42890. * Interface for screenshot methods with describe argument called `size` as object with options
  42891. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42892. */
  42893. export interface IScreenshotSize {
  42894. /**
  42895. * number in pixels for canvas height
  42896. */
  42897. height?: number;
  42898. /**
  42899. * multiplier allowing render at a higher or lower resolution
  42900. * If value is defined then height and width will be ignored and taken from camera
  42901. */
  42902. precision?: number;
  42903. /**
  42904. * number in pixels for canvas width
  42905. */
  42906. width?: number;
  42907. }
  42908. }
  42909. declare module "babylonjs/Misc/tools" {
  42910. import { Nullable, float } from "babylonjs/types";
  42911. import { DomManagement } from "babylonjs/Misc/domManagement";
  42912. import { WebRequest } from "babylonjs/Misc/webRequest";
  42913. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  42914. import { ReadFileError } from "babylonjs/Misc/fileTools";
  42915. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42916. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  42917. import { Camera } from "babylonjs/Cameras/camera";
  42918. import { Engine } from "babylonjs/Engines/engine";
  42919. interface IColor4Like {
  42920. r: float;
  42921. g: float;
  42922. b: float;
  42923. a: float;
  42924. }
  42925. /**
  42926. * Class containing a set of static utilities functions
  42927. */
  42928. export class Tools {
  42929. /**
  42930. * Gets or sets the base URL to use to load assets
  42931. */
  42932. static get BaseUrl(): string;
  42933. static set BaseUrl(value: string);
  42934. /**
  42935. * Enable/Disable Custom HTTP Request Headers globally.
  42936. * default = false
  42937. * @see CustomRequestHeaders
  42938. */
  42939. static UseCustomRequestHeaders: boolean;
  42940. /**
  42941. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42942. * i.e. when loading files, where the server/service expects an Authorization header
  42943. */
  42944. static CustomRequestHeaders: {
  42945. [key: string]: string;
  42946. };
  42947. /**
  42948. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42949. */
  42950. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42951. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42952. /**
  42953. * Default behaviour for cors in the application.
  42954. * It can be a string if the expected behavior is identical in the entire app.
  42955. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42956. */
  42957. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42958. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42959. /**
  42960. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42961. * @ignorenaming
  42962. */
  42963. static get UseFallbackTexture(): boolean;
  42964. static set UseFallbackTexture(value: boolean);
  42965. /**
  42966. * Use this object to register external classes like custom textures or material
  42967. * to allow the laoders to instantiate them
  42968. */
  42969. static get RegisteredExternalClasses(): {
  42970. [key: string]: Object;
  42971. };
  42972. static set RegisteredExternalClasses(classes: {
  42973. [key: string]: Object;
  42974. });
  42975. /**
  42976. * Texture content used if a texture cannot loaded
  42977. * @ignorenaming
  42978. */
  42979. static get fallbackTexture(): string;
  42980. static set fallbackTexture(value: string);
  42981. /**
  42982. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42983. * @param u defines the coordinate on X axis
  42984. * @param v defines the coordinate on Y axis
  42985. * @param width defines the width of the source data
  42986. * @param height defines the height of the source data
  42987. * @param pixels defines the source byte array
  42988. * @param color defines the output color
  42989. */
  42990. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42991. /**
  42992. * Interpolates between a and b via alpha
  42993. * @param a The lower value (returned when alpha = 0)
  42994. * @param b The upper value (returned when alpha = 1)
  42995. * @param alpha The interpolation-factor
  42996. * @return The mixed value
  42997. */
  42998. static Mix(a: number, b: number, alpha: number): number;
  42999. /**
  43000. * Tries to instantiate a new object from a given class name
  43001. * @param className defines the class name to instantiate
  43002. * @returns the new object or null if the system was not able to do the instantiation
  43003. */
  43004. static Instantiate(className: string): any;
  43005. /**
  43006. * Provides a slice function that will work even on IE
  43007. * @param data defines the array to slice
  43008. * @param start defines the start of the data (optional)
  43009. * @param end defines the end of the data (optional)
  43010. * @returns the new sliced array
  43011. */
  43012. static Slice<T>(data: T, start?: number, end?: number): T;
  43013. /**
  43014. * Provides a slice function that will work even on IE
  43015. * The difference between this and Slice is that this will force-convert to array
  43016. * @param data defines the array to slice
  43017. * @param start defines the start of the data (optional)
  43018. * @param end defines the end of the data (optional)
  43019. * @returns the new sliced array
  43020. */
  43021. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43022. /**
  43023. * Polyfill for setImmediate
  43024. * @param action defines the action to execute after the current execution block
  43025. */
  43026. static SetImmediate(action: () => void): void;
  43027. /**
  43028. * Function indicating if a number is an exponent of 2
  43029. * @param value defines the value to test
  43030. * @returns true if the value is an exponent of 2
  43031. */
  43032. static IsExponentOfTwo(value: number): boolean;
  43033. private static _tmpFloatArray;
  43034. /**
  43035. * Returns the nearest 32-bit single precision float representation of a Number
  43036. * @param value A Number. If the parameter is of a different type, it will get converted
  43037. * to a number or to NaN if it cannot be converted
  43038. * @returns number
  43039. */
  43040. static FloatRound(value: number): number;
  43041. /**
  43042. * Extracts the filename from a path
  43043. * @param path defines the path to use
  43044. * @returns the filename
  43045. */
  43046. static GetFilename(path: string): string;
  43047. /**
  43048. * Extracts the "folder" part of a path (everything before the filename).
  43049. * @param uri The URI to extract the info from
  43050. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43051. * @returns The "folder" part of the path
  43052. */
  43053. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43054. /**
  43055. * Extracts text content from a DOM element hierarchy
  43056. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43057. */
  43058. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43059. /**
  43060. * Convert an angle in radians to degrees
  43061. * @param angle defines the angle to convert
  43062. * @returns the angle in degrees
  43063. */
  43064. static ToDegrees(angle: number): number;
  43065. /**
  43066. * Convert an angle in degrees to radians
  43067. * @param angle defines the angle to convert
  43068. * @returns the angle in radians
  43069. */
  43070. static ToRadians(angle: number): number;
  43071. /**
  43072. * Returns an array if obj is not an array
  43073. * @param obj defines the object to evaluate as an array
  43074. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43075. * @returns either obj directly if obj is an array or a new array containing obj
  43076. */
  43077. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43078. /**
  43079. * Gets the pointer prefix to use
  43080. * @param engine defines the engine we are finding the prefix for
  43081. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43082. */
  43083. static GetPointerPrefix(engine: Engine): string;
  43084. /**
  43085. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43086. * @param url define the url we are trying
  43087. * @param element define the dom element where to configure the cors policy
  43088. */
  43089. static SetCorsBehavior(url: string | string[], element: {
  43090. crossOrigin: string | null;
  43091. }): void;
  43092. /**
  43093. * Removes unwanted characters from an url
  43094. * @param url defines the url to clean
  43095. * @returns the cleaned url
  43096. */
  43097. static CleanUrl(url: string): string;
  43098. /**
  43099. * Gets or sets a function used to pre-process url before using them to load assets
  43100. */
  43101. static get PreprocessUrl(): (url: string) => string;
  43102. static set PreprocessUrl(processor: (url: string) => string);
  43103. /**
  43104. * Loads an image as an HTMLImageElement.
  43105. * @param input url string, ArrayBuffer, or Blob to load
  43106. * @param onLoad callback called when the image successfully loads
  43107. * @param onError callback called when the image fails to load
  43108. * @param offlineProvider offline provider for caching
  43109. * @param mimeType optional mime type
  43110. * @returns the HTMLImageElement of the loaded image
  43111. */
  43112. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43113. /**
  43114. * Loads a file from a url
  43115. * @param url url string, ArrayBuffer, or Blob to load
  43116. * @param onSuccess callback called when the file successfully loads
  43117. * @param onProgress callback called while file is loading (if the server supports this mode)
  43118. * @param offlineProvider defines the offline provider for caching
  43119. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43120. * @param onError callback called when the file fails to load
  43121. * @returns a file request object
  43122. */
  43123. 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;
  43124. /**
  43125. * Loads a file from a url
  43126. * @param url the file url to load
  43127. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43128. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43129. */
  43130. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43131. /**
  43132. * Load a script (identified by an url). When the url returns, the
  43133. * content of this file is added into a new script element, attached to the DOM (body element)
  43134. * @param scriptUrl defines the url of the script to laod
  43135. * @param onSuccess defines the callback called when the script is loaded
  43136. * @param onError defines the callback to call if an error occurs
  43137. * @param scriptId defines the id of the script element
  43138. */
  43139. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43140. /**
  43141. * Load an asynchronous script (identified by an url). When the url returns, the
  43142. * content of this file is added into a new script element, attached to the DOM (body element)
  43143. * @param scriptUrl defines the url of the script to laod
  43144. * @param scriptId defines the id of the script element
  43145. * @returns a promise request object
  43146. */
  43147. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43148. /**
  43149. * Loads a file from a blob
  43150. * @param fileToLoad defines the blob to use
  43151. * @param callback defines the callback to call when data is loaded
  43152. * @param progressCallback defines the callback to call during loading process
  43153. * @returns a file request object
  43154. */
  43155. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43156. /**
  43157. * Reads a file from a File object
  43158. * @param file defines the file to load
  43159. * @param onSuccess defines the callback to call when data is loaded
  43160. * @param onProgress defines the callback to call during loading process
  43161. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43162. * @param onError defines the callback to call when an error occurs
  43163. * @returns a file request object
  43164. */
  43165. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43166. /**
  43167. * Creates a data url from a given string content
  43168. * @param content defines the content to convert
  43169. * @returns the new data url link
  43170. */
  43171. static FileAsURL(content: string): string;
  43172. /**
  43173. * Format the given number to a specific decimal format
  43174. * @param value defines the number to format
  43175. * @param decimals defines the number of decimals to use
  43176. * @returns the formatted string
  43177. */
  43178. static Format(value: number, decimals?: number): string;
  43179. /**
  43180. * Tries to copy an object by duplicating every property
  43181. * @param source defines the source object
  43182. * @param destination defines the target object
  43183. * @param doNotCopyList defines a list of properties to avoid
  43184. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43185. */
  43186. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43187. /**
  43188. * Gets a boolean indicating if the given object has no own property
  43189. * @param obj defines the object to test
  43190. * @returns true if object has no own property
  43191. */
  43192. static IsEmpty(obj: any): boolean;
  43193. /**
  43194. * Function used to register events at window level
  43195. * @param windowElement defines the Window object to use
  43196. * @param events defines the events to register
  43197. */
  43198. static RegisterTopRootEvents(windowElement: Window, events: {
  43199. name: string;
  43200. handler: Nullable<(e: FocusEvent) => any>;
  43201. }[]): void;
  43202. /**
  43203. * Function used to unregister events from window level
  43204. * @param windowElement defines the Window object to use
  43205. * @param events defines the events to unregister
  43206. */
  43207. static UnregisterTopRootEvents(windowElement: Window, events: {
  43208. name: string;
  43209. handler: Nullable<(e: FocusEvent) => any>;
  43210. }[]): void;
  43211. /**
  43212. * @ignore
  43213. */
  43214. static _ScreenshotCanvas: HTMLCanvasElement;
  43215. /**
  43216. * Dumps the current bound framebuffer
  43217. * @param width defines the rendering width
  43218. * @param height defines the rendering height
  43219. * @param engine defines the hosting engine
  43220. * @param successCallback defines the callback triggered once the data are available
  43221. * @param mimeType defines the mime type of the result
  43222. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43223. */
  43224. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43225. /**
  43226. * Converts the canvas data to blob.
  43227. * This acts as a polyfill for browsers not supporting the to blob function.
  43228. * @param canvas Defines the canvas to extract the data from
  43229. * @param successCallback Defines the callback triggered once the data are available
  43230. * @param mimeType Defines the mime type of the result
  43231. */
  43232. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43233. /**
  43234. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43235. * @param successCallback defines the callback triggered once the data are available
  43236. * @param mimeType defines the mime type of the result
  43237. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43238. */
  43239. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43240. /**
  43241. * Downloads a blob in the browser
  43242. * @param blob defines the blob to download
  43243. * @param fileName defines the name of the downloaded file
  43244. */
  43245. static Download(blob: Blob, fileName: string): void;
  43246. /**
  43247. * Will return the right value of the noPreventDefault variable
  43248. * Needed to keep backwards compatibility to the old API.
  43249. *
  43250. * @param args arguments passed to the attachControl function
  43251. * @returns the correct value for noPreventDefault
  43252. */
  43253. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43254. /**
  43255. * Captures a screenshot of the current rendering
  43256. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43257. * @param engine defines the rendering engine
  43258. * @param camera defines the source camera
  43259. * @param size This parameter can be set to a single number or to an object with the
  43260. * following (optional) properties: precision, width, height. If a single number is passed,
  43261. * it will be used for both width and height. If an object is passed, the screenshot size
  43262. * will be derived from the parameters. The precision property is a multiplier allowing
  43263. * rendering at a higher or lower resolution
  43264. * @param successCallback defines the callback receives a single parameter which contains the
  43265. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43266. * src parameter of an <img> to display it
  43267. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43268. * Check your browser for supported MIME types
  43269. */
  43270. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43271. /**
  43272. * Captures a screenshot of the current rendering
  43273. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43274. * @param engine defines the rendering engine
  43275. * @param camera defines the source camera
  43276. * @param size This parameter can be set to a single number or to an object with the
  43277. * following (optional) properties: precision, width, height. If a single number is passed,
  43278. * it will be used for both width and height. If an object is passed, the screenshot size
  43279. * will be derived from the parameters. The precision property is a multiplier allowing
  43280. * rendering at a higher or lower resolution
  43281. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43282. * Check your browser for supported MIME types
  43283. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43284. * to the src parameter of an <img> to display it
  43285. */
  43286. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43287. /**
  43288. * Generates an image screenshot from the specified camera.
  43289. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43290. * @param engine The engine to use for rendering
  43291. * @param camera The camera to use for rendering
  43292. * @param size This parameter can be set to a single number or to an object with the
  43293. * following (optional) properties: precision, width, height. If a single number is passed,
  43294. * it will be used for both width and height. If an object is passed, the screenshot size
  43295. * will be derived from the parameters. The precision property is a multiplier allowing
  43296. * rendering at a higher or lower resolution
  43297. * @param successCallback The callback receives a single parameter which contains the
  43298. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43299. * src parameter of an <img> to display it
  43300. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43301. * Check your browser for supported MIME types
  43302. * @param samples Texture samples (default: 1)
  43303. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43304. * @param fileName A name for for the downloaded file.
  43305. */
  43306. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43307. /**
  43308. * Generates an image screenshot from the specified camera.
  43309. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43310. * @param engine The engine to use for rendering
  43311. * @param camera The camera to use for rendering
  43312. * @param size This parameter can be set to a single number or to an object with the
  43313. * following (optional) properties: precision, width, height. If a single number is passed,
  43314. * it will be used for both width and height. If an object is passed, the screenshot size
  43315. * will be derived from the parameters. The precision property is a multiplier allowing
  43316. * rendering at a higher or lower resolution
  43317. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43318. * Check your browser for supported MIME types
  43319. * @param samples Texture samples (default: 1)
  43320. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43321. * @param fileName A name for for the downloaded file.
  43322. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43323. * to the src parameter of an <img> to display it
  43324. */
  43325. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43326. /**
  43327. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43328. * Be aware Math.random() could cause collisions, but:
  43329. * "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"
  43330. * @returns a pseudo random id
  43331. */
  43332. static RandomId(): string;
  43333. /**
  43334. * Test if the given uri is a base64 string
  43335. * @param uri The uri to test
  43336. * @return True if the uri is a base64 string or false otherwise
  43337. */
  43338. static IsBase64(uri: string): boolean;
  43339. /**
  43340. * Decode the given base64 uri.
  43341. * @param uri The uri to decode
  43342. * @return The decoded base64 data.
  43343. */
  43344. static DecodeBase64(uri: string): ArrayBuffer;
  43345. /**
  43346. * Gets the absolute url.
  43347. * @param url the input url
  43348. * @return the absolute url
  43349. */
  43350. static GetAbsoluteUrl(url: string): string;
  43351. /**
  43352. * No log
  43353. */
  43354. static readonly NoneLogLevel: number;
  43355. /**
  43356. * Only message logs
  43357. */
  43358. static readonly MessageLogLevel: number;
  43359. /**
  43360. * Only warning logs
  43361. */
  43362. static readonly WarningLogLevel: number;
  43363. /**
  43364. * Only error logs
  43365. */
  43366. static readonly ErrorLogLevel: number;
  43367. /**
  43368. * All logs
  43369. */
  43370. static readonly AllLogLevel: number;
  43371. /**
  43372. * Gets a value indicating the number of loading errors
  43373. * @ignorenaming
  43374. */
  43375. static get errorsCount(): number;
  43376. /**
  43377. * Callback called when a new log is added
  43378. */
  43379. static OnNewCacheEntry: (entry: string) => void;
  43380. /**
  43381. * Log a message to the console
  43382. * @param message defines the message to log
  43383. */
  43384. static Log(message: string): void;
  43385. /**
  43386. * Write a warning message to the console
  43387. * @param message defines the message to log
  43388. */
  43389. static Warn(message: string): void;
  43390. /**
  43391. * Write an error message to the console
  43392. * @param message defines the message to log
  43393. */
  43394. static Error(message: string): void;
  43395. /**
  43396. * Gets current log cache (list of logs)
  43397. */
  43398. static get LogCache(): string;
  43399. /**
  43400. * Clears the log cache
  43401. */
  43402. static ClearLogCache(): void;
  43403. /**
  43404. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43405. */
  43406. static set LogLevels(level: number);
  43407. /**
  43408. * Checks if the window object exists
  43409. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43410. */
  43411. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43412. /**
  43413. * No performance log
  43414. */
  43415. static readonly PerformanceNoneLogLevel: number;
  43416. /**
  43417. * Use user marks to log performance
  43418. */
  43419. static readonly PerformanceUserMarkLogLevel: number;
  43420. /**
  43421. * Log performance to the console
  43422. */
  43423. static readonly PerformanceConsoleLogLevel: number;
  43424. private static _performance;
  43425. /**
  43426. * Sets the current performance log level
  43427. */
  43428. static set PerformanceLogLevel(level: number);
  43429. private static _StartPerformanceCounterDisabled;
  43430. private static _EndPerformanceCounterDisabled;
  43431. private static _StartUserMark;
  43432. private static _EndUserMark;
  43433. private static _StartPerformanceConsole;
  43434. private static _EndPerformanceConsole;
  43435. /**
  43436. * Starts a performance counter
  43437. */
  43438. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43439. /**
  43440. * Ends a specific performance coutner
  43441. */
  43442. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43443. /**
  43444. * Gets either window.performance.now() if supported or Date.now() else
  43445. */
  43446. static get Now(): number;
  43447. /**
  43448. * This method will return the name of the class used to create the instance of the given object.
  43449. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43450. * @param object the object to get the class name from
  43451. * @param isType defines if the object is actually a type
  43452. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43453. */
  43454. static GetClassName(object: any, isType?: boolean): string;
  43455. /**
  43456. * Gets the first element of an array satisfying a given predicate
  43457. * @param array defines the array to browse
  43458. * @param predicate defines the predicate to use
  43459. * @returns null if not found or the element
  43460. */
  43461. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43462. /**
  43463. * This method will return the name of the full name of the class, including its owning module (if any).
  43464. * 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).
  43465. * @param object the object to get the class name from
  43466. * @param isType defines if the object is actually a type
  43467. * @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.
  43468. * @ignorenaming
  43469. */
  43470. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43471. /**
  43472. * Returns a promise that resolves after the given amount of time.
  43473. * @param delay Number of milliseconds to delay
  43474. * @returns Promise that resolves after the given amount of time
  43475. */
  43476. static DelayAsync(delay: number): Promise<void>;
  43477. /**
  43478. * Utility function to detect if the current user agent is Safari
  43479. * @returns whether or not the current user agent is safari
  43480. */
  43481. static IsSafari(): boolean;
  43482. }
  43483. /**
  43484. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43485. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43486. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43487. * @param name The name of the class, case should be preserved
  43488. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43489. */
  43490. export function className(name: string, module?: string): (target: Object) => void;
  43491. /**
  43492. * An implementation of a loop for asynchronous functions.
  43493. */
  43494. export class AsyncLoop {
  43495. /**
  43496. * Defines the number of iterations for the loop
  43497. */
  43498. iterations: number;
  43499. /**
  43500. * Defines the current index of the loop.
  43501. */
  43502. index: number;
  43503. private _done;
  43504. private _fn;
  43505. private _successCallback;
  43506. /**
  43507. * Constructor.
  43508. * @param iterations the number of iterations.
  43509. * @param func the function to run each iteration
  43510. * @param successCallback the callback that will be called upon succesful execution
  43511. * @param offset starting offset.
  43512. */
  43513. constructor(
  43514. /**
  43515. * Defines the number of iterations for the loop
  43516. */
  43517. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43518. /**
  43519. * Execute the next iteration. Must be called after the last iteration was finished.
  43520. */
  43521. executeNext(): void;
  43522. /**
  43523. * Break the loop and run the success callback.
  43524. */
  43525. breakLoop(): void;
  43526. /**
  43527. * Create and run an async loop.
  43528. * @param iterations the number of iterations.
  43529. * @param fn the function to run each iteration
  43530. * @param successCallback the callback that will be called upon succesful execution
  43531. * @param offset starting offset.
  43532. * @returns the created async loop object
  43533. */
  43534. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43535. /**
  43536. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43537. * @param iterations total number of iterations
  43538. * @param syncedIterations number of synchronous iterations in each async iteration.
  43539. * @param fn the function to call each iteration.
  43540. * @param callback a success call back that will be called when iterating stops.
  43541. * @param breakFunction a break condition (optional)
  43542. * @param timeout timeout settings for the setTimeout function. default - 0.
  43543. * @returns the created async loop object
  43544. */
  43545. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43546. }
  43547. }
  43548. declare module "babylonjs/Misc/stringDictionary" {
  43549. import { Nullable } from "babylonjs/types";
  43550. /**
  43551. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43552. * The underlying implementation relies on an associative array to ensure the best performances.
  43553. * The value can be anything including 'null' but except 'undefined'
  43554. */
  43555. export class StringDictionary<T> {
  43556. /**
  43557. * This will clear this dictionary and copy the content from the 'source' one.
  43558. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43559. * @param source the dictionary to take the content from and copy to this dictionary
  43560. */
  43561. copyFrom(source: StringDictionary<T>): void;
  43562. /**
  43563. * Get a value based from its key
  43564. * @param key the given key to get the matching value from
  43565. * @return the value if found, otherwise undefined is returned
  43566. */
  43567. get(key: string): T | undefined;
  43568. /**
  43569. * Get a value from its key or add it if it doesn't exist.
  43570. * This method will ensure you that a given key/data will be present in the dictionary.
  43571. * @param key the given key to get the matching value from
  43572. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43573. * The factory will only be invoked if there's no data for the given key.
  43574. * @return the value corresponding to the key.
  43575. */
  43576. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43577. /**
  43578. * Get a value from its key if present in the dictionary otherwise add it
  43579. * @param key the key to get the value from
  43580. * @param val if there's no such key/value pair in the dictionary add it with this value
  43581. * @return the value corresponding to the key
  43582. */
  43583. getOrAdd(key: string, val: T): T;
  43584. /**
  43585. * Check if there's a given key in the dictionary
  43586. * @param key the key to check for
  43587. * @return true if the key is present, false otherwise
  43588. */
  43589. contains(key: string): boolean;
  43590. /**
  43591. * Add a new key and its corresponding value
  43592. * @param key the key to add
  43593. * @param value the value corresponding to the key
  43594. * @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
  43595. */
  43596. add(key: string, value: T): boolean;
  43597. /**
  43598. * Update a specific value associated to a key
  43599. * @param key defines the key to use
  43600. * @param value defines the value to store
  43601. * @returns true if the value was updated (or false if the key was not found)
  43602. */
  43603. set(key: string, value: T): boolean;
  43604. /**
  43605. * Get the element of the given key and remove it from the dictionary
  43606. * @param key defines the key to search
  43607. * @returns the value associated with the key or null if not found
  43608. */
  43609. getAndRemove(key: string): Nullable<T>;
  43610. /**
  43611. * Remove a key/value from the dictionary.
  43612. * @param key the key to remove
  43613. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43614. */
  43615. remove(key: string): boolean;
  43616. /**
  43617. * Clear the whole content of the dictionary
  43618. */
  43619. clear(): void;
  43620. /**
  43621. * Gets the current count
  43622. */
  43623. get count(): number;
  43624. /**
  43625. * Execute a callback on each key/val of the dictionary.
  43626. * Note that you can remove any element in this dictionary in the callback implementation
  43627. * @param callback the callback to execute on a given key/value pair
  43628. */
  43629. forEach(callback: (key: string, val: T) => void): void;
  43630. /**
  43631. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43632. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43633. * Note that you can remove any element in this dictionary in the callback implementation
  43634. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43635. * @returns the first item
  43636. */
  43637. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43638. private _count;
  43639. private _data;
  43640. }
  43641. }
  43642. declare module "babylonjs/Collisions/collisionCoordinator" {
  43643. import { Nullable } from "babylonjs/types";
  43644. import { Scene } from "babylonjs/scene";
  43645. import { Vector3 } from "babylonjs/Maths/math.vector";
  43646. import { Collider } from "babylonjs/Collisions/collider";
  43647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43648. /** @hidden */
  43649. export interface ICollisionCoordinator {
  43650. createCollider(): Collider;
  43651. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43652. init(scene: Scene): void;
  43653. }
  43654. /** @hidden */
  43655. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43656. private _scene;
  43657. private _scaledPosition;
  43658. private _scaledVelocity;
  43659. private _finalPosition;
  43660. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43661. createCollider(): Collider;
  43662. init(scene: Scene): void;
  43663. private _collideWithWorld;
  43664. }
  43665. }
  43666. declare module "babylonjs/Inputs/scene.inputManager" {
  43667. import { Nullable } from "babylonjs/types";
  43668. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43669. import { Vector2 } from "babylonjs/Maths/math.vector";
  43670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43671. import { Scene } from "babylonjs/scene";
  43672. /**
  43673. * Class used to manage all inputs for the scene.
  43674. */
  43675. export class InputManager {
  43676. /** The distance in pixel that you have to move to prevent some events */
  43677. static DragMovementThreshold: number;
  43678. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43679. static LongPressDelay: number;
  43680. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43681. static DoubleClickDelay: number;
  43682. /** If you need to check double click without raising a single click at first click, enable this flag */
  43683. static ExclusiveDoubleClickMode: boolean;
  43684. /** 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. */
  43685. private _alreadyAttached;
  43686. private _alreadyAttachedTo;
  43687. private _wheelEventName;
  43688. private _onPointerMove;
  43689. private _onPointerDown;
  43690. private _onPointerUp;
  43691. private _initClickEvent;
  43692. private _initActionManager;
  43693. private _delayedSimpleClick;
  43694. private _delayedSimpleClickTimeout;
  43695. private _previousDelayedSimpleClickTimeout;
  43696. private _meshPickProceed;
  43697. private _previousButtonPressed;
  43698. private _currentPickResult;
  43699. private _previousPickResult;
  43700. private _totalPointersPressed;
  43701. private _doubleClickOccured;
  43702. private _pointerOverMesh;
  43703. private _pickedDownMesh;
  43704. private _pickedUpMesh;
  43705. private _pointerX;
  43706. private _pointerY;
  43707. private _unTranslatedPointerX;
  43708. private _unTranslatedPointerY;
  43709. private _startingPointerPosition;
  43710. private _previousStartingPointerPosition;
  43711. private _startingPointerTime;
  43712. private _previousStartingPointerTime;
  43713. private _pointerCaptures;
  43714. private _meshUnderPointerId;
  43715. private _onKeyDown;
  43716. private _onKeyUp;
  43717. private _keyboardIsAttached;
  43718. private _onCanvasFocusObserver;
  43719. private _onCanvasBlurObserver;
  43720. private _scene;
  43721. /**
  43722. * Creates a new InputManager
  43723. * @param scene defines the hosting scene
  43724. */
  43725. constructor(scene: Scene);
  43726. /**
  43727. * Gets the mesh that is currently under the pointer
  43728. */
  43729. get meshUnderPointer(): Nullable<AbstractMesh>;
  43730. /**
  43731. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43732. * @param pointerId the pointer id to use
  43733. * @returns The mesh under this pointer id or null if not found
  43734. */
  43735. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43736. /**
  43737. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43738. */
  43739. get unTranslatedPointer(): Vector2;
  43740. /**
  43741. * Gets or sets the current on-screen X position of the pointer
  43742. */
  43743. get pointerX(): number;
  43744. set pointerX(value: number);
  43745. /**
  43746. * Gets or sets the current on-screen Y position of the pointer
  43747. */
  43748. get pointerY(): number;
  43749. set pointerY(value: number);
  43750. private _updatePointerPosition;
  43751. private _processPointerMove;
  43752. private _setRayOnPointerInfo;
  43753. private _checkPrePointerObservable;
  43754. /**
  43755. * Use this method to simulate a pointer move on a mesh
  43756. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43757. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43758. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43759. */
  43760. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43761. /**
  43762. * Use this method to simulate a pointer down on a mesh
  43763. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43764. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43765. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43766. */
  43767. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43768. private _processPointerDown;
  43769. /** @hidden */
  43770. _isPointerSwiping(): boolean;
  43771. /**
  43772. * Use this method to simulate a pointer up on a mesh
  43773. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43774. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43775. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43776. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43777. */
  43778. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43779. private _processPointerUp;
  43780. /**
  43781. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43782. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43783. * @returns true if the pointer was captured
  43784. */
  43785. isPointerCaptured(pointerId?: number): boolean;
  43786. /**
  43787. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43788. * @param attachUp defines if you want to attach events to pointerup
  43789. * @param attachDown defines if you want to attach events to pointerdown
  43790. * @param attachMove defines if you want to attach events to pointermove
  43791. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43792. */
  43793. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43794. /**
  43795. * Detaches all event handlers
  43796. */
  43797. detachControl(): void;
  43798. /**
  43799. * Force the value of meshUnderPointer
  43800. * @param mesh defines the mesh to use
  43801. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43802. */
  43803. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43804. /**
  43805. * Gets the mesh under the pointer
  43806. * @returns a Mesh or null if no mesh is under the pointer
  43807. */
  43808. getPointerOverMesh(): Nullable<AbstractMesh>;
  43809. }
  43810. }
  43811. declare module "babylonjs/Animations/animationGroup" {
  43812. import { Animatable } from "babylonjs/Animations/animatable";
  43813. import { Animation } from "babylonjs/Animations/animation";
  43814. import { Scene, IDisposable } from "babylonjs/scene";
  43815. import { Observable } from "babylonjs/Misc/observable";
  43816. import { Nullable } from "babylonjs/types";
  43817. import "babylonjs/Animations/animatable";
  43818. /**
  43819. * This class defines the direct association between an animation and a target
  43820. */
  43821. export class TargetedAnimation {
  43822. /**
  43823. * Animation to perform
  43824. */
  43825. animation: Animation;
  43826. /**
  43827. * Target to animate
  43828. */
  43829. target: any;
  43830. /**
  43831. * Returns the string "TargetedAnimation"
  43832. * @returns "TargetedAnimation"
  43833. */
  43834. getClassName(): string;
  43835. /**
  43836. * Serialize the object
  43837. * @returns the JSON object representing the current entity
  43838. */
  43839. serialize(): any;
  43840. }
  43841. /**
  43842. * Use this class to create coordinated animations on multiple targets
  43843. */
  43844. export class AnimationGroup implements IDisposable {
  43845. /** The name of the animation group */
  43846. name: string;
  43847. private _scene;
  43848. private _targetedAnimations;
  43849. private _animatables;
  43850. private _from;
  43851. private _to;
  43852. private _isStarted;
  43853. private _isPaused;
  43854. private _speedRatio;
  43855. private _loopAnimation;
  43856. private _isAdditive;
  43857. /**
  43858. * Gets or sets the unique id of the node
  43859. */
  43860. uniqueId: number;
  43861. /**
  43862. * This observable will notify when one animation have ended
  43863. */
  43864. onAnimationEndObservable: Observable<TargetedAnimation>;
  43865. /**
  43866. * Observer raised when one animation loops
  43867. */
  43868. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43869. /**
  43870. * Observer raised when all animations have looped
  43871. */
  43872. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43873. /**
  43874. * This observable will notify when all animations have ended.
  43875. */
  43876. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43877. /**
  43878. * This observable will notify when all animations have paused.
  43879. */
  43880. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43881. /**
  43882. * This observable will notify when all animations are playing.
  43883. */
  43884. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43885. /**
  43886. * Gets the first frame
  43887. */
  43888. get from(): number;
  43889. /**
  43890. * Gets the last frame
  43891. */
  43892. get to(): number;
  43893. /**
  43894. * Define if the animations are started
  43895. */
  43896. get isStarted(): boolean;
  43897. /**
  43898. * Gets a value indicating that the current group is playing
  43899. */
  43900. get isPlaying(): boolean;
  43901. /**
  43902. * Gets or sets the speed ratio to use for all animations
  43903. */
  43904. get speedRatio(): number;
  43905. /**
  43906. * Gets or sets the speed ratio to use for all animations
  43907. */
  43908. set speedRatio(value: number);
  43909. /**
  43910. * Gets or sets if all animations should loop or not
  43911. */
  43912. get loopAnimation(): boolean;
  43913. set loopAnimation(value: boolean);
  43914. /**
  43915. * Gets or sets if all animations should be evaluated additively
  43916. */
  43917. get isAdditive(): boolean;
  43918. set isAdditive(value: boolean);
  43919. /**
  43920. * Gets the targeted animations for this animation group
  43921. */
  43922. get targetedAnimations(): Array<TargetedAnimation>;
  43923. /**
  43924. * returning the list of animatables controlled by this animation group.
  43925. */
  43926. get animatables(): Array<Animatable>;
  43927. /**
  43928. * Gets the list of target animations
  43929. */
  43930. get children(): TargetedAnimation[];
  43931. /**
  43932. * Instantiates a new Animation Group.
  43933. * This helps managing several animations at once.
  43934. * @see https://doc.babylonjs.com/how_to/group
  43935. * @param name Defines the name of the group
  43936. * @param scene Defines the scene the group belongs to
  43937. */
  43938. constructor(
  43939. /** The name of the animation group */
  43940. name: string, scene?: Nullable<Scene>);
  43941. /**
  43942. * Add an animation (with its target) in the group
  43943. * @param animation defines the animation we want to add
  43944. * @param target defines the target of the animation
  43945. * @returns the TargetedAnimation object
  43946. */
  43947. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43948. /**
  43949. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43950. * It can add constant keys at begin or end
  43951. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43952. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43953. * @returns the animation group
  43954. */
  43955. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43956. private _animationLoopCount;
  43957. private _animationLoopFlags;
  43958. private _processLoop;
  43959. /**
  43960. * Start all animations on given targets
  43961. * @param loop defines if animations must loop
  43962. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43963. * @param from defines the from key (optional)
  43964. * @param to defines the to key (optional)
  43965. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43966. * @returns the current animation group
  43967. */
  43968. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43969. /**
  43970. * Pause all animations
  43971. * @returns the animation group
  43972. */
  43973. pause(): AnimationGroup;
  43974. /**
  43975. * Play all animations to initial state
  43976. * This function will start() the animations if they were not started or will restart() them if they were paused
  43977. * @param loop defines if animations must loop
  43978. * @returns the animation group
  43979. */
  43980. play(loop?: boolean): AnimationGroup;
  43981. /**
  43982. * Reset all animations to initial state
  43983. * @returns the animation group
  43984. */
  43985. reset(): AnimationGroup;
  43986. /**
  43987. * Restart animations from key 0
  43988. * @returns the animation group
  43989. */
  43990. restart(): AnimationGroup;
  43991. /**
  43992. * Stop all animations
  43993. * @returns the animation group
  43994. */
  43995. stop(): AnimationGroup;
  43996. /**
  43997. * Set animation weight for all animatables
  43998. * @param weight defines the weight to use
  43999. * @return the animationGroup
  44000. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44001. */
  44002. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44003. /**
  44004. * Synchronize and normalize all animatables with a source animatable
  44005. * @param root defines the root animatable to synchronize with
  44006. * @return the animationGroup
  44007. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44008. */
  44009. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44010. /**
  44011. * Goes to a specific frame in this animation group
  44012. * @param frame the frame number to go to
  44013. * @return the animationGroup
  44014. */
  44015. goToFrame(frame: number): AnimationGroup;
  44016. /**
  44017. * Dispose all associated resources
  44018. */
  44019. dispose(): void;
  44020. private _checkAnimationGroupEnded;
  44021. /**
  44022. * Clone the current animation group and returns a copy
  44023. * @param newName defines the name of the new group
  44024. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44025. * @returns the new aniamtion group
  44026. */
  44027. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44028. /**
  44029. * Serializes the animationGroup to an object
  44030. * @returns Serialized object
  44031. */
  44032. serialize(): any;
  44033. /**
  44034. * Returns a new AnimationGroup object parsed from the source provided.
  44035. * @param parsedAnimationGroup defines the source
  44036. * @param scene defines the scene that will receive the animationGroup
  44037. * @returns a new AnimationGroup
  44038. */
  44039. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44040. /**
  44041. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44042. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44043. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44044. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44045. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44046. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44047. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44048. */
  44049. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44050. /**
  44051. * Returns the string "AnimationGroup"
  44052. * @returns "AnimationGroup"
  44053. */
  44054. getClassName(): string;
  44055. /**
  44056. * Creates a detailled string about the object
  44057. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44058. * @returns a string representing the object
  44059. */
  44060. toString(fullDetails?: boolean): string;
  44061. }
  44062. }
  44063. declare module "babylonjs/scene" {
  44064. import { Nullable } from "babylonjs/types";
  44065. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  44066. import { Observable } from "babylonjs/Misc/observable";
  44067. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44068. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  44069. import { Geometry } from "babylonjs/Meshes/geometry";
  44070. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44071. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44073. import { Mesh } from "babylonjs/Meshes/mesh";
  44074. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44075. import { Bone } from "babylonjs/Bones/bone";
  44076. import { Skeleton } from "babylonjs/Bones/skeleton";
  44077. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  44078. import { Camera } from "babylonjs/Cameras/camera";
  44079. import { AbstractScene } from "babylonjs/abstractScene";
  44080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44081. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44082. import { Material } from "babylonjs/Materials/material";
  44083. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44084. import { Effect } from "babylonjs/Materials/effect";
  44085. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44086. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  44087. import { Light } from "babylonjs/Lights/light";
  44088. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44089. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  44090. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  44091. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  44092. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  44093. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  44094. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  44095. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  44096. import { Engine } from "babylonjs/Engines/engine";
  44097. import { Node } from "babylonjs/node";
  44098. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  44099. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  44100. import { WebRequest } from "babylonjs/Misc/webRequest";
  44101. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  44102. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  44103. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44104. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  44105. import { Plane } from "babylonjs/Maths/math.plane";
  44106. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  44107. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  44108. import { Ray } from "babylonjs/Culling/ray";
  44109. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  44110. import { Animation } from "babylonjs/Animations/animation";
  44111. import { Animatable } from "babylonjs/Animations/animatable";
  44112. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44113. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  44114. import { Collider } from "babylonjs/Collisions/collider";
  44115. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44116. /**
  44117. * Define an interface for all classes that will hold resources
  44118. */
  44119. export interface IDisposable {
  44120. /**
  44121. * Releases all held resources
  44122. */
  44123. dispose(): void;
  44124. }
  44125. /** Interface defining initialization parameters for Scene class */
  44126. export interface SceneOptions {
  44127. /**
  44128. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  44129. * It will improve performance when the number of geometries becomes important.
  44130. */
  44131. useGeometryUniqueIdsMap?: boolean;
  44132. /**
  44133. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  44134. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44135. */
  44136. useMaterialMeshMap?: boolean;
  44137. /**
  44138. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  44139. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44140. */
  44141. useClonedMeshMap?: boolean;
  44142. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  44143. virtual?: boolean;
  44144. }
  44145. /**
  44146. * Represents a scene to be rendered by the engine.
  44147. * @see https://doc.babylonjs.com/features/scene
  44148. */
  44149. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  44150. /** The fog is deactivated */
  44151. static readonly FOGMODE_NONE: number;
  44152. /** The fog density is following an exponential function */
  44153. static readonly FOGMODE_EXP: number;
  44154. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  44155. static readonly FOGMODE_EXP2: number;
  44156. /** The fog density is following a linear function. */
  44157. static readonly FOGMODE_LINEAR: number;
  44158. /**
  44159. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  44160. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44161. */
  44162. static MinDeltaTime: number;
  44163. /**
  44164. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  44165. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44166. */
  44167. static MaxDeltaTime: number;
  44168. /**
  44169. * Factory used to create the default material.
  44170. * @param name The name of the material to create
  44171. * @param scene The scene to create the material for
  44172. * @returns The default material
  44173. */
  44174. static DefaultMaterialFactory(scene: Scene): Material;
  44175. /**
  44176. * Factory used to create the a collision coordinator.
  44177. * @returns The collision coordinator
  44178. */
  44179. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  44180. /** @hidden */
  44181. _inputManager: InputManager;
  44182. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  44183. cameraToUseForPointers: Nullable<Camera>;
  44184. /** @hidden */
  44185. readonly _isScene: boolean;
  44186. /** @hidden */
  44187. _blockEntityCollection: boolean;
  44188. /**
  44189. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  44190. */
  44191. autoClear: boolean;
  44192. /**
  44193. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  44194. */
  44195. autoClearDepthAndStencil: boolean;
  44196. /**
  44197. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  44198. */
  44199. clearColor: Color4;
  44200. /**
  44201. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  44202. */
  44203. ambientColor: Color3;
  44204. /**
  44205. * This is use to store the default BRDF lookup for PBR materials in your scene.
  44206. * It should only be one of the following (if not the default embedded one):
  44207. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44208. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  44209. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44210. * The material properties need to be setup according to the type of texture in use.
  44211. */
  44212. environmentBRDFTexture: BaseTexture;
  44213. /**
  44214. * Texture used in all pbr material as the reflection texture.
  44215. * As in the majority of the scene they are the same (exception for multi room and so on),
  44216. * this is easier to reference from here than from all the materials.
  44217. */
  44218. get environmentTexture(): Nullable<BaseTexture>;
  44219. /**
  44220. * Texture used in all pbr material as the reflection texture.
  44221. * As in the majority of the scene they are the same (exception for multi room and so on),
  44222. * this is easier to set here than in all the materials.
  44223. */
  44224. set environmentTexture(value: Nullable<BaseTexture>);
  44225. /** @hidden */
  44226. protected _environmentIntensity: number;
  44227. /**
  44228. * Intensity of the environment in all pbr material.
  44229. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44230. * As in the majority of the scene they are the same (exception for multi room and so on),
  44231. * this is easier to reference from here than from all the materials.
  44232. */
  44233. get environmentIntensity(): number;
  44234. /**
  44235. * Intensity of the environment in all pbr material.
  44236. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44237. * As in the majority of the scene they are the same (exception for multi room and so on),
  44238. * this is easier to set here than in all the materials.
  44239. */
  44240. set environmentIntensity(value: number);
  44241. /** @hidden */
  44242. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44243. /**
  44244. * Default image processing configuration used either in the rendering
  44245. * Forward main pass or through the imageProcessingPostProcess if present.
  44246. * As in the majority of the scene they are the same (exception for multi camera),
  44247. * this is easier to reference from here than from all the materials and post process.
  44248. *
  44249. * No setter as we it is a shared configuration, you can set the values instead.
  44250. */
  44251. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44252. private _forceWireframe;
  44253. /**
  44254. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  44255. */
  44256. set forceWireframe(value: boolean);
  44257. get forceWireframe(): boolean;
  44258. private _skipFrustumClipping;
  44259. /**
  44260. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  44261. */
  44262. set skipFrustumClipping(value: boolean);
  44263. get skipFrustumClipping(): boolean;
  44264. private _forcePointsCloud;
  44265. /**
  44266. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  44267. */
  44268. set forcePointsCloud(value: boolean);
  44269. get forcePointsCloud(): boolean;
  44270. /**
  44271. * Gets or sets the active clipplane 1
  44272. */
  44273. clipPlane: Nullable<Plane>;
  44274. /**
  44275. * Gets or sets the active clipplane 2
  44276. */
  44277. clipPlane2: Nullable<Plane>;
  44278. /**
  44279. * Gets or sets the active clipplane 3
  44280. */
  44281. clipPlane3: Nullable<Plane>;
  44282. /**
  44283. * Gets or sets the active clipplane 4
  44284. */
  44285. clipPlane4: Nullable<Plane>;
  44286. /**
  44287. * Gets or sets the active clipplane 5
  44288. */
  44289. clipPlane5: Nullable<Plane>;
  44290. /**
  44291. * Gets or sets the active clipplane 6
  44292. */
  44293. clipPlane6: Nullable<Plane>;
  44294. /**
  44295. * Gets or sets a boolean indicating if animations are enabled
  44296. */
  44297. animationsEnabled: boolean;
  44298. private _animationPropertiesOverride;
  44299. /**
  44300. * Gets or sets the animation properties override
  44301. */
  44302. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44303. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44304. /**
  44305. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44306. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44307. */
  44308. useConstantAnimationDeltaTime: boolean;
  44309. /**
  44310. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44311. * Please note that it requires to run a ray cast through the scene on every frame
  44312. */
  44313. constantlyUpdateMeshUnderPointer: boolean;
  44314. /**
  44315. * Defines the HTML cursor to use when hovering over interactive elements
  44316. */
  44317. hoverCursor: string;
  44318. /**
  44319. * Defines the HTML default cursor to use (empty by default)
  44320. */
  44321. defaultCursor: string;
  44322. /**
  44323. * Defines whether cursors are handled by the scene.
  44324. */
  44325. doNotHandleCursors: boolean;
  44326. /**
  44327. * This is used to call preventDefault() on pointer down
  44328. * in order to block unwanted artifacts like system double clicks
  44329. */
  44330. preventDefaultOnPointerDown: boolean;
  44331. /**
  44332. * This is used to call preventDefault() on pointer up
  44333. * in order to block unwanted artifacts like system double clicks
  44334. */
  44335. preventDefaultOnPointerUp: boolean;
  44336. /**
  44337. * Gets or sets user defined metadata
  44338. */
  44339. metadata: any;
  44340. /**
  44341. * For internal use only. Please do not use.
  44342. */
  44343. reservedDataStore: any;
  44344. /**
  44345. * Gets the name of the plugin used to load this scene (null by default)
  44346. */
  44347. loadingPluginName: string;
  44348. /**
  44349. * Use this array to add regular expressions used to disable offline support for specific urls
  44350. */
  44351. disableOfflineSupportExceptionRules: RegExp[];
  44352. /**
  44353. * An event triggered when the scene is disposed.
  44354. */
  44355. onDisposeObservable: Observable<Scene>;
  44356. private _onDisposeObserver;
  44357. /** Sets a function to be executed when this scene is disposed. */
  44358. set onDispose(callback: () => void);
  44359. /**
  44360. * An event triggered before rendering the scene (right after animations and physics)
  44361. */
  44362. onBeforeRenderObservable: Observable<Scene>;
  44363. private _onBeforeRenderObserver;
  44364. /** Sets a function to be executed before rendering this scene */
  44365. set beforeRender(callback: Nullable<() => void>);
  44366. /**
  44367. * An event triggered after rendering the scene
  44368. */
  44369. onAfterRenderObservable: Observable<Scene>;
  44370. /**
  44371. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44372. */
  44373. onAfterRenderCameraObservable: Observable<Camera>;
  44374. private _onAfterRenderObserver;
  44375. /** Sets a function to be executed after rendering this scene */
  44376. set afterRender(callback: Nullable<() => void>);
  44377. /**
  44378. * An event triggered before animating the scene
  44379. */
  44380. onBeforeAnimationsObservable: Observable<Scene>;
  44381. /**
  44382. * An event triggered after animations processing
  44383. */
  44384. onAfterAnimationsObservable: Observable<Scene>;
  44385. /**
  44386. * An event triggered before draw calls are ready to be sent
  44387. */
  44388. onBeforeDrawPhaseObservable: Observable<Scene>;
  44389. /**
  44390. * An event triggered after draw calls have been sent
  44391. */
  44392. onAfterDrawPhaseObservable: Observable<Scene>;
  44393. /**
  44394. * An event triggered when the scene is ready
  44395. */
  44396. onReadyObservable: Observable<Scene>;
  44397. /**
  44398. * An event triggered before rendering a camera
  44399. */
  44400. onBeforeCameraRenderObservable: Observable<Camera>;
  44401. private _onBeforeCameraRenderObserver;
  44402. /** Sets a function to be executed before rendering a camera*/
  44403. set beforeCameraRender(callback: () => void);
  44404. /**
  44405. * An event triggered after rendering a camera
  44406. */
  44407. onAfterCameraRenderObservable: Observable<Camera>;
  44408. private _onAfterCameraRenderObserver;
  44409. /** Sets a function to be executed after rendering a camera*/
  44410. set afterCameraRender(callback: () => void);
  44411. /**
  44412. * An event triggered when active meshes evaluation is about to start
  44413. */
  44414. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44415. /**
  44416. * An event triggered when active meshes evaluation is done
  44417. */
  44418. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44419. /**
  44420. * An event triggered when particles rendering is about to start
  44421. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44422. */
  44423. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44424. /**
  44425. * An event triggered when particles rendering is done
  44426. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44427. */
  44428. onAfterParticlesRenderingObservable: Observable<Scene>;
  44429. /**
  44430. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44431. */
  44432. onDataLoadedObservable: Observable<Scene>;
  44433. /**
  44434. * An event triggered when a camera is created
  44435. */
  44436. onNewCameraAddedObservable: Observable<Camera>;
  44437. /**
  44438. * An event triggered when a camera is removed
  44439. */
  44440. onCameraRemovedObservable: Observable<Camera>;
  44441. /**
  44442. * An event triggered when a light is created
  44443. */
  44444. onNewLightAddedObservable: Observable<Light>;
  44445. /**
  44446. * An event triggered when a light is removed
  44447. */
  44448. onLightRemovedObservable: Observable<Light>;
  44449. /**
  44450. * An event triggered when a geometry is created
  44451. */
  44452. onNewGeometryAddedObservable: Observable<Geometry>;
  44453. /**
  44454. * An event triggered when a geometry is removed
  44455. */
  44456. onGeometryRemovedObservable: Observable<Geometry>;
  44457. /**
  44458. * An event triggered when a transform node is created
  44459. */
  44460. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44461. /**
  44462. * An event triggered when a transform node is removed
  44463. */
  44464. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44465. /**
  44466. * An event triggered when a mesh is created
  44467. */
  44468. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44469. /**
  44470. * An event triggered when a mesh is removed
  44471. */
  44472. onMeshRemovedObservable: Observable<AbstractMesh>;
  44473. /**
  44474. * An event triggered when a skeleton is created
  44475. */
  44476. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44477. /**
  44478. * An event triggered when a skeleton is removed
  44479. */
  44480. onSkeletonRemovedObservable: Observable<Skeleton>;
  44481. /**
  44482. * An event triggered when a material is created
  44483. */
  44484. onNewMaterialAddedObservable: Observable<Material>;
  44485. /**
  44486. * An event triggered when a material is removed
  44487. */
  44488. onMaterialRemovedObservable: Observable<Material>;
  44489. /**
  44490. * An event triggered when a texture is created
  44491. */
  44492. onNewTextureAddedObservable: Observable<BaseTexture>;
  44493. /**
  44494. * An event triggered when a texture is removed
  44495. */
  44496. onTextureRemovedObservable: Observable<BaseTexture>;
  44497. /**
  44498. * An event triggered when render targets are about to be rendered
  44499. * Can happen multiple times per frame.
  44500. */
  44501. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44502. /**
  44503. * An event triggered when render targets were rendered.
  44504. * Can happen multiple times per frame.
  44505. */
  44506. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44507. /**
  44508. * An event triggered before calculating deterministic simulation step
  44509. */
  44510. onBeforeStepObservable: Observable<Scene>;
  44511. /**
  44512. * An event triggered after calculating deterministic simulation step
  44513. */
  44514. onAfterStepObservable: Observable<Scene>;
  44515. /**
  44516. * An event triggered when the activeCamera property is updated
  44517. */
  44518. onActiveCameraChanged: Observable<Scene>;
  44519. /**
  44520. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44521. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44522. * 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)
  44523. */
  44524. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44525. /**
  44526. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44527. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44528. * 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)
  44529. */
  44530. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44531. /**
  44532. * This Observable will when a mesh has been imported into the scene.
  44533. */
  44534. onMeshImportedObservable: Observable<AbstractMesh>;
  44535. /**
  44536. * This Observable will when an animation file has been imported into the scene.
  44537. */
  44538. onAnimationFileImportedObservable: Observable<Scene>;
  44539. /**
  44540. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44541. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44542. */
  44543. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44544. /** @hidden */
  44545. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44546. /**
  44547. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44548. */
  44549. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44550. /**
  44551. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44552. */
  44553. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44554. /**
  44555. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44556. */
  44557. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44558. /** Callback called when a pointer move is detected */
  44559. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44560. /** Callback called when a pointer down is detected */
  44561. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44562. /** Callback called when a pointer up is detected */
  44563. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44564. /** Callback called when a pointer pick is detected */
  44565. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44566. /**
  44567. * 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).
  44568. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44569. */
  44570. onPrePointerObservable: Observable<PointerInfoPre>;
  44571. /**
  44572. * Observable event triggered each time an input event is received from the rendering canvas
  44573. */
  44574. onPointerObservable: Observable<PointerInfo>;
  44575. /**
  44576. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44577. */
  44578. get unTranslatedPointer(): Vector2;
  44579. /**
  44580. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44581. */
  44582. static get DragMovementThreshold(): number;
  44583. static set DragMovementThreshold(value: number);
  44584. /**
  44585. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44586. */
  44587. static get LongPressDelay(): number;
  44588. static set LongPressDelay(value: number);
  44589. /**
  44590. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44591. */
  44592. static get DoubleClickDelay(): number;
  44593. static set DoubleClickDelay(value: number);
  44594. /** If you need to check double click without raising a single click at first click, enable this flag */
  44595. static get ExclusiveDoubleClickMode(): boolean;
  44596. static set ExclusiveDoubleClickMode(value: boolean);
  44597. /** @hidden */
  44598. _mirroredCameraPosition: Nullable<Vector3>;
  44599. /**
  44600. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44601. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44602. */
  44603. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44604. /**
  44605. * Observable event triggered each time an keyboard event is received from the hosting window
  44606. */
  44607. onKeyboardObservable: Observable<KeyboardInfo>;
  44608. private _useRightHandedSystem;
  44609. /**
  44610. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44611. */
  44612. set useRightHandedSystem(value: boolean);
  44613. get useRightHandedSystem(): boolean;
  44614. private _timeAccumulator;
  44615. private _currentStepId;
  44616. private _currentInternalStep;
  44617. /**
  44618. * Sets the step Id used by deterministic lock step
  44619. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44620. * @param newStepId defines the step Id
  44621. */
  44622. setStepId(newStepId: number): void;
  44623. /**
  44624. * Gets the step Id used by deterministic lock step
  44625. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44626. * @returns the step Id
  44627. */
  44628. getStepId(): number;
  44629. /**
  44630. * Gets the internal step used by deterministic lock step
  44631. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44632. * @returns the internal step
  44633. */
  44634. getInternalStep(): number;
  44635. private _fogEnabled;
  44636. /**
  44637. * Gets or sets a boolean indicating if fog is enabled on this scene
  44638. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44639. * (Default is true)
  44640. */
  44641. set fogEnabled(value: boolean);
  44642. get fogEnabled(): boolean;
  44643. private _fogMode;
  44644. /**
  44645. * Gets or sets the fog mode to use
  44646. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44647. * | mode | value |
  44648. * | --- | --- |
  44649. * | FOGMODE_NONE | 0 |
  44650. * | FOGMODE_EXP | 1 |
  44651. * | FOGMODE_EXP2 | 2 |
  44652. * | FOGMODE_LINEAR | 3 |
  44653. */
  44654. set fogMode(value: number);
  44655. get fogMode(): number;
  44656. /**
  44657. * Gets or sets the fog color to use
  44658. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44659. * (Default is Color3(0.2, 0.2, 0.3))
  44660. */
  44661. fogColor: Color3;
  44662. /**
  44663. * Gets or sets the fog density to use
  44664. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44665. * (Default is 0.1)
  44666. */
  44667. fogDensity: number;
  44668. /**
  44669. * Gets or sets the fog start distance to use
  44670. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44671. * (Default is 0)
  44672. */
  44673. fogStart: number;
  44674. /**
  44675. * Gets or sets the fog end distance to use
  44676. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44677. * (Default is 1000)
  44678. */
  44679. fogEnd: number;
  44680. /**
  44681. * Flag indicating that the frame buffer binding is handled by another component
  44682. */
  44683. prePass: boolean;
  44684. private _shadowsEnabled;
  44685. /**
  44686. * Gets or sets a boolean indicating if shadows are enabled on this scene
  44687. */
  44688. set shadowsEnabled(value: boolean);
  44689. get shadowsEnabled(): boolean;
  44690. private _lightsEnabled;
  44691. /**
  44692. * Gets or sets a boolean indicating if lights are enabled on this scene
  44693. */
  44694. set lightsEnabled(value: boolean);
  44695. get lightsEnabled(): boolean;
  44696. /** All of the active cameras added to this scene. */
  44697. activeCameras: Camera[];
  44698. /** @hidden */
  44699. _activeCamera: Nullable<Camera>;
  44700. /** Gets or sets the current active camera */
  44701. get activeCamera(): Nullable<Camera>;
  44702. set activeCamera(value: Nullable<Camera>);
  44703. private _defaultMaterial;
  44704. /** The default material used on meshes when no material is affected */
  44705. get defaultMaterial(): Material;
  44706. /** The default material used on meshes when no material is affected */
  44707. set defaultMaterial(value: Material);
  44708. private _texturesEnabled;
  44709. /**
  44710. * Gets or sets a boolean indicating if textures are enabled on this scene
  44711. */
  44712. set texturesEnabled(value: boolean);
  44713. get texturesEnabled(): boolean;
  44714. /**
  44715. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  44716. */
  44717. physicsEnabled: boolean;
  44718. /**
  44719. * Gets or sets a boolean indicating if particles are enabled on this scene
  44720. */
  44721. particlesEnabled: boolean;
  44722. /**
  44723. * Gets or sets a boolean indicating if sprites are enabled on this scene
  44724. */
  44725. spritesEnabled: boolean;
  44726. private _skeletonsEnabled;
  44727. /**
  44728. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  44729. */
  44730. set skeletonsEnabled(value: boolean);
  44731. get skeletonsEnabled(): boolean;
  44732. /**
  44733. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  44734. */
  44735. lensFlaresEnabled: boolean;
  44736. /**
  44737. * Gets or sets a boolean indicating if collisions are enabled on this scene
  44738. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44739. */
  44740. collisionsEnabled: boolean;
  44741. private _collisionCoordinator;
  44742. /** @hidden */
  44743. get collisionCoordinator(): ICollisionCoordinator;
  44744. /**
  44745. * Defines the gravity applied to this scene (used only for collisions)
  44746. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44747. */
  44748. gravity: Vector3;
  44749. /**
  44750. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  44751. */
  44752. postProcessesEnabled: boolean;
  44753. /**
  44754. * Gets the current postprocess manager
  44755. */
  44756. postProcessManager: PostProcessManager;
  44757. /**
  44758. * Gets or sets a boolean indicating if render targets are enabled on this scene
  44759. */
  44760. renderTargetsEnabled: boolean;
  44761. /**
  44762. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  44763. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  44764. */
  44765. dumpNextRenderTargets: boolean;
  44766. /**
  44767. * The list of user defined render targets added to the scene
  44768. */
  44769. customRenderTargets: RenderTargetTexture[];
  44770. /**
  44771. * Defines if texture loading must be delayed
  44772. * If true, textures will only be loaded when they need to be rendered
  44773. */
  44774. useDelayedTextureLoading: boolean;
  44775. /**
  44776. * Gets the list of meshes imported to the scene through SceneLoader
  44777. */
  44778. importedMeshesFiles: String[];
  44779. /**
  44780. * Gets or sets a boolean indicating if probes are enabled on this scene
  44781. */
  44782. probesEnabled: boolean;
  44783. /**
  44784. * Gets or sets the current offline provider to use to store scene data
  44785. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  44786. */
  44787. offlineProvider: IOfflineProvider;
  44788. /**
  44789. * Gets or sets the action manager associated with the scene
  44790. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44791. */
  44792. actionManager: AbstractActionManager;
  44793. private _meshesForIntersections;
  44794. /**
  44795. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  44796. */
  44797. proceduralTexturesEnabled: boolean;
  44798. private _engine;
  44799. private _totalVertices;
  44800. /** @hidden */
  44801. _activeIndices: PerfCounter;
  44802. /** @hidden */
  44803. _activeParticles: PerfCounter;
  44804. /** @hidden */
  44805. _activeBones: PerfCounter;
  44806. private _animationRatio;
  44807. /** @hidden */
  44808. _animationTimeLast: number;
  44809. /** @hidden */
  44810. _animationTime: number;
  44811. /**
  44812. * Gets or sets a general scale for animation speed
  44813. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  44814. */
  44815. animationTimeScale: number;
  44816. /** @hidden */
  44817. _cachedMaterial: Nullable<Material>;
  44818. /** @hidden */
  44819. _cachedEffect: Nullable<Effect>;
  44820. /** @hidden */
  44821. _cachedVisibility: Nullable<number>;
  44822. private _renderId;
  44823. private _frameId;
  44824. private _executeWhenReadyTimeoutId;
  44825. private _intermediateRendering;
  44826. private _viewUpdateFlag;
  44827. private _projectionUpdateFlag;
  44828. /** @hidden */
  44829. _toBeDisposed: Nullable<IDisposable>[];
  44830. private _activeRequests;
  44831. /** @hidden */
  44832. _pendingData: any[];
  44833. private _isDisposed;
  44834. /**
  44835. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  44836. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  44837. */
  44838. dispatchAllSubMeshesOfActiveMeshes: boolean;
  44839. private _activeMeshes;
  44840. private _processedMaterials;
  44841. private _renderTargets;
  44842. /** @hidden */
  44843. _activeParticleSystems: SmartArray<IParticleSystem>;
  44844. private _activeSkeletons;
  44845. private _softwareSkinnedMeshes;
  44846. private _renderingManager;
  44847. /** @hidden */
  44848. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  44849. private _transformMatrix;
  44850. private _sceneUbo;
  44851. /** @hidden */
  44852. _viewMatrix: Matrix;
  44853. private _projectionMatrix;
  44854. /** @hidden */
  44855. _forcedViewPosition: Nullable<Vector3>;
  44856. /** @hidden */
  44857. _frustumPlanes: Plane[];
  44858. /**
  44859. * Gets the list of frustum planes (built from the active camera)
  44860. */
  44861. get frustumPlanes(): Plane[];
  44862. /**
  44863. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  44864. * This is useful if there are more lights that the maximum simulteanous authorized
  44865. */
  44866. requireLightSorting: boolean;
  44867. /** @hidden */
  44868. readonly useMaterialMeshMap: boolean;
  44869. /** @hidden */
  44870. readonly useClonedMeshMap: boolean;
  44871. private _externalData;
  44872. private _uid;
  44873. /**
  44874. * @hidden
  44875. * Backing store of defined scene components.
  44876. */
  44877. _components: ISceneComponent[];
  44878. /**
  44879. * @hidden
  44880. * Backing store of defined scene components.
  44881. */
  44882. _serializableComponents: ISceneSerializableComponent[];
  44883. /**
  44884. * List of components to register on the next registration step.
  44885. */
  44886. private _transientComponents;
  44887. /**
  44888. * Registers the transient components if needed.
  44889. */
  44890. private _registerTransientComponents;
  44891. /**
  44892. * @hidden
  44893. * Add a component to the scene.
  44894. * Note that the ccomponent could be registered on th next frame if this is called after
  44895. * the register component stage.
  44896. * @param component Defines the component to add to the scene
  44897. */
  44898. _addComponent(component: ISceneComponent): void;
  44899. /**
  44900. * @hidden
  44901. * Gets a component from the scene.
  44902. * @param name defines the name of the component to retrieve
  44903. * @returns the component or null if not present
  44904. */
  44905. _getComponent(name: string): Nullable<ISceneComponent>;
  44906. /**
  44907. * @hidden
  44908. * Defines the actions happening before camera updates.
  44909. */
  44910. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  44911. /**
  44912. * @hidden
  44913. * Defines the actions happening before clear the canvas.
  44914. */
  44915. _beforeClearStage: Stage<SimpleStageAction>;
  44916. /**
  44917. * @hidden
  44918. * Defines the actions when collecting render targets for the frame.
  44919. */
  44920. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44921. /**
  44922. * @hidden
  44923. * Defines the actions happening for one camera in the frame.
  44924. */
  44925. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44926. /**
  44927. * @hidden
  44928. * Defines the actions happening during the per mesh ready checks.
  44929. */
  44930. _isReadyForMeshStage: Stage<MeshStageAction>;
  44931. /**
  44932. * @hidden
  44933. * Defines the actions happening before evaluate active mesh checks.
  44934. */
  44935. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  44936. /**
  44937. * @hidden
  44938. * Defines the actions happening during the evaluate sub mesh checks.
  44939. */
  44940. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  44941. /**
  44942. * @hidden
  44943. * Defines the actions happening during the active mesh stage.
  44944. */
  44945. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  44946. /**
  44947. * @hidden
  44948. * Defines the actions happening during the per camera render target step.
  44949. */
  44950. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  44951. /**
  44952. * @hidden
  44953. * Defines the actions happening just before the active camera is drawing.
  44954. */
  44955. _beforeCameraDrawStage: Stage<CameraStageAction>;
  44956. /**
  44957. * @hidden
  44958. * Defines the actions happening just before a render target is drawing.
  44959. */
  44960. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44961. /**
  44962. * @hidden
  44963. * Defines the actions happening just before a rendering group is drawing.
  44964. */
  44965. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44966. /**
  44967. * @hidden
  44968. * Defines the actions happening just before a mesh is drawing.
  44969. */
  44970. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44971. /**
  44972. * @hidden
  44973. * Defines the actions happening just after a mesh has been drawn.
  44974. */
  44975. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44976. /**
  44977. * @hidden
  44978. * Defines the actions happening just after a rendering group has been drawn.
  44979. */
  44980. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44981. /**
  44982. * @hidden
  44983. * Defines the actions happening just after the active camera has been drawn.
  44984. */
  44985. _afterCameraDrawStage: Stage<CameraStageAction>;
  44986. /**
  44987. * @hidden
  44988. * Defines the actions happening just after a render target has been drawn.
  44989. */
  44990. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44991. /**
  44992. * @hidden
  44993. * Defines the actions happening just after rendering all cameras and computing intersections.
  44994. */
  44995. _afterRenderStage: Stage<SimpleStageAction>;
  44996. /**
  44997. * @hidden
  44998. * Defines the actions happening when a pointer move event happens.
  44999. */
  45000. _pointerMoveStage: Stage<PointerMoveStageAction>;
  45001. /**
  45002. * @hidden
  45003. * Defines the actions happening when a pointer down event happens.
  45004. */
  45005. _pointerDownStage: Stage<PointerUpDownStageAction>;
  45006. /**
  45007. * @hidden
  45008. * Defines the actions happening when a pointer up event happens.
  45009. */
  45010. _pointerUpStage: Stage<PointerUpDownStageAction>;
  45011. /**
  45012. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  45013. */
  45014. private geometriesByUniqueId;
  45015. /**
  45016. * Creates a new Scene
  45017. * @param engine defines the engine to use to render this scene
  45018. * @param options defines the scene options
  45019. */
  45020. constructor(engine: Engine, options?: SceneOptions);
  45021. /**
  45022. * Gets a string identifying the name of the class
  45023. * @returns "Scene" string
  45024. */
  45025. getClassName(): string;
  45026. private _defaultMeshCandidates;
  45027. /**
  45028. * @hidden
  45029. */
  45030. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45031. private _defaultSubMeshCandidates;
  45032. /**
  45033. * @hidden
  45034. */
  45035. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45036. /**
  45037. * Sets the default candidate providers for the scene.
  45038. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  45039. * and getCollidingSubMeshCandidates to their default function
  45040. */
  45041. setDefaultCandidateProviders(): void;
  45042. /**
  45043. * Gets the mesh that is currently under the pointer
  45044. */
  45045. get meshUnderPointer(): Nullable<AbstractMesh>;
  45046. /**
  45047. * Gets or sets the current on-screen X position of the pointer
  45048. */
  45049. get pointerX(): number;
  45050. set pointerX(value: number);
  45051. /**
  45052. * Gets or sets the current on-screen Y position of the pointer
  45053. */
  45054. get pointerY(): number;
  45055. set pointerY(value: number);
  45056. /**
  45057. * Gets the cached material (ie. the latest rendered one)
  45058. * @returns the cached material
  45059. */
  45060. getCachedMaterial(): Nullable<Material>;
  45061. /**
  45062. * Gets the cached effect (ie. the latest rendered one)
  45063. * @returns the cached effect
  45064. */
  45065. getCachedEffect(): Nullable<Effect>;
  45066. /**
  45067. * Gets the cached visibility state (ie. the latest rendered one)
  45068. * @returns the cached visibility state
  45069. */
  45070. getCachedVisibility(): Nullable<number>;
  45071. /**
  45072. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  45073. * @param material defines the current material
  45074. * @param effect defines the current effect
  45075. * @param visibility defines the current visibility state
  45076. * @returns true if one parameter is not cached
  45077. */
  45078. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  45079. /**
  45080. * Gets the engine associated with the scene
  45081. * @returns an Engine
  45082. */
  45083. getEngine(): Engine;
  45084. /**
  45085. * Gets the total number of vertices rendered per frame
  45086. * @returns the total number of vertices rendered per frame
  45087. */
  45088. getTotalVertices(): number;
  45089. /**
  45090. * Gets the performance counter for total vertices
  45091. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45092. */
  45093. get totalVerticesPerfCounter(): PerfCounter;
  45094. /**
  45095. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  45096. * @returns the total number of active indices rendered per frame
  45097. */
  45098. getActiveIndices(): number;
  45099. /**
  45100. * Gets the performance counter for active indices
  45101. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45102. */
  45103. get totalActiveIndicesPerfCounter(): PerfCounter;
  45104. /**
  45105. * Gets the total number of active particles rendered per frame
  45106. * @returns the total number of active particles rendered per frame
  45107. */
  45108. getActiveParticles(): number;
  45109. /**
  45110. * Gets the performance counter for active particles
  45111. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45112. */
  45113. get activeParticlesPerfCounter(): PerfCounter;
  45114. /**
  45115. * Gets the total number of active bones rendered per frame
  45116. * @returns the total number of active bones rendered per frame
  45117. */
  45118. getActiveBones(): number;
  45119. /**
  45120. * Gets the performance counter for active bones
  45121. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45122. */
  45123. get activeBonesPerfCounter(): PerfCounter;
  45124. /**
  45125. * Gets the array of active meshes
  45126. * @returns an array of AbstractMesh
  45127. */
  45128. getActiveMeshes(): SmartArray<AbstractMesh>;
  45129. /**
  45130. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  45131. * @returns a number
  45132. */
  45133. getAnimationRatio(): number;
  45134. /**
  45135. * Gets an unique Id for the current render phase
  45136. * @returns a number
  45137. */
  45138. getRenderId(): number;
  45139. /**
  45140. * Gets an unique Id for the current frame
  45141. * @returns a number
  45142. */
  45143. getFrameId(): number;
  45144. /** Call this function if you want to manually increment the render Id*/
  45145. incrementRenderId(): void;
  45146. private _createUbo;
  45147. /**
  45148. * Use this method to simulate a pointer move on a mesh
  45149. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45150. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45151. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45152. * @returns the current scene
  45153. */
  45154. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45155. /**
  45156. * Use this method to simulate a pointer down on a mesh
  45157. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45158. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45159. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45160. * @returns the current scene
  45161. */
  45162. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45163. /**
  45164. * Use this method to simulate a pointer up on a mesh
  45165. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45166. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45167. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45168. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  45169. * @returns the current scene
  45170. */
  45171. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  45172. /**
  45173. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  45174. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  45175. * @returns true if the pointer was captured
  45176. */
  45177. isPointerCaptured(pointerId?: number): boolean;
  45178. /**
  45179. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  45180. * @param attachUp defines if you want to attach events to pointerup
  45181. * @param attachDown defines if you want to attach events to pointerdown
  45182. * @param attachMove defines if you want to attach events to pointermove
  45183. */
  45184. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  45185. /** Detaches all event handlers*/
  45186. detachControl(): void;
  45187. /**
  45188. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  45189. * Delay loaded resources are not taking in account
  45190. * @return true if all required resources are ready
  45191. */
  45192. isReady(): boolean;
  45193. /** Resets all cached information relative to material (including effect and visibility) */
  45194. resetCachedMaterial(): void;
  45195. /**
  45196. * Registers a function to be called before every frame render
  45197. * @param func defines the function to register
  45198. */
  45199. registerBeforeRender(func: () => void): void;
  45200. /**
  45201. * Unregisters a function called before every frame render
  45202. * @param func defines the function to unregister
  45203. */
  45204. unregisterBeforeRender(func: () => void): void;
  45205. /**
  45206. * Registers a function to be called after every frame render
  45207. * @param func defines the function to register
  45208. */
  45209. registerAfterRender(func: () => void): void;
  45210. /**
  45211. * Unregisters a function called after every frame render
  45212. * @param func defines the function to unregister
  45213. */
  45214. unregisterAfterRender(func: () => void): void;
  45215. private _executeOnceBeforeRender;
  45216. /**
  45217. * The provided function will run before render once and will be disposed afterwards.
  45218. * A timeout delay can be provided so that the function will be executed in N ms.
  45219. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  45220. * @param func The function to be executed.
  45221. * @param timeout optional delay in ms
  45222. */
  45223. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  45224. /** @hidden */
  45225. _addPendingData(data: any): void;
  45226. /** @hidden */
  45227. _removePendingData(data: any): void;
  45228. /**
  45229. * Returns the number of items waiting to be loaded
  45230. * @returns the number of items waiting to be loaded
  45231. */
  45232. getWaitingItemsCount(): number;
  45233. /**
  45234. * Returns a boolean indicating if the scene is still loading data
  45235. */
  45236. get isLoading(): boolean;
  45237. /**
  45238. * Registers a function to be executed when the scene is ready
  45239. * @param {Function} func - the function to be executed
  45240. */
  45241. executeWhenReady(func: () => void): void;
  45242. /**
  45243. * Returns a promise that resolves when the scene is ready
  45244. * @returns A promise that resolves when the scene is ready
  45245. */
  45246. whenReadyAsync(): Promise<void>;
  45247. /** @hidden */
  45248. _checkIsReady(): void;
  45249. /**
  45250. * Gets all animatable attached to the scene
  45251. */
  45252. get animatables(): Animatable[];
  45253. /**
  45254. * Resets the last animation time frame.
  45255. * Useful to override when animations start running when loading a scene for the first time.
  45256. */
  45257. resetLastAnimationTimeFrame(): void;
  45258. /**
  45259. * Gets the current view matrix
  45260. * @returns a Matrix
  45261. */
  45262. getViewMatrix(): Matrix;
  45263. /**
  45264. * Gets the current projection matrix
  45265. * @returns a Matrix
  45266. */
  45267. getProjectionMatrix(): Matrix;
  45268. /**
  45269. * Gets the current transform matrix
  45270. * @returns a Matrix made of View * Projection
  45271. */
  45272. getTransformMatrix(): Matrix;
  45273. /**
  45274. * Sets the current transform matrix
  45275. * @param viewL defines the View matrix to use
  45276. * @param projectionL defines the Projection matrix to use
  45277. * @param viewR defines the right View matrix to use (if provided)
  45278. * @param projectionR defines the right Projection matrix to use (if provided)
  45279. */
  45280. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45281. /**
  45282. * Gets the uniform buffer used to store scene data
  45283. * @returns a UniformBuffer
  45284. */
  45285. getSceneUniformBuffer(): UniformBuffer;
  45286. /**
  45287. * Gets an unique (relatively to the current scene) Id
  45288. * @returns an unique number for the scene
  45289. */
  45290. getUniqueId(): number;
  45291. /**
  45292. * Add a mesh to the list of scene's meshes
  45293. * @param newMesh defines the mesh to add
  45294. * @param recursive if all child meshes should also be added to the scene
  45295. */
  45296. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45297. /**
  45298. * Remove a mesh for the list of scene's meshes
  45299. * @param toRemove defines the mesh to remove
  45300. * @param recursive if all child meshes should also be removed from the scene
  45301. * @returns the index where the mesh was in the mesh list
  45302. */
  45303. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45304. /**
  45305. * Add a transform node to the list of scene's transform nodes
  45306. * @param newTransformNode defines the transform node to add
  45307. */
  45308. addTransformNode(newTransformNode: TransformNode): void;
  45309. /**
  45310. * Remove a transform node for the list of scene's transform nodes
  45311. * @param toRemove defines the transform node to remove
  45312. * @returns the index where the transform node was in the transform node list
  45313. */
  45314. removeTransformNode(toRemove: TransformNode): number;
  45315. /**
  45316. * Remove a skeleton for the list of scene's skeletons
  45317. * @param toRemove defines the skeleton to remove
  45318. * @returns the index where the skeleton was in the skeleton list
  45319. */
  45320. removeSkeleton(toRemove: Skeleton): number;
  45321. /**
  45322. * Remove a morph target for the list of scene's morph targets
  45323. * @param toRemove defines the morph target to remove
  45324. * @returns the index where the morph target was in the morph target list
  45325. */
  45326. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45327. /**
  45328. * Remove a light for the list of scene's lights
  45329. * @param toRemove defines the light to remove
  45330. * @returns the index where the light was in the light list
  45331. */
  45332. removeLight(toRemove: Light): number;
  45333. /**
  45334. * Remove a camera for the list of scene's cameras
  45335. * @param toRemove defines the camera to remove
  45336. * @returns the index where the camera was in the camera list
  45337. */
  45338. removeCamera(toRemove: Camera): number;
  45339. /**
  45340. * Remove a particle system for the list of scene's particle systems
  45341. * @param toRemove defines the particle system to remove
  45342. * @returns the index where the particle system was in the particle system list
  45343. */
  45344. removeParticleSystem(toRemove: IParticleSystem): number;
  45345. /**
  45346. * Remove a animation for the list of scene's animations
  45347. * @param toRemove defines the animation to remove
  45348. * @returns the index where the animation was in the animation list
  45349. */
  45350. removeAnimation(toRemove: Animation): number;
  45351. /**
  45352. * Will stop the animation of the given target
  45353. * @param target - the target
  45354. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45355. * @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)
  45356. */
  45357. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45358. /**
  45359. * Removes the given animation group from this scene.
  45360. * @param toRemove The animation group to remove
  45361. * @returns The index of the removed animation group
  45362. */
  45363. removeAnimationGroup(toRemove: AnimationGroup): number;
  45364. /**
  45365. * Removes the given multi-material from this scene.
  45366. * @param toRemove The multi-material to remove
  45367. * @returns The index of the removed multi-material
  45368. */
  45369. removeMultiMaterial(toRemove: MultiMaterial): number;
  45370. /**
  45371. * Removes the given material from this scene.
  45372. * @param toRemove The material to remove
  45373. * @returns The index of the removed material
  45374. */
  45375. removeMaterial(toRemove: Material): number;
  45376. /**
  45377. * Removes the given action manager from this scene.
  45378. * @param toRemove The action manager to remove
  45379. * @returns The index of the removed action manager
  45380. */
  45381. removeActionManager(toRemove: AbstractActionManager): number;
  45382. /**
  45383. * Removes the given texture from this scene.
  45384. * @param toRemove The texture to remove
  45385. * @returns The index of the removed texture
  45386. */
  45387. removeTexture(toRemove: BaseTexture): number;
  45388. /**
  45389. * Adds the given light to this scene
  45390. * @param newLight The light to add
  45391. */
  45392. addLight(newLight: Light): void;
  45393. /**
  45394. * Sorts the list list based on light priorities
  45395. */
  45396. sortLightsByPriority(): void;
  45397. /**
  45398. * Adds the given camera to this scene
  45399. * @param newCamera The camera to add
  45400. */
  45401. addCamera(newCamera: Camera): void;
  45402. /**
  45403. * Adds the given skeleton to this scene
  45404. * @param newSkeleton The skeleton to add
  45405. */
  45406. addSkeleton(newSkeleton: Skeleton): void;
  45407. /**
  45408. * Adds the given particle system to this scene
  45409. * @param newParticleSystem The particle system to add
  45410. */
  45411. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45412. /**
  45413. * Adds the given animation to this scene
  45414. * @param newAnimation The animation to add
  45415. */
  45416. addAnimation(newAnimation: Animation): void;
  45417. /**
  45418. * Adds the given animation group to this scene.
  45419. * @param newAnimationGroup The animation group to add
  45420. */
  45421. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45422. /**
  45423. * Adds the given multi-material to this scene
  45424. * @param newMultiMaterial The multi-material to add
  45425. */
  45426. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45427. /**
  45428. * Adds the given material to this scene
  45429. * @param newMaterial The material to add
  45430. */
  45431. addMaterial(newMaterial: Material): void;
  45432. /**
  45433. * Adds the given morph target to this scene
  45434. * @param newMorphTargetManager The morph target to add
  45435. */
  45436. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45437. /**
  45438. * Adds the given geometry to this scene
  45439. * @param newGeometry The geometry to add
  45440. */
  45441. addGeometry(newGeometry: Geometry): void;
  45442. /**
  45443. * Adds the given action manager to this scene
  45444. * @param newActionManager The action manager to add
  45445. */
  45446. addActionManager(newActionManager: AbstractActionManager): void;
  45447. /**
  45448. * Adds the given texture to this scene.
  45449. * @param newTexture The texture to add
  45450. */
  45451. addTexture(newTexture: BaseTexture): void;
  45452. /**
  45453. * Switch active camera
  45454. * @param newCamera defines the new active camera
  45455. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45456. */
  45457. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45458. /**
  45459. * sets the active camera of the scene using its ID
  45460. * @param id defines the camera's ID
  45461. * @return the new active camera or null if none found.
  45462. */
  45463. setActiveCameraByID(id: string): Nullable<Camera>;
  45464. /**
  45465. * sets the active camera of the scene using its name
  45466. * @param name defines the camera's name
  45467. * @returns the new active camera or null if none found.
  45468. */
  45469. setActiveCameraByName(name: string): Nullable<Camera>;
  45470. /**
  45471. * get an animation group using its name
  45472. * @param name defines the material's name
  45473. * @return the animation group or null if none found.
  45474. */
  45475. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45476. /**
  45477. * Get a material using its unique id
  45478. * @param uniqueId defines the material's unique id
  45479. * @return the material or null if none found.
  45480. */
  45481. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45482. /**
  45483. * get a material using its id
  45484. * @param id defines the material's ID
  45485. * @return the material or null if none found.
  45486. */
  45487. getMaterialByID(id: string): Nullable<Material>;
  45488. /**
  45489. * Gets a the last added material using a given id
  45490. * @param id defines the material's ID
  45491. * @return the last material with the given id or null if none found.
  45492. */
  45493. getLastMaterialByID(id: string): Nullable<Material>;
  45494. /**
  45495. * Gets a material using its name
  45496. * @param name defines the material's name
  45497. * @return the material or null if none found.
  45498. */
  45499. getMaterialByName(name: string): Nullable<Material>;
  45500. /**
  45501. * Get a texture using its unique id
  45502. * @param uniqueId defines the texture's unique id
  45503. * @return the texture or null if none found.
  45504. */
  45505. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45506. /**
  45507. * Gets a camera using its id
  45508. * @param id defines the id to look for
  45509. * @returns the camera or null if not found
  45510. */
  45511. getCameraByID(id: string): Nullable<Camera>;
  45512. /**
  45513. * Gets a camera using its unique id
  45514. * @param uniqueId defines the unique id to look for
  45515. * @returns the camera or null if not found
  45516. */
  45517. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45518. /**
  45519. * Gets a camera using its name
  45520. * @param name defines the camera's name
  45521. * @return the camera or null if none found.
  45522. */
  45523. getCameraByName(name: string): Nullable<Camera>;
  45524. /**
  45525. * Gets a bone using its id
  45526. * @param id defines the bone's id
  45527. * @return the bone or null if not found
  45528. */
  45529. getBoneByID(id: string): Nullable<Bone>;
  45530. /**
  45531. * Gets a bone using its id
  45532. * @param name defines the bone's name
  45533. * @return the bone or null if not found
  45534. */
  45535. getBoneByName(name: string): Nullable<Bone>;
  45536. /**
  45537. * Gets a light node using its name
  45538. * @param name defines the the light's name
  45539. * @return the light or null if none found.
  45540. */
  45541. getLightByName(name: string): Nullable<Light>;
  45542. /**
  45543. * Gets a light node using its id
  45544. * @param id defines the light's id
  45545. * @return the light or null if none found.
  45546. */
  45547. getLightByID(id: string): Nullable<Light>;
  45548. /**
  45549. * Gets a light node using its scene-generated unique ID
  45550. * @param uniqueId defines the light's unique id
  45551. * @return the light or null if none found.
  45552. */
  45553. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45554. /**
  45555. * Gets a particle system by id
  45556. * @param id defines the particle system id
  45557. * @return the corresponding system or null if none found
  45558. */
  45559. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45560. /**
  45561. * Gets a geometry using its ID
  45562. * @param id defines the geometry's id
  45563. * @return the geometry or null if none found.
  45564. */
  45565. getGeometryByID(id: string): Nullable<Geometry>;
  45566. private _getGeometryByUniqueID;
  45567. /**
  45568. * Add a new geometry to this scene
  45569. * @param geometry defines the geometry to be added to the scene.
  45570. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45571. * @return a boolean defining if the geometry was added or not
  45572. */
  45573. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45574. /**
  45575. * Removes an existing geometry
  45576. * @param geometry defines the geometry to be removed from the scene
  45577. * @return a boolean defining if the geometry was removed or not
  45578. */
  45579. removeGeometry(geometry: Geometry): boolean;
  45580. /**
  45581. * Gets the list of geometries attached to the scene
  45582. * @returns an array of Geometry
  45583. */
  45584. getGeometries(): Geometry[];
  45585. /**
  45586. * Gets the first added mesh found of a given ID
  45587. * @param id defines the id to search for
  45588. * @return the mesh found or null if not found at all
  45589. */
  45590. getMeshByID(id: string): Nullable<AbstractMesh>;
  45591. /**
  45592. * Gets a list of meshes using their id
  45593. * @param id defines the id to search for
  45594. * @returns a list of meshes
  45595. */
  45596. getMeshesByID(id: string): Array<AbstractMesh>;
  45597. /**
  45598. * Gets the first added transform node found of a given ID
  45599. * @param id defines the id to search for
  45600. * @return the found transform node or null if not found at all.
  45601. */
  45602. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45603. /**
  45604. * Gets a transform node with its auto-generated unique id
  45605. * @param uniqueId efines the unique id to search for
  45606. * @return the found transform node or null if not found at all.
  45607. */
  45608. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45609. /**
  45610. * Gets a list of transform nodes using their id
  45611. * @param id defines the id to search for
  45612. * @returns a list of transform nodes
  45613. */
  45614. getTransformNodesByID(id: string): Array<TransformNode>;
  45615. /**
  45616. * Gets a mesh with its auto-generated unique id
  45617. * @param uniqueId defines the unique id to search for
  45618. * @return the found mesh or null if not found at all.
  45619. */
  45620. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45621. /**
  45622. * Gets a the last added mesh using a given id
  45623. * @param id defines the id to search for
  45624. * @return the found mesh or null if not found at all.
  45625. */
  45626. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45627. /**
  45628. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45629. * @param id defines the id to search for
  45630. * @return the found node or null if not found at all
  45631. */
  45632. getLastEntryByID(id: string): Nullable<Node>;
  45633. /**
  45634. * Gets a node (Mesh, Camera, Light) using a given id
  45635. * @param id defines the id to search for
  45636. * @return the found node or null if not found at all
  45637. */
  45638. getNodeByID(id: string): Nullable<Node>;
  45639. /**
  45640. * Gets a node (Mesh, Camera, Light) using a given name
  45641. * @param name defines the name to search for
  45642. * @return the found node or null if not found at all.
  45643. */
  45644. getNodeByName(name: string): Nullable<Node>;
  45645. /**
  45646. * Gets a mesh using a given name
  45647. * @param name defines the name to search for
  45648. * @return the found mesh or null if not found at all.
  45649. */
  45650. getMeshByName(name: string): Nullable<AbstractMesh>;
  45651. /**
  45652. * Gets a transform node using a given name
  45653. * @param name defines the name to search for
  45654. * @return the found transform node or null if not found at all.
  45655. */
  45656. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45657. /**
  45658. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45659. * @param id defines the id to search for
  45660. * @return the found skeleton or null if not found at all.
  45661. */
  45662. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  45663. /**
  45664. * Gets a skeleton using a given auto generated unique id
  45665. * @param uniqueId defines the unique id to search for
  45666. * @return the found skeleton or null if not found at all.
  45667. */
  45668. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  45669. /**
  45670. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  45671. * @param id defines the id to search for
  45672. * @return the found skeleton or null if not found at all.
  45673. */
  45674. getSkeletonById(id: string): Nullable<Skeleton>;
  45675. /**
  45676. * Gets a skeleton using a given name
  45677. * @param name defines the name to search for
  45678. * @return the found skeleton or null if not found at all.
  45679. */
  45680. getSkeletonByName(name: string): Nullable<Skeleton>;
  45681. /**
  45682. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  45683. * @param id defines the id to search for
  45684. * @return the found morph target manager or null if not found at all.
  45685. */
  45686. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  45687. /**
  45688. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  45689. * @param id defines the id to search for
  45690. * @return the found morph target or null if not found at all.
  45691. */
  45692. getMorphTargetById(id: string): Nullable<MorphTarget>;
  45693. /**
  45694. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  45695. * @param name defines the name to search for
  45696. * @return the found morph target or null if not found at all.
  45697. */
  45698. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  45699. /**
  45700. * Gets a post process using a given name (if many are found, this function will pick the first one)
  45701. * @param name defines the name to search for
  45702. * @return the found post process or null if not found at all.
  45703. */
  45704. getPostProcessByName(name: string): Nullable<PostProcess>;
  45705. /**
  45706. * Gets a boolean indicating if the given mesh is active
  45707. * @param mesh defines the mesh to look for
  45708. * @returns true if the mesh is in the active list
  45709. */
  45710. isActiveMesh(mesh: AbstractMesh): boolean;
  45711. /**
  45712. * Return a unique id as a string which can serve as an identifier for the scene
  45713. */
  45714. get uid(): string;
  45715. /**
  45716. * Add an externaly attached data from its key.
  45717. * This method call will fail and return false, if such key already exists.
  45718. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  45719. * @param key the unique key that identifies the data
  45720. * @param data the data object to associate to the key for this Engine instance
  45721. * @return true if no such key were already present and the data was added successfully, false otherwise
  45722. */
  45723. addExternalData<T>(key: string, data: T): boolean;
  45724. /**
  45725. * Get an externaly attached data from its key
  45726. * @param key the unique key that identifies the data
  45727. * @return the associated data, if present (can be null), or undefined if not present
  45728. */
  45729. getExternalData<T>(key: string): Nullable<T>;
  45730. /**
  45731. * Get an externaly attached data from its key, create it using a factory if it's not already present
  45732. * @param key the unique key that identifies the data
  45733. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  45734. * @return the associated data, can be null if the factory returned null.
  45735. */
  45736. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  45737. /**
  45738. * Remove an externaly attached data from the Engine instance
  45739. * @param key the unique key that identifies the data
  45740. * @return true if the data was successfully removed, false if it doesn't exist
  45741. */
  45742. removeExternalData(key: string): boolean;
  45743. private _evaluateSubMesh;
  45744. /**
  45745. * Clear the processed materials smart array preventing retention point in material dispose.
  45746. */
  45747. freeProcessedMaterials(): void;
  45748. private _preventFreeActiveMeshesAndRenderingGroups;
  45749. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  45750. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  45751. * when disposing several meshes in a row or a hierarchy of meshes.
  45752. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  45753. */
  45754. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  45755. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  45756. /**
  45757. * Clear the active meshes smart array preventing retention point in mesh dispose.
  45758. */
  45759. freeActiveMeshes(): void;
  45760. /**
  45761. * Clear the info related to rendering groups preventing retention points during dispose.
  45762. */
  45763. freeRenderingGroups(): void;
  45764. /** @hidden */
  45765. _isInIntermediateRendering(): boolean;
  45766. /**
  45767. * Lambda returning the list of potentially active meshes.
  45768. */
  45769. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  45770. /**
  45771. * Lambda returning the list of potentially active sub meshes.
  45772. */
  45773. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  45774. /**
  45775. * Lambda returning the list of potentially intersecting sub meshes.
  45776. */
  45777. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  45778. /**
  45779. * Lambda returning the list of potentially colliding sub meshes.
  45780. */
  45781. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  45782. private _activeMeshesFrozen;
  45783. private _skipEvaluateActiveMeshesCompletely;
  45784. /**
  45785. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  45786. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  45787. * @param onSuccess optional success callback
  45788. * @param onError optional error callback
  45789. * @returns the current scene
  45790. */
  45791. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  45792. /**
  45793. * Use this function to restart evaluating active meshes on every frame
  45794. * @returns the current scene
  45795. */
  45796. unfreezeActiveMeshes(): Scene;
  45797. private _evaluateActiveMeshes;
  45798. private _activeMesh;
  45799. /**
  45800. * Update the transform matrix to update from the current active camera
  45801. * @param force defines a boolean used to force the update even if cache is up to date
  45802. */
  45803. updateTransformMatrix(force?: boolean): void;
  45804. private _bindFrameBuffer;
  45805. /** @hidden */
  45806. _allowPostProcessClearColor: boolean;
  45807. /** @hidden */
  45808. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  45809. private _processSubCameras;
  45810. private _checkIntersections;
  45811. /** @hidden */
  45812. _advancePhysicsEngineStep(step: number): void;
  45813. /**
  45814. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  45815. */
  45816. getDeterministicFrameTime: () => number;
  45817. /** @hidden */
  45818. _animate(): void;
  45819. /** Execute all animations (for a frame) */
  45820. animate(): void;
  45821. /**
  45822. * Render the scene
  45823. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  45824. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  45825. */
  45826. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  45827. /**
  45828. * Freeze all materials
  45829. * A frozen material will not be updatable but should be faster to render
  45830. */
  45831. freezeMaterials(): void;
  45832. /**
  45833. * Unfreeze all materials
  45834. * A frozen material will not be updatable but should be faster to render
  45835. */
  45836. unfreezeMaterials(): void;
  45837. /**
  45838. * Releases all held ressources
  45839. */
  45840. dispose(): void;
  45841. /**
  45842. * Gets if the scene is already disposed
  45843. */
  45844. get isDisposed(): boolean;
  45845. /**
  45846. * Call this function to reduce memory footprint of the scene.
  45847. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  45848. */
  45849. clearCachedVertexData(): void;
  45850. /**
  45851. * This function will remove the local cached buffer data from texture.
  45852. * It will save memory but will prevent the texture from being rebuilt
  45853. */
  45854. cleanCachedTextureBuffer(): void;
  45855. /**
  45856. * Get the world extend vectors with an optional filter
  45857. *
  45858. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  45859. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  45860. */
  45861. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  45862. min: Vector3;
  45863. max: Vector3;
  45864. };
  45865. /**
  45866. * Creates a ray that can be used to pick in the scene
  45867. * @param x defines the x coordinate of the origin (on-screen)
  45868. * @param y defines the y coordinate of the origin (on-screen)
  45869. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45870. * @param camera defines the camera to use for the picking
  45871. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45872. * @returns a Ray
  45873. */
  45874. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  45875. /**
  45876. * Creates a ray that can be used to pick in the scene
  45877. * @param x defines the x coordinate of the origin (on-screen)
  45878. * @param y defines the y coordinate of the origin (on-screen)
  45879. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45880. * @param result defines the ray where to store the picking ray
  45881. * @param camera defines the camera to use for the picking
  45882. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45883. * @returns the current scene
  45884. */
  45885. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  45886. /**
  45887. * Creates a ray that can be used to pick in the scene
  45888. * @param x defines the x coordinate of the origin (on-screen)
  45889. * @param y defines the y coordinate of the origin (on-screen)
  45890. * @param camera defines the camera to use for the picking
  45891. * @returns a Ray
  45892. */
  45893. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  45894. /**
  45895. * Creates a ray that can be used to pick in the scene
  45896. * @param x defines the x coordinate of the origin (on-screen)
  45897. * @param y defines the y coordinate of the origin (on-screen)
  45898. * @param result defines the ray where to store the picking ray
  45899. * @param camera defines the camera to use for the picking
  45900. * @returns the current scene
  45901. */
  45902. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  45903. /** Launch a ray to try to pick a mesh in the scene
  45904. * @param x position on screen
  45905. * @param y position on screen
  45906. * @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
  45907. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45908. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45909. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45910. * @returns a PickingInfo
  45911. */
  45912. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45913. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  45914. * @param x position on screen
  45915. * @param y position on screen
  45916. * @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
  45917. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45918. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45919. * @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)
  45920. */
  45921. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  45922. /** Use the given ray to pick a mesh in the scene
  45923. * @param ray The ray to use to pick meshes
  45924. * @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
  45925. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45926. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45927. * @returns a PickingInfo
  45928. */
  45929. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45930. /**
  45931. * Launch a ray to try to pick a mesh in the scene
  45932. * @param x X position on screen
  45933. * @param y Y position on screen
  45934. * @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
  45935. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45936. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45937. * @returns an array of PickingInfo
  45938. */
  45939. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45940. /**
  45941. * Launch a ray to try to pick a mesh in the scene
  45942. * @param ray Ray to use
  45943. * @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
  45944. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45945. * @returns an array of PickingInfo
  45946. */
  45947. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45948. /**
  45949. * Force the value of meshUnderPointer
  45950. * @param mesh defines the mesh to use
  45951. * @param pointerId optional pointer id when using more than one pointer
  45952. */
  45953. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45954. /**
  45955. * Gets the mesh under the pointer
  45956. * @returns a Mesh or null if no mesh is under the pointer
  45957. */
  45958. getPointerOverMesh(): Nullable<AbstractMesh>;
  45959. /** @hidden */
  45960. _rebuildGeometries(): void;
  45961. /** @hidden */
  45962. _rebuildTextures(): void;
  45963. private _getByTags;
  45964. /**
  45965. * Get a list of meshes by tags
  45966. * @param tagsQuery defines the tags query to use
  45967. * @param forEach defines a predicate used to filter results
  45968. * @returns an array of Mesh
  45969. */
  45970. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  45971. /**
  45972. * Get a list of cameras by tags
  45973. * @param tagsQuery defines the tags query to use
  45974. * @param forEach defines a predicate used to filter results
  45975. * @returns an array of Camera
  45976. */
  45977. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  45978. /**
  45979. * Get a list of lights by tags
  45980. * @param tagsQuery defines the tags query to use
  45981. * @param forEach defines a predicate used to filter results
  45982. * @returns an array of Light
  45983. */
  45984. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  45985. /**
  45986. * Get a list of materials by tags
  45987. * @param tagsQuery defines the tags query to use
  45988. * @param forEach defines a predicate used to filter results
  45989. * @returns an array of Material
  45990. */
  45991. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  45992. /**
  45993. * Get a list of transform nodes by tags
  45994. * @param tagsQuery defines the tags query to use
  45995. * @param forEach defines a predicate used to filter results
  45996. * @returns an array of TransformNode
  45997. */
  45998. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  45999. /**
  46000. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  46001. * This allowed control for front to back rendering or reversly depending of the special needs.
  46002. *
  46003. * @param renderingGroupId The rendering group id corresponding to its index
  46004. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  46005. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  46006. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  46007. */
  46008. 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;
  46009. /**
  46010. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  46011. *
  46012. * @param renderingGroupId The rendering group id corresponding to its index
  46013. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  46014. * @param depth Automatically clears depth between groups if true and autoClear is true.
  46015. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  46016. */
  46017. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  46018. /**
  46019. * Gets the current auto clear configuration for one rendering group of the rendering
  46020. * manager.
  46021. * @param index the rendering group index to get the information for
  46022. * @returns The auto clear setup for the requested rendering group
  46023. */
  46024. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  46025. private _blockMaterialDirtyMechanism;
  46026. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  46027. get blockMaterialDirtyMechanism(): boolean;
  46028. set blockMaterialDirtyMechanism(value: boolean);
  46029. /**
  46030. * Will flag all materials as dirty to trigger new shader compilation
  46031. * @param flag defines the flag used to specify which material part must be marked as dirty
  46032. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  46033. */
  46034. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  46035. /** @hidden */
  46036. _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;
  46037. /** @hidden */
  46038. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46039. /** @hidden */
  46040. _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;
  46041. /** @hidden */
  46042. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  46043. /** @hidden */
  46044. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  46045. /** @hidden */
  46046. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46047. }
  46048. }
  46049. declare module "babylonjs/assetContainer" {
  46050. import { AbstractScene } from "babylonjs/abstractScene";
  46051. import { Scene } from "babylonjs/scene";
  46052. import { Mesh } from "babylonjs/Meshes/mesh";
  46053. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46054. import { Skeleton } from "babylonjs/Bones/skeleton";
  46055. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46056. import { Animatable } from "babylonjs/Animations/animatable";
  46057. import { Nullable } from "babylonjs/types";
  46058. import { Node } from "babylonjs/node";
  46059. /**
  46060. * Set of assets to keep when moving a scene into an asset container.
  46061. */
  46062. export class KeepAssets extends AbstractScene {
  46063. }
  46064. /**
  46065. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  46066. */
  46067. export class InstantiatedEntries {
  46068. /**
  46069. * List of new root nodes (eg. nodes with no parent)
  46070. */
  46071. rootNodes: TransformNode[];
  46072. /**
  46073. * List of new skeletons
  46074. */
  46075. skeletons: Skeleton[];
  46076. /**
  46077. * List of new animation groups
  46078. */
  46079. animationGroups: AnimationGroup[];
  46080. }
  46081. /**
  46082. * Container with a set of assets that can be added or removed from a scene.
  46083. */
  46084. export class AssetContainer extends AbstractScene {
  46085. private _wasAddedToScene;
  46086. /**
  46087. * The scene the AssetContainer belongs to.
  46088. */
  46089. scene: Scene;
  46090. /**
  46091. * Instantiates an AssetContainer.
  46092. * @param scene The scene the AssetContainer belongs to.
  46093. */
  46094. constructor(scene: Scene);
  46095. /**
  46096. * Instantiate or clone all meshes and add the new ones to the scene.
  46097. * Skeletons and animation groups will all be cloned
  46098. * @param nameFunction defines an optional function used to get new names for clones
  46099. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  46100. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  46101. */
  46102. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  46103. /**
  46104. * Adds all the assets from the container to the scene.
  46105. */
  46106. addAllToScene(): void;
  46107. /**
  46108. * Removes all the assets in the container from the scene
  46109. */
  46110. removeAllFromScene(): void;
  46111. /**
  46112. * Disposes all the assets in the container
  46113. */
  46114. dispose(): void;
  46115. private _moveAssets;
  46116. /**
  46117. * Removes all the assets contained in the scene and adds them to the container.
  46118. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  46119. */
  46120. moveAllFromScene(keepAssets?: KeepAssets): void;
  46121. /**
  46122. * 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.
  46123. * @returns the root mesh
  46124. */
  46125. createRootMesh(): Mesh;
  46126. /**
  46127. * Merge animations (direct and animation groups) from this asset container into a scene
  46128. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46129. * @param animatables set of animatables to retarget to a node from the scene
  46130. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  46131. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  46132. */
  46133. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  46134. }
  46135. }
  46136. declare module "babylonjs/abstractScene" {
  46137. import { Scene } from "babylonjs/scene";
  46138. import { Nullable } from "babylonjs/types";
  46139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46140. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46141. import { Geometry } from "babylonjs/Meshes/geometry";
  46142. import { Skeleton } from "babylonjs/Bones/skeleton";
  46143. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  46144. import { AssetContainer } from "babylonjs/assetContainer";
  46145. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  46146. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46147. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46148. import { Material } from "babylonjs/Materials/material";
  46149. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  46150. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  46151. import { Camera } from "babylonjs/Cameras/camera";
  46152. import { Light } from "babylonjs/Lights/light";
  46153. import { Node } from "babylonjs/node";
  46154. import { Animation } from "babylonjs/Animations/animation";
  46155. /**
  46156. * Defines how the parser contract is defined.
  46157. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  46158. */
  46159. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  46160. /**
  46161. * Defines how the individual parser contract is defined.
  46162. * These parser can parse an individual asset
  46163. */
  46164. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  46165. /**
  46166. * Base class of the scene acting as a container for the different elements composing a scene.
  46167. * This class is dynamically extended by the different components of the scene increasing
  46168. * flexibility and reducing coupling
  46169. */
  46170. export abstract class AbstractScene {
  46171. /**
  46172. * Stores the list of available parsers in the application.
  46173. */
  46174. private static _BabylonFileParsers;
  46175. /**
  46176. * Stores the list of available individual parsers in the application.
  46177. */
  46178. private static _IndividualBabylonFileParsers;
  46179. /**
  46180. * Adds a parser in the list of available ones
  46181. * @param name Defines the name of the parser
  46182. * @param parser Defines the parser to add
  46183. */
  46184. static AddParser(name: string, parser: BabylonFileParser): void;
  46185. /**
  46186. * Gets a general parser from the list of avaialble ones
  46187. * @param name Defines the name of the parser
  46188. * @returns the requested parser or null
  46189. */
  46190. static GetParser(name: string): Nullable<BabylonFileParser>;
  46191. /**
  46192. * Adds n individual parser in the list of available ones
  46193. * @param name Defines the name of the parser
  46194. * @param parser Defines the parser to add
  46195. */
  46196. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  46197. /**
  46198. * Gets an individual parser from the list of avaialble ones
  46199. * @param name Defines the name of the parser
  46200. * @returns the requested parser or null
  46201. */
  46202. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  46203. /**
  46204. * Parser json data and populate both a scene and its associated container object
  46205. * @param jsonData Defines the data to parse
  46206. * @param scene Defines the scene to parse the data for
  46207. * @param container Defines the container attached to the parsing sequence
  46208. * @param rootUrl Defines the root url of the data
  46209. */
  46210. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  46211. /**
  46212. * Gets the list of root nodes (ie. nodes with no parent)
  46213. */
  46214. rootNodes: Node[];
  46215. /** All of the cameras added to this scene
  46216. * @see https://doc.babylonjs.com/babylon101/cameras
  46217. */
  46218. cameras: Camera[];
  46219. /**
  46220. * All of the lights added to this scene
  46221. * @see https://doc.babylonjs.com/babylon101/lights
  46222. */
  46223. lights: Light[];
  46224. /**
  46225. * All of the (abstract) meshes added to this scene
  46226. */
  46227. meshes: AbstractMesh[];
  46228. /**
  46229. * The list of skeletons added to the scene
  46230. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  46231. */
  46232. skeletons: Skeleton[];
  46233. /**
  46234. * All of the particle systems added to this scene
  46235. * @see https://doc.babylonjs.com/babylon101/particles
  46236. */
  46237. particleSystems: IParticleSystem[];
  46238. /**
  46239. * Gets a list of Animations associated with the scene
  46240. */
  46241. animations: Animation[];
  46242. /**
  46243. * All of the animation groups added to this scene
  46244. * @see https://doc.babylonjs.com/how_to/group
  46245. */
  46246. animationGroups: AnimationGroup[];
  46247. /**
  46248. * All of the multi-materials added to this scene
  46249. * @see https://doc.babylonjs.com/how_to/multi_materials
  46250. */
  46251. multiMaterials: MultiMaterial[];
  46252. /**
  46253. * All of the materials added to this scene
  46254. * In the context of a Scene, it is not supposed to be modified manually.
  46255. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  46256. * Note also that the order of the Material within the array is not significant and might change.
  46257. * @see https://doc.babylonjs.com/babylon101/materials
  46258. */
  46259. materials: Material[];
  46260. /**
  46261. * The list of morph target managers added to the scene
  46262. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  46263. */
  46264. morphTargetManagers: MorphTargetManager[];
  46265. /**
  46266. * The list of geometries used in the scene.
  46267. */
  46268. geometries: Geometry[];
  46269. /**
  46270. * All of the tranform nodes added to this scene
  46271. * In the context of a Scene, it is not supposed to be modified manually.
  46272. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  46273. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  46274. * @see https://doc.babylonjs.com/how_to/transformnode
  46275. */
  46276. transformNodes: TransformNode[];
  46277. /**
  46278. * ActionManagers available on the scene.
  46279. */
  46280. actionManagers: AbstractActionManager[];
  46281. /**
  46282. * Textures to keep.
  46283. */
  46284. textures: BaseTexture[];
  46285. /** @hidden */
  46286. protected _environmentTexture: Nullable<BaseTexture>;
  46287. /**
  46288. * Texture used in all pbr material as the reflection texture.
  46289. * As in the majority of the scene they are the same (exception for multi room and so on),
  46290. * this is easier to reference from here than from all the materials.
  46291. */
  46292. get environmentTexture(): Nullable<BaseTexture>;
  46293. set environmentTexture(value: Nullable<BaseTexture>);
  46294. /**
  46295. * The list of postprocesses added to the scene
  46296. */
  46297. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46298. /**
  46299. * @returns all meshes, lights, cameras, transformNodes and bones
  46300. */
  46301. getNodes(): Array<Node>;
  46302. }
  46303. }
  46304. declare module "babylonjs/Audio/Interfaces/ISoundOptions" {
  46305. /**
  46306. * Interface used to define options for Sound class
  46307. */
  46308. export interface ISoundOptions {
  46309. /**
  46310. * Does the sound autoplay once loaded.
  46311. */
  46312. autoplay?: boolean;
  46313. /**
  46314. * Does the sound loop after it finishes playing once.
  46315. */
  46316. loop?: boolean;
  46317. /**
  46318. * Sound's volume
  46319. */
  46320. volume?: number;
  46321. /**
  46322. * Is it a spatial sound?
  46323. */
  46324. spatialSound?: boolean;
  46325. /**
  46326. * Maximum distance to hear that sound
  46327. */
  46328. maxDistance?: number;
  46329. /**
  46330. * Uses user defined attenuation function
  46331. */
  46332. useCustomAttenuation?: boolean;
  46333. /**
  46334. * Define the roll off factor of spatial sounds.
  46335. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46336. */
  46337. rolloffFactor?: number;
  46338. /**
  46339. * Define the reference distance the sound should be heard perfectly.
  46340. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46341. */
  46342. refDistance?: number;
  46343. /**
  46344. * Define the distance attenuation model the sound will follow.
  46345. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46346. */
  46347. distanceModel?: string;
  46348. /**
  46349. * Defines the playback speed (1 by default)
  46350. */
  46351. playbackRate?: number;
  46352. /**
  46353. * Defines if the sound is from a streaming source
  46354. */
  46355. streaming?: boolean;
  46356. /**
  46357. * Defines an optional length (in seconds) inside the sound file
  46358. */
  46359. length?: number;
  46360. /**
  46361. * Defines an optional offset (in seconds) inside the sound file
  46362. */
  46363. offset?: number;
  46364. /**
  46365. * If true, URLs will not be required to state the audio file codec to use.
  46366. */
  46367. skipCodecCheck?: boolean;
  46368. }
  46369. }
  46370. declare module "babylonjs/Audio/sound" {
  46371. import { Observable } from "babylonjs/Misc/observable";
  46372. import { Vector3 } from "babylonjs/Maths/math.vector";
  46373. import { Nullable } from "babylonjs/types";
  46374. import { Scene } from "babylonjs/scene";
  46375. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46376. import { ISoundOptions } from "babylonjs/Audio/Interfaces/ISoundOptions";
  46377. /**
  46378. * Defines a sound that can be played in the application.
  46379. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46380. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46381. */
  46382. export class Sound {
  46383. /**
  46384. * The name of the sound in the scene.
  46385. */
  46386. name: string;
  46387. /**
  46388. * Does the sound autoplay once loaded.
  46389. */
  46390. autoplay: boolean;
  46391. /**
  46392. * Does the sound loop after it finishes playing once.
  46393. */
  46394. loop: boolean;
  46395. /**
  46396. * Does the sound use a custom attenuation curve to simulate the falloff
  46397. * happening when the source gets further away from the camera.
  46398. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46399. */
  46400. useCustomAttenuation: boolean;
  46401. /**
  46402. * The sound track id this sound belongs to.
  46403. */
  46404. soundTrackId: number;
  46405. /**
  46406. * Is this sound currently played.
  46407. */
  46408. isPlaying: boolean;
  46409. /**
  46410. * Is this sound currently paused.
  46411. */
  46412. isPaused: boolean;
  46413. /**
  46414. * Does this sound enables spatial sound.
  46415. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46416. */
  46417. spatialSound: boolean;
  46418. /**
  46419. * Define the reference distance the sound should be heard perfectly.
  46420. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46421. */
  46422. refDistance: number;
  46423. /**
  46424. * Define the roll off factor of spatial sounds.
  46425. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46426. */
  46427. rolloffFactor: number;
  46428. /**
  46429. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46430. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46431. */
  46432. maxDistance: number;
  46433. /**
  46434. * Define the distance attenuation model the sound will follow.
  46435. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46436. */
  46437. distanceModel: string;
  46438. /**
  46439. * @hidden
  46440. * Back Compat
  46441. **/
  46442. onended: () => any;
  46443. /**
  46444. * Gets or sets an object used to store user defined information for the sound.
  46445. */
  46446. metadata: any;
  46447. /**
  46448. * Observable event when the current playing sound finishes.
  46449. */
  46450. onEndedObservable: Observable<Sound>;
  46451. /**
  46452. * Gets the current time for the sound.
  46453. */
  46454. get currentTime(): number;
  46455. private _panningModel;
  46456. private _playbackRate;
  46457. private _streaming;
  46458. private _startTime;
  46459. private _startOffset;
  46460. private _position;
  46461. /** @hidden */
  46462. _positionInEmitterSpace: boolean;
  46463. private _localDirection;
  46464. private _volume;
  46465. private _isReadyToPlay;
  46466. private _isDirectional;
  46467. private _readyToPlayCallback;
  46468. private _audioBuffer;
  46469. private _soundSource;
  46470. private _streamingSource;
  46471. private _soundPanner;
  46472. private _soundGain;
  46473. private _inputAudioNode;
  46474. private _outputAudioNode;
  46475. private _coneInnerAngle;
  46476. private _coneOuterAngle;
  46477. private _coneOuterGain;
  46478. private _scene;
  46479. private _connectedTransformNode;
  46480. private _customAttenuationFunction;
  46481. private _registerFunc;
  46482. private _isOutputConnected;
  46483. private _htmlAudioElement;
  46484. private _urlType;
  46485. private _length?;
  46486. private _offset?;
  46487. /** @hidden */
  46488. static _SceneComponentInitialization: (scene: Scene) => void;
  46489. /**
  46490. * Create a sound and attach it to a scene
  46491. * @param name Name of your sound
  46492. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46493. * @param scene defines the scene the sound belongs to
  46494. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46495. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46496. */
  46497. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46498. /**
  46499. * Release the sound and its associated resources
  46500. */
  46501. dispose(): void;
  46502. /**
  46503. * Gets if the sounds is ready to be played or not.
  46504. * @returns true if ready, otherwise false
  46505. */
  46506. isReady(): boolean;
  46507. private _soundLoaded;
  46508. /**
  46509. * Sets the data of the sound from an audiobuffer
  46510. * @param audioBuffer The audioBuffer containing the data
  46511. */
  46512. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46513. /**
  46514. * Updates the current sounds options such as maxdistance, loop...
  46515. * @param options A JSON object containing values named as the object properties
  46516. */
  46517. updateOptions(options: ISoundOptions): void;
  46518. private _createSpatialParameters;
  46519. private _updateSpatialParameters;
  46520. /**
  46521. * Switch the panning model to HRTF:
  46522. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46523. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46524. */
  46525. switchPanningModelToHRTF(): void;
  46526. /**
  46527. * Switch the panning model to Equal Power:
  46528. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46529. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46530. */
  46531. switchPanningModelToEqualPower(): void;
  46532. private _switchPanningModel;
  46533. /**
  46534. * Connect this sound to a sound track audio node like gain...
  46535. * @param soundTrackAudioNode the sound track audio node to connect to
  46536. */
  46537. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46538. /**
  46539. * Transform this sound into a directional source
  46540. * @param coneInnerAngle Size of the inner cone in degree
  46541. * @param coneOuterAngle Size of the outer cone in degree
  46542. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46543. */
  46544. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46545. /**
  46546. * Gets or sets the inner angle for the directional cone.
  46547. */
  46548. get directionalConeInnerAngle(): number;
  46549. /**
  46550. * Gets or sets the inner angle for the directional cone.
  46551. */
  46552. set directionalConeInnerAngle(value: number);
  46553. /**
  46554. * Gets or sets the outer angle for the directional cone.
  46555. */
  46556. get directionalConeOuterAngle(): number;
  46557. /**
  46558. * Gets or sets the outer angle for the directional cone.
  46559. */
  46560. set directionalConeOuterAngle(value: number);
  46561. /**
  46562. * Sets the position of the emitter if spatial sound is enabled
  46563. * @param newPosition Defines the new posisiton
  46564. */
  46565. setPosition(newPosition: Vector3): void;
  46566. /**
  46567. * Sets the local direction of the emitter if spatial sound is enabled
  46568. * @param newLocalDirection Defines the new local direction
  46569. */
  46570. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46571. private _updateDirection;
  46572. /** @hidden */
  46573. updateDistanceFromListener(): void;
  46574. /**
  46575. * Sets a new custom attenuation function for the sound.
  46576. * @param callback Defines the function used for the attenuation
  46577. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46578. */
  46579. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46580. /**
  46581. * Play the sound
  46582. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46583. * @param offset (optional) Start the sound at a specific time in seconds
  46584. * @param length (optional) Sound duration (in seconds)
  46585. */
  46586. play(time?: number, offset?: number, length?: number): void;
  46587. private _onended;
  46588. /**
  46589. * Stop the sound
  46590. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46591. */
  46592. stop(time?: number): void;
  46593. /**
  46594. * Put the sound in pause
  46595. */
  46596. pause(): void;
  46597. /**
  46598. * Sets a dedicated volume for this sounds
  46599. * @param newVolume Define the new volume of the sound
  46600. * @param time Define time for gradual change to new volume
  46601. */
  46602. setVolume(newVolume: number, time?: number): void;
  46603. /**
  46604. * Set the sound play back rate
  46605. * @param newPlaybackRate Define the playback rate the sound should be played at
  46606. */
  46607. setPlaybackRate(newPlaybackRate: number): void;
  46608. /**
  46609. * Gets the volume of the sound.
  46610. * @returns the volume of the sound
  46611. */
  46612. getVolume(): number;
  46613. /**
  46614. * Attach the sound to a dedicated mesh
  46615. * @param transformNode The transform node to connect the sound with
  46616. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46617. */
  46618. attachToMesh(transformNode: TransformNode): void;
  46619. /**
  46620. * Detach the sound from the previously attached mesh
  46621. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46622. */
  46623. detachFromMesh(): void;
  46624. private _onRegisterAfterWorldMatrixUpdate;
  46625. /**
  46626. * Clone the current sound in the scene.
  46627. * @returns the new sound clone
  46628. */
  46629. clone(): Nullable<Sound>;
  46630. /**
  46631. * Gets the current underlying audio buffer containing the data
  46632. * @returns the audio buffer
  46633. */
  46634. getAudioBuffer(): Nullable<AudioBuffer>;
  46635. /**
  46636. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46637. * @returns the source node
  46638. */
  46639. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46640. /**
  46641. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46642. * @returns the gain node
  46643. */
  46644. getSoundGain(): Nullable<GainNode>;
  46645. /**
  46646. * Serializes the Sound in a JSON representation
  46647. * @returns the JSON representation of the sound
  46648. */
  46649. serialize(): any;
  46650. /**
  46651. * Parse a JSON representation of a sound to innstantiate in a given scene
  46652. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46653. * @param scene Define the scene the new parsed sound should be created in
  46654. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46655. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46656. * @returns the newly parsed sound
  46657. */
  46658. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46659. }
  46660. }
  46661. declare module "babylonjs/Actions/directAudioActions" {
  46662. import { Action } from "babylonjs/Actions/action";
  46663. import { Condition } from "babylonjs/Actions/condition";
  46664. import { Sound } from "babylonjs/Audio/sound";
  46665. /**
  46666. * This defines an action helpful to play a defined sound on a triggered action.
  46667. */
  46668. export class PlaySoundAction extends Action {
  46669. private _sound;
  46670. /**
  46671. * Instantiate the action
  46672. * @param triggerOptions defines the trigger options
  46673. * @param sound defines the sound to play
  46674. * @param condition defines the trigger related conditions
  46675. */
  46676. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46677. /** @hidden */
  46678. _prepare(): void;
  46679. /**
  46680. * Execute the action and play the sound.
  46681. */
  46682. execute(): void;
  46683. /**
  46684. * Serializes the actions and its related information.
  46685. * @param parent defines the object to serialize in
  46686. * @returns the serialized object
  46687. */
  46688. serialize(parent: any): any;
  46689. }
  46690. /**
  46691. * This defines an action helpful to stop a defined sound on a triggered action.
  46692. */
  46693. export class StopSoundAction extends Action {
  46694. private _sound;
  46695. /**
  46696. * Instantiate the action
  46697. * @param triggerOptions defines the trigger options
  46698. * @param sound defines the sound to stop
  46699. * @param condition defines the trigger related conditions
  46700. */
  46701. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46702. /** @hidden */
  46703. _prepare(): void;
  46704. /**
  46705. * Execute the action and stop the sound.
  46706. */
  46707. execute(): void;
  46708. /**
  46709. * Serializes the actions and its related information.
  46710. * @param parent defines the object to serialize in
  46711. * @returns the serialized object
  46712. */
  46713. serialize(parent: any): any;
  46714. }
  46715. }
  46716. declare module "babylonjs/Actions/interpolateValueAction" {
  46717. import { Action } from "babylonjs/Actions/action";
  46718. import { Condition } from "babylonjs/Actions/condition";
  46719. import { Observable } from "babylonjs/Misc/observable";
  46720. /**
  46721. * This defines an action responsible to change the value of a property
  46722. * by interpolating between its current value and the newly set one once triggered.
  46723. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46724. */
  46725. export class InterpolateValueAction extends Action {
  46726. /**
  46727. * Defines the path of the property where the value should be interpolated
  46728. */
  46729. propertyPath: string;
  46730. /**
  46731. * Defines the target value at the end of the interpolation.
  46732. */
  46733. value: any;
  46734. /**
  46735. * Defines the time it will take for the property to interpolate to the value.
  46736. */
  46737. duration: number;
  46738. /**
  46739. * Defines if the other scene animations should be stopped when the action has been triggered
  46740. */
  46741. stopOtherAnimations?: boolean;
  46742. /**
  46743. * Defines a callback raised once the interpolation animation has been done.
  46744. */
  46745. onInterpolationDone?: () => void;
  46746. /**
  46747. * Observable triggered once the interpolation animation has been done.
  46748. */
  46749. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  46750. private _target;
  46751. private _effectiveTarget;
  46752. private _property;
  46753. /**
  46754. * Instantiate the action
  46755. * @param triggerOptions defines the trigger options
  46756. * @param target defines the object containing the value to interpolate
  46757. * @param propertyPath defines the path to the property in the target object
  46758. * @param value defines the target value at the end of the interpolation
  46759. * @param duration deines the time it will take for the property to interpolate to the value.
  46760. * @param condition defines the trigger related conditions
  46761. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  46762. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  46763. */
  46764. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  46765. /** @hidden */
  46766. _prepare(): void;
  46767. /**
  46768. * Execute the action starts the value interpolation.
  46769. */
  46770. execute(): void;
  46771. /**
  46772. * Serializes the actions and its related information.
  46773. * @param parent defines the object to serialize in
  46774. * @returns the serialized object
  46775. */
  46776. serialize(parent: any): any;
  46777. }
  46778. }
  46779. declare module "babylonjs/Actions/index" {
  46780. export * from "babylonjs/Actions/abstractActionManager";
  46781. export * from "babylonjs/Actions/action";
  46782. export * from "babylonjs/Actions/actionEvent";
  46783. export * from "babylonjs/Actions/actionManager";
  46784. export * from "babylonjs/Actions/condition";
  46785. export * from "babylonjs/Actions/directActions";
  46786. export * from "babylonjs/Actions/directAudioActions";
  46787. export * from "babylonjs/Actions/interpolateValueAction";
  46788. }
  46789. declare module "babylonjs/Animations/index" {
  46790. export * from "babylonjs/Animations/animatable";
  46791. export * from "babylonjs/Animations/animation";
  46792. export * from "babylonjs/Animations/animationGroup";
  46793. export * from "babylonjs/Animations/animationPropertiesOverride";
  46794. export * from "babylonjs/Animations/easing";
  46795. export * from "babylonjs/Animations/runtimeAnimation";
  46796. export * from "babylonjs/Animations/animationEvent";
  46797. export * from "babylonjs/Animations/animationGroup";
  46798. export * from "babylonjs/Animations/animationKey";
  46799. export * from "babylonjs/Animations/animationRange";
  46800. export * from "babylonjs/Animations/animatable.interface";
  46801. }
  46802. declare module "babylonjs/Audio/audioEngine" {
  46803. import { Analyser } from "babylonjs/Audio/analyser";
  46804. import { Nullable } from "babylonjs/types";
  46805. import { Observable } from "babylonjs/Misc/observable";
  46806. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  46807. /**
  46808. * This represents the default audio engine used in babylon.
  46809. * It is responsible to play, synchronize and analyse sounds throughout the application.
  46810. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46811. */
  46812. export class AudioEngine implements IAudioEngine {
  46813. private _audioContext;
  46814. private _audioContextInitialized;
  46815. private _muteButton;
  46816. private _hostElement;
  46817. /**
  46818. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  46819. */
  46820. canUseWebAudio: boolean;
  46821. /**
  46822. * The master gain node defines the global audio volume of your audio engine.
  46823. */
  46824. masterGain: GainNode;
  46825. /**
  46826. * Defines if Babylon should emit a warning if WebAudio is not supported.
  46827. * @ignoreNaming
  46828. */
  46829. WarnedWebAudioUnsupported: boolean;
  46830. /**
  46831. * Gets whether or not mp3 are supported by your browser.
  46832. */
  46833. isMP3supported: boolean;
  46834. /**
  46835. * Gets whether or not ogg are supported by your browser.
  46836. */
  46837. isOGGsupported: boolean;
  46838. /**
  46839. * Gets whether audio has been unlocked on the device.
  46840. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  46841. * a user interaction has happened.
  46842. */
  46843. unlocked: boolean;
  46844. /**
  46845. * Defines if the audio engine relies on a custom unlocked button.
  46846. * In this case, the embedded button will not be displayed.
  46847. */
  46848. useCustomUnlockedButton: boolean;
  46849. /**
  46850. * Event raised when audio has been unlocked on the browser.
  46851. */
  46852. onAudioUnlockedObservable: Observable<IAudioEngine>;
  46853. /**
  46854. * Event raised when audio has been locked on the browser.
  46855. */
  46856. onAudioLockedObservable: Observable<IAudioEngine>;
  46857. /**
  46858. * Gets the current AudioContext if available.
  46859. */
  46860. get audioContext(): Nullable<AudioContext>;
  46861. private _connectedAnalyser;
  46862. /**
  46863. * Instantiates a new audio engine.
  46864. *
  46865. * There should be only one per page as some browsers restrict the number
  46866. * of audio contexts you can create.
  46867. * @param hostElement defines the host element where to display the mute icon if necessary
  46868. */
  46869. constructor(hostElement?: Nullable<HTMLElement>);
  46870. /**
  46871. * Flags the audio engine in Locked state.
  46872. * This happens due to new browser policies preventing audio to autoplay.
  46873. */
  46874. lock(): void;
  46875. /**
  46876. * Unlocks the audio engine once a user action has been done on the dom.
  46877. * This is helpful to resume play once browser policies have been satisfied.
  46878. */
  46879. unlock(): void;
  46880. private _resumeAudioContext;
  46881. private _initializeAudioContext;
  46882. private _tryToRun;
  46883. private _triggerRunningState;
  46884. private _triggerSuspendedState;
  46885. private _displayMuteButton;
  46886. private _moveButtonToTopLeft;
  46887. private _onResize;
  46888. private _hideMuteButton;
  46889. /**
  46890. * Destroy and release the resources associated with the audio ccontext.
  46891. */
  46892. dispose(): void;
  46893. /**
  46894. * Gets the global volume sets on the master gain.
  46895. * @returns the global volume if set or -1 otherwise
  46896. */
  46897. getGlobalVolume(): number;
  46898. /**
  46899. * Sets the global volume of your experience (sets on the master gain).
  46900. * @param newVolume Defines the new global volume of the application
  46901. */
  46902. setGlobalVolume(newVolume: number): void;
  46903. /**
  46904. * Connect the audio engine to an audio analyser allowing some amazing
  46905. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  46906. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  46907. * @param analyser The analyser to connect to the engine
  46908. */
  46909. connectToAnalyser(analyser: Analyser): void;
  46910. }
  46911. }
  46912. declare module "babylonjs/Audio/soundTrack" {
  46913. import { Sound } from "babylonjs/Audio/sound";
  46914. import { Analyser } from "babylonjs/Audio/analyser";
  46915. import { Scene } from "babylonjs/scene";
  46916. /**
  46917. * Options allowed during the creation of a sound track.
  46918. */
  46919. export interface ISoundTrackOptions {
  46920. /**
  46921. * The volume the sound track should take during creation
  46922. */
  46923. volume?: number;
  46924. /**
  46925. * Define if the sound track is the main sound track of the scene
  46926. */
  46927. mainTrack?: boolean;
  46928. }
  46929. /**
  46930. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  46931. * It will be also used in a future release to apply effects on a specific track.
  46932. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46933. */
  46934. export class SoundTrack {
  46935. /**
  46936. * The unique identifier of the sound track in the scene.
  46937. */
  46938. id: number;
  46939. /**
  46940. * The list of sounds included in the sound track.
  46941. */
  46942. soundCollection: Array<Sound>;
  46943. private _outputAudioNode;
  46944. private _scene;
  46945. private _connectedAnalyser;
  46946. private _options;
  46947. private _isInitialized;
  46948. /**
  46949. * Creates a new sound track.
  46950. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46951. * @param scene Define the scene the sound track belongs to
  46952. * @param options
  46953. */
  46954. constructor(scene: Scene, options?: ISoundTrackOptions);
  46955. private _initializeSoundTrackAudioGraph;
  46956. /**
  46957. * Release the sound track and its associated resources
  46958. */
  46959. dispose(): void;
  46960. /**
  46961. * Adds a sound to this sound track
  46962. * @param sound define the cound to add
  46963. * @ignoreNaming
  46964. */
  46965. addSound(sound: Sound): void;
  46966. /**
  46967. * Removes a sound to this sound track
  46968. * @param sound define the cound to remove
  46969. * @ignoreNaming
  46970. */
  46971. removeSound(sound: Sound): void;
  46972. /**
  46973. * Set a global volume for the full sound track.
  46974. * @param newVolume Define the new volume of the sound track
  46975. */
  46976. setVolume(newVolume: number): void;
  46977. /**
  46978. * Switch the panning model to HRTF:
  46979. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46980. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46981. */
  46982. switchPanningModelToHRTF(): void;
  46983. /**
  46984. * Switch the panning model to Equal Power:
  46985. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46986. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46987. */
  46988. switchPanningModelToEqualPower(): void;
  46989. /**
  46990. * Connect the sound track to an audio analyser allowing some amazing
  46991. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  46992. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  46993. * @param analyser The analyser to connect to the engine
  46994. */
  46995. connectToAnalyser(analyser: Analyser): void;
  46996. }
  46997. }
  46998. declare module "babylonjs/Audio/audioSceneComponent" {
  46999. import { Sound } from "babylonjs/Audio/sound";
  47000. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  47001. import { Nullable } from "babylonjs/types";
  47002. import { Vector3 } from "babylonjs/Maths/math.vector";
  47003. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47004. import { Scene } from "babylonjs/scene";
  47005. import { AbstractScene } from "babylonjs/abstractScene";
  47006. import "babylonjs/Audio/audioEngine";
  47007. module "babylonjs/abstractScene" {
  47008. interface AbstractScene {
  47009. /**
  47010. * The list of sounds used in the scene.
  47011. */
  47012. sounds: Nullable<Array<Sound>>;
  47013. }
  47014. }
  47015. module "babylonjs/scene" {
  47016. interface Scene {
  47017. /**
  47018. * @hidden
  47019. * Backing field
  47020. */
  47021. _mainSoundTrack: SoundTrack;
  47022. /**
  47023. * The main sound track played by the scene.
  47024. * It cotains your primary collection of sounds.
  47025. */
  47026. mainSoundTrack: SoundTrack;
  47027. /**
  47028. * The list of sound tracks added to the scene
  47029. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47030. */
  47031. soundTracks: Nullable<Array<SoundTrack>>;
  47032. /**
  47033. * Gets a sound using a given name
  47034. * @param name defines the name to search for
  47035. * @return the found sound or null if not found at all.
  47036. */
  47037. getSoundByName(name: string): Nullable<Sound>;
  47038. /**
  47039. * Gets or sets if audio support is enabled
  47040. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47041. */
  47042. audioEnabled: boolean;
  47043. /**
  47044. * Gets or sets if audio will be output to headphones
  47045. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47046. */
  47047. headphone: boolean;
  47048. /**
  47049. * Gets or sets custom audio listener position provider
  47050. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47051. */
  47052. audioListenerPositionProvider: Nullable<() => Vector3>;
  47053. /**
  47054. * Gets or sets a refresh rate when using 3D audio positioning
  47055. */
  47056. audioPositioningRefreshRate: number;
  47057. }
  47058. }
  47059. /**
  47060. * Defines the sound scene component responsible to manage any sounds
  47061. * in a given scene.
  47062. */
  47063. export class AudioSceneComponent implements ISceneSerializableComponent {
  47064. private static _CameraDirectionLH;
  47065. private static _CameraDirectionRH;
  47066. /**
  47067. * The component name helpfull to identify the component in the list of scene components.
  47068. */
  47069. readonly name: string;
  47070. /**
  47071. * The scene the component belongs to.
  47072. */
  47073. scene: Scene;
  47074. private _audioEnabled;
  47075. /**
  47076. * Gets whether audio is enabled or not.
  47077. * Please use related enable/disable method to switch state.
  47078. */
  47079. get audioEnabled(): boolean;
  47080. private _headphone;
  47081. /**
  47082. * Gets whether audio is outputing to headphone or not.
  47083. * Please use the according Switch methods to change output.
  47084. */
  47085. get headphone(): boolean;
  47086. /**
  47087. * Gets or sets a refresh rate when using 3D audio positioning
  47088. */
  47089. audioPositioningRefreshRate: number;
  47090. private _audioListenerPositionProvider;
  47091. /**
  47092. * Gets the current audio listener position provider
  47093. */
  47094. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  47095. /**
  47096. * Sets a custom listener position for all sounds in the scene
  47097. * By default, this is the position of the first active camera
  47098. */
  47099. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  47100. /**
  47101. * Creates a new instance of the component for the given scene
  47102. * @param scene Defines the scene to register the component in
  47103. */
  47104. constructor(scene: Scene);
  47105. /**
  47106. * Registers the component in a given scene
  47107. */
  47108. register(): void;
  47109. /**
  47110. * Rebuilds the elements related to this component in case of
  47111. * context lost for instance.
  47112. */
  47113. rebuild(): void;
  47114. /**
  47115. * Serializes the component data to the specified json object
  47116. * @param serializationObject The object to serialize to
  47117. */
  47118. serialize(serializationObject: any): void;
  47119. /**
  47120. * Adds all the elements from the container to the scene
  47121. * @param container the container holding the elements
  47122. */
  47123. addFromContainer(container: AbstractScene): void;
  47124. /**
  47125. * Removes all the elements in the container from the scene
  47126. * @param container contains the elements to remove
  47127. * @param dispose if the removed element should be disposed (default: false)
  47128. */
  47129. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47130. /**
  47131. * Disposes the component and the associated ressources.
  47132. */
  47133. dispose(): void;
  47134. /**
  47135. * Disables audio in the associated scene.
  47136. */
  47137. disableAudio(): void;
  47138. /**
  47139. * Enables audio in the associated scene.
  47140. */
  47141. enableAudio(): void;
  47142. /**
  47143. * Switch audio to headphone output.
  47144. */
  47145. switchAudioModeForHeadphones(): void;
  47146. /**
  47147. * Switch audio to normal speakers.
  47148. */
  47149. switchAudioModeForNormalSpeakers(): void;
  47150. private _cachedCameraDirection;
  47151. private _cachedCameraPosition;
  47152. private _lastCheck;
  47153. private _afterRender;
  47154. }
  47155. }
  47156. declare module "babylonjs/Audio/weightedsound" {
  47157. import { Sound } from "babylonjs/Audio/sound";
  47158. /**
  47159. * Wraps one or more Sound objects and selects one with random weight for playback.
  47160. */
  47161. export class WeightedSound {
  47162. /** When true a Sound will be selected and played when the current playing Sound completes. */
  47163. loop: boolean;
  47164. private _coneInnerAngle;
  47165. private _coneOuterAngle;
  47166. private _volume;
  47167. /** A Sound is currently playing. */
  47168. isPlaying: boolean;
  47169. /** A Sound is currently paused. */
  47170. isPaused: boolean;
  47171. private _sounds;
  47172. private _weights;
  47173. private _currentIndex?;
  47174. /**
  47175. * Creates a new WeightedSound from the list of sounds given.
  47176. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  47177. * @param sounds Array of Sounds that will be selected from.
  47178. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  47179. */
  47180. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  47181. /**
  47182. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  47183. */
  47184. get directionalConeInnerAngle(): number;
  47185. /**
  47186. * The size of cone in degress for a directional sound in which there will be no attenuation.
  47187. */
  47188. set directionalConeInnerAngle(value: number);
  47189. /**
  47190. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47191. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47192. */
  47193. get directionalConeOuterAngle(): number;
  47194. /**
  47195. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47196. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47197. */
  47198. set directionalConeOuterAngle(value: number);
  47199. /**
  47200. * Playback volume.
  47201. */
  47202. get volume(): number;
  47203. /**
  47204. * Playback volume.
  47205. */
  47206. set volume(value: number);
  47207. private _onended;
  47208. /**
  47209. * Suspend playback
  47210. */
  47211. pause(): void;
  47212. /**
  47213. * Stop playback
  47214. */
  47215. stop(): void;
  47216. /**
  47217. * Start playback.
  47218. * @param startOffset Position the clip head at a specific time in seconds.
  47219. */
  47220. play(startOffset?: number): void;
  47221. }
  47222. }
  47223. declare module "babylonjs/Audio/index" {
  47224. export * from "babylonjs/Audio/Interfaces/IAudioEngine";
  47225. export * from "babylonjs/Audio/Interfaces/ISoundOptions";
  47226. export * from "babylonjs/Audio/analyser";
  47227. export * from "babylonjs/Audio/audioEngine";
  47228. export * from "babylonjs/Audio/audioSceneComponent";
  47229. export * from "babylonjs/Audio/sound";
  47230. export * from "babylonjs/Audio/soundTrack";
  47231. export * from "babylonjs/Audio/weightedsound";
  47232. }
  47233. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  47234. import { Behavior } from "babylonjs/Behaviors/behavior";
  47235. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47236. import { BackEase } from "babylonjs/Animations/easing";
  47237. /**
  47238. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  47239. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47240. */
  47241. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  47242. /**
  47243. * Gets the name of the behavior.
  47244. */
  47245. get name(): string;
  47246. /**
  47247. * The easing function used by animations
  47248. */
  47249. static EasingFunction: BackEase;
  47250. /**
  47251. * The easing mode used by animations
  47252. */
  47253. static EasingMode: number;
  47254. /**
  47255. * The duration of the animation, in milliseconds
  47256. */
  47257. transitionDuration: number;
  47258. /**
  47259. * Length of the distance animated by the transition when lower radius is reached
  47260. */
  47261. lowerRadiusTransitionRange: number;
  47262. /**
  47263. * Length of the distance animated by the transition when upper radius is reached
  47264. */
  47265. upperRadiusTransitionRange: number;
  47266. private _autoTransitionRange;
  47267. /**
  47268. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47269. */
  47270. get autoTransitionRange(): boolean;
  47271. /**
  47272. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47273. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  47274. */
  47275. set autoTransitionRange(value: boolean);
  47276. private _attachedCamera;
  47277. private _onAfterCheckInputsObserver;
  47278. private _onMeshTargetChangedObserver;
  47279. /**
  47280. * Initializes the behavior.
  47281. */
  47282. init(): void;
  47283. /**
  47284. * Attaches the behavior to its arc rotate camera.
  47285. * @param camera Defines the camera to attach the behavior to
  47286. */
  47287. attach(camera: ArcRotateCamera): void;
  47288. /**
  47289. * Detaches the behavior from its current arc rotate camera.
  47290. */
  47291. detach(): void;
  47292. private _radiusIsAnimating;
  47293. private _radiusBounceTransition;
  47294. private _animatables;
  47295. private _cachedWheelPrecision;
  47296. /**
  47297. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  47298. * @param radiusLimit The limit to check against.
  47299. * @return Bool to indicate if at limit.
  47300. */
  47301. private _isRadiusAtLimit;
  47302. /**
  47303. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  47304. * @param radiusDelta The delta by which to animate to. Can be negative.
  47305. */
  47306. private _applyBoundRadiusAnimation;
  47307. /**
  47308. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  47309. */
  47310. protected _clearAnimationLocks(): void;
  47311. /**
  47312. * Stops and removes all animations that have been applied to the camera
  47313. */
  47314. stopAllAnimations(): void;
  47315. }
  47316. }
  47317. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  47318. import { Behavior } from "babylonjs/Behaviors/behavior";
  47319. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47320. import { ExponentialEase } from "babylonjs/Animations/easing";
  47321. import { Nullable } from "babylonjs/types";
  47322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47323. import { Vector3 } from "babylonjs/Maths/math.vector";
  47324. /**
  47325. * 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.
  47326. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47327. */
  47328. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  47329. /**
  47330. * Gets the name of the behavior.
  47331. */
  47332. get name(): string;
  47333. private _mode;
  47334. private _radiusScale;
  47335. private _positionScale;
  47336. private _defaultElevation;
  47337. private _elevationReturnTime;
  47338. private _elevationReturnWaitTime;
  47339. private _zoomStopsAnimation;
  47340. private _framingTime;
  47341. /**
  47342. * The easing function used by animations
  47343. */
  47344. static EasingFunction: ExponentialEase;
  47345. /**
  47346. * The easing mode used by animations
  47347. */
  47348. static EasingMode: number;
  47349. /**
  47350. * Sets the current mode used by the behavior
  47351. */
  47352. set mode(mode: number);
  47353. /**
  47354. * Gets current mode used by the behavior.
  47355. */
  47356. get mode(): number;
  47357. /**
  47358. * Sets the scale applied to the radius (1 by default)
  47359. */
  47360. set radiusScale(radius: number);
  47361. /**
  47362. * Gets the scale applied to the radius
  47363. */
  47364. get radiusScale(): number;
  47365. /**
  47366. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47367. */
  47368. set positionScale(scale: number);
  47369. /**
  47370. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47371. */
  47372. get positionScale(): number;
  47373. /**
  47374. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47375. * behaviour is triggered, in radians.
  47376. */
  47377. set defaultElevation(elevation: number);
  47378. /**
  47379. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47380. * behaviour is triggered, in radians.
  47381. */
  47382. get defaultElevation(): number;
  47383. /**
  47384. * Sets the time (in milliseconds) taken to return to the default beta position.
  47385. * Negative value indicates camera should not return to default.
  47386. */
  47387. set elevationReturnTime(speed: number);
  47388. /**
  47389. * Gets the time (in milliseconds) taken to return to the default beta position.
  47390. * Negative value indicates camera should not return to default.
  47391. */
  47392. get elevationReturnTime(): number;
  47393. /**
  47394. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47395. */
  47396. set elevationReturnWaitTime(time: number);
  47397. /**
  47398. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47399. */
  47400. get elevationReturnWaitTime(): number;
  47401. /**
  47402. * Sets the flag that indicates if user zooming should stop animation.
  47403. */
  47404. set zoomStopsAnimation(flag: boolean);
  47405. /**
  47406. * Gets the flag that indicates if user zooming should stop animation.
  47407. */
  47408. get zoomStopsAnimation(): boolean;
  47409. /**
  47410. * Sets the transition time when framing the mesh, in milliseconds
  47411. */
  47412. set framingTime(time: number);
  47413. /**
  47414. * Gets the transition time when framing the mesh, in milliseconds
  47415. */
  47416. get framingTime(): number;
  47417. /**
  47418. * Define if the behavior should automatically change the configured
  47419. * camera limits and sensibilities.
  47420. */
  47421. autoCorrectCameraLimitsAndSensibility: boolean;
  47422. private _onPrePointerObservableObserver;
  47423. private _onAfterCheckInputsObserver;
  47424. private _onMeshTargetChangedObserver;
  47425. private _attachedCamera;
  47426. private _isPointerDown;
  47427. private _lastInteractionTime;
  47428. /**
  47429. * Initializes the behavior.
  47430. */
  47431. init(): void;
  47432. /**
  47433. * Attaches the behavior to its arc rotate camera.
  47434. * @param camera Defines the camera to attach the behavior to
  47435. */
  47436. attach(camera: ArcRotateCamera): void;
  47437. /**
  47438. * Detaches the behavior from its current arc rotate camera.
  47439. */
  47440. detach(): void;
  47441. private _animatables;
  47442. private _betaIsAnimating;
  47443. private _betaTransition;
  47444. private _radiusTransition;
  47445. private _vectorTransition;
  47446. /**
  47447. * Targets the given mesh and updates zoom level accordingly.
  47448. * @param mesh The mesh to target.
  47449. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47450. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47451. */
  47452. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47453. /**
  47454. * Targets the given mesh with its children and updates zoom level accordingly.
  47455. * @param mesh The mesh to target.
  47456. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47457. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47458. */
  47459. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47460. /**
  47461. * Targets the given meshes with their children and updates zoom level accordingly.
  47462. * @param meshes The mesh to target.
  47463. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47464. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47465. */
  47466. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47467. /**
  47468. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47469. * @param minimumWorld Determines the smaller position of the bounding box extend
  47470. * @param maximumWorld Determines the bigger position of the bounding box extend
  47471. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47472. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47473. */
  47474. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47475. /**
  47476. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47477. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47478. * frustum width.
  47479. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47480. * to fully enclose the mesh in the viewing frustum.
  47481. */
  47482. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47483. /**
  47484. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47485. * is automatically returned to its default position (expected to be above ground plane).
  47486. */
  47487. private _maintainCameraAboveGround;
  47488. /**
  47489. * Returns the frustum slope based on the canvas ratio and camera FOV
  47490. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47491. */
  47492. private _getFrustumSlope;
  47493. /**
  47494. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47495. */
  47496. private _clearAnimationLocks;
  47497. /**
  47498. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47499. */
  47500. private _applyUserInteraction;
  47501. /**
  47502. * Stops and removes all animations that have been applied to the camera
  47503. */
  47504. stopAllAnimations(): void;
  47505. /**
  47506. * Gets a value indicating if the user is moving the camera
  47507. */
  47508. get isUserIsMoving(): boolean;
  47509. /**
  47510. * The camera can move all the way towards the mesh.
  47511. */
  47512. static IgnoreBoundsSizeMode: number;
  47513. /**
  47514. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47515. */
  47516. static FitFrustumSidesMode: number;
  47517. }
  47518. }
  47519. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47520. import { Nullable } from "babylonjs/types";
  47521. import { Camera } from "babylonjs/Cameras/camera";
  47522. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47523. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47524. /**
  47525. * Base class for Camera Pointer Inputs.
  47526. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47527. * for example usage.
  47528. */
  47529. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47530. /**
  47531. * Defines the camera the input is attached to.
  47532. */
  47533. abstract camera: Camera;
  47534. /**
  47535. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47536. */
  47537. protected _altKey: boolean;
  47538. protected _ctrlKey: boolean;
  47539. protected _metaKey: boolean;
  47540. protected _shiftKey: boolean;
  47541. /**
  47542. * Which mouse buttons were pressed at time of last mouse event.
  47543. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47544. */
  47545. protected _buttonsPressed: number;
  47546. /**
  47547. * Defines the buttons associated with the input to handle camera move.
  47548. */
  47549. buttons: number[];
  47550. /**
  47551. * Attach the input controls to a specific dom element to get the input from.
  47552. * @param element Defines the element the controls should be listened from
  47553. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47554. */
  47555. attachControl(noPreventDefault?: boolean): void;
  47556. /**
  47557. * Detach the current controls from the specified dom element.
  47558. */
  47559. detachControl(): void;
  47560. /**
  47561. * Gets the class name of the current input.
  47562. * @returns the class name
  47563. */
  47564. getClassName(): string;
  47565. /**
  47566. * Get the friendly name associated with the input class.
  47567. * @returns the input friendly name
  47568. */
  47569. getSimpleName(): string;
  47570. /**
  47571. * Called on pointer POINTERDOUBLETAP event.
  47572. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47573. */
  47574. protected onDoubleTap(type: string): void;
  47575. /**
  47576. * Called on pointer POINTERMOVE event if only a single touch is active.
  47577. * Override this method to provide functionality.
  47578. */
  47579. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47580. /**
  47581. * Called on pointer POINTERMOVE event if multiple touches are active.
  47582. * Override this method to provide functionality.
  47583. */
  47584. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47585. /**
  47586. * Called on JS contextmenu event.
  47587. * Override this method to provide functionality.
  47588. */
  47589. protected onContextMenu(evt: PointerEvent): void;
  47590. /**
  47591. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47592. * press.
  47593. * Override this method to provide functionality.
  47594. */
  47595. protected onButtonDown(evt: PointerEvent): void;
  47596. /**
  47597. * Called each time a new POINTERUP event occurs. Ie, for each button
  47598. * release.
  47599. * Override this method to provide functionality.
  47600. */
  47601. protected onButtonUp(evt: PointerEvent): void;
  47602. /**
  47603. * Called when window becomes inactive.
  47604. * Override this method to provide functionality.
  47605. */
  47606. protected onLostFocus(): void;
  47607. private _pointerInput;
  47608. private _observer;
  47609. private _onLostFocus;
  47610. private pointA;
  47611. private pointB;
  47612. }
  47613. }
  47614. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47615. import { Nullable } from "babylonjs/types";
  47616. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47617. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47618. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47619. /**
  47620. * Manage the pointers inputs to control an arc rotate camera.
  47621. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47622. */
  47623. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47624. /**
  47625. * Defines the camera the input is attached to.
  47626. */
  47627. camera: ArcRotateCamera;
  47628. /**
  47629. * Gets the class name of the current input.
  47630. * @returns the class name
  47631. */
  47632. getClassName(): string;
  47633. /**
  47634. * Defines the buttons associated with the input to handle camera move.
  47635. */
  47636. buttons: number[];
  47637. /**
  47638. * Defines the pointer angular sensibility along the X axis or how fast is
  47639. * the camera rotating.
  47640. */
  47641. angularSensibilityX: number;
  47642. /**
  47643. * Defines the pointer angular sensibility along the Y axis or how fast is
  47644. * the camera rotating.
  47645. */
  47646. angularSensibilityY: number;
  47647. /**
  47648. * Defines the pointer pinch precision or how fast is the camera zooming.
  47649. */
  47650. pinchPrecision: number;
  47651. /**
  47652. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47653. * from 0.
  47654. * It defines the percentage of current camera.radius to use as delta when
  47655. * pinch zoom is used.
  47656. */
  47657. pinchDeltaPercentage: number;
  47658. /**
  47659. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47660. * that any object in the plane at the camera's target point will scale
  47661. * perfectly with finger motion.
  47662. * Overrides pinchDeltaPercentage and pinchPrecision.
  47663. */
  47664. useNaturalPinchZoom: boolean;
  47665. /**
  47666. * Defines the pointer panning sensibility or how fast is the camera moving.
  47667. */
  47668. panningSensibility: number;
  47669. /**
  47670. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  47671. */
  47672. multiTouchPanning: boolean;
  47673. /**
  47674. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  47675. * zoom (pinch) through multitouch.
  47676. */
  47677. multiTouchPanAndZoom: boolean;
  47678. /**
  47679. * Revers pinch action direction.
  47680. */
  47681. pinchInwards: boolean;
  47682. private _isPanClick;
  47683. private _twoFingerActivityCount;
  47684. private _isPinching;
  47685. /**
  47686. * Called on pointer POINTERMOVE event if only a single touch is active.
  47687. */
  47688. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47689. /**
  47690. * Called on pointer POINTERDOUBLETAP event.
  47691. */
  47692. protected onDoubleTap(type: string): void;
  47693. /**
  47694. * Called on pointer POINTERMOVE event if multiple touches are active.
  47695. */
  47696. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47697. /**
  47698. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47699. * press.
  47700. */
  47701. protected onButtonDown(evt: PointerEvent): void;
  47702. /**
  47703. * Called each time a new POINTERUP event occurs. Ie, for each button
  47704. * release.
  47705. */
  47706. protected onButtonUp(evt: PointerEvent): void;
  47707. /**
  47708. * Called when window becomes inactive.
  47709. */
  47710. protected onLostFocus(): void;
  47711. }
  47712. }
  47713. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  47714. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47715. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47716. /**
  47717. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  47718. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47719. */
  47720. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  47721. /**
  47722. * Defines the camera the input is attached to.
  47723. */
  47724. camera: ArcRotateCamera;
  47725. /**
  47726. * Defines the list of key codes associated with the up action (increase alpha)
  47727. */
  47728. keysUp: number[];
  47729. /**
  47730. * Defines the list of key codes associated with the down action (decrease alpha)
  47731. */
  47732. keysDown: number[];
  47733. /**
  47734. * Defines the list of key codes associated with the left action (increase beta)
  47735. */
  47736. keysLeft: number[];
  47737. /**
  47738. * Defines the list of key codes associated with the right action (decrease beta)
  47739. */
  47740. keysRight: number[];
  47741. /**
  47742. * Defines the list of key codes associated with the reset action.
  47743. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  47744. */
  47745. keysReset: number[];
  47746. /**
  47747. * Defines the panning sensibility of the inputs.
  47748. * (How fast is the camera panning)
  47749. */
  47750. panningSensibility: number;
  47751. /**
  47752. * Defines the zooming sensibility of the inputs.
  47753. * (How fast is the camera zooming)
  47754. */
  47755. zoomingSensibility: number;
  47756. /**
  47757. * Defines whether maintaining the alt key down switch the movement mode from
  47758. * orientation to zoom.
  47759. */
  47760. useAltToZoom: boolean;
  47761. /**
  47762. * Rotation speed of the camera
  47763. */
  47764. angularSpeed: number;
  47765. private _keys;
  47766. private _ctrlPressed;
  47767. private _altPressed;
  47768. private _onCanvasBlurObserver;
  47769. private _onKeyboardObserver;
  47770. private _engine;
  47771. private _scene;
  47772. /**
  47773. * Attach the input controls to a specific dom element to get the input from.
  47774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47775. */
  47776. attachControl(noPreventDefault?: boolean): void;
  47777. /**
  47778. * Detach the current controls from the specified dom element.
  47779. */
  47780. detachControl(): void;
  47781. /**
  47782. * Update the current camera state depending on the inputs that have been used this frame.
  47783. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47784. */
  47785. checkInputs(): void;
  47786. /**
  47787. * Gets the class name of the current intput.
  47788. * @returns the class name
  47789. */
  47790. getClassName(): string;
  47791. /**
  47792. * Get the friendly name associated with the input class.
  47793. * @returns the input friendly name
  47794. */
  47795. getSimpleName(): string;
  47796. }
  47797. }
  47798. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  47799. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47800. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47801. /**
  47802. * Manage the mouse wheel inputs to control an arc rotate camera.
  47803. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47804. */
  47805. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  47806. /**
  47807. * Defines the camera the input is attached to.
  47808. */
  47809. camera: ArcRotateCamera;
  47810. /**
  47811. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47812. */
  47813. wheelPrecision: number;
  47814. /**
  47815. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47816. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47817. */
  47818. wheelDeltaPercentage: number;
  47819. private _wheel;
  47820. private _observer;
  47821. private computeDeltaFromMouseWheelLegacyEvent;
  47822. /**
  47823. * Attach the input controls to a specific dom element to get the input from.
  47824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47825. */
  47826. attachControl(noPreventDefault?: boolean): void;
  47827. /**
  47828. * Detach the current controls from the specified dom element.
  47829. */
  47830. detachControl(): void;
  47831. /**
  47832. * Gets the class name of the current intput.
  47833. * @returns the class name
  47834. */
  47835. getClassName(): string;
  47836. /**
  47837. * Get the friendly name associated with the input class.
  47838. * @returns the input friendly name
  47839. */
  47840. getSimpleName(): string;
  47841. }
  47842. }
  47843. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47844. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47845. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  47846. /**
  47847. * Default Inputs manager for the ArcRotateCamera.
  47848. * It groups all the default supported inputs for ease of use.
  47849. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47850. */
  47851. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  47852. /**
  47853. * Instantiates a new ArcRotateCameraInputsManager.
  47854. * @param camera Defines the camera the inputs belong to
  47855. */
  47856. constructor(camera: ArcRotateCamera);
  47857. /**
  47858. * Add mouse wheel input support to the input manager.
  47859. * @returns the current input manager
  47860. */
  47861. addMouseWheel(): ArcRotateCameraInputsManager;
  47862. /**
  47863. * Add pointers input support to the input manager.
  47864. * @returns the current input manager
  47865. */
  47866. addPointers(): ArcRotateCameraInputsManager;
  47867. /**
  47868. * Add keyboard input support to the input manager.
  47869. * @returns the current input manager
  47870. */
  47871. addKeyboard(): ArcRotateCameraInputsManager;
  47872. }
  47873. }
  47874. declare module "babylonjs/Cameras/arcRotateCamera" {
  47875. import { Observable } from "babylonjs/Misc/observable";
  47876. import { Nullable } from "babylonjs/types";
  47877. import { Scene } from "babylonjs/scene";
  47878. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47880. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  47881. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  47882. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  47883. import { Camera } from "babylonjs/Cameras/camera";
  47884. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  47885. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47886. import { Collider } from "babylonjs/Collisions/collider";
  47887. /**
  47888. * This represents an orbital type of camera.
  47889. *
  47890. * 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.
  47891. * 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.
  47892. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  47893. */
  47894. export class ArcRotateCamera extends TargetCamera {
  47895. /**
  47896. * Defines the rotation angle of the camera along the longitudinal axis.
  47897. */
  47898. alpha: number;
  47899. /**
  47900. * Defines the rotation angle of the camera along the latitudinal axis.
  47901. */
  47902. beta: number;
  47903. /**
  47904. * Defines the radius of the camera from it s target point.
  47905. */
  47906. radius: number;
  47907. protected _target: Vector3;
  47908. protected _targetHost: Nullable<AbstractMesh>;
  47909. /**
  47910. * Defines the target point of the camera.
  47911. * The camera looks towards it form the radius distance.
  47912. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  47913. */
  47914. get target(): Vector3;
  47915. set target(value: Vector3);
  47916. /**
  47917. * Define the current local position of the camera in the scene
  47918. */
  47919. get position(): Vector3;
  47920. set position(newPosition: Vector3);
  47921. protected _upToYMatrix: Matrix;
  47922. protected _YToUpMatrix: Matrix;
  47923. /**
  47924. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  47925. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  47926. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  47927. */
  47928. set upVector(vec: Vector3);
  47929. get upVector(): Vector3;
  47930. /**
  47931. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  47932. */
  47933. setMatUp(): void;
  47934. /**
  47935. * Current inertia value on the longitudinal axis.
  47936. * The bigger this number the longer it will take for the camera to stop.
  47937. */
  47938. inertialAlphaOffset: number;
  47939. /**
  47940. * Current inertia value on the latitudinal axis.
  47941. * The bigger this number the longer it will take for the camera to stop.
  47942. */
  47943. inertialBetaOffset: number;
  47944. /**
  47945. * Current inertia value on the radius axis.
  47946. * The bigger this number the longer it will take for the camera to stop.
  47947. */
  47948. inertialRadiusOffset: number;
  47949. /**
  47950. * Minimum allowed angle on the longitudinal axis.
  47951. * This can help limiting how the Camera is able to move in the scene.
  47952. */
  47953. lowerAlphaLimit: Nullable<number>;
  47954. /**
  47955. * Maximum allowed angle on the longitudinal axis.
  47956. * This can help limiting how the Camera is able to move in the scene.
  47957. */
  47958. upperAlphaLimit: Nullable<number>;
  47959. /**
  47960. * Minimum allowed angle on the latitudinal axis.
  47961. * This can help limiting how the Camera is able to move in the scene.
  47962. */
  47963. lowerBetaLimit: number;
  47964. /**
  47965. * Maximum allowed angle on the latitudinal axis.
  47966. * This can help limiting how the Camera is able to move in the scene.
  47967. */
  47968. upperBetaLimit: number;
  47969. /**
  47970. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  47971. * This can help limiting how the Camera is able to move in the scene.
  47972. */
  47973. lowerRadiusLimit: Nullable<number>;
  47974. /**
  47975. * Maximum allowed distance of the camera to the target (The camera can not get further).
  47976. * This can help limiting how the Camera is able to move in the scene.
  47977. */
  47978. upperRadiusLimit: Nullable<number>;
  47979. /**
  47980. * Defines the current inertia value used during panning of the camera along the X axis.
  47981. */
  47982. inertialPanningX: number;
  47983. /**
  47984. * Defines the current inertia value used during panning of the camera along the Y axis.
  47985. */
  47986. inertialPanningY: number;
  47987. /**
  47988. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  47989. * Basically if your fingers moves away from more than this distance you will be considered
  47990. * in pinch mode.
  47991. */
  47992. pinchToPanMaxDistance: number;
  47993. /**
  47994. * Defines the maximum distance the camera can pan.
  47995. * This could help keeping the cammera always in your scene.
  47996. */
  47997. panningDistanceLimit: Nullable<number>;
  47998. /**
  47999. * Defines the target of the camera before paning.
  48000. */
  48001. panningOriginTarget: Vector3;
  48002. /**
  48003. * Defines the value of the inertia used during panning.
  48004. * 0 would mean stop inertia and one would mean no decelleration at all.
  48005. */
  48006. panningInertia: number;
  48007. /**
  48008. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  48009. */
  48010. get angularSensibilityX(): number;
  48011. set angularSensibilityX(value: number);
  48012. /**
  48013. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  48014. */
  48015. get angularSensibilityY(): number;
  48016. set angularSensibilityY(value: number);
  48017. /**
  48018. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  48019. */
  48020. get pinchPrecision(): number;
  48021. set pinchPrecision(value: number);
  48022. /**
  48023. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  48024. * It will be used instead of pinchDeltaPrecision if different from 0.
  48025. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48026. */
  48027. get pinchDeltaPercentage(): number;
  48028. set pinchDeltaPercentage(value: number);
  48029. /**
  48030. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  48031. * and pinch delta percentage.
  48032. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  48033. * that any object in the plane at the camera's target point will scale
  48034. * perfectly with finger motion.
  48035. */
  48036. get useNaturalPinchZoom(): boolean;
  48037. set useNaturalPinchZoom(value: boolean);
  48038. /**
  48039. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  48040. */
  48041. get panningSensibility(): number;
  48042. set panningSensibility(value: number);
  48043. /**
  48044. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  48045. */
  48046. get keysUp(): number[];
  48047. set keysUp(value: number[]);
  48048. /**
  48049. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  48050. */
  48051. get keysDown(): number[];
  48052. set keysDown(value: number[]);
  48053. /**
  48054. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  48055. */
  48056. get keysLeft(): number[];
  48057. set keysLeft(value: number[]);
  48058. /**
  48059. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  48060. */
  48061. get keysRight(): number[];
  48062. set keysRight(value: number[]);
  48063. /**
  48064. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  48065. */
  48066. get wheelPrecision(): number;
  48067. set wheelPrecision(value: number);
  48068. /**
  48069. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  48070. * It will be used instead of pinchDeltaPrecision if different from 0.
  48071. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48072. */
  48073. get wheelDeltaPercentage(): number;
  48074. set wheelDeltaPercentage(value: number);
  48075. /**
  48076. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  48077. */
  48078. zoomOnFactor: number;
  48079. /**
  48080. * Defines a screen offset for the camera position.
  48081. */
  48082. targetScreenOffset: Vector2;
  48083. /**
  48084. * Allows the camera to be completely reversed.
  48085. * If false the camera can not arrive upside down.
  48086. */
  48087. allowUpsideDown: boolean;
  48088. /**
  48089. * Define if double tap/click is used to restore the previously saved state of the camera.
  48090. */
  48091. useInputToRestoreState: boolean;
  48092. /** @hidden */
  48093. _viewMatrix: Matrix;
  48094. /** @hidden */
  48095. _useCtrlForPanning: boolean;
  48096. /** @hidden */
  48097. _panningMouseButton: number;
  48098. /**
  48099. * Defines the input associated to the camera.
  48100. */
  48101. inputs: ArcRotateCameraInputsManager;
  48102. /** @hidden */
  48103. _reset: () => void;
  48104. /**
  48105. * Defines the allowed panning axis.
  48106. */
  48107. panningAxis: Vector3;
  48108. protected _localDirection: Vector3;
  48109. protected _transformedDirection: Vector3;
  48110. private _bouncingBehavior;
  48111. /**
  48112. * Gets the bouncing behavior of the camera if it has been enabled.
  48113. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48114. */
  48115. get bouncingBehavior(): Nullable<BouncingBehavior>;
  48116. /**
  48117. * Defines if the bouncing behavior of the camera is enabled on the camera.
  48118. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48119. */
  48120. get useBouncingBehavior(): boolean;
  48121. set useBouncingBehavior(value: boolean);
  48122. private _framingBehavior;
  48123. /**
  48124. * Gets the framing behavior of the camera if it has been enabled.
  48125. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48126. */
  48127. get framingBehavior(): Nullable<FramingBehavior>;
  48128. /**
  48129. * Defines if the framing behavior of the camera is enabled on the camera.
  48130. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48131. */
  48132. get useFramingBehavior(): boolean;
  48133. set useFramingBehavior(value: boolean);
  48134. private _autoRotationBehavior;
  48135. /**
  48136. * Gets the auto rotation behavior of the camera if it has been enabled.
  48137. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48138. */
  48139. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  48140. /**
  48141. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  48142. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48143. */
  48144. get useAutoRotationBehavior(): boolean;
  48145. set useAutoRotationBehavior(value: boolean);
  48146. /**
  48147. * Observable triggered when the mesh target has been changed on the camera.
  48148. */
  48149. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  48150. /**
  48151. * Event raised when the camera is colliding with a mesh.
  48152. */
  48153. onCollide: (collidedMesh: AbstractMesh) => void;
  48154. /**
  48155. * Defines whether the camera should check collision with the objects oh the scene.
  48156. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  48157. */
  48158. checkCollisions: boolean;
  48159. /**
  48160. * Defines the collision radius of the camera.
  48161. * This simulates a sphere around the camera.
  48162. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  48163. */
  48164. collisionRadius: Vector3;
  48165. protected _collider: Collider;
  48166. protected _previousPosition: Vector3;
  48167. protected _collisionVelocity: Vector3;
  48168. protected _newPosition: Vector3;
  48169. protected _previousAlpha: number;
  48170. protected _previousBeta: number;
  48171. protected _previousRadius: number;
  48172. protected _collisionTriggered: boolean;
  48173. protected _targetBoundingCenter: Nullable<Vector3>;
  48174. private _computationVector;
  48175. /**
  48176. * Instantiates a new ArcRotateCamera in a given scene
  48177. * @param name Defines the name of the camera
  48178. * @param alpha Defines the camera rotation along the logitudinal axis
  48179. * @param beta Defines the camera rotation along the latitudinal axis
  48180. * @param radius Defines the camera distance from its target
  48181. * @param target Defines the camera target
  48182. * @param scene Defines the scene the camera belongs to
  48183. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  48184. */
  48185. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  48186. /** @hidden */
  48187. _initCache(): void;
  48188. /** @hidden */
  48189. _updateCache(ignoreParentClass?: boolean): void;
  48190. protected _getTargetPosition(): Vector3;
  48191. private _storedAlpha;
  48192. private _storedBeta;
  48193. private _storedRadius;
  48194. private _storedTarget;
  48195. private _storedTargetScreenOffset;
  48196. /**
  48197. * Stores the current state of the camera (alpha, beta, radius and target)
  48198. * @returns the camera itself
  48199. */
  48200. storeState(): Camera;
  48201. /**
  48202. * @hidden
  48203. * Restored camera state. You must call storeState() first
  48204. */
  48205. _restoreStateValues(): boolean;
  48206. /** @hidden */
  48207. _isSynchronizedViewMatrix(): boolean;
  48208. /**
  48209. * Attached controls to the current camera.
  48210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48211. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48212. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  48213. */
  48214. attachControl(noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  48215. /**
  48216. * Detach the current controls from the camera.
  48217. * The camera will stop reacting to inputs.
  48218. */
  48219. detachControl(): void;
  48220. /** @hidden */
  48221. _checkInputs(): void;
  48222. protected _checkLimits(): void;
  48223. /**
  48224. * Rebuilds angles (alpha, beta) and radius from the give position and target
  48225. */
  48226. rebuildAnglesAndRadius(): void;
  48227. /**
  48228. * Use a position to define the current camera related information like alpha, beta and radius
  48229. * @param position Defines the position to set the camera at
  48230. */
  48231. setPosition(position: Vector3): void;
  48232. /**
  48233. * Defines the target the camera should look at.
  48234. * This will automatically adapt alpha beta and radius to fit within the new target.
  48235. * @param target Defines the new target as a Vector or a mesh
  48236. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  48237. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  48238. */
  48239. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  48240. /** @hidden */
  48241. _getViewMatrix(): Matrix;
  48242. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  48243. /**
  48244. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  48245. * @param meshes Defines the mesh to zoom on
  48246. * @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)
  48247. */
  48248. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  48249. /**
  48250. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  48251. * The target will be changed but the radius
  48252. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  48253. * @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)
  48254. */
  48255. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  48256. min: Vector3;
  48257. max: Vector3;
  48258. distance: number;
  48259. }, doNotUpdateMaxZ?: boolean): void;
  48260. /**
  48261. * @override
  48262. * Override Camera.createRigCamera
  48263. */
  48264. createRigCamera(name: string, cameraIndex: number): Camera;
  48265. /**
  48266. * @hidden
  48267. * @override
  48268. * Override Camera._updateRigCameras
  48269. */
  48270. _updateRigCameras(): void;
  48271. /**
  48272. * Destroy the camera and release the current resources hold by it.
  48273. */
  48274. dispose(): void;
  48275. /**
  48276. * Gets the current object class name.
  48277. * @return the class name
  48278. */
  48279. getClassName(): string;
  48280. }
  48281. }
  48282. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  48283. import { Behavior } from "babylonjs/Behaviors/behavior";
  48284. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48285. /**
  48286. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  48287. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48288. */
  48289. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  48290. /**
  48291. * Gets the name of the behavior.
  48292. */
  48293. get name(): string;
  48294. private _zoomStopsAnimation;
  48295. private _idleRotationSpeed;
  48296. private _idleRotationWaitTime;
  48297. private _idleRotationSpinupTime;
  48298. /**
  48299. * Sets the flag that indicates if user zooming should stop animation.
  48300. */
  48301. set zoomStopsAnimation(flag: boolean);
  48302. /**
  48303. * Gets the flag that indicates if user zooming should stop animation.
  48304. */
  48305. get zoomStopsAnimation(): boolean;
  48306. /**
  48307. * Sets the default speed at which the camera rotates around the model.
  48308. */
  48309. set idleRotationSpeed(speed: number);
  48310. /**
  48311. * Gets the default speed at which the camera rotates around the model.
  48312. */
  48313. get idleRotationSpeed(): number;
  48314. /**
  48315. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  48316. */
  48317. set idleRotationWaitTime(time: number);
  48318. /**
  48319. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  48320. */
  48321. get idleRotationWaitTime(): number;
  48322. /**
  48323. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48324. */
  48325. set idleRotationSpinupTime(time: number);
  48326. /**
  48327. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48328. */
  48329. get idleRotationSpinupTime(): number;
  48330. /**
  48331. * Gets a value indicating if the camera is currently rotating because of this behavior
  48332. */
  48333. get rotationInProgress(): boolean;
  48334. private _onPrePointerObservableObserver;
  48335. private _onAfterCheckInputsObserver;
  48336. private _attachedCamera;
  48337. private _isPointerDown;
  48338. private _lastFrameTime;
  48339. private _lastInteractionTime;
  48340. private _cameraRotationSpeed;
  48341. /**
  48342. * Initializes the behavior.
  48343. */
  48344. init(): void;
  48345. /**
  48346. * Attaches the behavior to its arc rotate camera.
  48347. * @param camera Defines the camera to attach the behavior to
  48348. */
  48349. attach(camera: ArcRotateCamera): void;
  48350. /**
  48351. * Detaches the behavior from its current arc rotate camera.
  48352. */
  48353. detach(): void;
  48354. /**
  48355. * Returns true if user is scrolling.
  48356. * @return true if user is scrolling.
  48357. */
  48358. private _userIsZooming;
  48359. private _lastFrameRadius;
  48360. private _shouldAnimationStopForInteraction;
  48361. /**
  48362. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48363. */
  48364. private _applyUserInteraction;
  48365. private _userIsMoving;
  48366. }
  48367. }
  48368. declare module "babylonjs/Behaviors/Cameras/index" {
  48369. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48370. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48371. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  48372. }
  48373. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  48374. import { Mesh } from "babylonjs/Meshes/mesh";
  48375. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48376. import { Behavior } from "babylonjs/Behaviors/behavior";
  48377. /**
  48378. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  48379. */
  48380. export class AttachToBoxBehavior implements Behavior<Mesh> {
  48381. private ui;
  48382. /**
  48383. * The name of the behavior
  48384. */
  48385. name: string;
  48386. /**
  48387. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48388. */
  48389. distanceAwayFromFace: number;
  48390. /**
  48391. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48392. */
  48393. distanceAwayFromBottomOfFace: number;
  48394. private _faceVectors;
  48395. private _target;
  48396. private _scene;
  48397. private _onRenderObserver;
  48398. private _tmpMatrix;
  48399. private _tmpVector;
  48400. /**
  48401. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48402. * @param ui The transform node that should be attched to the mesh
  48403. */
  48404. constructor(ui: TransformNode);
  48405. /**
  48406. * Initializes the behavior
  48407. */
  48408. init(): void;
  48409. private _closestFace;
  48410. private _zeroVector;
  48411. private _lookAtTmpMatrix;
  48412. private _lookAtToRef;
  48413. /**
  48414. * Attaches the AttachToBoxBehavior to the passed in mesh
  48415. * @param target The mesh that the specified node will be attached to
  48416. */
  48417. attach(target: Mesh): void;
  48418. /**
  48419. * Detaches the behavior from the mesh
  48420. */
  48421. detach(): void;
  48422. }
  48423. }
  48424. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48425. import { Behavior } from "babylonjs/Behaviors/behavior";
  48426. import { Mesh } from "babylonjs/Meshes/mesh";
  48427. /**
  48428. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48429. */
  48430. export class FadeInOutBehavior implements Behavior<Mesh> {
  48431. /**
  48432. * Time in milliseconds to delay before fading in (Default: 0)
  48433. */
  48434. delay: number;
  48435. /**
  48436. * Time in milliseconds for the mesh to fade in (Default: 300)
  48437. */
  48438. fadeInTime: number;
  48439. private _millisecondsPerFrame;
  48440. private _hovered;
  48441. private _hoverValue;
  48442. private _ownerNode;
  48443. /**
  48444. * Instatiates the FadeInOutBehavior
  48445. */
  48446. constructor();
  48447. /**
  48448. * The name of the behavior
  48449. */
  48450. get name(): string;
  48451. /**
  48452. * Initializes the behavior
  48453. */
  48454. init(): void;
  48455. /**
  48456. * Attaches the fade behavior on the passed in mesh
  48457. * @param ownerNode The mesh that will be faded in/out once attached
  48458. */
  48459. attach(ownerNode: Mesh): void;
  48460. /**
  48461. * Detaches the behavior from the mesh
  48462. */
  48463. detach(): void;
  48464. /**
  48465. * Triggers the mesh to begin fading in or out
  48466. * @param value if the object should fade in or out (true to fade in)
  48467. */
  48468. fadeIn(value: boolean): void;
  48469. private _update;
  48470. private _setAllVisibility;
  48471. }
  48472. }
  48473. declare module "babylonjs/Misc/pivotTools" {
  48474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48475. /**
  48476. * Class containing a set of static utilities functions for managing Pivots
  48477. * @hidden
  48478. */
  48479. export class PivotTools {
  48480. private static _PivotCached;
  48481. private static _OldPivotPoint;
  48482. private static _PivotTranslation;
  48483. private static _PivotTmpVector;
  48484. private static _PivotPostMultiplyPivotMatrix;
  48485. /** @hidden */
  48486. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48487. /** @hidden */
  48488. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48489. }
  48490. }
  48491. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48492. import { Scene } from "babylonjs/scene";
  48493. import { Vector4 } from "babylonjs/Maths/math.vector";
  48494. import { Mesh } from "babylonjs/Meshes/mesh";
  48495. import { Nullable } from "babylonjs/types";
  48496. import { Plane } from "babylonjs/Maths/math.plane";
  48497. /**
  48498. * Class containing static functions to help procedurally build meshes
  48499. */
  48500. export class PlaneBuilder {
  48501. /**
  48502. * Creates a plane mesh
  48503. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48504. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48505. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48507. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48509. * @param name defines the name of the mesh
  48510. * @param options defines the options used to create the mesh
  48511. * @param scene defines the hosting scene
  48512. * @returns the plane mesh
  48513. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48514. */
  48515. static CreatePlane(name: string, options: {
  48516. size?: number;
  48517. width?: number;
  48518. height?: number;
  48519. sideOrientation?: number;
  48520. frontUVs?: Vector4;
  48521. backUVs?: Vector4;
  48522. updatable?: boolean;
  48523. sourcePlane?: Plane;
  48524. }, scene?: Nullable<Scene>): Mesh;
  48525. }
  48526. }
  48527. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48528. import { Behavior } from "babylonjs/Behaviors/behavior";
  48529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48530. import { Observable } from "babylonjs/Misc/observable";
  48531. import { Vector3 } from "babylonjs/Maths/math.vector";
  48532. import { Ray } from "babylonjs/Culling/ray";
  48533. import "babylonjs/Meshes/Builders/planeBuilder";
  48534. /**
  48535. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48536. */
  48537. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48538. private static _AnyMouseID;
  48539. /**
  48540. * Abstract mesh the behavior is set on
  48541. */
  48542. attachedNode: AbstractMesh;
  48543. private _dragPlane;
  48544. private _scene;
  48545. private _pointerObserver;
  48546. private _beforeRenderObserver;
  48547. private static _planeScene;
  48548. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48549. /**
  48550. * 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)
  48551. */
  48552. maxDragAngle: number;
  48553. /**
  48554. * @hidden
  48555. */
  48556. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48557. /**
  48558. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48559. */
  48560. currentDraggingPointerID: number;
  48561. /**
  48562. * The last position where the pointer hit the drag plane in world space
  48563. */
  48564. lastDragPosition: Vector3;
  48565. /**
  48566. * If the behavior is currently in a dragging state
  48567. */
  48568. dragging: boolean;
  48569. /**
  48570. * 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)
  48571. */
  48572. dragDeltaRatio: number;
  48573. /**
  48574. * If the drag plane orientation should be updated during the dragging (Default: true)
  48575. */
  48576. updateDragPlane: boolean;
  48577. private _debugMode;
  48578. private _moving;
  48579. /**
  48580. * Fires each time the attached mesh is dragged with the pointer
  48581. * * delta between last drag position and current drag position in world space
  48582. * * dragDistance along the drag axis
  48583. * * dragPlaneNormal normal of the current drag plane used during the drag
  48584. * * dragPlanePoint in world space where the drag intersects the drag plane
  48585. */
  48586. onDragObservable: Observable<{
  48587. delta: Vector3;
  48588. dragPlanePoint: Vector3;
  48589. dragPlaneNormal: Vector3;
  48590. dragDistance: number;
  48591. pointerId: number;
  48592. }>;
  48593. /**
  48594. * Fires each time a drag begins (eg. mouse down on mesh)
  48595. */
  48596. onDragStartObservable: Observable<{
  48597. dragPlanePoint: Vector3;
  48598. pointerId: number;
  48599. }>;
  48600. /**
  48601. * Fires each time a drag ends (eg. mouse release after drag)
  48602. */
  48603. onDragEndObservable: Observable<{
  48604. dragPlanePoint: Vector3;
  48605. pointerId: number;
  48606. }>;
  48607. /**
  48608. * If the attached mesh should be moved when dragged
  48609. */
  48610. moveAttached: boolean;
  48611. /**
  48612. * If the drag behavior will react to drag events (Default: true)
  48613. */
  48614. enabled: boolean;
  48615. /**
  48616. * If pointer events should start and release the drag (Default: true)
  48617. */
  48618. startAndReleaseDragOnPointerEvents: boolean;
  48619. /**
  48620. * If camera controls should be detached during the drag
  48621. */
  48622. detachCameraControls: boolean;
  48623. /**
  48624. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48625. */
  48626. useObjectOrientationForDragging: boolean;
  48627. private _options;
  48628. /**
  48629. * Gets the options used by the behavior
  48630. */
  48631. get options(): {
  48632. dragAxis?: Vector3;
  48633. dragPlaneNormal?: Vector3;
  48634. };
  48635. /**
  48636. * Sets the options used by the behavior
  48637. */
  48638. set options(options: {
  48639. dragAxis?: Vector3;
  48640. dragPlaneNormal?: Vector3;
  48641. });
  48642. /**
  48643. * Creates a pointer drag behavior that can be attached to a mesh
  48644. * @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)
  48645. */
  48646. constructor(options?: {
  48647. dragAxis?: Vector3;
  48648. dragPlaneNormal?: Vector3;
  48649. });
  48650. /**
  48651. * Predicate to determine if it is valid to move the object to a new position when it is moved
  48652. */
  48653. validateDrag: (targetPosition: Vector3) => boolean;
  48654. /**
  48655. * The name of the behavior
  48656. */
  48657. get name(): string;
  48658. /**
  48659. * Initializes the behavior
  48660. */
  48661. init(): void;
  48662. private _tmpVector;
  48663. private _alternatePickedPoint;
  48664. private _worldDragAxis;
  48665. private _targetPosition;
  48666. private _attachedElement;
  48667. /**
  48668. * Attaches the drag behavior the passed in mesh
  48669. * @param ownerNode The mesh that will be dragged around once attached
  48670. * @param predicate Predicate to use for pick filtering
  48671. */
  48672. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  48673. /**
  48674. * Force relase the drag action by code.
  48675. */
  48676. releaseDrag(): void;
  48677. private _startDragRay;
  48678. private _lastPointerRay;
  48679. /**
  48680. * Simulates the start of a pointer drag event on the behavior
  48681. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  48682. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  48683. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  48684. */
  48685. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48686. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48687. private _dragDelta;
  48688. protected _moveDrag(ray: Ray): void;
  48689. private _pickWithRayOnDragPlane;
  48690. private _pointA;
  48691. private _pointC;
  48692. private _localAxis;
  48693. private _lookAt;
  48694. private _updateDragPlanePosition;
  48695. /**
  48696. * Detaches the behavior from the mesh
  48697. */
  48698. detach(): void;
  48699. }
  48700. }
  48701. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  48702. import { Mesh } from "babylonjs/Meshes/mesh";
  48703. import { Behavior } from "babylonjs/Behaviors/behavior";
  48704. /**
  48705. * A behavior that when attached to a mesh will allow the mesh to be scaled
  48706. */
  48707. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  48708. private _dragBehaviorA;
  48709. private _dragBehaviorB;
  48710. private _startDistance;
  48711. private _initialScale;
  48712. private _targetScale;
  48713. private _ownerNode;
  48714. private _sceneRenderObserver;
  48715. /**
  48716. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  48717. */
  48718. constructor();
  48719. /**
  48720. * The name of the behavior
  48721. */
  48722. get name(): string;
  48723. /**
  48724. * Initializes the behavior
  48725. */
  48726. init(): void;
  48727. private _getCurrentDistance;
  48728. /**
  48729. * Attaches the scale behavior the passed in mesh
  48730. * @param ownerNode The mesh that will be scaled around once attached
  48731. */
  48732. attach(ownerNode: Mesh): void;
  48733. /**
  48734. * Detaches the behavior from the mesh
  48735. */
  48736. detach(): void;
  48737. }
  48738. }
  48739. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  48740. import { Behavior } from "babylonjs/Behaviors/behavior";
  48741. import { Mesh } from "babylonjs/Meshes/mesh";
  48742. import { Observable } from "babylonjs/Misc/observable";
  48743. /**
  48744. * 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
  48745. */
  48746. export class SixDofDragBehavior implements Behavior<Mesh> {
  48747. private static _virtualScene;
  48748. private _ownerNode;
  48749. private _sceneRenderObserver;
  48750. private _scene;
  48751. private _targetPosition;
  48752. private _virtualOriginMesh;
  48753. private _virtualDragMesh;
  48754. private _pointerObserver;
  48755. private _moving;
  48756. private _startingOrientation;
  48757. private _attachedElement;
  48758. /**
  48759. * 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)
  48760. */
  48761. private zDragFactor;
  48762. /**
  48763. * If the object should rotate to face the drag origin
  48764. */
  48765. rotateDraggedObject: boolean;
  48766. /**
  48767. * If the behavior is currently in a dragging state
  48768. */
  48769. dragging: boolean;
  48770. /**
  48771. * 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)
  48772. */
  48773. dragDeltaRatio: number;
  48774. /**
  48775. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48776. */
  48777. currentDraggingPointerID: number;
  48778. /**
  48779. * If camera controls should be detached during the drag
  48780. */
  48781. detachCameraControls: boolean;
  48782. /**
  48783. * Fires each time a drag starts
  48784. */
  48785. onDragStartObservable: Observable<{}>;
  48786. /**
  48787. * Fires each time a drag ends (eg. mouse release after drag)
  48788. */
  48789. onDragEndObservable: Observable<{}>;
  48790. /**
  48791. * 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
  48792. */
  48793. constructor();
  48794. /**
  48795. * The name of the behavior
  48796. */
  48797. get name(): string;
  48798. /**
  48799. * Initializes the behavior
  48800. */
  48801. init(): void;
  48802. /**
  48803. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  48804. */
  48805. private get _pointerCamera();
  48806. /**
  48807. * Attaches the scale behavior the passed in mesh
  48808. * @param ownerNode The mesh that will be scaled around once attached
  48809. */
  48810. attach(ownerNode: Mesh): void;
  48811. /**
  48812. * Detaches the behavior from the mesh
  48813. */
  48814. detach(): void;
  48815. }
  48816. }
  48817. declare module "babylonjs/Behaviors/Meshes/index" {
  48818. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  48819. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  48820. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  48821. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48822. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48823. }
  48824. declare module "babylonjs/Behaviors/index" {
  48825. export * from "babylonjs/Behaviors/behavior";
  48826. export * from "babylonjs/Behaviors/Cameras/index";
  48827. export * from "babylonjs/Behaviors/Meshes/index";
  48828. }
  48829. declare module "babylonjs/Bones/boneIKController" {
  48830. import { Bone } from "babylonjs/Bones/bone";
  48831. import { Vector3 } from "babylonjs/Maths/math.vector";
  48832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48833. import { Nullable } from "babylonjs/types";
  48834. /**
  48835. * Class used to apply inverse kinematics to bones
  48836. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  48837. */
  48838. export class BoneIKController {
  48839. private static _tmpVecs;
  48840. private static _tmpQuat;
  48841. private static _tmpMats;
  48842. /**
  48843. * Gets or sets the target mesh
  48844. */
  48845. targetMesh: AbstractMesh;
  48846. /** Gets or sets the mesh used as pole */
  48847. poleTargetMesh: AbstractMesh;
  48848. /**
  48849. * Gets or sets the bone used as pole
  48850. */
  48851. poleTargetBone: Nullable<Bone>;
  48852. /**
  48853. * Gets or sets the target position
  48854. */
  48855. targetPosition: Vector3;
  48856. /**
  48857. * Gets or sets the pole target position
  48858. */
  48859. poleTargetPosition: Vector3;
  48860. /**
  48861. * Gets or sets the pole target local offset
  48862. */
  48863. poleTargetLocalOffset: Vector3;
  48864. /**
  48865. * Gets or sets the pole angle
  48866. */
  48867. poleAngle: number;
  48868. /**
  48869. * Gets or sets the mesh associated with the controller
  48870. */
  48871. mesh: AbstractMesh;
  48872. /**
  48873. * 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)
  48874. */
  48875. slerpAmount: number;
  48876. private _bone1Quat;
  48877. private _bone1Mat;
  48878. private _bone2Ang;
  48879. private _bone1;
  48880. private _bone2;
  48881. private _bone1Length;
  48882. private _bone2Length;
  48883. private _maxAngle;
  48884. private _maxReach;
  48885. private _rightHandedSystem;
  48886. private _bendAxis;
  48887. private _slerping;
  48888. private _adjustRoll;
  48889. /**
  48890. * Gets or sets maximum allowed angle
  48891. */
  48892. get maxAngle(): number;
  48893. set maxAngle(value: number);
  48894. /**
  48895. * Creates a new BoneIKController
  48896. * @param mesh defines the mesh to control
  48897. * @param bone defines the bone to control
  48898. * @param options defines options to set up the controller
  48899. */
  48900. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  48901. targetMesh?: AbstractMesh;
  48902. poleTargetMesh?: AbstractMesh;
  48903. poleTargetBone?: Bone;
  48904. poleTargetLocalOffset?: Vector3;
  48905. poleAngle?: number;
  48906. bendAxis?: Vector3;
  48907. maxAngle?: number;
  48908. slerpAmount?: number;
  48909. });
  48910. private _setMaxAngle;
  48911. /**
  48912. * Force the controller to update the bones
  48913. */
  48914. update(): void;
  48915. }
  48916. }
  48917. declare module "babylonjs/Bones/boneLookController" {
  48918. import { Vector3 } from "babylonjs/Maths/math.vector";
  48919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48920. import { Bone } from "babylonjs/Bones/bone";
  48921. import { Space } from "babylonjs/Maths/math.axis";
  48922. /**
  48923. * Class used to make a bone look toward a point in space
  48924. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  48925. */
  48926. export class BoneLookController {
  48927. private static _tmpVecs;
  48928. private static _tmpQuat;
  48929. private static _tmpMats;
  48930. /**
  48931. * The target Vector3 that the bone will look at
  48932. */
  48933. target: Vector3;
  48934. /**
  48935. * The mesh that the bone is attached to
  48936. */
  48937. mesh: AbstractMesh;
  48938. /**
  48939. * The bone that will be looking to the target
  48940. */
  48941. bone: Bone;
  48942. /**
  48943. * The up axis of the coordinate system that is used when the bone is rotated
  48944. */
  48945. upAxis: Vector3;
  48946. /**
  48947. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  48948. */
  48949. upAxisSpace: Space;
  48950. /**
  48951. * Used to make an adjustment to the yaw of the bone
  48952. */
  48953. adjustYaw: number;
  48954. /**
  48955. * Used to make an adjustment to the pitch of the bone
  48956. */
  48957. adjustPitch: number;
  48958. /**
  48959. * Used to make an adjustment to the roll of the bone
  48960. */
  48961. adjustRoll: number;
  48962. /**
  48963. * 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)
  48964. */
  48965. slerpAmount: number;
  48966. private _minYaw;
  48967. private _maxYaw;
  48968. private _minPitch;
  48969. private _maxPitch;
  48970. private _minYawSin;
  48971. private _minYawCos;
  48972. private _maxYawSin;
  48973. private _maxYawCos;
  48974. private _midYawConstraint;
  48975. private _minPitchTan;
  48976. private _maxPitchTan;
  48977. private _boneQuat;
  48978. private _slerping;
  48979. private _transformYawPitch;
  48980. private _transformYawPitchInv;
  48981. private _firstFrameSkipped;
  48982. private _yawRange;
  48983. private _fowardAxis;
  48984. /**
  48985. * Gets or sets the minimum yaw angle that the bone can look to
  48986. */
  48987. get minYaw(): number;
  48988. set minYaw(value: number);
  48989. /**
  48990. * Gets or sets the maximum yaw angle that the bone can look to
  48991. */
  48992. get maxYaw(): number;
  48993. set maxYaw(value: number);
  48994. /**
  48995. * Gets or sets the minimum pitch angle that the bone can look to
  48996. */
  48997. get minPitch(): number;
  48998. set minPitch(value: number);
  48999. /**
  49000. * Gets or sets the maximum pitch angle that the bone can look to
  49001. */
  49002. get maxPitch(): number;
  49003. set maxPitch(value: number);
  49004. /**
  49005. * Create a BoneLookController
  49006. * @param mesh the mesh that the bone belongs to
  49007. * @param bone the bone that will be looking to the target
  49008. * @param target the target Vector3 to look at
  49009. * @param options optional settings:
  49010. * * maxYaw: the maximum angle the bone will yaw to
  49011. * * minYaw: the minimum angle the bone will yaw to
  49012. * * maxPitch: the maximum angle the bone will pitch to
  49013. * * minPitch: the minimum angle the bone will yaw to
  49014. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  49015. * * upAxis: the up axis of the coordinate system
  49016. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  49017. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  49018. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  49019. * * adjustYaw: used to make an adjustment to the yaw of the bone
  49020. * * adjustPitch: used to make an adjustment to the pitch of the bone
  49021. * * adjustRoll: used to make an adjustment to the roll of the bone
  49022. **/
  49023. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  49024. maxYaw?: number;
  49025. minYaw?: number;
  49026. maxPitch?: number;
  49027. minPitch?: number;
  49028. slerpAmount?: number;
  49029. upAxis?: Vector3;
  49030. upAxisSpace?: Space;
  49031. yawAxis?: Vector3;
  49032. pitchAxis?: Vector3;
  49033. adjustYaw?: number;
  49034. adjustPitch?: number;
  49035. adjustRoll?: number;
  49036. });
  49037. /**
  49038. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  49039. */
  49040. update(): void;
  49041. private _getAngleDiff;
  49042. private _getAngleBetween;
  49043. private _isAngleBetween;
  49044. }
  49045. }
  49046. declare module "babylonjs/Bones/index" {
  49047. export * from "babylonjs/Bones/bone";
  49048. export * from "babylonjs/Bones/boneIKController";
  49049. export * from "babylonjs/Bones/boneLookController";
  49050. export * from "babylonjs/Bones/skeleton";
  49051. }
  49052. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  49053. import { Nullable } from "babylonjs/types";
  49054. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49055. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49056. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49057. /**
  49058. * Manage the gamepad inputs to control an arc rotate camera.
  49059. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49060. */
  49061. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  49062. /**
  49063. * Defines the camera the input is attached to.
  49064. */
  49065. camera: ArcRotateCamera;
  49066. /**
  49067. * Defines the gamepad the input is gathering event from.
  49068. */
  49069. gamepad: Nullable<Gamepad>;
  49070. /**
  49071. * Defines the gamepad rotation sensiblity.
  49072. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49073. */
  49074. gamepadRotationSensibility: number;
  49075. /**
  49076. * Defines the gamepad move sensiblity.
  49077. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49078. */
  49079. gamepadMoveSensibility: number;
  49080. private _yAxisScale;
  49081. /**
  49082. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49083. */
  49084. get invertYAxis(): boolean;
  49085. set invertYAxis(value: boolean);
  49086. private _onGamepadConnectedObserver;
  49087. private _onGamepadDisconnectedObserver;
  49088. /**
  49089. * Attach the input controls to a specific dom element to get the input from.
  49090. */
  49091. attachControl(): void;
  49092. /**
  49093. * Detach the current controls from the specified dom element.
  49094. * @param element Defines the element to stop listening the inputs from
  49095. */
  49096. detachControl(): void;
  49097. /**
  49098. * Update the current camera state depending on the inputs that have been used this frame.
  49099. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49100. */
  49101. checkInputs(): void;
  49102. /**
  49103. * Gets the class name of the current intput.
  49104. * @returns the class name
  49105. */
  49106. getClassName(): string;
  49107. /**
  49108. * Get the friendly name associated with the input class.
  49109. * @returns the input friendly name
  49110. */
  49111. getSimpleName(): string;
  49112. }
  49113. }
  49114. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  49115. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49116. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49117. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  49118. interface ArcRotateCameraInputsManager {
  49119. /**
  49120. * Add orientation input support to the input manager.
  49121. * @returns the current input manager
  49122. */
  49123. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  49124. }
  49125. }
  49126. /**
  49127. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  49128. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49129. */
  49130. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  49131. /**
  49132. * Defines the camera the input is attached to.
  49133. */
  49134. camera: ArcRotateCamera;
  49135. /**
  49136. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  49137. */
  49138. alphaCorrection: number;
  49139. /**
  49140. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  49141. */
  49142. gammaCorrection: number;
  49143. private _alpha;
  49144. private _gamma;
  49145. private _dirty;
  49146. private _deviceOrientationHandler;
  49147. /**
  49148. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  49149. */
  49150. constructor();
  49151. /**
  49152. * Attach the input controls to a specific dom element to get the input from.
  49153. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49154. */
  49155. attachControl(noPreventDefault?: boolean): void;
  49156. /** @hidden */
  49157. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  49158. /**
  49159. * Update the current camera state depending on the inputs that have been used this frame.
  49160. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49161. */
  49162. checkInputs(): void;
  49163. /**
  49164. * Detach the current controls from the specified dom element.
  49165. */
  49166. detachControl(): void;
  49167. /**
  49168. * Gets the class name of the current intput.
  49169. * @returns the class name
  49170. */
  49171. getClassName(): string;
  49172. /**
  49173. * Get the friendly name associated with the input class.
  49174. * @returns the input friendly name
  49175. */
  49176. getSimpleName(): string;
  49177. }
  49178. }
  49179. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  49180. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49181. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49182. /**
  49183. * Listen to mouse events to control the camera.
  49184. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49185. */
  49186. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  49187. /**
  49188. * Defines the camera the input is attached to.
  49189. */
  49190. camera: FlyCamera;
  49191. /**
  49192. * Defines if touch is enabled. (Default is true.)
  49193. */
  49194. touchEnabled: boolean;
  49195. /**
  49196. * Defines the buttons associated with the input to handle camera rotation.
  49197. */
  49198. buttons: number[];
  49199. /**
  49200. * Assign buttons for Yaw control.
  49201. */
  49202. buttonsYaw: number[];
  49203. /**
  49204. * Assign buttons for Pitch control.
  49205. */
  49206. buttonsPitch: number[];
  49207. /**
  49208. * Assign buttons for Roll control.
  49209. */
  49210. buttonsRoll: number[];
  49211. /**
  49212. * Detect if any button is being pressed while mouse is moved.
  49213. * -1 = Mouse locked.
  49214. * 0 = Left button.
  49215. * 1 = Middle Button.
  49216. * 2 = Right Button.
  49217. */
  49218. activeButton: number;
  49219. /**
  49220. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  49221. * Higher values reduce its sensitivity.
  49222. */
  49223. angularSensibility: number;
  49224. private _observer;
  49225. private _rollObserver;
  49226. private previousPosition;
  49227. private noPreventDefault;
  49228. private element;
  49229. /**
  49230. * Listen to mouse events to control the camera.
  49231. * @param touchEnabled Define if touch is enabled. (Default is true.)
  49232. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49233. */
  49234. constructor(touchEnabled?: boolean);
  49235. /**
  49236. * Attach the mouse control to the HTML DOM element.
  49237. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  49238. */
  49239. attachControl(noPreventDefault?: boolean): void;
  49240. /**
  49241. * Detach the current controls from the specified dom element.
  49242. */
  49243. detachControl(): void;
  49244. /**
  49245. * Gets the class name of the current input.
  49246. * @returns the class name.
  49247. */
  49248. getClassName(): string;
  49249. /**
  49250. * Get the friendly name associated with the input class.
  49251. * @returns the input's friendly name.
  49252. */
  49253. getSimpleName(): string;
  49254. private _pointerInput;
  49255. private _onMouseMove;
  49256. /**
  49257. * Rotate camera by mouse offset.
  49258. */
  49259. private rotateCamera;
  49260. }
  49261. }
  49262. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  49263. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49264. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49265. /**
  49266. * Default Inputs manager for the FlyCamera.
  49267. * It groups all the default supported inputs for ease of use.
  49268. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49269. */
  49270. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  49271. /**
  49272. * Instantiates a new FlyCameraInputsManager.
  49273. * @param camera Defines the camera the inputs belong to.
  49274. */
  49275. constructor(camera: FlyCamera);
  49276. /**
  49277. * Add keyboard input support to the input manager.
  49278. * @returns the new FlyCameraKeyboardMoveInput().
  49279. */
  49280. addKeyboard(): FlyCameraInputsManager;
  49281. /**
  49282. * Add mouse input support to the input manager.
  49283. * @param touchEnabled Enable touch screen support.
  49284. * @returns the new FlyCameraMouseInput().
  49285. */
  49286. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  49287. }
  49288. }
  49289. declare module "babylonjs/Cameras/flyCamera" {
  49290. import { Scene } from "babylonjs/scene";
  49291. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  49292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49293. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49294. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  49295. /**
  49296. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49297. * such as in a 3D Space Shooter or a Flight Simulator.
  49298. */
  49299. export class FlyCamera extends TargetCamera {
  49300. /**
  49301. * Define the collision ellipsoid of the camera.
  49302. * This is helpful for simulating a camera body, like a player's body.
  49303. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49304. */
  49305. ellipsoid: Vector3;
  49306. /**
  49307. * Define an offset for the position of the ellipsoid around the camera.
  49308. * This can be helpful if the camera is attached away from the player's body center,
  49309. * such as at its head.
  49310. */
  49311. ellipsoidOffset: Vector3;
  49312. /**
  49313. * Enable or disable collisions of the camera with the rest of the scene objects.
  49314. */
  49315. checkCollisions: boolean;
  49316. /**
  49317. * Enable or disable gravity on the camera.
  49318. */
  49319. applyGravity: boolean;
  49320. /**
  49321. * Define the current direction the camera is moving to.
  49322. */
  49323. cameraDirection: Vector3;
  49324. /**
  49325. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  49326. * This overrides and empties cameraRotation.
  49327. */
  49328. rotationQuaternion: Quaternion;
  49329. /**
  49330. * Track Roll to maintain the wanted Rolling when looking around.
  49331. */
  49332. _trackRoll: number;
  49333. /**
  49334. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  49335. */
  49336. rollCorrect: number;
  49337. /**
  49338. * Mimic a banked turn, Rolling the camera when Yawing.
  49339. * It's recommended to use rollCorrect = 10 for faster banking correction.
  49340. */
  49341. bankedTurn: boolean;
  49342. /**
  49343. * Limit in radians for how much Roll banking will add. (Default: 90°)
  49344. */
  49345. bankedTurnLimit: number;
  49346. /**
  49347. * Value of 0 disables the banked Roll.
  49348. * Value of 1 is equal to the Yaw angle in radians.
  49349. */
  49350. bankedTurnMultiplier: number;
  49351. /**
  49352. * The inputs manager loads all the input sources, such as keyboard and mouse.
  49353. */
  49354. inputs: FlyCameraInputsManager;
  49355. /**
  49356. * Gets the input sensibility for mouse input.
  49357. * Higher values reduce sensitivity.
  49358. */
  49359. get angularSensibility(): number;
  49360. /**
  49361. * Sets the input sensibility for a mouse input.
  49362. * Higher values reduce sensitivity.
  49363. */
  49364. set angularSensibility(value: number);
  49365. /**
  49366. * Get the keys for camera movement forward.
  49367. */
  49368. get keysForward(): number[];
  49369. /**
  49370. * Set the keys for camera movement forward.
  49371. */
  49372. set keysForward(value: number[]);
  49373. /**
  49374. * Get the keys for camera movement backward.
  49375. */
  49376. get keysBackward(): number[];
  49377. set keysBackward(value: number[]);
  49378. /**
  49379. * Get the keys for camera movement up.
  49380. */
  49381. get keysUp(): number[];
  49382. /**
  49383. * Set the keys for camera movement up.
  49384. */
  49385. set keysUp(value: number[]);
  49386. /**
  49387. * Get the keys for camera movement down.
  49388. */
  49389. get keysDown(): number[];
  49390. /**
  49391. * Set the keys for camera movement down.
  49392. */
  49393. set keysDown(value: number[]);
  49394. /**
  49395. * Get the keys for camera movement left.
  49396. */
  49397. get keysLeft(): number[];
  49398. /**
  49399. * Set the keys for camera movement left.
  49400. */
  49401. set keysLeft(value: number[]);
  49402. /**
  49403. * Set the keys for camera movement right.
  49404. */
  49405. get keysRight(): number[];
  49406. /**
  49407. * Set the keys for camera movement right.
  49408. */
  49409. set keysRight(value: number[]);
  49410. /**
  49411. * Event raised when the camera collides with a mesh in the scene.
  49412. */
  49413. onCollide: (collidedMesh: AbstractMesh) => void;
  49414. private _collider;
  49415. private _needMoveForGravity;
  49416. private _oldPosition;
  49417. private _diffPosition;
  49418. private _newPosition;
  49419. /** @hidden */
  49420. _localDirection: Vector3;
  49421. /** @hidden */
  49422. _transformedDirection: Vector3;
  49423. /**
  49424. * Instantiates a FlyCamera.
  49425. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49426. * such as in a 3D Space Shooter or a Flight Simulator.
  49427. * @param name Define the name of the camera in the scene.
  49428. * @param position Define the starting position of the camera in the scene.
  49429. * @param scene Define the scene the camera belongs to.
  49430. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49431. */
  49432. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49433. /**
  49434. * Attach a control to the HTML DOM element.
  49435. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  49436. */
  49437. attachControl(noPreventDefault?: boolean): void;
  49438. /**
  49439. * Detach a control from the HTML DOM element.
  49440. * The camera will stop reacting to that input.
  49441. */
  49442. detachControl(): void;
  49443. private _collisionMask;
  49444. /**
  49445. * Get the mask that the camera ignores in collision events.
  49446. */
  49447. get collisionMask(): number;
  49448. /**
  49449. * Set the mask that the camera ignores in collision events.
  49450. */
  49451. set collisionMask(mask: number);
  49452. /** @hidden */
  49453. _collideWithWorld(displacement: Vector3): void;
  49454. /** @hidden */
  49455. private _onCollisionPositionChange;
  49456. /** @hidden */
  49457. _checkInputs(): void;
  49458. /** @hidden */
  49459. _decideIfNeedsToMove(): boolean;
  49460. /** @hidden */
  49461. _updatePosition(): void;
  49462. /**
  49463. * Restore the Roll to its target value at the rate specified.
  49464. * @param rate - Higher means slower restoring.
  49465. * @hidden
  49466. */
  49467. restoreRoll(rate: number): void;
  49468. /**
  49469. * Destroy the camera and release the current resources held by it.
  49470. */
  49471. dispose(): void;
  49472. /**
  49473. * Get the current object class name.
  49474. * @returns the class name.
  49475. */
  49476. getClassName(): string;
  49477. }
  49478. }
  49479. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49480. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49481. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49482. /**
  49483. * Listen to keyboard events to control the camera.
  49484. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49485. */
  49486. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49487. /**
  49488. * Defines the camera the input is attached to.
  49489. */
  49490. camera: FlyCamera;
  49491. /**
  49492. * The list of keyboard keys used to control the forward move of the camera.
  49493. */
  49494. keysForward: number[];
  49495. /**
  49496. * The list of keyboard keys used to control the backward move of the camera.
  49497. */
  49498. keysBackward: number[];
  49499. /**
  49500. * The list of keyboard keys used to control the forward move of the camera.
  49501. */
  49502. keysUp: number[];
  49503. /**
  49504. * The list of keyboard keys used to control the backward move of the camera.
  49505. */
  49506. keysDown: number[];
  49507. /**
  49508. * The list of keyboard keys used to control the right strafe move of the camera.
  49509. */
  49510. keysRight: number[];
  49511. /**
  49512. * The list of keyboard keys used to control the left strafe move of the camera.
  49513. */
  49514. keysLeft: number[];
  49515. private _keys;
  49516. private _onCanvasBlurObserver;
  49517. private _onKeyboardObserver;
  49518. private _engine;
  49519. private _scene;
  49520. /**
  49521. * Attach the input controls to a specific dom element to get the input from.
  49522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49523. */
  49524. attachControl(noPreventDefault?: boolean): void;
  49525. /**
  49526. * Detach the current controls from the specified dom element.
  49527. */
  49528. detachControl(): void;
  49529. /**
  49530. * Gets the class name of the current intput.
  49531. * @returns the class name
  49532. */
  49533. getClassName(): string;
  49534. /** @hidden */
  49535. _onLostFocus(e: FocusEvent): void;
  49536. /**
  49537. * Get the friendly name associated with the input class.
  49538. * @returns the input friendly name
  49539. */
  49540. getSimpleName(): string;
  49541. /**
  49542. * Update the current camera state depending on the inputs that have been used this frame.
  49543. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49544. */
  49545. checkInputs(): void;
  49546. }
  49547. }
  49548. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49549. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49550. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49551. /**
  49552. * Manage the mouse wheel inputs to control a follow camera.
  49553. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49554. */
  49555. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49556. /**
  49557. * Defines the camera the input is attached to.
  49558. */
  49559. camera: FollowCamera;
  49560. /**
  49561. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49562. */
  49563. axisControlRadius: boolean;
  49564. /**
  49565. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49566. */
  49567. axisControlHeight: boolean;
  49568. /**
  49569. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49570. */
  49571. axisControlRotation: boolean;
  49572. /**
  49573. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49574. * relation to mouseWheel events.
  49575. */
  49576. wheelPrecision: number;
  49577. /**
  49578. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49579. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49580. */
  49581. wheelDeltaPercentage: number;
  49582. private _wheel;
  49583. private _observer;
  49584. /**
  49585. * Attach the input controls to a specific dom element to get the input from.
  49586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49587. */
  49588. attachControl(noPreventDefault?: boolean): void;
  49589. /**
  49590. * Detach the current controls from the specified dom element.
  49591. */
  49592. detachControl(): void;
  49593. /**
  49594. * Gets the class name of the current intput.
  49595. * @returns the class name
  49596. */
  49597. getClassName(): string;
  49598. /**
  49599. * Get the friendly name associated with the input class.
  49600. * @returns the input friendly name
  49601. */
  49602. getSimpleName(): string;
  49603. }
  49604. }
  49605. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49606. import { Nullable } from "babylonjs/types";
  49607. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49608. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49609. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49610. /**
  49611. * Manage the pointers inputs to control an follow camera.
  49612. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49613. */
  49614. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49615. /**
  49616. * Defines the camera the input is attached to.
  49617. */
  49618. camera: FollowCamera;
  49619. /**
  49620. * Gets the class name of the current input.
  49621. * @returns the class name
  49622. */
  49623. getClassName(): string;
  49624. /**
  49625. * Defines the pointer angular sensibility along the X axis or how fast is
  49626. * the camera rotating.
  49627. * A negative number will reverse the axis direction.
  49628. */
  49629. angularSensibilityX: number;
  49630. /**
  49631. * Defines the pointer angular sensibility along the Y axis or how fast is
  49632. * the camera rotating.
  49633. * A negative number will reverse the axis direction.
  49634. */
  49635. angularSensibilityY: number;
  49636. /**
  49637. * Defines the pointer pinch precision or how fast is the camera zooming.
  49638. * A negative number will reverse the axis direction.
  49639. */
  49640. pinchPrecision: number;
  49641. /**
  49642. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49643. * from 0.
  49644. * It defines the percentage of current camera.radius to use as delta when
  49645. * pinch zoom is used.
  49646. */
  49647. pinchDeltaPercentage: number;
  49648. /**
  49649. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  49650. */
  49651. axisXControlRadius: boolean;
  49652. /**
  49653. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  49654. */
  49655. axisXControlHeight: boolean;
  49656. /**
  49657. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  49658. */
  49659. axisXControlRotation: boolean;
  49660. /**
  49661. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  49662. */
  49663. axisYControlRadius: boolean;
  49664. /**
  49665. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  49666. */
  49667. axisYControlHeight: boolean;
  49668. /**
  49669. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  49670. */
  49671. axisYControlRotation: boolean;
  49672. /**
  49673. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  49674. */
  49675. axisPinchControlRadius: boolean;
  49676. /**
  49677. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  49678. */
  49679. axisPinchControlHeight: boolean;
  49680. /**
  49681. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  49682. */
  49683. axisPinchControlRotation: boolean;
  49684. /**
  49685. * Log error messages if basic misconfiguration has occurred.
  49686. */
  49687. warningEnable: boolean;
  49688. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49689. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49690. private _warningCounter;
  49691. private _warning;
  49692. }
  49693. }
  49694. declare module "babylonjs/Cameras/followCameraInputsManager" {
  49695. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49696. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49697. /**
  49698. * Default Inputs manager for the FollowCamera.
  49699. * It groups all the default supported inputs for ease of use.
  49700. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49701. */
  49702. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  49703. /**
  49704. * Instantiates a new FollowCameraInputsManager.
  49705. * @param camera Defines the camera the inputs belong to
  49706. */
  49707. constructor(camera: FollowCamera);
  49708. /**
  49709. * Add keyboard input support to the input manager.
  49710. * @returns the current input manager
  49711. */
  49712. addKeyboard(): FollowCameraInputsManager;
  49713. /**
  49714. * Add mouse wheel input support to the input manager.
  49715. * @returns the current input manager
  49716. */
  49717. addMouseWheel(): FollowCameraInputsManager;
  49718. /**
  49719. * Add pointers input support to the input manager.
  49720. * @returns the current input manager
  49721. */
  49722. addPointers(): FollowCameraInputsManager;
  49723. /**
  49724. * Add orientation input support to the input manager.
  49725. * @returns the current input manager
  49726. */
  49727. addVRDeviceOrientation(): FollowCameraInputsManager;
  49728. }
  49729. }
  49730. declare module "babylonjs/Cameras/followCamera" {
  49731. import { Nullable } from "babylonjs/types";
  49732. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49733. import { Scene } from "babylonjs/scene";
  49734. import { Vector3 } from "babylonjs/Maths/math.vector";
  49735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49736. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  49737. /**
  49738. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  49739. * an arc rotate version arcFollowCamera are available.
  49740. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49741. */
  49742. export class FollowCamera extends TargetCamera {
  49743. /**
  49744. * Distance the follow camera should follow an object at
  49745. */
  49746. radius: number;
  49747. /**
  49748. * Minimum allowed distance of the camera to the axis of rotation
  49749. * (The camera can not get closer).
  49750. * This can help limiting how the Camera is able to move in the scene.
  49751. */
  49752. lowerRadiusLimit: Nullable<number>;
  49753. /**
  49754. * Maximum allowed distance of the camera to the axis of rotation
  49755. * (The camera can not get further).
  49756. * This can help limiting how the Camera is able to move in the scene.
  49757. */
  49758. upperRadiusLimit: Nullable<number>;
  49759. /**
  49760. * Define a rotation offset between the camera and the object it follows
  49761. */
  49762. rotationOffset: number;
  49763. /**
  49764. * Minimum allowed angle to camera position relative to target object.
  49765. * This can help limiting how the Camera is able to move in the scene.
  49766. */
  49767. lowerRotationOffsetLimit: Nullable<number>;
  49768. /**
  49769. * Maximum allowed angle to camera position relative to target object.
  49770. * This can help limiting how the Camera is able to move in the scene.
  49771. */
  49772. upperRotationOffsetLimit: Nullable<number>;
  49773. /**
  49774. * Define a height offset between the camera and the object it follows.
  49775. * It can help following an object from the top (like a car chaing a plane)
  49776. */
  49777. heightOffset: number;
  49778. /**
  49779. * Minimum allowed height of camera position relative to target object.
  49780. * This can help limiting how the Camera is able to move in the scene.
  49781. */
  49782. lowerHeightOffsetLimit: Nullable<number>;
  49783. /**
  49784. * Maximum allowed height of camera position relative to target object.
  49785. * This can help limiting how the Camera is able to move in the scene.
  49786. */
  49787. upperHeightOffsetLimit: Nullable<number>;
  49788. /**
  49789. * Define how fast the camera can accelerate to follow it s target.
  49790. */
  49791. cameraAcceleration: number;
  49792. /**
  49793. * Define the speed limit of the camera following an object.
  49794. */
  49795. maxCameraSpeed: number;
  49796. /**
  49797. * Define the target of the camera.
  49798. */
  49799. lockedTarget: Nullable<AbstractMesh>;
  49800. /**
  49801. * Defines the input associated with the camera.
  49802. */
  49803. inputs: FollowCameraInputsManager;
  49804. /**
  49805. * Instantiates the follow camera.
  49806. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49807. * @param name Define the name of the camera in the scene
  49808. * @param position Define the position of the camera
  49809. * @param scene Define the scene the camera belong to
  49810. * @param lockedTarget Define the target of the camera
  49811. */
  49812. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  49813. private _follow;
  49814. /**
  49815. * Attached controls to the current camera.
  49816. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49817. */
  49818. attachControl(noPreventDefault?: boolean): void;
  49819. /**
  49820. * Detach the current controls from the camera.
  49821. * The camera will stop reacting to inputs.
  49822. */
  49823. detachControl(): void;
  49824. /** @hidden */
  49825. _checkInputs(): void;
  49826. private _checkLimits;
  49827. /**
  49828. * Gets the camera class name.
  49829. * @returns the class name
  49830. */
  49831. getClassName(): string;
  49832. }
  49833. /**
  49834. * Arc Rotate version of the follow camera.
  49835. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  49836. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49837. */
  49838. export class ArcFollowCamera extends TargetCamera {
  49839. /** The longitudinal angle of the camera */
  49840. alpha: number;
  49841. /** The latitudinal angle of the camera */
  49842. beta: number;
  49843. /** The radius of the camera from its target */
  49844. radius: number;
  49845. private _cartesianCoordinates;
  49846. /** Define the camera target (the mesh it should follow) */
  49847. private _meshTarget;
  49848. /**
  49849. * Instantiates a new ArcFollowCamera
  49850. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49851. * @param name Define the name of the camera
  49852. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  49853. * @param beta Define the rotation angle of the camera around the elevation axis
  49854. * @param radius Define the radius of the camera from its target point
  49855. * @param target Define the target of the camera
  49856. * @param scene Define the scene the camera belongs to
  49857. */
  49858. constructor(name: string,
  49859. /** The longitudinal angle of the camera */
  49860. alpha: number,
  49861. /** The latitudinal angle of the camera */
  49862. beta: number,
  49863. /** The radius of the camera from its target */
  49864. radius: number,
  49865. /** Define the camera target (the mesh it should follow) */
  49866. target: Nullable<AbstractMesh>, scene: Scene);
  49867. private _follow;
  49868. /** @hidden */
  49869. _checkInputs(): void;
  49870. /**
  49871. * Returns the class name of the object.
  49872. * It is mostly used internally for serialization purposes.
  49873. */
  49874. getClassName(): string;
  49875. }
  49876. }
  49877. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  49878. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49879. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49880. /**
  49881. * Manage the keyboard inputs to control the movement of a follow camera.
  49882. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49883. */
  49884. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  49885. /**
  49886. * Defines the camera the input is attached to.
  49887. */
  49888. camera: FollowCamera;
  49889. /**
  49890. * Defines the list of key codes associated with the up action (increase heightOffset)
  49891. */
  49892. keysHeightOffsetIncr: number[];
  49893. /**
  49894. * Defines the list of key codes associated with the down action (decrease heightOffset)
  49895. */
  49896. keysHeightOffsetDecr: number[];
  49897. /**
  49898. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  49899. */
  49900. keysHeightOffsetModifierAlt: boolean;
  49901. /**
  49902. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  49903. */
  49904. keysHeightOffsetModifierCtrl: boolean;
  49905. /**
  49906. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  49907. */
  49908. keysHeightOffsetModifierShift: boolean;
  49909. /**
  49910. * Defines the list of key codes associated with the left action (increase rotationOffset)
  49911. */
  49912. keysRotationOffsetIncr: number[];
  49913. /**
  49914. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  49915. */
  49916. keysRotationOffsetDecr: number[];
  49917. /**
  49918. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  49919. */
  49920. keysRotationOffsetModifierAlt: boolean;
  49921. /**
  49922. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  49923. */
  49924. keysRotationOffsetModifierCtrl: boolean;
  49925. /**
  49926. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  49927. */
  49928. keysRotationOffsetModifierShift: boolean;
  49929. /**
  49930. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  49931. */
  49932. keysRadiusIncr: number[];
  49933. /**
  49934. * Defines the list of key codes associated with the zoom-out action (increase radius)
  49935. */
  49936. keysRadiusDecr: number[];
  49937. /**
  49938. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  49939. */
  49940. keysRadiusModifierAlt: boolean;
  49941. /**
  49942. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  49943. */
  49944. keysRadiusModifierCtrl: boolean;
  49945. /**
  49946. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  49947. */
  49948. keysRadiusModifierShift: boolean;
  49949. /**
  49950. * Defines the rate of change of heightOffset.
  49951. */
  49952. heightSensibility: number;
  49953. /**
  49954. * Defines the rate of change of rotationOffset.
  49955. */
  49956. rotationSensibility: number;
  49957. /**
  49958. * Defines the rate of change of radius.
  49959. */
  49960. radiusSensibility: number;
  49961. private _keys;
  49962. private _ctrlPressed;
  49963. private _altPressed;
  49964. private _shiftPressed;
  49965. private _onCanvasBlurObserver;
  49966. private _onKeyboardObserver;
  49967. private _engine;
  49968. private _scene;
  49969. /**
  49970. * Attach the input controls to a specific dom element to get the input from.
  49971. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49972. */
  49973. attachControl(noPreventDefault?: boolean): void;
  49974. /**
  49975. * Detach the current controls from the specified dom element.
  49976. */
  49977. detachControl(): void;
  49978. /**
  49979. * Update the current camera state depending on the inputs that have been used this frame.
  49980. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49981. */
  49982. checkInputs(): void;
  49983. /**
  49984. * Gets the class name of the current input.
  49985. * @returns the class name
  49986. */
  49987. getClassName(): string;
  49988. /**
  49989. * Get the friendly name associated with the input class.
  49990. * @returns the input friendly name
  49991. */
  49992. getSimpleName(): string;
  49993. /**
  49994. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49995. * allow modification of the heightOffset value.
  49996. */
  49997. private _modifierHeightOffset;
  49998. /**
  49999. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50000. * allow modification of the rotationOffset value.
  50001. */
  50002. private _modifierRotationOffset;
  50003. /**
  50004. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50005. * allow modification of the radius value.
  50006. */
  50007. private _modifierRadius;
  50008. }
  50009. }
  50010. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  50011. import { Nullable } from "babylonjs/types";
  50012. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50013. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50014. import { Observable } from "babylonjs/Misc/observable";
  50015. module "babylonjs/Cameras/freeCameraInputsManager" {
  50016. interface FreeCameraInputsManager {
  50017. /**
  50018. * @hidden
  50019. */
  50020. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  50021. /**
  50022. * Add orientation input support to the input manager.
  50023. * @returns the current input manager
  50024. */
  50025. addDeviceOrientation(): FreeCameraInputsManager;
  50026. }
  50027. }
  50028. /**
  50029. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  50030. * Screen rotation is taken into account.
  50031. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50032. */
  50033. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  50034. private _camera;
  50035. private _screenOrientationAngle;
  50036. private _constantTranform;
  50037. private _screenQuaternion;
  50038. private _alpha;
  50039. private _beta;
  50040. private _gamma;
  50041. /**
  50042. * Can be used to detect if a device orientation sensor is available on a device
  50043. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  50044. * @returns a promise that will resolve on orientation change
  50045. */
  50046. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  50047. /**
  50048. * @hidden
  50049. */
  50050. _onDeviceOrientationChangedObservable: Observable<void>;
  50051. /**
  50052. * Instantiates a new input
  50053. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50054. */
  50055. constructor();
  50056. /**
  50057. * Define the camera controlled by the input.
  50058. */
  50059. get camera(): FreeCamera;
  50060. set camera(camera: FreeCamera);
  50061. /**
  50062. * Attach the input controls to a specific dom element to get the input from.
  50063. */
  50064. attachControl(): void;
  50065. private _orientationChanged;
  50066. private _deviceOrientation;
  50067. /**
  50068. * Detach the current controls from the specified dom element.
  50069. */
  50070. detachControl(): void;
  50071. /**
  50072. * Update the current camera state depending on the inputs that have been used this frame.
  50073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50074. */
  50075. checkInputs(): void;
  50076. /**
  50077. * Gets the class name of the current intput.
  50078. * @returns the class name
  50079. */
  50080. getClassName(): string;
  50081. /**
  50082. * Get the friendly name associated with the input class.
  50083. * @returns the input friendly name
  50084. */
  50085. getSimpleName(): string;
  50086. }
  50087. }
  50088. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  50089. import { Nullable } from "babylonjs/types";
  50090. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50091. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50092. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50093. /**
  50094. * Manage the gamepad inputs to control a free camera.
  50095. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50096. */
  50097. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  50098. /**
  50099. * Define the camera the input is attached to.
  50100. */
  50101. camera: FreeCamera;
  50102. /**
  50103. * Define the Gamepad controlling the input
  50104. */
  50105. gamepad: Nullable<Gamepad>;
  50106. /**
  50107. * Defines the gamepad rotation sensiblity.
  50108. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50109. */
  50110. gamepadAngularSensibility: number;
  50111. /**
  50112. * Defines the gamepad move sensiblity.
  50113. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50114. */
  50115. gamepadMoveSensibility: number;
  50116. private _yAxisScale;
  50117. /**
  50118. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50119. */
  50120. get invertYAxis(): boolean;
  50121. set invertYAxis(value: boolean);
  50122. private _onGamepadConnectedObserver;
  50123. private _onGamepadDisconnectedObserver;
  50124. private _cameraTransform;
  50125. private _deltaTransform;
  50126. private _vector3;
  50127. private _vector2;
  50128. /**
  50129. * Attach the input controls to a specific dom element to get the input from.
  50130. */
  50131. attachControl(): void;
  50132. /**
  50133. * Detach the current controls from the specified dom element.
  50134. */
  50135. detachControl(): void;
  50136. /**
  50137. * Update the current camera state depending on the inputs that have been used this frame.
  50138. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50139. */
  50140. checkInputs(): void;
  50141. /**
  50142. * Gets the class name of the current intput.
  50143. * @returns the class name
  50144. */
  50145. getClassName(): string;
  50146. /**
  50147. * Get the friendly name associated with the input class.
  50148. * @returns the input friendly name
  50149. */
  50150. getSimpleName(): string;
  50151. }
  50152. }
  50153. declare module "babylonjs/Misc/virtualJoystick" {
  50154. import { Nullable } from "babylonjs/types";
  50155. import { Vector3 } from "babylonjs/Maths/math.vector";
  50156. /**
  50157. * Defines the potential axis of a Joystick
  50158. */
  50159. export enum JoystickAxis {
  50160. /** X axis */
  50161. X = 0,
  50162. /** Y axis */
  50163. Y = 1,
  50164. /** Z axis */
  50165. Z = 2
  50166. }
  50167. /**
  50168. * Represents the different customization options available
  50169. * for VirtualJoystick
  50170. */
  50171. interface VirtualJoystickCustomizations {
  50172. /**
  50173. * Size of the joystick's puck
  50174. */
  50175. puckSize: number;
  50176. /**
  50177. * Size of the joystick's container
  50178. */
  50179. containerSize: number;
  50180. /**
  50181. * Color of the joystick && puck
  50182. */
  50183. color: string;
  50184. /**
  50185. * Image URL for the joystick's puck
  50186. */
  50187. puckImage?: string;
  50188. /**
  50189. * Image URL for the joystick's container
  50190. */
  50191. containerImage?: string;
  50192. /**
  50193. * Defines the unmoving position of the joystick container
  50194. */
  50195. position?: {
  50196. x: number;
  50197. y: number;
  50198. };
  50199. /**
  50200. * Defines whether or not the joystick container is always visible
  50201. */
  50202. alwaysVisible: boolean;
  50203. /**
  50204. * Defines whether or not to limit the movement of the puck to the joystick's container
  50205. */
  50206. limitToContainer: boolean;
  50207. }
  50208. /**
  50209. * Class used to define virtual joystick (used in touch mode)
  50210. */
  50211. export class VirtualJoystick {
  50212. /**
  50213. * Gets or sets a boolean indicating that left and right values must be inverted
  50214. */
  50215. reverseLeftRight: boolean;
  50216. /**
  50217. * Gets or sets a boolean indicating that up and down values must be inverted
  50218. */
  50219. reverseUpDown: boolean;
  50220. /**
  50221. * Gets the offset value for the position (ie. the change of the position value)
  50222. */
  50223. deltaPosition: Vector3;
  50224. /**
  50225. * Gets a boolean indicating if the virtual joystick was pressed
  50226. */
  50227. pressed: boolean;
  50228. /**
  50229. * Canvas the virtual joystick will render onto, default z-index of this is 5
  50230. */
  50231. static Canvas: Nullable<HTMLCanvasElement>;
  50232. /**
  50233. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  50234. */
  50235. limitToContainer: boolean;
  50236. private static _globalJoystickIndex;
  50237. private static _alwaysVisibleSticks;
  50238. private static vjCanvasContext;
  50239. private static vjCanvasWidth;
  50240. private static vjCanvasHeight;
  50241. private static halfWidth;
  50242. private static _GetDefaultOptions;
  50243. private _action;
  50244. private _axisTargetedByLeftAndRight;
  50245. private _axisTargetedByUpAndDown;
  50246. private _joystickSensibility;
  50247. private _inversedSensibility;
  50248. private _joystickPointerID;
  50249. private _joystickColor;
  50250. private _joystickPointerPos;
  50251. private _joystickPreviousPointerPos;
  50252. private _joystickPointerStartPos;
  50253. private _deltaJoystickVector;
  50254. private _leftJoystick;
  50255. private _touches;
  50256. private _joystickPosition;
  50257. private _alwaysVisible;
  50258. private _puckImage;
  50259. private _containerImage;
  50260. private _joystickPuckSize;
  50261. private _joystickContainerSize;
  50262. private _clearPuckSize;
  50263. private _clearContainerSize;
  50264. private _clearPuckSizeOffset;
  50265. private _clearContainerSizeOffset;
  50266. private _onPointerDownHandlerRef;
  50267. private _onPointerMoveHandlerRef;
  50268. private _onPointerUpHandlerRef;
  50269. private _onResize;
  50270. /**
  50271. * Creates a new virtual joystick
  50272. * @param leftJoystick defines that the joystick is for left hand (false by default)
  50273. * @param customizations Defines the options we want to customize the VirtualJoystick
  50274. */
  50275. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  50276. /**
  50277. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  50278. * @param newJoystickSensibility defines the new sensibility
  50279. */
  50280. setJoystickSensibility(newJoystickSensibility: number): void;
  50281. private _onPointerDown;
  50282. private _onPointerMove;
  50283. private _onPointerUp;
  50284. /**
  50285. * Change the color of the virtual joystick
  50286. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  50287. */
  50288. setJoystickColor(newColor: string): void;
  50289. /**
  50290. * Size of the joystick's container
  50291. */
  50292. set containerSize(newSize: number);
  50293. get containerSize(): number;
  50294. /**
  50295. * Size of the joystick's puck
  50296. */
  50297. set puckSize(newSize: number);
  50298. get puckSize(): number;
  50299. /**
  50300. * Clears the set position of the joystick
  50301. */
  50302. clearPosition(): void;
  50303. /**
  50304. * Defines whether or not the joystick container is always visible
  50305. */
  50306. set alwaysVisible(value: boolean);
  50307. get alwaysVisible(): boolean;
  50308. /**
  50309. * Sets the constant position of the Joystick container
  50310. * @param x X axis coordinate
  50311. * @param y Y axis coordinate
  50312. */
  50313. setPosition(x: number, y: number): void;
  50314. /**
  50315. * Defines a callback to call when the joystick is touched
  50316. * @param action defines the callback
  50317. */
  50318. setActionOnTouch(action: () => any): void;
  50319. /**
  50320. * Defines which axis you'd like to control for left & right
  50321. * @param axis defines the axis to use
  50322. */
  50323. setAxisForLeftRight(axis: JoystickAxis): void;
  50324. /**
  50325. * Defines which axis you'd like to control for up & down
  50326. * @param axis defines the axis to use
  50327. */
  50328. setAxisForUpDown(axis: JoystickAxis): void;
  50329. /**
  50330. * Clears the canvas from the previous puck / container draw
  50331. */
  50332. private _clearPreviousDraw;
  50333. /**
  50334. * Loads `urlPath` to be used for the container's image
  50335. * @param urlPath defines the urlPath of an image to use
  50336. */
  50337. setContainerImage(urlPath: string): void;
  50338. /**
  50339. * Loads `urlPath` to be used for the puck's image
  50340. * @param urlPath defines the urlPath of an image to use
  50341. */
  50342. setPuckImage(urlPath: string): void;
  50343. /**
  50344. * Draws the Virtual Joystick's container
  50345. */
  50346. private _drawContainer;
  50347. /**
  50348. * Draws the Virtual Joystick's puck
  50349. */
  50350. private _drawPuck;
  50351. private _drawVirtualJoystick;
  50352. /**
  50353. * Release internal HTML canvas
  50354. */
  50355. releaseCanvas(): void;
  50356. }
  50357. }
  50358. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50359. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50360. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50361. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50362. module "babylonjs/Cameras/freeCameraInputsManager" {
  50363. interface FreeCameraInputsManager {
  50364. /**
  50365. * Add virtual joystick input support to the input manager.
  50366. * @returns the current input manager
  50367. */
  50368. addVirtualJoystick(): FreeCameraInputsManager;
  50369. }
  50370. }
  50371. /**
  50372. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50373. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50374. */
  50375. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50376. /**
  50377. * Defines the camera the input is attached to.
  50378. */
  50379. camera: FreeCamera;
  50380. private _leftjoystick;
  50381. private _rightjoystick;
  50382. /**
  50383. * Gets the left stick of the virtual joystick.
  50384. * @returns The virtual Joystick
  50385. */
  50386. getLeftJoystick(): VirtualJoystick;
  50387. /**
  50388. * Gets the right stick of the virtual joystick.
  50389. * @returns The virtual Joystick
  50390. */
  50391. getRightJoystick(): VirtualJoystick;
  50392. /**
  50393. * Update the current camera state depending on the inputs that have been used this frame.
  50394. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50395. */
  50396. checkInputs(): void;
  50397. /**
  50398. * Attach the input controls to a specific dom element to get the input from.
  50399. */
  50400. attachControl(): void;
  50401. /**
  50402. * Detach the current controls from the specified dom element.
  50403. */
  50404. detachControl(): void;
  50405. /**
  50406. * Gets the class name of the current intput.
  50407. * @returns the class name
  50408. */
  50409. getClassName(): string;
  50410. /**
  50411. * Get the friendly name associated with the input class.
  50412. * @returns the input friendly name
  50413. */
  50414. getSimpleName(): string;
  50415. }
  50416. }
  50417. declare module "babylonjs/Cameras/Inputs/index" {
  50418. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50419. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50420. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50421. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50422. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50423. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50424. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50425. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50426. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50427. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50428. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50429. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50430. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50431. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50432. export * from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  50433. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50434. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50435. }
  50436. declare module "babylonjs/Cameras/touchCamera" {
  50437. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50438. import { Scene } from "babylonjs/scene";
  50439. import { Vector3 } from "babylonjs/Maths/math.vector";
  50440. /**
  50441. * This represents a FPS type of camera controlled by touch.
  50442. * This is like a universal camera minus the Gamepad controls.
  50443. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50444. */
  50445. export class TouchCamera extends FreeCamera {
  50446. /**
  50447. * Defines the touch sensibility for rotation.
  50448. * The higher the faster.
  50449. */
  50450. get touchAngularSensibility(): number;
  50451. set touchAngularSensibility(value: number);
  50452. /**
  50453. * Defines the touch sensibility for move.
  50454. * The higher the faster.
  50455. */
  50456. get touchMoveSensibility(): number;
  50457. set touchMoveSensibility(value: number);
  50458. /**
  50459. * Instantiates a new touch camera.
  50460. * This represents a FPS type of camera controlled by touch.
  50461. * This is like a universal camera minus the Gamepad controls.
  50462. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50463. * @param name Define the name of the camera in the scene
  50464. * @param position Define the start position of the camera in the scene
  50465. * @param scene Define the scene the camera belongs to
  50466. */
  50467. constructor(name: string, position: Vector3, scene: Scene);
  50468. /**
  50469. * Gets the current object class name.
  50470. * @return the class name
  50471. */
  50472. getClassName(): string;
  50473. /** @hidden */
  50474. _setupInputs(): void;
  50475. }
  50476. }
  50477. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50478. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50479. import { Scene } from "babylonjs/scene";
  50480. import { Vector3 } from "babylonjs/Maths/math.vector";
  50481. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50482. import { Axis } from "babylonjs/Maths/math.axis";
  50483. /**
  50484. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50485. * being tilted forward or back and left or right.
  50486. */
  50487. export class DeviceOrientationCamera extends FreeCamera {
  50488. private _initialQuaternion;
  50489. private _quaternionCache;
  50490. private _tmpDragQuaternion;
  50491. private _disablePointerInputWhenUsingDeviceOrientation;
  50492. /**
  50493. * Creates a new device orientation camera
  50494. * @param name The name of the camera
  50495. * @param position The start position camera
  50496. * @param scene The scene the camera belongs to
  50497. */
  50498. constructor(name: string, position: Vector3, scene: Scene);
  50499. /**
  50500. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50501. */
  50502. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50503. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50504. private _dragFactor;
  50505. /**
  50506. * Enabled turning on the y axis when the orientation sensor is active
  50507. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50508. */
  50509. enableHorizontalDragging(dragFactor?: number): void;
  50510. /**
  50511. * Gets the current instance class name ("DeviceOrientationCamera").
  50512. * This helps avoiding instanceof at run time.
  50513. * @returns the class name
  50514. */
  50515. getClassName(): string;
  50516. /**
  50517. * @hidden
  50518. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50519. */
  50520. _checkInputs(): void;
  50521. /**
  50522. * Reset the camera to its default orientation on the specified axis only.
  50523. * @param axis The axis to reset
  50524. */
  50525. resetToCurrentRotation(axis?: Axis): void;
  50526. }
  50527. }
  50528. declare module "babylonjs/Gamepads/xboxGamepad" {
  50529. import { Observable } from "babylonjs/Misc/observable";
  50530. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50531. /**
  50532. * Defines supported buttons for XBox360 compatible gamepads
  50533. */
  50534. export enum Xbox360Button {
  50535. /** A */
  50536. A = 0,
  50537. /** B */
  50538. B = 1,
  50539. /** X */
  50540. X = 2,
  50541. /** Y */
  50542. Y = 3,
  50543. /** Left button */
  50544. LB = 4,
  50545. /** Right button */
  50546. RB = 5,
  50547. /** Back */
  50548. Back = 8,
  50549. /** Start */
  50550. Start = 9,
  50551. /** Left stick */
  50552. LeftStick = 10,
  50553. /** Right stick */
  50554. RightStick = 11
  50555. }
  50556. /** Defines values for XBox360 DPad */
  50557. export enum Xbox360Dpad {
  50558. /** Up */
  50559. Up = 12,
  50560. /** Down */
  50561. Down = 13,
  50562. /** Left */
  50563. Left = 14,
  50564. /** Right */
  50565. Right = 15
  50566. }
  50567. /**
  50568. * Defines a XBox360 gamepad
  50569. */
  50570. export class Xbox360Pad extends Gamepad {
  50571. private _leftTrigger;
  50572. private _rightTrigger;
  50573. private _onlefttriggerchanged;
  50574. private _onrighttriggerchanged;
  50575. private _onbuttondown;
  50576. private _onbuttonup;
  50577. private _ondpaddown;
  50578. private _ondpadup;
  50579. /** Observable raised when a button is pressed */
  50580. onButtonDownObservable: Observable<Xbox360Button>;
  50581. /** Observable raised when a button is released */
  50582. onButtonUpObservable: Observable<Xbox360Button>;
  50583. /** Observable raised when a pad is pressed */
  50584. onPadDownObservable: Observable<Xbox360Dpad>;
  50585. /** Observable raised when a pad is released */
  50586. onPadUpObservable: Observable<Xbox360Dpad>;
  50587. private _buttonA;
  50588. private _buttonB;
  50589. private _buttonX;
  50590. private _buttonY;
  50591. private _buttonBack;
  50592. private _buttonStart;
  50593. private _buttonLB;
  50594. private _buttonRB;
  50595. private _buttonLeftStick;
  50596. private _buttonRightStick;
  50597. private _dPadUp;
  50598. private _dPadDown;
  50599. private _dPadLeft;
  50600. private _dPadRight;
  50601. private _isXboxOnePad;
  50602. /**
  50603. * Creates a new XBox360 gamepad object
  50604. * @param id defines the id of this gamepad
  50605. * @param index defines its index
  50606. * @param gamepad defines the internal HTML gamepad object
  50607. * @param xboxOne defines if it is a XBox One gamepad
  50608. */
  50609. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50610. /**
  50611. * Defines the callback to call when left trigger is pressed
  50612. * @param callback defines the callback to use
  50613. */
  50614. onlefttriggerchanged(callback: (value: number) => void): void;
  50615. /**
  50616. * Defines the callback to call when right trigger is pressed
  50617. * @param callback defines the callback to use
  50618. */
  50619. onrighttriggerchanged(callback: (value: number) => void): void;
  50620. /**
  50621. * Gets the left trigger value
  50622. */
  50623. get leftTrigger(): number;
  50624. /**
  50625. * Sets the left trigger value
  50626. */
  50627. set leftTrigger(newValue: number);
  50628. /**
  50629. * Gets the right trigger value
  50630. */
  50631. get rightTrigger(): number;
  50632. /**
  50633. * Sets the right trigger value
  50634. */
  50635. set rightTrigger(newValue: number);
  50636. /**
  50637. * Defines the callback to call when a button is pressed
  50638. * @param callback defines the callback to use
  50639. */
  50640. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  50641. /**
  50642. * Defines the callback to call when a button is released
  50643. * @param callback defines the callback to use
  50644. */
  50645. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  50646. /**
  50647. * Defines the callback to call when a pad is pressed
  50648. * @param callback defines the callback to use
  50649. */
  50650. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  50651. /**
  50652. * Defines the callback to call when a pad is released
  50653. * @param callback defines the callback to use
  50654. */
  50655. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  50656. private _setButtonValue;
  50657. private _setDPadValue;
  50658. /**
  50659. * Gets the value of the `A` button
  50660. */
  50661. get buttonA(): number;
  50662. /**
  50663. * Sets the value of the `A` button
  50664. */
  50665. set buttonA(value: number);
  50666. /**
  50667. * Gets the value of the `B` button
  50668. */
  50669. get buttonB(): number;
  50670. /**
  50671. * Sets the value of the `B` button
  50672. */
  50673. set buttonB(value: number);
  50674. /**
  50675. * Gets the value of the `X` button
  50676. */
  50677. get buttonX(): number;
  50678. /**
  50679. * Sets the value of the `X` button
  50680. */
  50681. set buttonX(value: number);
  50682. /**
  50683. * Gets the value of the `Y` button
  50684. */
  50685. get buttonY(): number;
  50686. /**
  50687. * Sets the value of the `Y` button
  50688. */
  50689. set buttonY(value: number);
  50690. /**
  50691. * Gets the value of the `Start` button
  50692. */
  50693. get buttonStart(): number;
  50694. /**
  50695. * Sets the value of the `Start` button
  50696. */
  50697. set buttonStart(value: number);
  50698. /**
  50699. * Gets the value of the `Back` button
  50700. */
  50701. get buttonBack(): number;
  50702. /**
  50703. * Sets the value of the `Back` button
  50704. */
  50705. set buttonBack(value: number);
  50706. /**
  50707. * Gets the value of the `Left` button
  50708. */
  50709. get buttonLB(): number;
  50710. /**
  50711. * Sets the value of the `Left` button
  50712. */
  50713. set buttonLB(value: number);
  50714. /**
  50715. * Gets the value of the `Right` button
  50716. */
  50717. get buttonRB(): number;
  50718. /**
  50719. * Sets the value of the `Right` button
  50720. */
  50721. set buttonRB(value: number);
  50722. /**
  50723. * Gets the value of the Left joystick
  50724. */
  50725. get buttonLeftStick(): number;
  50726. /**
  50727. * Sets the value of the Left joystick
  50728. */
  50729. set buttonLeftStick(value: number);
  50730. /**
  50731. * Gets the value of the Right joystick
  50732. */
  50733. get buttonRightStick(): number;
  50734. /**
  50735. * Sets the value of the Right joystick
  50736. */
  50737. set buttonRightStick(value: number);
  50738. /**
  50739. * Gets the value of D-pad up
  50740. */
  50741. get dPadUp(): number;
  50742. /**
  50743. * Sets the value of D-pad up
  50744. */
  50745. set dPadUp(value: number);
  50746. /**
  50747. * Gets the value of D-pad down
  50748. */
  50749. get dPadDown(): number;
  50750. /**
  50751. * Sets the value of D-pad down
  50752. */
  50753. set dPadDown(value: number);
  50754. /**
  50755. * Gets the value of D-pad left
  50756. */
  50757. get dPadLeft(): number;
  50758. /**
  50759. * Sets the value of D-pad left
  50760. */
  50761. set dPadLeft(value: number);
  50762. /**
  50763. * Gets the value of D-pad right
  50764. */
  50765. get dPadRight(): number;
  50766. /**
  50767. * Sets the value of D-pad right
  50768. */
  50769. set dPadRight(value: number);
  50770. /**
  50771. * Force the gamepad to synchronize with device values
  50772. */
  50773. update(): void;
  50774. /**
  50775. * Disposes the gamepad
  50776. */
  50777. dispose(): void;
  50778. }
  50779. }
  50780. declare module "babylonjs/Gamepads/dualShockGamepad" {
  50781. import { Observable } from "babylonjs/Misc/observable";
  50782. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50783. /**
  50784. * Defines supported buttons for DualShock compatible gamepads
  50785. */
  50786. export enum DualShockButton {
  50787. /** Cross */
  50788. Cross = 0,
  50789. /** Circle */
  50790. Circle = 1,
  50791. /** Square */
  50792. Square = 2,
  50793. /** Triangle */
  50794. Triangle = 3,
  50795. /** L1 */
  50796. L1 = 4,
  50797. /** R1 */
  50798. R1 = 5,
  50799. /** Share */
  50800. Share = 8,
  50801. /** Options */
  50802. Options = 9,
  50803. /** Left stick */
  50804. LeftStick = 10,
  50805. /** Right stick */
  50806. RightStick = 11
  50807. }
  50808. /** Defines values for DualShock DPad */
  50809. export enum DualShockDpad {
  50810. /** Up */
  50811. Up = 12,
  50812. /** Down */
  50813. Down = 13,
  50814. /** Left */
  50815. Left = 14,
  50816. /** Right */
  50817. Right = 15
  50818. }
  50819. /**
  50820. * Defines a DualShock gamepad
  50821. */
  50822. export class DualShockPad extends Gamepad {
  50823. private _leftTrigger;
  50824. private _rightTrigger;
  50825. private _onlefttriggerchanged;
  50826. private _onrighttriggerchanged;
  50827. private _onbuttondown;
  50828. private _onbuttonup;
  50829. private _ondpaddown;
  50830. private _ondpadup;
  50831. /** Observable raised when a button is pressed */
  50832. onButtonDownObservable: Observable<DualShockButton>;
  50833. /** Observable raised when a button is released */
  50834. onButtonUpObservable: Observable<DualShockButton>;
  50835. /** Observable raised when a pad is pressed */
  50836. onPadDownObservable: Observable<DualShockDpad>;
  50837. /** Observable raised when a pad is released */
  50838. onPadUpObservable: Observable<DualShockDpad>;
  50839. private _buttonCross;
  50840. private _buttonCircle;
  50841. private _buttonSquare;
  50842. private _buttonTriangle;
  50843. private _buttonShare;
  50844. private _buttonOptions;
  50845. private _buttonL1;
  50846. private _buttonR1;
  50847. private _buttonLeftStick;
  50848. private _buttonRightStick;
  50849. private _dPadUp;
  50850. private _dPadDown;
  50851. private _dPadLeft;
  50852. private _dPadRight;
  50853. /**
  50854. * Creates a new DualShock gamepad object
  50855. * @param id defines the id of this gamepad
  50856. * @param index defines its index
  50857. * @param gamepad defines the internal HTML gamepad object
  50858. */
  50859. constructor(id: string, index: number, gamepad: any);
  50860. /**
  50861. * Defines the callback to call when left trigger is pressed
  50862. * @param callback defines the callback to use
  50863. */
  50864. onlefttriggerchanged(callback: (value: number) => void): void;
  50865. /**
  50866. * Defines the callback to call when right trigger is pressed
  50867. * @param callback defines the callback to use
  50868. */
  50869. onrighttriggerchanged(callback: (value: number) => void): void;
  50870. /**
  50871. * Gets the left trigger value
  50872. */
  50873. get leftTrigger(): number;
  50874. /**
  50875. * Sets the left trigger value
  50876. */
  50877. set leftTrigger(newValue: number);
  50878. /**
  50879. * Gets the right trigger value
  50880. */
  50881. get rightTrigger(): number;
  50882. /**
  50883. * Sets the right trigger value
  50884. */
  50885. set rightTrigger(newValue: number);
  50886. /**
  50887. * Defines the callback to call when a button is pressed
  50888. * @param callback defines the callback to use
  50889. */
  50890. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  50891. /**
  50892. * Defines the callback to call when a button is released
  50893. * @param callback defines the callback to use
  50894. */
  50895. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  50896. /**
  50897. * Defines the callback to call when a pad is pressed
  50898. * @param callback defines the callback to use
  50899. */
  50900. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  50901. /**
  50902. * Defines the callback to call when a pad is released
  50903. * @param callback defines the callback to use
  50904. */
  50905. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  50906. private _setButtonValue;
  50907. private _setDPadValue;
  50908. /**
  50909. * Gets the value of the `Cross` button
  50910. */
  50911. get buttonCross(): number;
  50912. /**
  50913. * Sets the value of the `Cross` button
  50914. */
  50915. set buttonCross(value: number);
  50916. /**
  50917. * Gets the value of the `Circle` button
  50918. */
  50919. get buttonCircle(): number;
  50920. /**
  50921. * Sets the value of the `Circle` button
  50922. */
  50923. set buttonCircle(value: number);
  50924. /**
  50925. * Gets the value of the `Square` button
  50926. */
  50927. get buttonSquare(): number;
  50928. /**
  50929. * Sets the value of the `Square` button
  50930. */
  50931. set buttonSquare(value: number);
  50932. /**
  50933. * Gets the value of the `Triangle` button
  50934. */
  50935. get buttonTriangle(): number;
  50936. /**
  50937. * Sets the value of the `Triangle` button
  50938. */
  50939. set buttonTriangle(value: number);
  50940. /**
  50941. * Gets the value of the `Options` button
  50942. */
  50943. get buttonOptions(): number;
  50944. /**
  50945. * Sets the value of the `Options` button
  50946. */
  50947. set buttonOptions(value: number);
  50948. /**
  50949. * Gets the value of the `Share` button
  50950. */
  50951. get buttonShare(): number;
  50952. /**
  50953. * Sets the value of the `Share` button
  50954. */
  50955. set buttonShare(value: number);
  50956. /**
  50957. * Gets the value of the `L1` button
  50958. */
  50959. get buttonL1(): number;
  50960. /**
  50961. * Sets the value of the `L1` button
  50962. */
  50963. set buttonL1(value: number);
  50964. /**
  50965. * Gets the value of the `R1` button
  50966. */
  50967. get buttonR1(): number;
  50968. /**
  50969. * Sets the value of the `R1` button
  50970. */
  50971. set buttonR1(value: number);
  50972. /**
  50973. * Gets the value of the Left joystick
  50974. */
  50975. get buttonLeftStick(): number;
  50976. /**
  50977. * Sets the value of the Left joystick
  50978. */
  50979. set buttonLeftStick(value: number);
  50980. /**
  50981. * Gets the value of the Right joystick
  50982. */
  50983. get buttonRightStick(): number;
  50984. /**
  50985. * Sets the value of the Right joystick
  50986. */
  50987. set buttonRightStick(value: number);
  50988. /**
  50989. * Gets the value of D-pad up
  50990. */
  50991. get dPadUp(): number;
  50992. /**
  50993. * Sets the value of D-pad up
  50994. */
  50995. set dPadUp(value: number);
  50996. /**
  50997. * Gets the value of D-pad down
  50998. */
  50999. get dPadDown(): number;
  51000. /**
  51001. * Sets the value of D-pad down
  51002. */
  51003. set dPadDown(value: number);
  51004. /**
  51005. * Gets the value of D-pad left
  51006. */
  51007. get dPadLeft(): number;
  51008. /**
  51009. * Sets the value of D-pad left
  51010. */
  51011. set dPadLeft(value: number);
  51012. /**
  51013. * Gets the value of D-pad right
  51014. */
  51015. get dPadRight(): number;
  51016. /**
  51017. * Sets the value of D-pad right
  51018. */
  51019. set dPadRight(value: number);
  51020. /**
  51021. * Force the gamepad to synchronize with device values
  51022. */
  51023. update(): void;
  51024. /**
  51025. * Disposes the gamepad
  51026. */
  51027. dispose(): void;
  51028. }
  51029. }
  51030. declare module "babylonjs/Gamepads/gamepadManager" {
  51031. import { Observable } from "babylonjs/Misc/observable";
  51032. import { Nullable } from "babylonjs/types";
  51033. import { Scene } from "babylonjs/scene";
  51034. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  51035. /**
  51036. * Manager for handling gamepads
  51037. */
  51038. export class GamepadManager {
  51039. private _scene?;
  51040. private _babylonGamepads;
  51041. private _oneGamepadConnected;
  51042. /** @hidden */
  51043. _isMonitoring: boolean;
  51044. private _gamepadEventSupported;
  51045. private _gamepadSupport?;
  51046. /**
  51047. * observable to be triggered when the gamepad controller has been connected
  51048. */
  51049. onGamepadConnectedObservable: Observable<Gamepad>;
  51050. /**
  51051. * observable to be triggered when the gamepad controller has been disconnected
  51052. */
  51053. onGamepadDisconnectedObservable: Observable<Gamepad>;
  51054. private _onGamepadConnectedEvent;
  51055. private _onGamepadDisconnectedEvent;
  51056. /**
  51057. * Initializes the gamepad manager
  51058. * @param _scene BabylonJS scene
  51059. */
  51060. constructor(_scene?: Scene | undefined);
  51061. /**
  51062. * The gamepads in the game pad manager
  51063. */
  51064. get gamepads(): Gamepad[];
  51065. /**
  51066. * Get the gamepad controllers based on type
  51067. * @param type The type of gamepad controller
  51068. * @returns Nullable gamepad
  51069. */
  51070. getGamepadByType(type?: number): Nullable<Gamepad>;
  51071. /**
  51072. * Disposes the gamepad manager
  51073. */
  51074. dispose(): void;
  51075. private _addNewGamepad;
  51076. private _startMonitoringGamepads;
  51077. private _stopMonitoringGamepads;
  51078. /** @hidden */
  51079. _checkGamepadsStatus(): void;
  51080. private _updateGamepadObjects;
  51081. }
  51082. }
  51083. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  51084. import { Nullable } from "babylonjs/types";
  51085. import { Scene } from "babylonjs/scene";
  51086. import { ISceneComponent } from "babylonjs/sceneComponent";
  51087. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  51088. module "babylonjs/scene" {
  51089. interface Scene {
  51090. /** @hidden */
  51091. _gamepadManager: Nullable<GamepadManager>;
  51092. /**
  51093. * Gets the gamepad manager associated with the scene
  51094. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  51095. */
  51096. gamepadManager: GamepadManager;
  51097. }
  51098. }
  51099. module "babylonjs/Cameras/freeCameraInputsManager" {
  51100. /**
  51101. * Interface representing a free camera inputs manager
  51102. */
  51103. interface FreeCameraInputsManager {
  51104. /**
  51105. * Adds gamepad input support to the FreeCameraInputsManager.
  51106. * @returns the FreeCameraInputsManager
  51107. */
  51108. addGamepad(): FreeCameraInputsManager;
  51109. }
  51110. }
  51111. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  51112. /**
  51113. * Interface representing an arc rotate camera inputs manager
  51114. */
  51115. interface ArcRotateCameraInputsManager {
  51116. /**
  51117. * Adds gamepad input support to the ArcRotateCamera InputManager.
  51118. * @returns the camera inputs manager
  51119. */
  51120. addGamepad(): ArcRotateCameraInputsManager;
  51121. }
  51122. }
  51123. /**
  51124. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  51125. */
  51126. export class GamepadSystemSceneComponent implements ISceneComponent {
  51127. /**
  51128. * The component name helpfull to identify the component in the list of scene components.
  51129. */
  51130. readonly name: string;
  51131. /**
  51132. * The scene the component belongs to.
  51133. */
  51134. scene: Scene;
  51135. /**
  51136. * Creates a new instance of the component for the given scene
  51137. * @param scene Defines the scene to register the component in
  51138. */
  51139. constructor(scene: Scene);
  51140. /**
  51141. * Registers the component in a given scene
  51142. */
  51143. register(): void;
  51144. /**
  51145. * Rebuilds the elements related to this component in case of
  51146. * context lost for instance.
  51147. */
  51148. rebuild(): void;
  51149. /**
  51150. * Disposes the component and the associated ressources
  51151. */
  51152. dispose(): void;
  51153. private _beforeCameraUpdate;
  51154. }
  51155. }
  51156. declare module "babylonjs/Cameras/universalCamera" {
  51157. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  51158. import { Scene } from "babylonjs/scene";
  51159. import { Vector3 } from "babylonjs/Maths/math.vector";
  51160. import "babylonjs/Gamepads/gamepadSceneComponent";
  51161. /**
  51162. * 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,
  51163. * which still works and will still be found in many Playgrounds.
  51164. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51165. */
  51166. export class UniversalCamera extends TouchCamera {
  51167. /**
  51168. * Defines the gamepad rotation sensiblity.
  51169. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51170. */
  51171. get gamepadAngularSensibility(): number;
  51172. set gamepadAngularSensibility(value: number);
  51173. /**
  51174. * Defines the gamepad move sensiblity.
  51175. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51176. */
  51177. get gamepadMoveSensibility(): number;
  51178. set gamepadMoveSensibility(value: number);
  51179. /**
  51180. * 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,
  51181. * which still works and will still be found in many Playgrounds.
  51182. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51183. * @param name Define the name of the camera in the scene
  51184. * @param position Define the start position of the camera in the scene
  51185. * @param scene Define the scene the camera belongs to
  51186. */
  51187. constructor(name: string, position: Vector3, scene: Scene);
  51188. /**
  51189. * Gets the current object class name.
  51190. * @return the class name
  51191. */
  51192. getClassName(): string;
  51193. }
  51194. }
  51195. declare module "babylonjs/Cameras/gamepadCamera" {
  51196. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51197. import { Scene } from "babylonjs/scene";
  51198. import { Vector3 } from "babylonjs/Maths/math.vector";
  51199. /**
  51200. * This represents a FPS type of camera. This is only here for back compat purpose.
  51201. * Please use the UniversalCamera instead as both are identical.
  51202. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51203. */
  51204. export class GamepadCamera extends UniversalCamera {
  51205. /**
  51206. * Instantiates a new Gamepad Camera
  51207. * This represents a FPS type of camera. This is only here for back compat purpose.
  51208. * Please use the UniversalCamera instead as both are identical.
  51209. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51210. * @param name Define the name of the camera in the scene
  51211. * @param position Define the start position of the camera in the scene
  51212. * @param scene Define the scene the camera belongs to
  51213. */
  51214. constructor(name: string, position: Vector3, scene: Scene);
  51215. /**
  51216. * Gets the current object class name.
  51217. * @return the class name
  51218. */
  51219. getClassName(): string;
  51220. }
  51221. }
  51222. declare module "babylonjs/Shaders/pass.fragment" {
  51223. /** @hidden */
  51224. export var passPixelShader: {
  51225. name: string;
  51226. shader: string;
  51227. };
  51228. }
  51229. declare module "babylonjs/Shaders/passCube.fragment" {
  51230. /** @hidden */
  51231. export var passCubePixelShader: {
  51232. name: string;
  51233. shader: string;
  51234. };
  51235. }
  51236. declare module "babylonjs/PostProcesses/passPostProcess" {
  51237. import { Nullable } from "babylonjs/types";
  51238. import { Camera } from "babylonjs/Cameras/camera";
  51239. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51240. import { Engine } from "babylonjs/Engines/engine";
  51241. import "babylonjs/Shaders/pass.fragment";
  51242. import "babylonjs/Shaders/passCube.fragment";
  51243. import { Scene } from "babylonjs/scene";
  51244. /**
  51245. * PassPostProcess which produces an output the same as it's input
  51246. */
  51247. export class PassPostProcess extends PostProcess {
  51248. /**
  51249. * Gets a string identifying the name of the class
  51250. * @returns "PassPostProcess" string
  51251. */
  51252. getClassName(): string;
  51253. /**
  51254. * Creates the PassPostProcess
  51255. * @param name The name of the effect.
  51256. * @param options The required width/height ratio to downsize to before computing the render pass.
  51257. * @param camera The camera to apply the render pass to.
  51258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51259. * @param engine The engine which the post process will be applied. (default: current engine)
  51260. * @param reusable If the post process can be reused on the same frame. (default: false)
  51261. * @param textureType The type of texture to be used when performing the post processing.
  51262. * @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)
  51263. */
  51264. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51265. /** @hidden */
  51266. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  51267. }
  51268. /**
  51269. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  51270. */
  51271. export class PassCubePostProcess extends PostProcess {
  51272. private _face;
  51273. /**
  51274. * Gets or sets the cube face to display.
  51275. * * 0 is +X
  51276. * * 1 is -X
  51277. * * 2 is +Y
  51278. * * 3 is -Y
  51279. * * 4 is +Z
  51280. * * 5 is -Z
  51281. */
  51282. get face(): number;
  51283. set face(value: number);
  51284. /**
  51285. * Gets a string identifying the name of the class
  51286. * @returns "PassCubePostProcess" string
  51287. */
  51288. getClassName(): string;
  51289. /**
  51290. * Creates the PassCubePostProcess
  51291. * @param name The name of the effect.
  51292. * @param options The required width/height ratio to downsize to before computing the render pass.
  51293. * @param camera The camera to apply the render pass to.
  51294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51295. * @param engine The engine which the post process will be applied. (default: current engine)
  51296. * @param reusable If the post process can be reused on the same frame. (default: false)
  51297. * @param textureType The type of texture to be used when performing the post processing.
  51298. * @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)
  51299. */
  51300. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51301. /** @hidden */
  51302. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  51303. }
  51304. }
  51305. declare module "babylonjs/Shaders/anaglyph.fragment" {
  51306. /** @hidden */
  51307. export var anaglyphPixelShader: {
  51308. name: string;
  51309. shader: string;
  51310. };
  51311. }
  51312. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  51313. import { Engine } from "babylonjs/Engines/engine";
  51314. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51315. import { Camera } from "babylonjs/Cameras/camera";
  51316. import "babylonjs/Shaders/anaglyph.fragment";
  51317. /**
  51318. * Postprocess used to generate anaglyphic rendering
  51319. */
  51320. export class AnaglyphPostProcess extends PostProcess {
  51321. private _passedProcess;
  51322. /**
  51323. * Gets a string identifying the name of the class
  51324. * @returns "AnaglyphPostProcess" string
  51325. */
  51326. getClassName(): string;
  51327. /**
  51328. * Creates a new AnaglyphPostProcess
  51329. * @param name defines postprocess name
  51330. * @param options defines creation options or target ratio scale
  51331. * @param rigCameras defines cameras using this postprocess
  51332. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  51333. * @param engine defines hosting engine
  51334. * @param reusable defines if the postprocess will be reused multiple times per frame
  51335. */
  51336. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  51337. }
  51338. }
  51339. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  51340. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  51341. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51342. import { Scene } from "babylonjs/scene";
  51343. import { Vector3 } from "babylonjs/Maths/math.vector";
  51344. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51345. /**
  51346. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  51347. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51348. */
  51349. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  51350. /**
  51351. * Creates a new AnaglyphArcRotateCamera
  51352. * @param name defines camera name
  51353. * @param alpha defines alpha angle (in radians)
  51354. * @param beta defines beta angle (in radians)
  51355. * @param radius defines radius
  51356. * @param target defines camera target
  51357. * @param interaxialDistance defines distance between each color axis
  51358. * @param scene defines the hosting scene
  51359. */
  51360. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51361. /**
  51362. * Gets camera class name
  51363. * @returns AnaglyphArcRotateCamera
  51364. */
  51365. getClassName(): string;
  51366. }
  51367. }
  51368. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51369. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51370. import { Scene } from "babylonjs/scene";
  51371. import { Vector3 } from "babylonjs/Maths/math.vector";
  51372. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51373. /**
  51374. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51375. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51376. */
  51377. export class AnaglyphFreeCamera extends FreeCamera {
  51378. /**
  51379. * Creates a new AnaglyphFreeCamera
  51380. * @param name defines camera name
  51381. * @param position defines initial position
  51382. * @param interaxialDistance defines distance between each color axis
  51383. * @param scene defines the hosting scene
  51384. */
  51385. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51386. /**
  51387. * Gets camera class name
  51388. * @returns AnaglyphFreeCamera
  51389. */
  51390. getClassName(): string;
  51391. }
  51392. }
  51393. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51394. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51395. import { Scene } from "babylonjs/scene";
  51396. import { Vector3 } from "babylonjs/Maths/math.vector";
  51397. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51398. /**
  51399. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51400. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51401. */
  51402. export class AnaglyphGamepadCamera extends GamepadCamera {
  51403. /**
  51404. * Creates a new AnaglyphGamepadCamera
  51405. * @param name defines camera name
  51406. * @param position defines initial position
  51407. * @param interaxialDistance defines distance between each color axis
  51408. * @param scene defines the hosting scene
  51409. */
  51410. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51411. /**
  51412. * Gets camera class name
  51413. * @returns AnaglyphGamepadCamera
  51414. */
  51415. getClassName(): string;
  51416. }
  51417. }
  51418. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51419. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51420. import { Scene } from "babylonjs/scene";
  51421. import { Vector3 } from "babylonjs/Maths/math.vector";
  51422. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51423. /**
  51424. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51425. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51426. */
  51427. export class AnaglyphUniversalCamera extends UniversalCamera {
  51428. /**
  51429. * Creates a new AnaglyphUniversalCamera
  51430. * @param name defines camera name
  51431. * @param position defines initial position
  51432. * @param interaxialDistance defines distance between each color axis
  51433. * @param scene defines the hosting scene
  51434. */
  51435. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51436. /**
  51437. * Gets camera class name
  51438. * @returns AnaglyphUniversalCamera
  51439. */
  51440. getClassName(): string;
  51441. }
  51442. }
  51443. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51444. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51445. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51446. import { Scene } from "babylonjs/scene";
  51447. import { Vector3 } from "babylonjs/Maths/math.vector";
  51448. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51449. /**
  51450. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51451. * @see https://doc.babylonjs.com/features/cameras
  51452. */
  51453. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51454. /**
  51455. * Creates a new StereoscopicArcRotateCamera
  51456. * @param name defines camera name
  51457. * @param alpha defines alpha angle (in radians)
  51458. * @param beta defines beta angle (in radians)
  51459. * @param radius defines radius
  51460. * @param target defines camera target
  51461. * @param interaxialDistance defines distance between each color axis
  51462. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51463. * @param scene defines the hosting scene
  51464. */
  51465. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51466. /**
  51467. * Gets camera class name
  51468. * @returns StereoscopicArcRotateCamera
  51469. */
  51470. getClassName(): string;
  51471. }
  51472. }
  51473. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51474. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51475. import { Scene } from "babylonjs/scene";
  51476. import { Vector3 } from "babylonjs/Maths/math.vector";
  51477. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51478. /**
  51479. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51480. * @see https://doc.babylonjs.com/features/cameras
  51481. */
  51482. export class StereoscopicFreeCamera extends FreeCamera {
  51483. /**
  51484. * Creates a new StereoscopicFreeCamera
  51485. * @param name defines camera name
  51486. * @param position defines initial position
  51487. * @param interaxialDistance defines distance between each color axis
  51488. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51489. * @param scene defines the hosting scene
  51490. */
  51491. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51492. /**
  51493. * Gets camera class name
  51494. * @returns StereoscopicFreeCamera
  51495. */
  51496. getClassName(): string;
  51497. }
  51498. }
  51499. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51500. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51501. import { Scene } from "babylonjs/scene";
  51502. import { Vector3 } from "babylonjs/Maths/math.vector";
  51503. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51504. /**
  51505. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51506. * @see https://doc.babylonjs.com/features/cameras
  51507. */
  51508. export class StereoscopicGamepadCamera extends GamepadCamera {
  51509. /**
  51510. * Creates a new StereoscopicGamepadCamera
  51511. * @param name defines camera name
  51512. * @param position defines initial position
  51513. * @param interaxialDistance defines distance between each color axis
  51514. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51515. * @param scene defines the hosting scene
  51516. */
  51517. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51518. /**
  51519. * Gets camera class name
  51520. * @returns StereoscopicGamepadCamera
  51521. */
  51522. getClassName(): string;
  51523. }
  51524. }
  51525. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51526. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51527. import { Scene } from "babylonjs/scene";
  51528. import { Vector3 } from "babylonjs/Maths/math.vector";
  51529. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51530. /**
  51531. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51532. * @see https://doc.babylonjs.com/features/cameras
  51533. */
  51534. export class StereoscopicUniversalCamera extends UniversalCamera {
  51535. /**
  51536. * Creates a new StereoscopicUniversalCamera
  51537. * @param name defines camera name
  51538. * @param position defines initial position
  51539. * @param interaxialDistance defines distance between each color axis
  51540. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51541. * @param scene defines the hosting scene
  51542. */
  51543. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51544. /**
  51545. * Gets camera class name
  51546. * @returns StereoscopicUniversalCamera
  51547. */
  51548. getClassName(): string;
  51549. }
  51550. }
  51551. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51552. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51553. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51554. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51555. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51556. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51557. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51558. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51559. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51560. }
  51561. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51562. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51563. import { Scene } from "babylonjs/scene";
  51564. import { Vector3 } from "babylonjs/Maths/math.vector";
  51565. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51566. /**
  51567. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51568. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51569. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51570. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51571. */
  51572. export class VirtualJoysticksCamera extends FreeCamera {
  51573. /**
  51574. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51575. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51576. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51577. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51578. * @param name Define the name of the camera in the scene
  51579. * @param position Define the start position of the camera in the scene
  51580. * @param scene Define the scene the camera belongs to
  51581. */
  51582. constructor(name: string, position: Vector3, scene: Scene);
  51583. /**
  51584. * Gets the current object class name.
  51585. * @return the class name
  51586. */
  51587. getClassName(): string;
  51588. }
  51589. }
  51590. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51591. import { Matrix } from "babylonjs/Maths/math.vector";
  51592. /**
  51593. * This represents all the required metrics to create a VR camera.
  51594. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51595. */
  51596. export class VRCameraMetrics {
  51597. /**
  51598. * Define the horizontal resolution off the screen.
  51599. */
  51600. hResolution: number;
  51601. /**
  51602. * Define the vertical resolution off the screen.
  51603. */
  51604. vResolution: number;
  51605. /**
  51606. * Define the horizontal screen size.
  51607. */
  51608. hScreenSize: number;
  51609. /**
  51610. * Define the vertical screen size.
  51611. */
  51612. vScreenSize: number;
  51613. /**
  51614. * Define the vertical screen center position.
  51615. */
  51616. vScreenCenter: number;
  51617. /**
  51618. * Define the distance of the eyes to the screen.
  51619. */
  51620. eyeToScreenDistance: number;
  51621. /**
  51622. * Define the distance between both lenses
  51623. */
  51624. lensSeparationDistance: number;
  51625. /**
  51626. * Define the distance between both viewer's eyes.
  51627. */
  51628. interpupillaryDistance: number;
  51629. /**
  51630. * Define the distortion factor of the VR postprocess.
  51631. * Please, touch with care.
  51632. */
  51633. distortionK: number[];
  51634. /**
  51635. * Define the chromatic aberration correction factors for the VR post process.
  51636. */
  51637. chromaAbCorrection: number[];
  51638. /**
  51639. * Define the scale factor of the post process.
  51640. * The smaller the better but the slower.
  51641. */
  51642. postProcessScaleFactor: number;
  51643. /**
  51644. * Define an offset for the lens center.
  51645. */
  51646. lensCenterOffset: number;
  51647. /**
  51648. * Define if the current vr camera should compensate the distortion of the lense or not.
  51649. */
  51650. compensateDistortion: boolean;
  51651. /**
  51652. * Defines if multiview should be enabled when rendering (Default: false)
  51653. */
  51654. multiviewEnabled: boolean;
  51655. /**
  51656. * Gets the rendering aspect ratio based on the provided resolutions.
  51657. */
  51658. get aspectRatio(): number;
  51659. /**
  51660. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  51661. */
  51662. get aspectRatioFov(): number;
  51663. /**
  51664. * @hidden
  51665. */
  51666. get leftHMatrix(): Matrix;
  51667. /**
  51668. * @hidden
  51669. */
  51670. get rightHMatrix(): Matrix;
  51671. /**
  51672. * @hidden
  51673. */
  51674. get leftPreViewMatrix(): Matrix;
  51675. /**
  51676. * @hidden
  51677. */
  51678. get rightPreViewMatrix(): Matrix;
  51679. /**
  51680. * Get the default VRMetrics based on the most generic setup.
  51681. * @returns the default vr metrics
  51682. */
  51683. static GetDefault(): VRCameraMetrics;
  51684. }
  51685. }
  51686. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  51687. /** @hidden */
  51688. export var vrDistortionCorrectionPixelShader: {
  51689. name: string;
  51690. shader: string;
  51691. };
  51692. }
  51693. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  51694. import { Camera } from "babylonjs/Cameras/camera";
  51695. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51696. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51697. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  51698. /**
  51699. * VRDistortionCorrectionPostProcess used for mobile VR
  51700. */
  51701. export class VRDistortionCorrectionPostProcess extends PostProcess {
  51702. private _isRightEye;
  51703. private _distortionFactors;
  51704. private _postProcessScaleFactor;
  51705. private _lensCenterOffset;
  51706. private _scaleIn;
  51707. private _scaleFactor;
  51708. private _lensCenter;
  51709. /**
  51710. * Gets a string identifying the name of the class
  51711. * @returns "VRDistortionCorrectionPostProcess" string
  51712. */
  51713. getClassName(): string;
  51714. /**
  51715. * Initializes the VRDistortionCorrectionPostProcess
  51716. * @param name The name of the effect.
  51717. * @param camera The camera to apply the render pass to.
  51718. * @param isRightEye If this is for the right eye distortion
  51719. * @param vrMetrics All the required metrics for the VR camera
  51720. */
  51721. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  51722. }
  51723. }
  51724. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  51725. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  51726. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51727. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51728. import { Scene } from "babylonjs/scene";
  51729. import { Vector3 } from "babylonjs/Maths/math.vector";
  51730. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  51731. import "babylonjs/Cameras/RigModes/vrRigMode";
  51732. /**
  51733. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  51734. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51735. */
  51736. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  51737. /**
  51738. * Creates a new VRDeviceOrientationArcRotateCamera
  51739. * @param name defines camera name
  51740. * @param alpha defines the camera rotation along the logitudinal axis
  51741. * @param beta defines the camera rotation along the latitudinal axis
  51742. * @param radius defines the camera distance from its target
  51743. * @param target defines the camera target
  51744. * @param scene defines the scene the camera belongs to
  51745. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51746. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51747. */
  51748. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51749. /**
  51750. * Gets camera class name
  51751. * @returns VRDeviceOrientationArcRotateCamera
  51752. */
  51753. getClassName(): string;
  51754. }
  51755. }
  51756. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  51757. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51758. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51759. import { Scene } from "babylonjs/scene";
  51760. import { Vector3 } from "babylonjs/Maths/math.vector";
  51761. import "babylonjs/Cameras/RigModes/vrRigMode";
  51762. /**
  51763. * Camera used to simulate VR rendering (based on FreeCamera)
  51764. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51765. */
  51766. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  51767. /**
  51768. * Creates a new VRDeviceOrientationFreeCamera
  51769. * @param name defines camera name
  51770. * @param position defines the start position of the camera
  51771. * @param scene defines the scene the camera belongs to
  51772. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51773. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51774. */
  51775. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51776. /**
  51777. * Gets camera class name
  51778. * @returns VRDeviceOrientationFreeCamera
  51779. */
  51780. getClassName(): string;
  51781. }
  51782. }
  51783. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  51784. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51785. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51786. import { Scene } from "babylonjs/scene";
  51787. import { Vector3 } from "babylonjs/Maths/math.vector";
  51788. import "babylonjs/Gamepads/gamepadSceneComponent";
  51789. /**
  51790. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  51791. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51792. */
  51793. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  51794. /**
  51795. * Creates a new VRDeviceOrientationGamepadCamera
  51796. * @param name defines camera name
  51797. * @param position defines the start position of the camera
  51798. * @param scene defines the scene the camera belongs to
  51799. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51800. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51801. */
  51802. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51803. /**
  51804. * Gets camera class name
  51805. * @returns VRDeviceOrientationGamepadCamera
  51806. */
  51807. getClassName(): string;
  51808. }
  51809. }
  51810. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  51811. import { Scene } from "babylonjs/scene";
  51812. import { Texture } from "babylonjs/Materials/Textures/texture";
  51813. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  51814. /**
  51815. * A class extending Texture allowing drawing on a texture
  51816. * @see https://doc.babylonjs.com/how_to/dynamictexture
  51817. */
  51818. export class DynamicTexture extends Texture {
  51819. private _generateMipMaps;
  51820. private _canvas;
  51821. private _context;
  51822. /**
  51823. * Creates a DynamicTexture
  51824. * @param name defines the name of the texture
  51825. * @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
  51826. * @param scene defines the scene where you want the texture
  51827. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  51828. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51829. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  51830. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  51831. */
  51832. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  51833. /**
  51834. * Get the current class name of the texture useful for serialization or dynamic coding.
  51835. * @returns "DynamicTexture"
  51836. */
  51837. getClassName(): string;
  51838. /**
  51839. * Gets the current state of canRescale
  51840. */
  51841. get canRescale(): boolean;
  51842. private _recreate;
  51843. /**
  51844. * Scales the texture
  51845. * @param ratio the scale factor to apply to both width and height
  51846. */
  51847. scale(ratio: number): void;
  51848. /**
  51849. * Resizes the texture
  51850. * @param width the new width
  51851. * @param height the new height
  51852. */
  51853. scaleTo(width: number, height: number): void;
  51854. /**
  51855. * Gets the context of the canvas used by the texture
  51856. * @returns the canvas context of the dynamic texture
  51857. */
  51858. getContext(): CanvasRenderingContext2D;
  51859. /**
  51860. * Clears the texture
  51861. */
  51862. clear(): void;
  51863. /**
  51864. * Updates the texture
  51865. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51866. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  51867. */
  51868. update(invertY?: boolean, premulAlpha?: boolean): void;
  51869. /**
  51870. * Draws text onto the texture
  51871. * @param text defines the text to be drawn
  51872. * @param x defines the placement of the text from the left
  51873. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  51874. * @param font defines the font to be used with font-style, font-size, font-name
  51875. * @param color defines the color used for the text
  51876. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  51877. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51878. * @param update defines whether texture is immediately update (default is true)
  51879. */
  51880. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  51881. /**
  51882. * Clones the texture
  51883. * @returns the clone of the texture.
  51884. */
  51885. clone(): DynamicTexture;
  51886. /**
  51887. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  51888. * @returns a serialized dynamic texture object
  51889. */
  51890. serialize(): any;
  51891. private _IsCanvasElement;
  51892. /** @hidden */
  51893. _rebuild(): void;
  51894. }
  51895. }
  51896. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  51897. import { Scene } from "babylonjs/scene";
  51898. import { Color3 } from "babylonjs/Maths/math.color";
  51899. import { Mesh } from "babylonjs/Meshes/mesh";
  51900. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51901. import { Nullable } from "babylonjs/types";
  51902. /**
  51903. * Class containing static functions to help procedurally build meshes
  51904. */
  51905. export class GroundBuilder {
  51906. /**
  51907. * Creates a ground mesh
  51908. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51909. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51911. * @param name defines the name of the mesh
  51912. * @param options defines the options used to create the mesh
  51913. * @param scene defines the hosting scene
  51914. * @returns the ground mesh
  51915. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51916. */
  51917. static CreateGround(name: string, options: {
  51918. width?: number;
  51919. height?: number;
  51920. subdivisions?: number;
  51921. subdivisionsX?: number;
  51922. subdivisionsY?: number;
  51923. updatable?: boolean;
  51924. }, scene: any): Mesh;
  51925. /**
  51926. * Creates a tiled ground mesh
  51927. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51928. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51929. * * 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
  51930. * * 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
  51931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51932. * @param name defines the name of the mesh
  51933. * @param options defines the options used to create the mesh
  51934. * @param scene defines the hosting scene
  51935. * @returns the tiled ground mesh
  51936. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51937. */
  51938. static CreateTiledGround(name: string, options: {
  51939. xmin: number;
  51940. zmin: number;
  51941. xmax: number;
  51942. zmax: number;
  51943. subdivisions?: {
  51944. w: number;
  51945. h: number;
  51946. };
  51947. precision?: {
  51948. w: number;
  51949. h: number;
  51950. };
  51951. updatable?: boolean;
  51952. }, scene?: Nullable<Scene>): Mesh;
  51953. /**
  51954. * Creates a ground mesh from a height map
  51955. * * The parameter `url` sets the URL of the height map image resource.
  51956. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51957. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51958. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51959. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51960. * * 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.
  51961. * * 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).
  51962. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51964. * @param name defines the name of the mesh
  51965. * @param url defines the url to the height map
  51966. * @param options defines the options used to create the mesh
  51967. * @param scene defines the hosting scene
  51968. * @returns the ground mesh
  51969. * @see https://doc.babylonjs.com/babylon101/height_map
  51970. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51971. */
  51972. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51973. width?: number;
  51974. height?: number;
  51975. subdivisions?: number;
  51976. minHeight?: number;
  51977. maxHeight?: number;
  51978. colorFilter?: Color3;
  51979. alphaFilter?: number;
  51980. updatable?: boolean;
  51981. onReady?: (mesh: GroundMesh) => void;
  51982. }, scene?: Nullable<Scene>): GroundMesh;
  51983. }
  51984. }
  51985. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  51986. import { Vector4 } from "babylonjs/Maths/math.vector";
  51987. import { Mesh } from "babylonjs/Meshes/mesh";
  51988. /**
  51989. * Class containing static functions to help procedurally build meshes
  51990. */
  51991. export class TorusBuilder {
  51992. /**
  51993. * Creates a torus mesh
  51994. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51995. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51996. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51998. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52000. * @param name defines the name of the mesh
  52001. * @param options defines the options used to create the mesh
  52002. * @param scene defines the hosting scene
  52003. * @returns the torus mesh
  52004. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52005. */
  52006. static CreateTorus(name: string, options: {
  52007. diameter?: number;
  52008. thickness?: number;
  52009. tessellation?: number;
  52010. updatable?: boolean;
  52011. sideOrientation?: number;
  52012. frontUVs?: Vector4;
  52013. backUVs?: Vector4;
  52014. }, scene: any): Mesh;
  52015. }
  52016. }
  52017. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  52018. import { Vector4 } from "babylonjs/Maths/math.vector";
  52019. import { Color4 } from "babylonjs/Maths/math.color";
  52020. import { Mesh } from "babylonjs/Meshes/mesh";
  52021. /**
  52022. * Class containing static functions to help procedurally build meshes
  52023. */
  52024. export class CylinderBuilder {
  52025. /**
  52026. * Creates a cylinder or a cone mesh
  52027. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52028. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52029. * * 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.
  52030. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52031. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52032. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52033. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52034. * * 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).
  52035. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52036. * * 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).
  52037. * * 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
  52038. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52039. * * 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
  52040. * * 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.
  52041. * * If `enclose` is false, a ring surface is one element.
  52042. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52043. * * 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
  52044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52047. * @param name defines the name of the mesh
  52048. * @param options defines the options used to create the mesh
  52049. * @param scene defines the hosting scene
  52050. * @returns the cylinder mesh
  52051. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52052. */
  52053. static CreateCylinder(name: string, options: {
  52054. height?: number;
  52055. diameterTop?: number;
  52056. diameterBottom?: number;
  52057. diameter?: number;
  52058. tessellation?: number;
  52059. subdivisions?: number;
  52060. arc?: number;
  52061. faceColors?: Color4[];
  52062. faceUV?: Vector4[];
  52063. updatable?: boolean;
  52064. hasRings?: boolean;
  52065. enclose?: boolean;
  52066. cap?: number;
  52067. sideOrientation?: number;
  52068. frontUVs?: Vector4;
  52069. backUVs?: Vector4;
  52070. }, scene: any): Mesh;
  52071. }
  52072. }
  52073. declare module "babylonjs/XR/webXRTypes" {
  52074. import { Nullable } from "babylonjs/types";
  52075. import { IDisposable } from "babylonjs/scene";
  52076. /**
  52077. * States of the webXR experience
  52078. */
  52079. export enum WebXRState {
  52080. /**
  52081. * Transitioning to being in XR mode
  52082. */
  52083. ENTERING_XR = 0,
  52084. /**
  52085. * Transitioning to non XR mode
  52086. */
  52087. EXITING_XR = 1,
  52088. /**
  52089. * In XR mode and presenting
  52090. */
  52091. IN_XR = 2,
  52092. /**
  52093. * Not entered XR mode
  52094. */
  52095. NOT_IN_XR = 3
  52096. }
  52097. /**
  52098. * The state of the XR camera's tracking
  52099. */
  52100. export enum WebXRTrackingState {
  52101. /**
  52102. * No transformation received, device is not being tracked
  52103. */
  52104. NOT_TRACKING = 0,
  52105. /**
  52106. * Tracking lost - using emulated position
  52107. */
  52108. TRACKING_LOST = 1,
  52109. /**
  52110. * Transformation tracking works normally
  52111. */
  52112. TRACKING = 2
  52113. }
  52114. /**
  52115. * Abstraction of the XR render target
  52116. */
  52117. export interface WebXRRenderTarget extends IDisposable {
  52118. /**
  52119. * xrpresent context of the canvas which can be used to display/mirror xr content
  52120. */
  52121. canvasContext: WebGLRenderingContext;
  52122. /**
  52123. * xr layer for the canvas
  52124. */
  52125. xrLayer: Nullable<XRWebGLLayer>;
  52126. /**
  52127. * Initializes the xr layer for the session
  52128. * @param xrSession xr session
  52129. * @returns a promise that will resolve once the XR Layer has been created
  52130. */
  52131. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52132. }
  52133. }
  52134. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  52135. import { Nullable } from "babylonjs/types";
  52136. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  52137. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52138. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52139. import { Observable } from "babylonjs/Misc/observable";
  52140. /**
  52141. * COnfiguration object for WebXR output canvas
  52142. */
  52143. export class WebXRManagedOutputCanvasOptions {
  52144. /**
  52145. * An optional canvas in case you wish to create it yourself and provide it here.
  52146. * If not provided, a new canvas will be created
  52147. */
  52148. canvasElement?: HTMLCanvasElement;
  52149. /**
  52150. * Options for this XR Layer output
  52151. */
  52152. canvasOptions?: XRWebGLLayerInit;
  52153. /**
  52154. * CSS styling for a newly created canvas (if not provided)
  52155. */
  52156. newCanvasCssStyle?: string;
  52157. /**
  52158. * Get the default values of the configuration object
  52159. * @param engine defines the engine to use (can be null)
  52160. * @returns default values of this configuration object
  52161. */
  52162. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  52163. }
  52164. /**
  52165. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  52166. */
  52167. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  52168. private _options;
  52169. private _canvas;
  52170. private _engine;
  52171. private _originalCanvasSize;
  52172. /**
  52173. * Rendering context of the canvas which can be used to display/mirror xr content
  52174. */
  52175. canvasContext: WebGLRenderingContext;
  52176. /**
  52177. * xr layer for the canvas
  52178. */
  52179. xrLayer: Nullable<XRWebGLLayer>;
  52180. /**
  52181. * Obseervers registered here will be triggered when the xr layer was initialized
  52182. */
  52183. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  52184. /**
  52185. * Initializes the canvas to be added/removed upon entering/exiting xr
  52186. * @param _xrSessionManager The XR Session manager
  52187. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  52188. */
  52189. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  52190. /**
  52191. * Disposes of the object
  52192. */
  52193. dispose(): void;
  52194. /**
  52195. * Initializes the xr layer for the session
  52196. * @param xrSession xr session
  52197. * @returns a promise that will resolve once the XR Layer has been created
  52198. */
  52199. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52200. private _addCanvas;
  52201. private _removeCanvas;
  52202. private _setCanvasSize;
  52203. private _setManagedOutputCanvas;
  52204. }
  52205. }
  52206. declare module "babylonjs/XR/webXRSessionManager" {
  52207. import { Observable } from "babylonjs/Misc/observable";
  52208. import { Nullable } from "babylonjs/types";
  52209. import { IDisposable, Scene } from "babylonjs/scene";
  52210. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52211. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52212. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  52213. /**
  52214. * Manages an XRSession to work with Babylon's engine
  52215. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  52216. */
  52217. export class WebXRSessionManager implements IDisposable {
  52218. /** The scene which the session should be created for */
  52219. scene: Scene;
  52220. private _referenceSpace;
  52221. private _rttProvider;
  52222. private _sessionEnded;
  52223. private _xrNavigator;
  52224. private baseLayer;
  52225. /**
  52226. * The base reference space from which the session started. good if you want to reset your
  52227. * reference space
  52228. */
  52229. baseReferenceSpace: XRReferenceSpace;
  52230. /**
  52231. * Current XR frame
  52232. */
  52233. currentFrame: Nullable<XRFrame>;
  52234. /** WebXR timestamp updated every frame */
  52235. currentTimestamp: number;
  52236. /**
  52237. * Used just in case of a failure to initialize an immersive session.
  52238. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  52239. */
  52240. defaultHeightCompensation: number;
  52241. /**
  52242. * Fires every time a new xrFrame arrives which can be used to update the camera
  52243. */
  52244. onXRFrameObservable: Observable<XRFrame>;
  52245. /**
  52246. * Fires when the reference space changed
  52247. */
  52248. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  52249. /**
  52250. * Fires when the xr session is ended either by the device or manually done
  52251. */
  52252. onXRSessionEnded: Observable<any>;
  52253. /**
  52254. * Fires when the xr session is ended either by the device or manually done
  52255. */
  52256. onXRSessionInit: Observable<XRSession>;
  52257. /**
  52258. * Underlying xr session
  52259. */
  52260. session: XRSession;
  52261. /**
  52262. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  52263. * or get the offset the player is currently at.
  52264. */
  52265. viewerReferenceSpace: XRReferenceSpace;
  52266. /**
  52267. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  52268. * @param scene The scene which the session should be created for
  52269. */
  52270. constructor(
  52271. /** The scene which the session should be created for */
  52272. scene: Scene);
  52273. /**
  52274. * The current reference space used in this session. This reference space can constantly change!
  52275. * It is mainly used to offset the camera's position.
  52276. */
  52277. get referenceSpace(): XRReferenceSpace;
  52278. /**
  52279. * Set a new reference space and triggers the observable
  52280. */
  52281. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  52282. /**
  52283. * Disposes of the session manager
  52284. */
  52285. dispose(): void;
  52286. /**
  52287. * Stops the xrSession and restores the render loop
  52288. * @returns Promise which resolves after it exits XR
  52289. */
  52290. exitXRAsync(): Promise<void>;
  52291. /**
  52292. * Gets the correct render target texture to be rendered this frame for this eye
  52293. * @param eye the eye for which to get the render target
  52294. * @returns the render target for the specified eye
  52295. */
  52296. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  52297. /**
  52298. * Creates a WebXRRenderTarget object for the XR session
  52299. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  52300. * @param options optional options to provide when creating a new render target
  52301. * @returns a WebXR render target to which the session can render
  52302. */
  52303. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  52304. /**
  52305. * Initializes the manager
  52306. * After initialization enterXR can be called to start an XR session
  52307. * @returns Promise which resolves after it is initialized
  52308. */
  52309. initializeAsync(): Promise<void>;
  52310. /**
  52311. * Initializes an xr session
  52312. * @param xrSessionMode mode to initialize
  52313. * @param xrSessionInit defines optional and required values to pass to the session builder
  52314. * @returns a promise which will resolve once the session has been initialized
  52315. */
  52316. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  52317. /**
  52318. * Checks if a session would be supported for the creation options specified
  52319. * @param sessionMode session mode to check if supported eg. immersive-vr
  52320. * @returns A Promise that resolves to true if supported and false if not
  52321. */
  52322. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52323. /**
  52324. * Resets the reference space to the one started the session
  52325. */
  52326. resetReferenceSpace(): void;
  52327. /**
  52328. * Starts rendering to the xr layer
  52329. */
  52330. runXRRenderLoop(): void;
  52331. /**
  52332. * Sets the reference space on the xr session
  52333. * @param referenceSpaceType space to set
  52334. * @returns a promise that will resolve once the reference space has been set
  52335. */
  52336. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  52337. /**
  52338. * Updates the render state of the session
  52339. * @param state state to set
  52340. * @returns a promise that resolves once the render state has been updated
  52341. */
  52342. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  52343. /**
  52344. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  52345. * @param sessionMode defines the session to test
  52346. * @returns a promise with boolean as final value
  52347. */
  52348. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52349. private _createRenderTargetTexture;
  52350. }
  52351. }
  52352. declare module "babylonjs/XR/webXRCamera" {
  52353. import { Vector3 } from "babylonjs/Maths/math.vector";
  52354. import { Scene } from "babylonjs/scene";
  52355. import { Camera } from "babylonjs/Cameras/camera";
  52356. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  52357. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52358. import { Observable } from "babylonjs/Misc/observable";
  52359. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  52360. /**
  52361. * WebXR Camera which holds the views for the xrSession
  52362. * @see https://doc.babylonjs.com/how_to/webxr_camera
  52363. */
  52364. export class WebXRCamera extends FreeCamera {
  52365. private _xrSessionManager;
  52366. private _firstFrame;
  52367. private _referenceQuaternion;
  52368. private _referencedPosition;
  52369. private _xrInvPositionCache;
  52370. private _xrInvQuaternionCache;
  52371. private _trackingState;
  52372. /**
  52373. * Observable raised before camera teleportation
  52374. */
  52375. onBeforeCameraTeleport: Observable<Vector3>;
  52376. /**
  52377. * Observable raised after camera teleportation
  52378. */
  52379. onAfterCameraTeleport: Observable<Vector3>;
  52380. /**
  52381. * Notifies when the camera's tracking state has changed.
  52382. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  52383. */
  52384. onTrackingStateChanged: Observable<WebXRTrackingState>;
  52385. /**
  52386. * Should position compensation execute on first frame.
  52387. * This is used when copying the position from a native (non XR) camera
  52388. */
  52389. compensateOnFirstFrame: boolean;
  52390. /**
  52391. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52392. * @param name the name of the camera
  52393. * @param scene the scene to add the camera to
  52394. * @param _xrSessionManager a constructed xr session manager
  52395. */
  52396. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52397. /**
  52398. * Get the current XR tracking state of the camera
  52399. */
  52400. get trackingState(): WebXRTrackingState;
  52401. private _setTrackingState;
  52402. /**
  52403. * Return the user's height, unrelated to the current ground.
  52404. * This will be the y position of this camera, when ground level is 0.
  52405. */
  52406. get realWorldHeight(): number;
  52407. /** @hidden */
  52408. _updateForDualEyeDebugging(): void;
  52409. /**
  52410. * Sets this camera's transformation based on a non-vr camera
  52411. * @param otherCamera the non-vr camera to copy the transformation from
  52412. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52413. */
  52414. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52415. /**
  52416. * Gets the current instance class name ("WebXRCamera").
  52417. * @returns the class name
  52418. */
  52419. getClassName(): string;
  52420. private _rotate180;
  52421. private _updateFromXRSession;
  52422. private _updateNumberOfRigCameras;
  52423. private _updateReferenceSpace;
  52424. private _updateReferenceSpaceOffset;
  52425. }
  52426. }
  52427. declare module "babylonjs/XR/webXRFeaturesManager" {
  52428. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52429. import { IDisposable } from "babylonjs/scene";
  52430. /**
  52431. * Defining the interface required for a (webxr) feature
  52432. */
  52433. export interface IWebXRFeature extends IDisposable {
  52434. /**
  52435. * Is this feature attached
  52436. */
  52437. attached: boolean;
  52438. /**
  52439. * Should auto-attach be disabled?
  52440. */
  52441. disableAutoAttach: boolean;
  52442. /**
  52443. * Attach the feature to the session
  52444. * Will usually be called by the features manager
  52445. *
  52446. * @param force should attachment be forced (even when already attached)
  52447. * @returns true if successful.
  52448. */
  52449. attach(force?: boolean): boolean;
  52450. /**
  52451. * Detach the feature from the session
  52452. * Will usually be called by the features manager
  52453. *
  52454. * @returns true if successful.
  52455. */
  52456. detach(): boolean;
  52457. /**
  52458. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52459. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52460. *
  52461. * @returns whether or not the feature is compatible in this environment
  52462. */
  52463. isCompatible(): boolean;
  52464. /**
  52465. * Was this feature disposed;
  52466. */
  52467. isDisposed: boolean;
  52468. /**
  52469. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52470. */
  52471. xrNativeFeatureName?: string;
  52472. /**
  52473. * A list of (Babylon WebXR) features this feature depends on
  52474. */
  52475. dependsOn?: string[];
  52476. }
  52477. /**
  52478. * A list of the currently available features without referencing them
  52479. */
  52480. export class WebXRFeatureName {
  52481. /**
  52482. * The name of the anchor system feature
  52483. */
  52484. static readonly ANCHOR_SYSTEM: string;
  52485. /**
  52486. * The name of the background remover feature
  52487. */
  52488. static readonly BACKGROUND_REMOVER: string;
  52489. /**
  52490. * The name of the hit test feature
  52491. */
  52492. static readonly HIT_TEST: string;
  52493. /**
  52494. * physics impostors for xr controllers feature
  52495. */
  52496. static readonly PHYSICS_CONTROLLERS: string;
  52497. /**
  52498. * The name of the plane detection feature
  52499. */
  52500. static readonly PLANE_DETECTION: string;
  52501. /**
  52502. * The name of the pointer selection feature
  52503. */
  52504. static readonly POINTER_SELECTION: string;
  52505. /**
  52506. * The name of the teleportation feature
  52507. */
  52508. static readonly TELEPORTATION: string;
  52509. /**
  52510. * The name of the feature points feature.
  52511. */
  52512. static readonly FEATURE_POINTS: string;
  52513. /**
  52514. * The name of the hand tracking feature.
  52515. */
  52516. static readonly HAND_TRACKING: string;
  52517. }
  52518. /**
  52519. * Defining the constructor of a feature. Used to register the modules.
  52520. */
  52521. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52522. /**
  52523. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52524. * It is mainly used in AR sessions.
  52525. *
  52526. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52527. */
  52528. export class WebXRFeaturesManager implements IDisposable {
  52529. private _xrSessionManager;
  52530. private static readonly _AvailableFeatures;
  52531. private _features;
  52532. /**
  52533. * constructs a new features manages.
  52534. *
  52535. * @param _xrSessionManager an instance of WebXRSessionManager
  52536. */
  52537. constructor(_xrSessionManager: WebXRSessionManager);
  52538. /**
  52539. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52540. * Mainly used internally.
  52541. *
  52542. * @param featureName the name of the feature to register
  52543. * @param constructorFunction the function used to construct the module
  52544. * @param version the (babylon) version of the module
  52545. * @param stable is that a stable version of this module
  52546. */
  52547. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52548. /**
  52549. * Returns a constructor of a specific feature.
  52550. *
  52551. * @param featureName the name of the feature to construct
  52552. * @param version the version of the feature to load
  52553. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52554. * @param options optional options provided to the module.
  52555. * @returns a function that, when called, will return a new instance of this feature
  52556. */
  52557. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52558. /**
  52559. * Can be used to return the list of features currently registered
  52560. *
  52561. * @returns an Array of available features
  52562. */
  52563. static GetAvailableFeatures(): string[];
  52564. /**
  52565. * Gets the versions available for a specific feature
  52566. * @param featureName the name of the feature
  52567. * @returns an array with the available versions
  52568. */
  52569. static GetAvailableVersions(featureName: string): string[];
  52570. /**
  52571. * Return the latest unstable version of this feature
  52572. * @param featureName the name of the feature to search
  52573. * @returns the version number. if not found will return -1
  52574. */
  52575. static GetLatestVersionOfFeature(featureName: string): number;
  52576. /**
  52577. * Return the latest stable version of this feature
  52578. * @param featureName the name of the feature to search
  52579. * @returns the version number. if not found will return -1
  52580. */
  52581. static GetStableVersionOfFeature(featureName: string): number;
  52582. /**
  52583. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52584. * Can be used during a session to start a feature
  52585. * @param featureName the name of feature to attach
  52586. */
  52587. attachFeature(featureName: string): void;
  52588. /**
  52589. * Can be used inside a session or when the session ends to detach a specific feature
  52590. * @param featureName the name of the feature to detach
  52591. */
  52592. detachFeature(featureName: string): void;
  52593. /**
  52594. * Used to disable an already-enabled feature
  52595. * The feature will be disposed and will be recreated once enabled.
  52596. * @param featureName the feature to disable
  52597. * @returns true if disable was successful
  52598. */
  52599. disableFeature(featureName: string | {
  52600. Name: string;
  52601. }): boolean;
  52602. /**
  52603. * dispose this features manager
  52604. */
  52605. dispose(): void;
  52606. /**
  52607. * 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.
  52608. * 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.
  52609. *
  52610. * @param featureName the name of the feature to load or the class of the feature
  52611. * @param version optional version to load. if not provided the latest version will be enabled
  52612. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52613. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52614. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52615. * @returns a new constructed feature or throws an error if feature not found.
  52616. */
  52617. enableFeature(featureName: string | {
  52618. Name: string;
  52619. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52620. /**
  52621. * get the implementation of an enabled feature.
  52622. * @param featureName the name of the feature to load
  52623. * @returns the feature class, if found
  52624. */
  52625. getEnabledFeature(featureName: string): IWebXRFeature;
  52626. /**
  52627. * Get the list of enabled features
  52628. * @returns an array of enabled features
  52629. */
  52630. getEnabledFeatures(): string[];
  52631. /**
  52632. * This function will exten the session creation configuration object with enabled features.
  52633. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  52634. * according to the defined "required" variable, provided during enableFeature call
  52635. * @param xrSessionInit the xr Session init object to extend
  52636. *
  52637. * @returns an extended XRSessionInit object
  52638. */
  52639. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  52640. }
  52641. }
  52642. declare module "babylonjs/XR/webXRExperienceHelper" {
  52643. import { Observable } from "babylonjs/Misc/observable";
  52644. import { IDisposable, Scene } from "babylonjs/scene";
  52645. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52646. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  52647. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52648. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  52649. /**
  52650. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  52651. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  52652. */
  52653. export class WebXRExperienceHelper implements IDisposable {
  52654. private scene;
  52655. private _nonVRCamera;
  52656. private _originalSceneAutoClear;
  52657. private _supported;
  52658. /**
  52659. * Camera used to render xr content
  52660. */
  52661. camera: WebXRCamera;
  52662. /** A features manager for this xr session */
  52663. featuresManager: WebXRFeaturesManager;
  52664. /**
  52665. * Observers registered here will be triggered after the camera's initial transformation is set
  52666. * This can be used to set a different ground level or an extra rotation.
  52667. *
  52668. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  52669. * to the position set after this observable is done executing.
  52670. */
  52671. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  52672. /**
  52673. * Fires when the state of the experience helper has changed
  52674. */
  52675. onStateChangedObservable: Observable<WebXRState>;
  52676. /** Session manager used to keep track of xr session */
  52677. sessionManager: WebXRSessionManager;
  52678. /**
  52679. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  52680. */
  52681. state: WebXRState;
  52682. /**
  52683. * Creates a WebXRExperienceHelper
  52684. * @param scene The scene the helper should be created in
  52685. */
  52686. private constructor();
  52687. /**
  52688. * Creates the experience helper
  52689. * @param scene the scene to attach the experience helper to
  52690. * @returns a promise for the experience helper
  52691. */
  52692. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  52693. /**
  52694. * Disposes of the experience helper
  52695. */
  52696. dispose(): void;
  52697. /**
  52698. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  52699. * @param sessionMode options for the XR session
  52700. * @param referenceSpaceType frame of reference of the XR session
  52701. * @param renderTarget the output canvas that will be used to enter XR mode
  52702. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  52703. * @returns promise that resolves after xr mode has entered
  52704. */
  52705. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  52706. /**
  52707. * Exits XR mode and returns the scene to its original state
  52708. * @returns promise that resolves after xr mode has exited
  52709. */
  52710. exitXRAsync(): Promise<void>;
  52711. private _nonXRToXRCamera;
  52712. private _setState;
  52713. }
  52714. }
  52715. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  52716. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  52717. import { Observable } from "babylonjs/Misc/observable";
  52718. import { IDisposable } from "babylonjs/scene";
  52719. /**
  52720. * X-Y values for axes in WebXR
  52721. */
  52722. export interface IWebXRMotionControllerAxesValue {
  52723. /**
  52724. * The value of the x axis
  52725. */
  52726. x: number;
  52727. /**
  52728. * The value of the y-axis
  52729. */
  52730. y: number;
  52731. }
  52732. /**
  52733. * changed / previous values for the values of this component
  52734. */
  52735. export interface IWebXRMotionControllerComponentChangesValues<T> {
  52736. /**
  52737. * current (this frame) value
  52738. */
  52739. current: T;
  52740. /**
  52741. * previous (last change) value
  52742. */
  52743. previous: T;
  52744. }
  52745. /**
  52746. * Represents changes in the component between current frame and last values recorded
  52747. */
  52748. export interface IWebXRMotionControllerComponentChanges {
  52749. /**
  52750. * will be populated with previous and current values if axes changed
  52751. */
  52752. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  52753. /**
  52754. * will be populated with previous and current values if pressed changed
  52755. */
  52756. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52757. /**
  52758. * will be populated with previous and current values if touched changed
  52759. */
  52760. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52761. /**
  52762. * will be populated with previous and current values if value changed
  52763. */
  52764. value?: IWebXRMotionControllerComponentChangesValues<number>;
  52765. }
  52766. /**
  52767. * This class represents a single component (for example button or thumbstick) of a motion controller
  52768. */
  52769. export class WebXRControllerComponent implements IDisposable {
  52770. /**
  52771. * the id of this component
  52772. */
  52773. id: string;
  52774. /**
  52775. * the type of the component
  52776. */
  52777. type: MotionControllerComponentType;
  52778. private _buttonIndex;
  52779. private _axesIndices;
  52780. private _axes;
  52781. private _changes;
  52782. private _currentValue;
  52783. private _hasChanges;
  52784. private _pressed;
  52785. private _touched;
  52786. /**
  52787. * button component type
  52788. */
  52789. static BUTTON_TYPE: MotionControllerComponentType;
  52790. /**
  52791. * squeeze component type
  52792. */
  52793. static SQUEEZE_TYPE: MotionControllerComponentType;
  52794. /**
  52795. * Thumbstick component type
  52796. */
  52797. static THUMBSTICK_TYPE: MotionControllerComponentType;
  52798. /**
  52799. * Touchpad component type
  52800. */
  52801. static TOUCHPAD_TYPE: MotionControllerComponentType;
  52802. /**
  52803. * trigger component type
  52804. */
  52805. static TRIGGER_TYPE: MotionControllerComponentType;
  52806. /**
  52807. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  52808. * the axes data changes
  52809. */
  52810. onAxisValueChangedObservable: Observable<{
  52811. x: number;
  52812. y: number;
  52813. }>;
  52814. /**
  52815. * Observers registered here will be triggered when the state of a button changes
  52816. * State change is either pressed / touched / value
  52817. */
  52818. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  52819. /**
  52820. * Creates a new component for a motion controller.
  52821. * It is created by the motion controller itself
  52822. *
  52823. * @param id the id of this component
  52824. * @param type the type of the component
  52825. * @param _buttonIndex index in the buttons array of the gamepad
  52826. * @param _axesIndices indices of the values in the axes array of the gamepad
  52827. */
  52828. constructor(
  52829. /**
  52830. * the id of this component
  52831. */
  52832. id: string,
  52833. /**
  52834. * the type of the component
  52835. */
  52836. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  52837. /**
  52838. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  52839. */
  52840. get axes(): IWebXRMotionControllerAxesValue;
  52841. /**
  52842. * Get the changes. Elements will be populated only if they changed with their previous and current value
  52843. */
  52844. get changes(): IWebXRMotionControllerComponentChanges;
  52845. /**
  52846. * Return whether or not the component changed the last frame
  52847. */
  52848. get hasChanges(): boolean;
  52849. /**
  52850. * is the button currently pressed
  52851. */
  52852. get pressed(): boolean;
  52853. /**
  52854. * is the button currently touched
  52855. */
  52856. get touched(): boolean;
  52857. /**
  52858. * Get the current value of this component
  52859. */
  52860. get value(): number;
  52861. /**
  52862. * Dispose this component
  52863. */
  52864. dispose(): void;
  52865. /**
  52866. * Are there axes correlating to this component
  52867. * @return true is axes data is available
  52868. */
  52869. isAxes(): boolean;
  52870. /**
  52871. * Is this component a button (hence - pressable)
  52872. * @returns true if can be pressed
  52873. */
  52874. isButton(): boolean;
  52875. /**
  52876. * update this component using the gamepad object it is in. Called on every frame
  52877. * @param nativeController the native gamepad controller object
  52878. */
  52879. update(nativeController: IMinimalMotionControllerObject): void;
  52880. }
  52881. }
  52882. declare module "babylonjs/Loading/sceneLoader" {
  52883. import { Observable } from "babylonjs/Misc/observable";
  52884. import { Nullable } from "babylonjs/types";
  52885. import { Scene } from "babylonjs/scene";
  52886. import { Engine } from "babylonjs/Engines/engine";
  52887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52888. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  52889. import { AssetContainer } from "babylonjs/assetContainer";
  52890. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52891. import { Skeleton } from "babylonjs/Bones/skeleton";
  52892. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  52893. import { WebRequest } from "babylonjs/Misc/webRequest";
  52894. /**
  52895. * Interface used to represent data loading progression
  52896. */
  52897. export interface ISceneLoaderProgressEvent {
  52898. /**
  52899. * Defines if data length to load can be evaluated
  52900. */
  52901. readonly lengthComputable: boolean;
  52902. /**
  52903. * Defines the loaded data length
  52904. */
  52905. readonly loaded: number;
  52906. /**
  52907. * Defines the data length to load
  52908. */
  52909. readonly total: number;
  52910. }
  52911. /**
  52912. * Interface used by SceneLoader plugins to define supported file extensions
  52913. */
  52914. export interface ISceneLoaderPluginExtensions {
  52915. /**
  52916. * Defines the list of supported extensions
  52917. */
  52918. [extension: string]: {
  52919. isBinary: boolean;
  52920. };
  52921. }
  52922. /**
  52923. * Interface used by SceneLoader plugin factory
  52924. */
  52925. export interface ISceneLoaderPluginFactory {
  52926. /**
  52927. * Defines the name of the factory
  52928. */
  52929. name: string;
  52930. /**
  52931. * Function called to create a new plugin
  52932. * @return the new plugin
  52933. */
  52934. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  52935. /**
  52936. * The callback that returns true if the data can be directly loaded.
  52937. * @param data string containing the file data
  52938. * @returns if the data can be loaded directly
  52939. */
  52940. canDirectLoad?(data: string): boolean;
  52941. }
  52942. /**
  52943. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  52944. */
  52945. export interface ISceneLoaderPluginBase {
  52946. /**
  52947. * The friendly name of this plugin.
  52948. */
  52949. name: string;
  52950. /**
  52951. * The file extensions supported by this plugin.
  52952. */
  52953. extensions: string | ISceneLoaderPluginExtensions;
  52954. /**
  52955. * The callback called when loading from a url.
  52956. * @param scene scene loading this url
  52957. * @param url url to load
  52958. * @param onSuccess callback called when the file successfully loads
  52959. * @param onProgress callback called while file is loading (if the server supports this mode)
  52960. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  52961. * @param onError callback called when the file fails to load
  52962. * @returns a file request object
  52963. */
  52964. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52965. /**
  52966. * The callback called when loading from a file object.
  52967. * @param scene scene loading this file
  52968. * @param file defines the file to load
  52969. * @param onSuccess defines the callback to call when data is loaded
  52970. * @param onProgress defines the callback to call during loading process
  52971. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  52972. * @param onError defines the callback to call when an error occurs
  52973. * @returns a file request object
  52974. */
  52975. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52976. /**
  52977. * The callback that returns true if the data can be directly loaded.
  52978. * @param data string containing the file data
  52979. * @returns if the data can be loaded directly
  52980. */
  52981. canDirectLoad?(data: string): boolean;
  52982. /**
  52983. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  52984. * @param scene scene loading this data
  52985. * @param data string containing the data
  52986. * @returns data to pass to the plugin
  52987. */
  52988. directLoad?(scene: Scene, data: string): any;
  52989. /**
  52990. * The callback that allows custom handling of the root url based on the response url.
  52991. * @param rootUrl the original root url
  52992. * @param responseURL the response url if available
  52993. * @returns the new root url
  52994. */
  52995. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  52996. }
  52997. /**
  52998. * Interface used to define a SceneLoader plugin
  52999. */
  53000. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  53001. /**
  53002. * Import meshes into a scene.
  53003. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53004. * @param scene The scene to import into
  53005. * @param data The data to import
  53006. * @param rootUrl The root url for scene and resources
  53007. * @param meshes The meshes array to import into
  53008. * @param particleSystems The particle systems array to import into
  53009. * @param skeletons The skeletons array to import into
  53010. * @param onError The callback when import fails
  53011. * @returns True if successful or false otherwise
  53012. */
  53013. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  53014. /**
  53015. * Load into a scene.
  53016. * @param scene The scene to load into
  53017. * @param data The data to import
  53018. * @param rootUrl The root url for scene and resources
  53019. * @param onError The callback when import fails
  53020. * @returns True if successful or false otherwise
  53021. */
  53022. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  53023. /**
  53024. * Load into an asset container.
  53025. * @param scene The scene to load into
  53026. * @param data The data to import
  53027. * @param rootUrl The root url for scene and resources
  53028. * @param onError The callback when import fails
  53029. * @returns The loaded asset container
  53030. */
  53031. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  53032. }
  53033. /**
  53034. * Interface used to define an async SceneLoader plugin
  53035. */
  53036. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  53037. /**
  53038. * Import meshes into a scene.
  53039. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53040. * @param scene The scene to import into
  53041. * @param data The data to import
  53042. * @param rootUrl The root url for scene and resources
  53043. * @param onProgress The callback when the load progresses
  53044. * @param fileName Defines the name of the file to load
  53045. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  53046. */
  53047. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  53048. meshes: AbstractMesh[];
  53049. particleSystems: IParticleSystem[];
  53050. skeletons: Skeleton[];
  53051. animationGroups: AnimationGroup[];
  53052. }>;
  53053. /**
  53054. * Load into a scene.
  53055. * @param scene The scene to load into
  53056. * @param data The data to import
  53057. * @param rootUrl The root url for scene and resources
  53058. * @param onProgress The callback when the load progresses
  53059. * @param fileName Defines the name of the file to load
  53060. * @returns Nothing
  53061. */
  53062. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  53063. /**
  53064. * Load into an asset container.
  53065. * @param scene The scene to load into
  53066. * @param data The data to import
  53067. * @param rootUrl The root url for scene and resources
  53068. * @param onProgress The callback when the load progresses
  53069. * @param fileName Defines the name of the file to load
  53070. * @returns The loaded asset container
  53071. */
  53072. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  53073. }
  53074. /**
  53075. * Mode that determines how to handle old animation groups before loading new ones.
  53076. */
  53077. export enum SceneLoaderAnimationGroupLoadingMode {
  53078. /**
  53079. * Reset all old animations to initial state then dispose them.
  53080. */
  53081. Clean = 0,
  53082. /**
  53083. * Stop all old animations.
  53084. */
  53085. Stop = 1,
  53086. /**
  53087. * Restart old animations from first frame.
  53088. */
  53089. Sync = 2,
  53090. /**
  53091. * Old animations remains untouched.
  53092. */
  53093. NoSync = 3
  53094. }
  53095. /**
  53096. * Defines a plugin registered by the SceneLoader
  53097. */
  53098. interface IRegisteredPlugin {
  53099. /**
  53100. * Defines the plugin to use
  53101. */
  53102. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53103. /**
  53104. * Defines if the plugin supports binary data
  53105. */
  53106. isBinary: boolean;
  53107. }
  53108. /**
  53109. * Class used to load scene from various file formats using registered plugins
  53110. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  53111. */
  53112. export class SceneLoader {
  53113. /**
  53114. * No logging while loading
  53115. */
  53116. static readonly NO_LOGGING: number;
  53117. /**
  53118. * Minimal logging while loading
  53119. */
  53120. static readonly MINIMAL_LOGGING: number;
  53121. /**
  53122. * Summary logging while loading
  53123. */
  53124. static readonly SUMMARY_LOGGING: number;
  53125. /**
  53126. * Detailled logging while loading
  53127. */
  53128. static readonly DETAILED_LOGGING: number;
  53129. /**
  53130. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  53131. */
  53132. static get ForceFullSceneLoadingForIncremental(): boolean;
  53133. static set ForceFullSceneLoadingForIncremental(value: boolean);
  53134. /**
  53135. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  53136. */
  53137. static get ShowLoadingScreen(): boolean;
  53138. static set ShowLoadingScreen(value: boolean);
  53139. /**
  53140. * Defines the current logging level (while loading the scene)
  53141. * @ignorenaming
  53142. */
  53143. static get loggingLevel(): number;
  53144. static set loggingLevel(value: number);
  53145. /**
  53146. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  53147. */
  53148. static get CleanBoneMatrixWeights(): boolean;
  53149. static set CleanBoneMatrixWeights(value: boolean);
  53150. /**
  53151. * Event raised when a plugin is used to load a scene
  53152. */
  53153. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  53154. private static _registeredPlugins;
  53155. private static _showingLoadingScreen;
  53156. /**
  53157. * Gets the default plugin (used to load Babylon files)
  53158. * @returns the .babylon plugin
  53159. */
  53160. static GetDefaultPlugin(): IRegisteredPlugin;
  53161. private static _GetPluginForExtension;
  53162. private static _GetPluginForDirectLoad;
  53163. private static _GetPluginForFilename;
  53164. private static _GetDirectLoad;
  53165. private static _LoadData;
  53166. private static _GetFileInfo;
  53167. /**
  53168. * Gets a plugin that can load the given extension
  53169. * @param extension defines the extension to load
  53170. * @returns a plugin or null if none works
  53171. */
  53172. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53173. /**
  53174. * Gets a boolean indicating that the given extension can be loaded
  53175. * @param extension defines the extension to load
  53176. * @returns true if the extension is supported
  53177. */
  53178. static IsPluginForExtensionAvailable(extension: string): boolean;
  53179. /**
  53180. * Adds a new plugin to the list of registered plugins
  53181. * @param plugin defines the plugin to add
  53182. */
  53183. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  53184. /**
  53185. * Import meshes into a scene
  53186. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53187. * @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)
  53188. * @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)
  53189. * @param scene the instance of BABYLON.Scene to append to
  53190. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  53191. * @param onProgress a callback with a progress event for each file being loaded
  53192. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53193. * @param pluginExtension the extension used to determine the plugin
  53194. * @returns The loaded plugin
  53195. */
  53196. 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>;
  53197. /**
  53198. * Import meshes into a scene
  53199. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53200. * @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)
  53201. * @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)
  53202. * @param scene the instance of BABYLON.Scene to append to
  53203. * @param onProgress a callback with a progress event for each file being loaded
  53204. * @param pluginExtension the extension used to determine the plugin
  53205. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  53206. */
  53207. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  53208. meshes: AbstractMesh[];
  53209. particleSystems: IParticleSystem[];
  53210. skeletons: Skeleton[];
  53211. animationGroups: AnimationGroup[];
  53212. }>;
  53213. /**
  53214. * Load a scene
  53215. * @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)
  53216. * @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)
  53217. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53218. * @param onSuccess a callback with the scene when import succeeds
  53219. * @param onProgress a callback with a progress event for each file being loaded
  53220. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53221. * @param pluginExtension the extension used to determine the plugin
  53222. * @returns The loaded plugin
  53223. */
  53224. 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>;
  53225. /**
  53226. * Load a scene
  53227. * @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)
  53228. * @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)
  53229. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53230. * @param onProgress a callback with a progress event for each file being loaded
  53231. * @param pluginExtension the extension used to determine the plugin
  53232. * @returns The loaded scene
  53233. */
  53234. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53235. /**
  53236. * Append a scene
  53237. * @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)
  53238. * @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)
  53239. * @param scene is the instance of BABYLON.Scene to append to
  53240. * @param onSuccess a callback with the scene when import succeeds
  53241. * @param onProgress a callback with a progress event for each file being loaded
  53242. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53243. * @param pluginExtension the extension used to determine the plugin
  53244. * @returns The loaded plugin
  53245. */
  53246. 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>;
  53247. /**
  53248. * Append a scene
  53249. * @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)
  53250. * @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)
  53251. * @param scene is the instance of BABYLON.Scene to append to
  53252. * @param onProgress a callback with a progress event for each file being loaded
  53253. * @param pluginExtension the extension used to determine the plugin
  53254. * @returns The given scene
  53255. */
  53256. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53257. /**
  53258. * Load a scene into an asset container
  53259. * @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)
  53260. * @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)
  53261. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53262. * @param onSuccess a callback with the scene when import succeeds
  53263. * @param onProgress a callback with a progress event for each file being loaded
  53264. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53265. * @param pluginExtension the extension used to determine the plugin
  53266. * @returns The loaded plugin
  53267. */
  53268. 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>;
  53269. /**
  53270. * Load a scene into an asset container
  53271. * @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)
  53272. * @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)
  53273. * @param scene is the instance of Scene to append to
  53274. * @param onProgress a callback with a progress event for each file being loaded
  53275. * @param pluginExtension the extension used to determine the plugin
  53276. * @returns The loaded asset container
  53277. */
  53278. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  53279. /**
  53280. * Import animations from a file into a scene
  53281. * @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)
  53282. * @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)
  53283. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53284. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53285. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53286. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53287. * @param onSuccess a callback with the scene when import succeeds
  53288. * @param onProgress a callback with a progress event for each file being loaded
  53289. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53290. * @param pluginExtension the extension used to determine the plugin
  53291. */
  53292. 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;
  53293. /**
  53294. * Import animations from a file into a scene
  53295. * @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)
  53296. * @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)
  53297. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53298. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53299. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53300. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53301. * @param onSuccess a callback with the scene when import succeeds
  53302. * @param onProgress a callback with a progress event for each file being loaded
  53303. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53304. * @param pluginExtension the extension used to determine the plugin
  53305. * @returns the updated scene with imported animations
  53306. */
  53307. 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>;
  53308. }
  53309. }
  53310. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  53311. import { IDisposable, Scene } from "babylonjs/scene";
  53312. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  53313. import { Observable } from "babylonjs/Misc/observable";
  53314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53315. import { Nullable } from "babylonjs/types";
  53316. /**
  53317. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  53318. */
  53319. export type MotionControllerHandedness = "none" | "left" | "right";
  53320. /**
  53321. * The type of components available in motion controllers.
  53322. * This is not the name of the component.
  53323. */
  53324. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  53325. /**
  53326. * The state of a controller component
  53327. */
  53328. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  53329. /**
  53330. * The schema of motion controller layout.
  53331. * No object will be initialized using this interface
  53332. * This is used just to define the profile.
  53333. */
  53334. export interface IMotionControllerLayout {
  53335. /**
  53336. * Path to load the assets. Usually relative to the base path
  53337. */
  53338. assetPath: string;
  53339. /**
  53340. * Available components (unsorted)
  53341. */
  53342. components: {
  53343. /**
  53344. * A map of component Ids
  53345. */
  53346. [componentId: string]: {
  53347. /**
  53348. * The type of input the component outputs
  53349. */
  53350. type: MotionControllerComponentType;
  53351. /**
  53352. * The indices of this component in the gamepad object
  53353. */
  53354. gamepadIndices: {
  53355. /**
  53356. * Index of button
  53357. */
  53358. button?: number;
  53359. /**
  53360. * If available, index of x-axis
  53361. */
  53362. xAxis?: number;
  53363. /**
  53364. * If available, index of y-axis
  53365. */
  53366. yAxis?: number;
  53367. };
  53368. /**
  53369. * The mesh's root node name
  53370. */
  53371. rootNodeName: string;
  53372. /**
  53373. * Animation definitions for this model
  53374. */
  53375. visualResponses: {
  53376. [stateKey: string]: {
  53377. /**
  53378. * What property will be animated
  53379. */
  53380. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  53381. /**
  53382. * What states influence this visual response
  53383. */
  53384. states: MotionControllerComponentStateType[];
  53385. /**
  53386. * Type of animation - movement or visibility
  53387. */
  53388. valueNodeProperty: "transform" | "visibility";
  53389. /**
  53390. * Base node name to move. Its position will be calculated according to the min and max nodes
  53391. */
  53392. valueNodeName?: string;
  53393. /**
  53394. * Minimum movement node
  53395. */
  53396. minNodeName?: string;
  53397. /**
  53398. * Max movement node
  53399. */
  53400. maxNodeName?: string;
  53401. };
  53402. };
  53403. /**
  53404. * If touch enabled, what is the name of node to display user feedback
  53405. */
  53406. touchPointNodeName?: string;
  53407. };
  53408. };
  53409. /**
  53410. * Is it xr standard mapping or not
  53411. */
  53412. gamepadMapping: "" | "xr-standard";
  53413. /**
  53414. * Base root node of this entire model
  53415. */
  53416. rootNodeName: string;
  53417. /**
  53418. * Defines the main button component id
  53419. */
  53420. selectComponentId: string;
  53421. }
  53422. /**
  53423. * A definition for the layout map in the input profile
  53424. */
  53425. export interface IMotionControllerLayoutMap {
  53426. /**
  53427. * Layouts with handedness type as a key
  53428. */
  53429. [handedness: string]: IMotionControllerLayout;
  53430. }
  53431. /**
  53432. * The XR Input profile schema
  53433. * Profiles can be found here:
  53434. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53435. */
  53436. export interface IMotionControllerProfile {
  53437. /**
  53438. * fallback profiles for this profileId
  53439. */
  53440. fallbackProfileIds: string[];
  53441. /**
  53442. * The layout map, with handedness as key
  53443. */
  53444. layouts: IMotionControllerLayoutMap;
  53445. /**
  53446. * The id of this profile
  53447. * correlates to the profile(s) in the xrInput.profiles array
  53448. */
  53449. profileId: string;
  53450. }
  53451. /**
  53452. * A helper-interface for the 3 meshes needed for controller button animation
  53453. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53454. */
  53455. export interface IMotionControllerButtonMeshMap {
  53456. /**
  53457. * the mesh that defines the pressed value mesh position.
  53458. * This is used to find the max-position of this button
  53459. */
  53460. pressedMesh: AbstractMesh;
  53461. /**
  53462. * the mesh that defines the unpressed value mesh position.
  53463. * This is used to find the min (or initial) position of this button
  53464. */
  53465. unpressedMesh: AbstractMesh;
  53466. /**
  53467. * The mesh that will be changed when value changes
  53468. */
  53469. valueMesh: AbstractMesh;
  53470. }
  53471. /**
  53472. * A helper-interface for the 3 meshes needed for controller axis animation.
  53473. * This will be expanded when touchpad animations are fully supported
  53474. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53475. */
  53476. export interface IMotionControllerMeshMap {
  53477. /**
  53478. * the mesh that defines the maximum value mesh position.
  53479. */
  53480. maxMesh?: AbstractMesh;
  53481. /**
  53482. * the mesh that defines the minimum value mesh position.
  53483. */
  53484. minMesh?: AbstractMesh;
  53485. /**
  53486. * The mesh that will be changed when axis value changes
  53487. */
  53488. valueMesh?: AbstractMesh;
  53489. }
  53490. /**
  53491. * The elements needed for change-detection of the gamepad objects in motion controllers
  53492. */
  53493. export interface IMinimalMotionControllerObject {
  53494. /**
  53495. * Available axes of this controller
  53496. */
  53497. axes: number[];
  53498. /**
  53499. * An array of available buttons
  53500. */
  53501. buttons: Array<{
  53502. /**
  53503. * Value of the button/trigger
  53504. */
  53505. value: number;
  53506. /**
  53507. * If the button/trigger is currently touched
  53508. */
  53509. touched: boolean;
  53510. /**
  53511. * If the button/trigger is currently pressed
  53512. */
  53513. pressed: boolean;
  53514. }>;
  53515. /**
  53516. * EXPERIMENTAL haptic support.
  53517. */
  53518. hapticActuators?: Array<{
  53519. pulse: (value: number, duration: number) => Promise<boolean>;
  53520. }>;
  53521. }
  53522. /**
  53523. * An Abstract Motion controller
  53524. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53525. * Each component has an observable to check for changes in value and state
  53526. */
  53527. export abstract class WebXRAbstractMotionController implements IDisposable {
  53528. protected scene: Scene;
  53529. protected layout: IMotionControllerLayout;
  53530. /**
  53531. * The gamepad object correlating to this controller
  53532. */
  53533. gamepadObject: IMinimalMotionControllerObject;
  53534. /**
  53535. * handedness (left/right/none) of this controller
  53536. */
  53537. handedness: MotionControllerHandedness;
  53538. private _initComponent;
  53539. private _modelReady;
  53540. /**
  53541. * A map of components (WebXRControllerComponent) in this motion controller
  53542. * Components have a ComponentType and can also have both button and axis definitions
  53543. */
  53544. readonly components: {
  53545. [id: string]: WebXRControllerComponent;
  53546. };
  53547. /**
  53548. * Disable the model's animation. Can be set at any time.
  53549. */
  53550. disableAnimation: boolean;
  53551. /**
  53552. * Observers registered here will be triggered when the model of this controller is done loading
  53553. */
  53554. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53555. /**
  53556. * The profile id of this motion controller
  53557. */
  53558. abstract profileId: string;
  53559. /**
  53560. * The root mesh of the model. It is null if the model was not yet initialized
  53561. */
  53562. rootMesh: Nullable<AbstractMesh>;
  53563. /**
  53564. * constructs a new abstract motion controller
  53565. * @param scene the scene to which the model of the controller will be added
  53566. * @param layout The profile layout to load
  53567. * @param gamepadObject The gamepad object correlating to this controller
  53568. * @param handedness handedness (left/right/none) of this controller
  53569. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53570. */
  53571. constructor(scene: Scene, layout: IMotionControllerLayout,
  53572. /**
  53573. * The gamepad object correlating to this controller
  53574. */
  53575. gamepadObject: IMinimalMotionControllerObject,
  53576. /**
  53577. * handedness (left/right/none) of this controller
  53578. */
  53579. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53580. /**
  53581. * Dispose this controller, the model mesh and all its components
  53582. */
  53583. dispose(): void;
  53584. /**
  53585. * Returns all components of specific type
  53586. * @param type the type to search for
  53587. * @return an array of components with this type
  53588. */
  53589. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53590. /**
  53591. * get a component based an its component id as defined in layout.components
  53592. * @param id the id of the component
  53593. * @returns the component correlates to the id or undefined if not found
  53594. */
  53595. getComponent(id: string): WebXRControllerComponent;
  53596. /**
  53597. * Get the list of components available in this motion controller
  53598. * @returns an array of strings correlating to available components
  53599. */
  53600. getComponentIds(): string[];
  53601. /**
  53602. * Get the first component of specific type
  53603. * @param type type of component to find
  53604. * @return a controller component or null if not found
  53605. */
  53606. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  53607. /**
  53608. * Get the main (Select) component of this controller as defined in the layout
  53609. * @returns the main component of this controller
  53610. */
  53611. getMainComponent(): WebXRControllerComponent;
  53612. /**
  53613. * Loads the model correlating to this controller
  53614. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  53615. * @returns A promise fulfilled with the result of the model loading
  53616. */
  53617. loadModel(): Promise<boolean>;
  53618. /**
  53619. * Update this model using the current XRFrame
  53620. * @param xrFrame the current xr frame to use and update the model
  53621. */
  53622. updateFromXRFrame(xrFrame: XRFrame): void;
  53623. /**
  53624. * Backwards compatibility due to a deeply-integrated typo
  53625. */
  53626. get handness(): XREye;
  53627. /**
  53628. * Pulse (vibrate) this controller
  53629. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  53630. * Consecutive calls to this function will cancel the last pulse call
  53631. *
  53632. * @param value the strength of the pulse in 0.0...1.0 range
  53633. * @param duration Duration of the pulse in milliseconds
  53634. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  53635. * @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
  53636. */
  53637. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  53638. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53639. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53640. /**
  53641. * Moves the axis on the controller mesh based on its current state
  53642. * @param axis the index of the axis
  53643. * @param axisValue the value of the axis which determines the meshes new position
  53644. * @hidden
  53645. */
  53646. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  53647. /**
  53648. * Update the model itself with the current frame data
  53649. * @param xrFrame the frame to use for updating the model mesh
  53650. */
  53651. protected updateModel(xrFrame: XRFrame): void;
  53652. /**
  53653. * Get the filename and path for this controller's model
  53654. * @returns a map of filename and path
  53655. */
  53656. protected abstract _getFilenameAndPath(): {
  53657. filename: string;
  53658. path: string;
  53659. };
  53660. /**
  53661. * This function is called before the mesh is loaded. It checks for loading constraints.
  53662. * For example, this function can check if the GLB loader is available
  53663. * If this function returns false, the generic controller will be loaded instead
  53664. * @returns Is the client ready to load the mesh
  53665. */
  53666. protected abstract _getModelLoadingConstraints(): boolean;
  53667. /**
  53668. * This function will be called after the model was successfully loaded and can be used
  53669. * for mesh transformations before it is available for the user
  53670. * @param meshes the loaded meshes
  53671. */
  53672. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  53673. /**
  53674. * Set the root mesh for this controller. Important for the WebXR controller class
  53675. * @param meshes the loaded meshes
  53676. */
  53677. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  53678. /**
  53679. * A function executed each frame that updates the mesh (if needed)
  53680. * @param xrFrame the current xrFrame
  53681. */
  53682. protected abstract _updateModel(xrFrame: XRFrame): void;
  53683. private _getGenericFilenameAndPath;
  53684. private _getGenericParentMesh;
  53685. }
  53686. }
  53687. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  53688. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53690. import { Scene } from "babylonjs/scene";
  53691. /**
  53692. * A generic trigger-only motion controller for WebXR
  53693. */
  53694. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  53695. /**
  53696. * Static version of the profile id of this controller
  53697. */
  53698. static ProfileId: string;
  53699. profileId: string;
  53700. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  53701. protected _getFilenameAndPath(): {
  53702. filename: string;
  53703. path: string;
  53704. };
  53705. protected _getModelLoadingConstraints(): boolean;
  53706. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  53707. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53708. protected _updateModel(): void;
  53709. }
  53710. }
  53711. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  53712. import { Vector4 } from "babylonjs/Maths/math.vector";
  53713. import { Mesh } from "babylonjs/Meshes/mesh";
  53714. import { Scene } from "babylonjs/scene";
  53715. import { Nullable } from "babylonjs/types";
  53716. /**
  53717. * Class containing static functions to help procedurally build meshes
  53718. */
  53719. export class SphereBuilder {
  53720. /**
  53721. * Creates a sphere mesh
  53722. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53723. * * 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`)
  53724. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53725. * * 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
  53726. * * 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)
  53727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53730. * @param name defines the name of the mesh
  53731. * @param options defines the options used to create the mesh
  53732. * @param scene defines the hosting scene
  53733. * @returns the sphere mesh
  53734. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53735. */
  53736. static CreateSphere(name: string, options: {
  53737. segments?: number;
  53738. diameter?: number;
  53739. diameterX?: number;
  53740. diameterY?: number;
  53741. diameterZ?: number;
  53742. arc?: number;
  53743. slice?: number;
  53744. sideOrientation?: number;
  53745. frontUVs?: Vector4;
  53746. backUVs?: Vector4;
  53747. updatable?: boolean;
  53748. }, scene?: Nullable<Scene>): Mesh;
  53749. }
  53750. }
  53751. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  53752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53753. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53754. import { Scene } from "babylonjs/scene";
  53755. /**
  53756. * A profiled motion controller has its profile loaded from an online repository.
  53757. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  53758. */
  53759. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  53760. private _repositoryUrl;
  53761. private _buttonMeshMapping;
  53762. private _touchDots;
  53763. /**
  53764. * The profile ID of this controller. Will be populated when the controller initializes.
  53765. */
  53766. profileId: string;
  53767. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  53768. dispose(): void;
  53769. protected _getFilenameAndPath(): {
  53770. filename: string;
  53771. path: string;
  53772. };
  53773. protected _getModelLoadingConstraints(): boolean;
  53774. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  53775. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53776. protected _updateModel(_xrFrame: XRFrame): void;
  53777. }
  53778. }
  53779. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  53780. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53781. import { Scene } from "babylonjs/scene";
  53782. /**
  53783. * A construction function type to create a new controller based on an xrInput object
  53784. */
  53785. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  53786. /**
  53787. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  53788. *
  53789. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  53790. * it should be replaced with auto-loaded controllers.
  53791. *
  53792. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  53793. */
  53794. export class WebXRMotionControllerManager {
  53795. private static _AvailableControllers;
  53796. private static _Fallbacks;
  53797. private static _ProfileLoadingPromises;
  53798. private static _ProfilesList;
  53799. /**
  53800. * The base URL of the online controller repository. Can be changed at any time.
  53801. */
  53802. static BaseRepositoryUrl: string;
  53803. /**
  53804. * Which repository gets priority - local or online
  53805. */
  53806. static PrioritizeOnlineRepository: boolean;
  53807. /**
  53808. * Use the online repository, or use only locally-defined controllers
  53809. */
  53810. static UseOnlineRepository: boolean;
  53811. /**
  53812. * Clear the cache used for profile loading and reload when requested again
  53813. */
  53814. static ClearProfilesCache(): void;
  53815. /**
  53816. * Register the default fallbacks.
  53817. * This function is called automatically when this file is imported.
  53818. */
  53819. static DefaultFallbacks(): void;
  53820. /**
  53821. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  53822. * @param profileId the profile to which a fallback needs to be found
  53823. * @return an array with corresponding fallback profiles
  53824. */
  53825. static FindFallbackWithProfileId(profileId: string): string[];
  53826. /**
  53827. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  53828. * The order of search:
  53829. *
  53830. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  53831. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  53832. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  53833. * 4) return the generic trigger controller if none were found
  53834. *
  53835. * @param xrInput the xrInput to which a new controller is initialized
  53836. * @param scene the scene to which the model will be added
  53837. * @param forceProfile force a certain profile for this controller
  53838. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  53839. */
  53840. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  53841. /**
  53842. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  53843. *
  53844. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  53845. *
  53846. * @param type the profile type to register
  53847. * @param constructFunction the function to be called when loading this profile
  53848. */
  53849. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  53850. /**
  53851. * Register a fallback to a specific profile.
  53852. * @param profileId the profileId that will receive the fallbacks
  53853. * @param fallbacks A list of fallback profiles
  53854. */
  53855. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  53856. /**
  53857. * Will update the list of profiles available in the repository
  53858. * @return a promise that resolves to a map of profiles available online
  53859. */
  53860. static UpdateProfilesList(): Promise<{
  53861. [profile: string]: string;
  53862. }>;
  53863. private static _LoadProfileFromRepository;
  53864. private static _LoadProfilesFromAvailableControllers;
  53865. }
  53866. }
  53867. declare module "babylonjs/XR/webXRInputSource" {
  53868. import { Observable } from "babylonjs/Misc/observable";
  53869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53870. import { Ray } from "babylonjs/Culling/ray";
  53871. import { Scene } from "babylonjs/scene";
  53872. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53873. /**
  53874. * Configuration options for the WebXR controller creation
  53875. */
  53876. export interface IWebXRControllerOptions {
  53877. /**
  53878. * Should the controller mesh be animated when a user interacts with it
  53879. * The pressed buttons / thumbstick and touchpad animations will be disabled
  53880. */
  53881. disableMotionControllerAnimation?: boolean;
  53882. /**
  53883. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  53884. */
  53885. doNotLoadControllerMesh?: boolean;
  53886. /**
  53887. * Force a specific controller type for this controller.
  53888. * This can be used when creating your own profile or when testing different controllers
  53889. */
  53890. forceControllerProfile?: string;
  53891. /**
  53892. * Defines a rendering group ID for meshes that will be loaded.
  53893. * This is for the default controllers only.
  53894. */
  53895. renderingGroupId?: number;
  53896. }
  53897. /**
  53898. * Represents an XR controller
  53899. */
  53900. export class WebXRInputSource {
  53901. private _scene;
  53902. /** The underlying input source for the controller */
  53903. inputSource: XRInputSource;
  53904. private _options;
  53905. private _tmpVector;
  53906. private _uniqueId;
  53907. private _disposed;
  53908. /**
  53909. * 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
  53910. */
  53911. grip?: AbstractMesh;
  53912. /**
  53913. * If available, this is the gamepad object related to this controller.
  53914. * Using this object it is possible to get click events and trackpad changes of the
  53915. * webxr controller that is currently being used.
  53916. */
  53917. motionController?: WebXRAbstractMotionController;
  53918. /**
  53919. * Event that fires when the controller is removed/disposed.
  53920. * The object provided as event data is this controller, after associated assets were disposed.
  53921. * uniqueId is still available.
  53922. */
  53923. onDisposeObservable: Observable<WebXRInputSource>;
  53924. /**
  53925. * Will be triggered when the mesh associated with the motion controller is done loading.
  53926. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  53927. * A shortened version of controller -> motion controller -> on mesh loaded.
  53928. */
  53929. onMeshLoadedObservable: Observable<AbstractMesh>;
  53930. /**
  53931. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  53932. */
  53933. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  53934. /**
  53935. * Pointer which can be used to select objects or attach a visible laser to
  53936. */
  53937. pointer: AbstractMesh;
  53938. /**
  53939. * Creates the input source object
  53940. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  53941. * @param _scene the scene which the controller should be associated to
  53942. * @param inputSource the underlying input source for the controller
  53943. * @param _options options for this controller creation
  53944. */
  53945. constructor(_scene: Scene,
  53946. /** The underlying input source for the controller */
  53947. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  53948. /**
  53949. * Get this controllers unique id
  53950. */
  53951. get uniqueId(): string;
  53952. /**
  53953. * Disposes of the object
  53954. */
  53955. dispose(): void;
  53956. /**
  53957. * Gets a world space ray coming from the pointer or grip
  53958. * @param result the resulting ray
  53959. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  53960. */
  53961. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  53962. /**
  53963. * Updates the controller pose based on the given XRFrame
  53964. * @param xrFrame xr frame to update the pose with
  53965. * @param referenceSpace reference space to use
  53966. */
  53967. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  53968. }
  53969. }
  53970. declare module "babylonjs/XR/webXRInput" {
  53971. import { Observable } from "babylonjs/Misc/observable";
  53972. import { IDisposable } from "babylonjs/scene";
  53973. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  53974. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53975. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53976. /**
  53977. * The schema for initialization options of the XR Input class
  53978. */
  53979. export interface IWebXRInputOptions {
  53980. /**
  53981. * If set to true no model will be automatically loaded
  53982. */
  53983. doNotLoadControllerMeshes?: boolean;
  53984. /**
  53985. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  53986. * If not found, the xr input profile data will be used.
  53987. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  53988. */
  53989. forceInputProfile?: string;
  53990. /**
  53991. * Do not send a request to the controller repository to load the profile.
  53992. *
  53993. * Instead, use the controllers available in babylon itself.
  53994. */
  53995. disableOnlineControllerRepository?: boolean;
  53996. /**
  53997. * A custom URL for the controllers repository
  53998. */
  53999. customControllersRepositoryURL?: string;
  54000. /**
  54001. * Should the controller model's components not move according to the user input
  54002. */
  54003. disableControllerAnimation?: boolean;
  54004. /**
  54005. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  54006. */
  54007. controllerOptions?: IWebXRControllerOptions;
  54008. }
  54009. /**
  54010. * XR input used to track XR inputs such as controllers/rays
  54011. */
  54012. export class WebXRInput implements IDisposable {
  54013. /**
  54014. * the xr session manager for this session
  54015. */
  54016. xrSessionManager: WebXRSessionManager;
  54017. /**
  54018. * the WebXR camera for this session. Mainly used for teleportation
  54019. */
  54020. xrCamera: WebXRCamera;
  54021. private readonly options;
  54022. /**
  54023. * XR controllers being tracked
  54024. */
  54025. controllers: Array<WebXRInputSource>;
  54026. private _frameObserver;
  54027. private _sessionEndedObserver;
  54028. private _sessionInitObserver;
  54029. /**
  54030. * Event when a controller has been connected/added
  54031. */
  54032. onControllerAddedObservable: Observable<WebXRInputSource>;
  54033. /**
  54034. * Event when a controller has been removed/disconnected
  54035. */
  54036. onControllerRemovedObservable: Observable<WebXRInputSource>;
  54037. /**
  54038. * Initializes the WebXRInput
  54039. * @param xrSessionManager the xr session manager for this session
  54040. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  54041. * @param options = initialization options for this xr input
  54042. */
  54043. constructor(
  54044. /**
  54045. * the xr session manager for this session
  54046. */
  54047. xrSessionManager: WebXRSessionManager,
  54048. /**
  54049. * the WebXR camera for this session. Mainly used for teleportation
  54050. */
  54051. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  54052. private _onInputSourcesChange;
  54053. private _addAndRemoveControllers;
  54054. /**
  54055. * Disposes of the object
  54056. */
  54057. dispose(): void;
  54058. }
  54059. }
  54060. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  54061. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54062. import { Observable, EventState } from "babylonjs/Misc/observable";
  54063. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54064. /**
  54065. * This is the base class for all WebXR features.
  54066. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  54067. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  54068. */
  54069. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  54070. protected _xrSessionManager: WebXRSessionManager;
  54071. private _attached;
  54072. private _removeOnDetach;
  54073. /**
  54074. * Is this feature disposed?
  54075. */
  54076. isDisposed: boolean;
  54077. /**
  54078. * Should auto-attach be disabled?
  54079. */
  54080. disableAutoAttach: boolean;
  54081. /**
  54082. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  54083. */
  54084. xrNativeFeatureName: string;
  54085. /**
  54086. * Construct a new (abstract) WebXR feature
  54087. * @param _xrSessionManager the xr session manager for this feature
  54088. */
  54089. constructor(_xrSessionManager: WebXRSessionManager);
  54090. /**
  54091. * Is this feature attached
  54092. */
  54093. get attached(): boolean;
  54094. /**
  54095. * attach this feature
  54096. *
  54097. * @param force should attachment be forced (even when already attached)
  54098. * @returns true if successful, false is failed or already attached
  54099. */
  54100. attach(force?: boolean): boolean;
  54101. /**
  54102. * detach this feature.
  54103. *
  54104. * @returns true if successful, false if failed or already detached
  54105. */
  54106. detach(): boolean;
  54107. /**
  54108. * Dispose this feature and all of the resources attached
  54109. */
  54110. dispose(): void;
  54111. /**
  54112. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54113. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54114. *
  54115. * @returns whether or not the feature is compatible in this environment
  54116. */
  54117. isCompatible(): boolean;
  54118. /**
  54119. * This is used to register callbacks that will automatically be removed when detach is called.
  54120. * @param observable the observable to which the observer will be attached
  54121. * @param callback the callback to register
  54122. */
  54123. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  54124. /**
  54125. * Code in this function will be executed on each xrFrame received from the browser.
  54126. * This function will not execute after the feature is detached.
  54127. * @param _xrFrame the current frame
  54128. */
  54129. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  54130. }
  54131. }
  54132. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  54133. import { IDisposable, Scene } from "babylonjs/scene";
  54134. import { Nullable } from "babylonjs/types";
  54135. import { Observable } from "babylonjs/Misc/observable";
  54136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54137. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  54138. import { Camera } from "babylonjs/Cameras/camera";
  54139. /**
  54140. * Renders a layer on top of an existing scene
  54141. */
  54142. export class UtilityLayerRenderer implements IDisposable {
  54143. /** the original scene that will be rendered on top of */
  54144. originalScene: Scene;
  54145. private _pointerCaptures;
  54146. private _lastPointerEvents;
  54147. private static _DefaultUtilityLayer;
  54148. private static _DefaultKeepDepthUtilityLayer;
  54149. private _sharedGizmoLight;
  54150. private _renderCamera;
  54151. /**
  54152. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  54153. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  54154. * @returns the camera that is used when rendering the utility layer
  54155. */
  54156. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  54157. /**
  54158. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  54159. * @param cam the camera that should be used when rendering the utility layer
  54160. */
  54161. setRenderCamera(cam: Nullable<Camera>): void;
  54162. /**
  54163. * @hidden
  54164. * Light which used by gizmos to get light shading
  54165. */
  54166. _getSharedGizmoLight(): HemisphericLight;
  54167. /**
  54168. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  54169. */
  54170. pickUtilitySceneFirst: boolean;
  54171. /**
  54172. * 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)
  54173. */
  54174. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  54175. /**
  54176. * 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)
  54177. */
  54178. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  54179. /**
  54180. * The scene that is rendered on top of the original scene
  54181. */
  54182. utilityLayerScene: Scene;
  54183. /**
  54184. * If the utility layer should automatically be rendered on top of existing scene
  54185. */
  54186. shouldRender: boolean;
  54187. /**
  54188. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  54189. */
  54190. onlyCheckPointerDownEvents: boolean;
  54191. /**
  54192. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  54193. */
  54194. processAllEvents: boolean;
  54195. /**
  54196. * Observable raised when the pointer move from the utility layer scene to the main scene
  54197. */
  54198. onPointerOutObservable: Observable<number>;
  54199. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  54200. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  54201. private _afterRenderObserver;
  54202. private _sceneDisposeObserver;
  54203. private _originalPointerObserver;
  54204. /**
  54205. * Instantiates a UtilityLayerRenderer
  54206. * @param originalScene the original scene that will be rendered on top of
  54207. * @param handleEvents boolean indicating if the utility layer should handle events
  54208. */
  54209. constructor(
  54210. /** the original scene that will be rendered on top of */
  54211. originalScene: Scene, handleEvents?: boolean);
  54212. private _notifyObservers;
  54213. /**
  54214. * Renders the utility layers scene on top of the original scene
  54215. */
  54216. render(): void;
  54217. /**
  54218. * Disposes of the renderer
  54219. */
  54220. dispose(): void;
  54221. private _updateCamera;
  54222. }
  54223. }
  54224. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  54225. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54227. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54228. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  54229. import { Scene } from "babylonjs/scene";
  54230. import { Nullable } from "babylonjs/types";
  54231. import { Color3 } from "babylonjs/Maths/math.color";
  54232. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54233. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54234. /**
  54235. * Options interface for the pointer selection module
  54236. */
  54237. export interface IWebXRControllerPointerSelectionOptions {
  54238. /**
  54239. * if provided, this scene will be used to render meshes.
  54240. */
  54241. customUtilityLayerScene?: Scene;
  54242. /**
  54243. * 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)
  54244. * If not disabled, the last picked point will be used to execute a pointer up event
  54245. * If disabled, pointer up event will be triggered right after the pointer down event.
  54246. * Used in screen and gaze target ray mode only
  54247. */
  54248. disablePointerUpOnTouchOut: boolean;
  54249. /**
  54250. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  54251. */
  54252. forceGazeMode: boolean;
  54253. /**
  54254. * 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
  54255. * to start a new countdown to the pointer down event.
  54256. * Defaults to 1.
  54257. */
  54258. gazeModePointerMovedFactor?: number;
  54259. /**
  54260. * Different button type to use instead of the main component
  54261. */
  54262. overrideButtonId?: string;
  54263. /**
  54264. * use this rendering group id for the meshes (optional)
  54265. */
  54266. renderingGroupId?: number;
  54267. /**
  54268. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  54269. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  54270. * 3000 means 3 seconds between pointing at something and selecting it
  54271. */
  54272. timeToSelect?: number;
  54273. /**
  54274. * Should meshes created here be added to a utility layer or the main scene
  54275. */
  54276. useUtilityLayer?: boolean;
  54277. /**
  54278. * Optional WebXR camera to be used for gaze selection
  54279. */
  54280. gazeCamera?: WebXRCamera;
  54281. /**
  54282. * the xr input to use with this pointer selection
  54283. */
  54284. xrInput: WebXRInput;
  54285. /**
  54286. * Should the scene pointerX and pointerY update be disabled
  54287. * This is required for fullscreen AR GUI, but might slow down other experiences.
  54288. * Disable in VR, if not needed.
  54289. * The first rig camera (left eye) will be used to calculate the projection
  54290. */
  54291. disableScenePointerVectorUpdate: boolean;
  54292. /**
  54293. * Enable pointer selection on all controllers instead of switching between them
  54294. */
  54295. enablePointerSelectionOnAllControllers?: boolean;
  54296. /**
  54297. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  54298. * If switch is enabled, it will still allow the user to switch between the different controllers
  54299. */
  54300. preferredHandedness?: XRHandedness;
  54301. /**
  54302. * Disable switching the pointer selection from one controller to the other.
  54303. * 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
  54304. */
  54305. disableSwitchOnClick?: boolean;
  54306. /**
  54307. * The maximum distance of the pointer selection feature. Defaults to 100.
  54308. */
  54309. maxPointerDistance?: number;
  54310. }
  54311. /**
  54312. * A module that will enable pointer selection for motion controllers of XR Input Sources
  54313. */
  54314. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  54315. private readonly _options;
  54316. private static _idCounter;
  54317. private _attachController;
  54318. private _controllers;
  54319. private _scene;
  54320. private _tmpVectorForPickCompare;
  54321. private _attachedController;
  54322. /**
  54323. * The module's name
  54324. */
  54325. static readonly Name: string;
  54326. /**
  54327. * The (Babylon) version of this module.
  54328. * This is an integer representing the implementation version.
  54329. * This number does not correspond to the WebXR specs version
  54330. */
  54331. static readonly Version: number;
  54332. /**
  54333. * Disable lighting on the laser pointer (so it will always be visible)
  54334. */
  54335. disablePointerLighting: boolean;
  54336. /**
  54337. * Disable lighting on the selection mesh (so it will always be visible)
  54338. */
  54339. disableSelectionMeshLighting: boolean;
  54340. /**
  54341. * Should the laser pointer be displayed
  54342. */
  54343. displayLaserPointer: boolean;
  54344. /**
  54345. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  54346. */
  54347. displaySelectionMesh: boolean;
  54348. /**
  54349. * This color will be set to the laser pointer when selection is triggered
  54350. */
  54351. laserPointerPickedColor: Color3;
  54352. /**
  54353. * Default color of the laser pointer
  54354. */
  54355. laserPointerDefaultColor: Color3;
  54356. /**
  54357. * default color of the selection ring
  54358. */
  54359. selectionMeshDefaultColor: Color3;
  54360. /**
  54361. * This color will be applied to the selection ring when selection is triggered
  54362. */
  54363. selectionMeshPickedColor: Color3;
  54364. /**
  54365. * Optional filter to be used for ray selection. This predicate shares behavior with
  54366. * scene.pointerMovePredicate which takes priority if it is also assigned.
  54367. */
  54368. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54369. /**
  54370. * constructs a new background remover module
  54371. * @param _xrSessionManager the session manager for this module
  54372. * @param _options read-only options to be used in this module
  54373. */
  54374. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  54375. /**
  54376. * attach this feature
  54377. * Will usually be called by the features manager
  54378. *
  54379. * @returns true if successful.
  54380. */
  54381. attach(): boolean;
  54382. /**
  54383. * detach this feature.
  54384. * Will usually be called by the features manager
  54385. *
  54386. * @returns true if successful.
  54387. */
  54388. detach(): boolean;
  54389. /**
  54390. * Will get the mesh under a specific pointer.
  54391. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  54392. * @param controllerId the controllerId to check
  54393. * @returns The mesh under pointer or null if no mesh is under the pointer
  54394. */
  54395. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  54396. /**
  54397. * Get the xr controller that correlates to the pointer id in the pointer event
  54398. *
  54399. * @param id the pointer id to search for
  54400. * @returns the controller that correlates to this id or null if not found
  54401. */
  54402. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  54403. private _identityMatrix;
  54404. private _screenCoordinatesRef;
  54405. private _viewportRef;
  54406. protected _onXRFrame(_xrFrame: XRFrame): void;
  54407. private _attachGazeMode;
  54408. private _attachScreenRayMode;
  54409. private _attachTrackedPointerRayMode;
  54410. private _convertNormalToDirectionOfRay;
  54411. private _detachController;
  54412. private _generateNewMeshPair;
  54413. private _pickingMoved;
  54414. private _updatePointerDistance;
  54415. /** @hidden */
  54416. get lasterPointerDefaultColor(): Color3;
  54417. }
  54418. }
  54419. declare module "babylonjs/XR/webXREnterExitUI" {
  54420. import { Nullable } from "babylonjs/types";
  54421. import { Observable } from "babylonjs/Misc/observable";
  54422. import { IDisposable, Scene } from "babylonjs/scene";
  54423. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54424. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54425. /**
  54426. * Button which can be used to enter a different mode of XR
  54427. */
  54428. export class WebXREnterExitUIButton {
  54429. /** button element */
  54430. element: HTMLElement;
  54431. /** XR initialization options for the button */
  54432. sessionMode: XRSessionMode;
  54433. /** Reference space type */
  54434. referenceSpaceType: XRReferenceSpaceType;
  54435. /**
  54436. * Creates a WebXREnterExitUIButton
  54437. * @param element button element
  54438. * @param sessionMode XR initialization session mode
  54439. * @param referenceSpaceType the type of reference space to be used
  54440. */
  54441. constructor(
  54442. /** button element */
  54443. element: HTMLElement,
  54444. /** XR initialization options for the button */
  54445. sessionMode: XRSessionMode,
  54446. /** Reference space type */
  54447. referenceSpaceType: XRReferenceSpaceType);
  54448. /**
  54449. * Extendable function which can be used to update the button's visuals when the state changes
  54450. * @param activeButton the current active button in the UI
  54451. */
  54452. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54453. }
  54454. /**
  54455. * Options to create the webXR UI
  54456. */
  54457. export class WebXREnterExitUIOptions {
  54458. /**
  54459. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54460. */
  54461. customButtons?: Array<WebXREnterExitUIButton>;
  54462. /**
  54463. * A reference space type to use when creating the default button.
  54464. * Default is local-floor
  54465. */
  54466. referenceSpaceType?: XRReferenceSpaceType;
  54467. /**
  54468. * Context to enter xr with
  54469. */
  54470. renderTarget?: Nullable<WebXRRenderTarget>;
  54471. /**
  54472. * A session mode to use when creating the default button.
  54473. * Default is immersive-vr
  54474. */
  54475. sessionMode?: XRSessionMode;
  54476. /**
  54477. * A list of optional features to init the session with
  54478. */
  54479. optionalFeatures?: string[];
  54480. /**
  54481. * A list of optional features to init the session with
  54482. */
  54483. requiredFeatures?: string[];
  54484. /**
  54485. * If defined, this function will be executed if the UI encounters an error when entering XR
  54486. */
  54487. onError?: (error: any) => void;
  54488. }
  54489. /**
  54490. * UI to allow the user to enter/exit XR mode
  54491. */
  54492. export class WebXREnterExitUI implements IDisposable {
  54493. private scene;
  54494. /** version of the options passed to this UI */
  54495. options: WebXREnterExitUIOptions;
  54496. private _activeButton;
  54497. private _buttons;
  54498. /**
  54499. * The HTML Div Element to which buttons are added.
  54500. */
  54501. readonly overlay: HTMLDivElement;
  54502. /**
  54503. * Fired every time the active button is changed.
  54504. *
  54505. * When xr is entered via a button that launches xr that button will be the callback parameter
  54506. *
  54507. * When exiting xr the callback parameter will be null)
  54508. */
  54509. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54510. /**
  54511. *
  54512. * @param scene babylon scene object to use
  54513. * @param options (read-only) version of the options passed to this UI
  54514. */
  54515. private constructor();
  54516. /**
  54517. * Creates UI to allow the user to enter/exit XR mode
  54518. * @param scene the scene to add the ui to
  54519. * @param helper the xr experience helper to enter/exit xr with
  54520. * @param options options to configure the UI
  54521. * @returns the created ui
  54522. */
  54523. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54524. /**
  54525. * Disposes of the XR UI component
  54526. */
  54527. dispose(): void;
  54528. private _updateButtons;
  54529. }
  54530. }
  54531. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54532. import { Vector3 } from "babylonjs/Maths/math.vector";
  54533. import { Color4 } from "babylonjs/Maths/math.color";
  54534. import { Nullable } from "babylonjs/types";
  54535. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54536. import { Scene } from "babylonjs/scene";
  54537. /**
  54538. * Class containing static functions to help procedurally build meshes
  54539. */
  54540. export class LinesBuilder {
  54541. /**
  54542. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54543. * * 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
  54544. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54545. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54546. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54547. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54548. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54549. * * 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
  54550. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54552. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54553. * @param name defines the name of the new line system
  54554. * @param options defines the options used to create the line system
  54555. * @param scene defines the hosting scene
  54556. * @returns a new line system mesh
  54557. */
  54558. static CreateLineSystem(name: string, options: {
  54559. lines: Vector3[][];
  54560. updatable?: boolean;
  54561. instance?: Nullable<LinesMesh>;
  54562. colors?: Nullable<Color4[][]>;
  54563. useVertexAlpha?: boolean;
  54564. }, scene: Nullable<Scene>): LinesMesh;
  54565. /**
  54566. * Creates a line mesh
  54567. * 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
  54568. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54569. * * The parameter `points` is an array successive Vector3
  54570. * * 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
  54571. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54572. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54573. * * When updating an instance, remember that only point positions can change, not the number of points
  54574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54575. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54576. * @param name defines the name of the new line system
  54577. * @param options defines the options used to create the line system
  54578. * @param scene defines the hosting scene
  54579. * @returns a new line mesh
  54580. */
  54581. static CreateLines(name: string, options: {
  54582. points: Vector3[];
  54583. updatable?: boolean;
  54584. instance?: Nullable<LinesMesh>;
  54585. colors?: Color4[];
  54586. useVertexAlpha?: boolean;
  54587. }, scene?: Nullable<Scene>): LinesMesh;
  54588. /**
  54589. * Creates a dashed line mesh
  54590. * * 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
  54591. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54592. * * The parameter `points` is an array successive Vector3
  54593. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54594. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54595. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54596. * * 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
  54597. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54598. * * When updating an instance, remember that only point positions can change, not the number of points
  54599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54600. * @param name defines the name of the mesh
  54601. * @param options defines the options used to create the mesh
  54602. * @param scene defines the hosting scene
  54603. * @returns the dashed line mesh
  54604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54605. */
  54606. static CreateDashedLines(name: string, options: {
  54607. points: Vector3[];
  54608. dashSize?: number;
  54609. gapSize?: number;
  54610. dashNb?: number;
  54611. updatable?: boolean;
  54612. instance?: LinesMesh;
  54613. useVertexAlpha?: boolean;
  54614. }, scene?: Nullable<Scene>): LinesMesh;
  54615. }
  54616. }
  54617. declare module "babylonjs/Misc/timer" {
  54618. import { Observable, Observer } from "babylonjs/Misc/observable";
  54619. import { Nullable } from "babylonjs/types";
  54620. import { IDisposable } from "babylonjs/scene";
  54621. /**
  54622. * Construction options for a timer
  54623. */
  54624. export interface ITimerOptions<T> {
  54625. /**
  54626. * Time-to-end
  54627. */
  54628. timeout: number;
  54629. /**
  54630. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  54631. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  54632. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  54633. */
  54634. contextObservable: Observable<T>;
  54635. /**
  54636. * Optional parameters when adding an observer to the observable
  54637. */
  54638. observableParameters?: {
  54639. mask?: number;
  54640. insertFirst?: boolean;
  54641. scope?: any;
  54642. };
  54643. /**
  54644. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  54645. */
  54646. breakCondition?: (data?: ITimerData<T>) => boolean;
  54647. /**
  54648. * Will be triggered when the time condition has met
  54649. */
  54650. onEnded?: (data: ITimerData<any>) => void;
  54651. /**
  54652. * Will be triggered when the break condition has met (prematurely ended)
  54653. */
  54654. onAborted?: (data: ITimerData<any>) => void;
  54655. /**
  54656. * Optional function to execute on each tick (or count)
  54657. */
  54658. onTick?: (data: ITimerData<any>) => void;
  54659. }
  54660. /**
  54661. * An interface defining the data sent by the timer
  54662. */
  54663. export interface ITimerData<T> {
  54664. /**
  54665. * When did it start
  54666. */
  54667. startTime: number;
  54668. /**
  54669. * Time now
  54670. */
  54671. currentTime: number;
  54672. /**
  54673. * Time passed since started
  54674. */
  54675. deltaTime: number;
  54676. /**
  54677. * How much is completed, in [0.0...1.0].
  54678. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  54679. */
  54680. completeRate: number;
  54681. /**
  54682. * What the registered observable sent in the last count
  54683. */
  54684. payload: T;
  54685. }
  54686. /**
  54687. * The current state of the timer
  54688. */
  54689. export enum TimerState {
  54690. /**
  54691. * Timer initialized, not yet started
  54692. */
  54693. INIT = 0,
  54694. /**
  54695. * Timer started and counting
  54696. */
  54697. STARTED = 1,
  54698. /**
  54699. * Timer ended (whether aborted or time reached)
  54700. */
  54701. ENDED = 2
  54702. }
  54703. /**
  54704. * A simple version of the timer. Will take options and start the timer immediately after calling it
  54705. *
  54706. * @param options options with which to initialize this timer
  54707. */
  54708. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  54709. /**
  54710. * An advanced implementation of a timer class
  54711. */
  54712. export class AdvancedTimer<T = any> implements IDisposable {
  54713. /**
  54714. * Will notify each time the timer calculates the remaining time
  54715. */
  54716. onEachCountObservable: Observable<ITimerData<T>>;
  54717. /**
  54718. * Will trigger when the timer was aborted due to the break condition
  54719. */
  54720. onTimerAbortedObservable: Observable<ITimerData<T>>;
  54721. /**
  54722. * Will trigger when the timer ended successfully
  54723. */
  54724. onTimerEndedObservable: Observable<ITimerData<T>>;
  54725. /**
  54726. * Will trigger when the timer state has changed
  54727. */
  54728. onStateChangedObservable: Observable<TimerState>;
  54729. private _observer;
  54730. private _contextObservable;
  54731. private _observableParameters;
  54732. private _startTime;
  54733. private _timer;
  54734. private _state;
  54735. private _breakCondition;
  54736. private _timeToEnd;
  54737. private _breakOnNextTick;
  54738. /**
  54739. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  54740. * @param options construction options for this advanced timer
  54741. */
  54742. constructor(options: ITimerOptions<T>);
  54743. /**
  54744. * set a breaking condition for this timer. Default is to never break during count
  54745. * @param predicate the new break condition. Returns true to break, false otherwise
  54746. */
  54747. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  54748. /**
  54749. * Reset ALL associated observables in this advanced timer
  54750. */
  54751. clearObservables(): void;
  54752. /**
  54753. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  54754. *
  54755. * @param timeToEnd how much time to measure until timer ended
  54756. */
  54757. start(timeToEnd?: number): void;
  54758. /**
  54759. * Will force a stop on the next tick.
  54760. */
  54761. stop(): void;
  54762. /**
  54763. * Dispose this timer, clearing all resources
  54764. */
  54765. dispose(): void;
  54766. private _setState;
  54767. private _tick;
  54768. private _stop;
  54769. }
  54770. }
  54771. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  54772. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54773. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54774. import { Nullable } from "babylonjs/types";
  54775. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54777. import { Vector3 } from "babylonjs/Maths/math.vector";
  54778. import { Material } from "babylonjs/Materials/material";
  54779. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54780. import { Scene } from "babylonjs/scene";
  54781. /**
  54782. * The options container for the teleportation module
  54783. */
  54784. export interface IWebXRTeleportationOptions {
  54785. /**
  54786. * if provided, this scene will be used to render meshes.
  54787. */
  54788. customUtilityLayerScene?: Scene;
  54789. /**
  54790. * Values to configure the default target mesh
  54791. */
  54792. defaultTargetMeshOptions?: {
  54793. /**
  54794. * Fill color of the teleportation area
  54795. */
  54796. teleportationFillColor?: string;
  54797. /**
  54798. * Border color for the teleportation area
  54799. */
  54800. teleportationBorderColor?: string;
  54801. /**
  54802. * Disable the mesh's animation sequence
  54803. */
  54804. disableAnimation?: boolean;
  54805. /**
  54806. * Disable lighting on the material or the ring and arrow
  54807. */
  54808. disableLighting?: boolean;
  54809. /**
  54810. * Override the default material of the torus and arrow
  54811. */
  54812. torusArrowMaterial?: Material;
  54813. };
  54814. /**
  54815. * A list of meshes to use as floor meshes.
  54816. * Meshes can be added and removed after initializing the feature using the
  54817. * addFloorMesh and removeFloorMesh functions
  54818. * If empty, rotation will still work
  54819. */
  54820. floorMeshes?: AbstractMesh[];
  54821. /**
  54822. * use this rendering group id for the meshes (optional)
  54823. */
  54824. renderingGroupId?: number;
  54825. /**
  54826. * Should teleportation move only to snap points
  54827. */
  54828. snapPointsOnly?: boolean;
  54829. /**
  54830. * An array of points to which the teleportation will snap to.
  54831. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  54832. */
  54833. snapPositions?: Vector3[];
  54834. /**
  54835. * How close should the teleportation ray be in order to snap to position.
  54836. * Default to 0.8 units (meters)
  54837. */
  54838. snapToPositionRadius?: number;
  54839. /**
  54840. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  54841. * If you want to support rotation, make sure your mesh has a direction indicator.
  54842. *
  54843. * When left untouched, the default mesh will be initialized.
  54844. */
  54845. teleportationTargetMesh?: AbstractMesh;
  54846. /**
  54847. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  54848. */
  54849. timeToTeleport?: number;
  54850. /**
  54851. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  54852. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  54853. */
  54854. useMainComponentOnly?: boolean;
  54855. /**
  54856. * Should meshes created here be added to a utility layer or the main scene
  54857. */
  54858. useUtilityLayer?: boolean;
  54859. /**
  54860. * Babylon XR Input class for controller
  54861. */
  54862. xrInput: WebXRInput;
  54863. /**
  54864. * Meshes that the teleportation ray cannot go through
  54865. */
  54866. pickBlockerMeshes?: AbstractMesh[];
  54867. }
  54868. /**
  54869. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  54870. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  54871. * the input of the attached controllers.
  54872. */
  54873. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  54874. private _options;
  54875. private _controllers;
  54876. private _currentTeleportationControllerId;
  54877. private _floorMeshes;
  54878. private _quadraticBezierCurve;
  54879. private _selectionFeature;
  54880. private _snapToPositions;
  54881. private _snappedToPoint;
  54882. private _teleportationRingMaterial?;
  54883. private _tmpRay;
  54884. private _tmpVector;
  54885. private _tmpQuaternion;
  54886. /**
  54887. * The module's name
  54888. */
  54889. static readonly Name: string;
  54890. /**
  54891. * The (Babylon) version of this module.
  54892. * This is an integer representing the implementation version.
  54893. * This number does not correspond to the webxr specs version
  54894. */
  54895. static readonly Version: number;
  54896. /**
  54897. * Is movement backwards enabled
  54898. */
  54899. backwardsMovementEnabled: boolean;
  54900. /**
  54901. * Distance to travel when moving backwards
  54902. */
  54903. backwardsTeleportationDistance: number;
  54904. /**
  54905. * The distance from the user to the inspection point in the direction of the controller
  54906. * A higher number will allow the user to move further
  54907. * defaults to 5 (meters, in xr units)
  54908. */
  54909. parabolicCheckRadius: number;
  54910. /**
  54911. * Should the module support parabolic ray on top of direct ray
  54912. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  54913. * Very helpful when moving between floors / different heights
  54914. */
  54915. parabolicRayEnabled: boolean;
  54916. /**
  54917. * How much rotation should be applied when rotating right and left
  54918. */
  54919. rotationAngle: number;
  54920. /**
  54921. * Is rotation enabled when moving forward?
  54922. * Disabling this feature will prevent the user from deciding the direction when teleporting
  54923. */
  54924. rotationEnabled: boolean;
  54925. /**
  54926. * constructs a new anchor system
  54927. * @param _xrSessionManager an instance of WebXRSessionManager
  54928. * @param _options configuration object for this feature
  54929. */
  54930. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  54931. /**
  54932. * Get the snapPointsOnly flag
  54933. */
  54934. get snapPointsOnly(): boolean;
  54935. /**
  54936. * Sets the snapPointsOnly flag
  54937. * @param snapToPoints should teleportation be exclusively to snap points
  54938. */
  54939. set snapPointsOnly(snapToPoints: boolean);
  54940. /**
  54941. * Add a new mesh to the floor meshes array
  54942. * @param mesh the mesh to use as floor mesh
  54943. */
  54944. addFloorMesh(mesh: AbstractMesh): void;
  54945. /**
  54946. * Add a new snap-to point to fix teleportation to this position
  54947. * @param newSnapPoint The new Snap-To point
  54948. */
  54949. addSnapPoint(newSnapPoint: Vector3): void;
  54950. attach(): boolean;
  54951. detach(): boolean;
  54952. dispose(): void;
  54953. /**
  54954. * Remove a mesh from the floor meshes array
  54955. * @param mesh the mesh to remove
  54956. */
  54957. removeFloorMesh(mesh: AbstractMesh): void;
  54958. /**
  54959. * Remove a mesh from the floor meshes array using its name
  54960. * @param name the mesh name to remove
  54961. */
  54962. removeFloorMeshByName(name: string): void;
  54963. /**
  54964. * 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
  54965. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  54966. * @returns was the point found and removed or not
  54967. */
  54968. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  54969. /**
  54970. * This function sets a selection feature that will be disabled when
  54971. * the forward ray is shown and will be reattached when hidden.
  54972. * This is used to remove the selection rays when moving.
  54973. * @param selectionFeature the feature to disable when forward movement is enabled
  54974. */
  54975. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  54976. protected _onXRFrame(_xrFrame: XRFrame): void;
  54977. private _attachController;
  54978. private _createDefaultTargetMesh;
  54979. private _detachController;
  54980. private _findClosestSnapPointWithRadius;
  54981. private _setTargetMeshPosition;
  54982. private _setTargetMeshVisibility;
  54983. private _showParabolicPath;
  54984. private _teleportForward;
  54985. }
  54986. }
  54987. declare module "babylonjs/XR/webXRDefaultExperience" {
  54988. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54989. import { Scene } from "babylonjs/scene";
  54990. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  54991. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  54992. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54993. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  54994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54995. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  54996. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  54997. /**
  54998. * Options for the default xr helper
  54999. */
  55000. export class WebXRDefaultExperienceOptions {
  55001. /**
  55002. * Enable or disable default UI to enter XR
  55003. */
  55004. disableDefaultUI?: boolean;
  55005. /**
  55006. * Should teleportation not initialize. defaults to false.
  55007. */
  55008. disableTeleportation?: boolean;
  55009. /**
  55010. * Floor meshes that will be used for teleport
  55011. */
  55012. floorMeshes?: Array<AbstractMesh>;
  55013. /**
  55014. * If set to true, the first frame will not be used to reset position
  55015. * The first frame is mainly used when copying transformation from the old camera
  55016. * Mainly used in AR
  55017. */
  55018. ignoreNativeCameraTransformation?: boolean;
  55019. /**
  55020. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  55021. */
  55022. inputOptions?: IWebXRInputOptions;
  55023. /**
  55024. * optional configuration for the output canvas
  55025. */
  55026. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  55027. /**
  55028. * optional UI options. This can be used among other to change session mode and reference space type
  55029. */
  55030. uiOptions?: WebXREnterExitUIOptions;
  55031. /**
  55032. * When loading teleportation and pointer select, use stable versions instead of latest.
  55033. */
  55034. useStablePlugins?: boolean;
  55035. /**
  55036. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  55037. */
  55038. renderingGroupId?: number;
  55039. /**
  55040. * A list of optional features to init the session with
  55041. * If set to true, all features we support will be added
  55042. */
  55043. optionalFeatures?: boolean | string[];
  55044. }
  55045. /**
  55046. * Default experience which provides a similar setup to the previous webVRExperience
  55047. */
  55048. export class WebXRDefaultExperience {
  55049. /**
  55050. * Base experience
  55051. */
  55052. baseExperience: WebXRExperienceHelper;
  55053. /**
  55054. * Enables ui for entering/exiting xr
  55055. */
  55056. enterExitUI: WebXREnterExitUI;
  55057. /**
  55058. * Input experience extension
  55059. */
  55060. input: WebXRInput;
  55061. /**
  55062. * Enables laser pointer and selection
  55063. */
  55064. pointerSelection: WebXRControllerPointerSelection;
  55065. /**
  55066. * Default target xr should render to
  55067. */
  55068. renderTarget: WebXRRenderTarget;
  55069. /**
  55070. * Enables teleportation
  55071. */
  55072. teleportation: WebXRMotionControllerTeleportation;
  55073. private constructor();
  55074. /**
  55075. * Creates the default xr experience
  55076. * @param scene scene
  55077. * @param options options for basic configuration
  55078. * @returns resulting WebXRDefaultExperience
  55079. */
  55080. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55081. /**
  55082. * DIsposes of the experience helper
  55083. */
  55084. dispose(): void;
  55085. }
  55086. }
  55087. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  55088. import { Observable } from "babylonjs/Misc/observable";
  55089. import { Nullable } from "babylonjs/types";
  55090. import { Camera } from "babylonjs/Cameras/camera";
  55091. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  55092. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55093. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  55094. import { Scene } from "babylonjs/scene";
  55095. import { Vector3 } from "babylonjs/Maths/math.vector";
  55096. import { Color3 } from "babylonjs/Maths/math.color";
  55097. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55099. import { Mesh } from "babylonjs/Meshes/mesh";
  55100. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  55101. import { EasingFunction } from "babylonjs/Animations/easing";
  55102. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55103. import "babylonjs/Meshes/Builders/groundBuilder";
  55104. import "babylonjs/Meshes/Builders/torusBuilder";
  55105. import "babylonjs/Meshes/Builders/cylinderBuilder";
  55106. import "babylonjs/Gamepads/gamepadSceneComponent";
  55107. import "babylonjs/Animations/animatable";
  55108. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  55109. /**
  55110. * Options to modify the vr teleportation behavior.
  55111. */
  55112. export interface VRTeleportationOptions {
  55113. /**
  55114. * The name of the mesh which should be used as the teleportation floor. (default: null)
  55115. */
  55116. floorMeshName?: string;
  55117. /**
  55118. * A list of meshes to be used as the teleportation floor. (default: empty)
  55119. */
  55120. floorMeshes?: Mesh[];
  55121. /**
  55122. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  55123. */
  55124. teleportationMode?: number;
  55125. /**
  55126. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  55127. */
  55128. teleportationTime?: number;
  55129. /**
  55130. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  55131. */
  55132. teleportationSpeed?: number;
  55133. /**
  55134. * The easing function used in the animation or null for Linear. (default CircleEase)
  55135. */
  55136. easingFunction?: EasingFunction;
  55137. }
  55138. /**
  55139. * Options to modify the vr experience helper's behavior.
  55140. */
  55141. export interface VRExperienceHelperOptions extends WebVROptions {
  55142. /**
  55143. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  55144. */
  55145. createDeviceOrientationCamera?: boolean;
  55146. /**
  55147. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  55148. */
  55149. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  55150. /**
  55151. * Uses the main button on the controller to toggle the laser casted. (default: true)
  55152. */
  55153. laserToggle?: boolean;
  55154. /**
  55155. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  55156. */
  55157. floorMeshes?: Mesh[];
  55158. /**
  55159. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  55160. */
  55161. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  55162. /**
  55163. * Defines if WebXR should be used instead of WebVR (if available)
  55164. */
  55165. useXR?: boolean;
  55166. }
  55167. /**
  55168. * Event containing information after VR has been entered
  55169. */
  55170. export class OnAfterEnteringVRObservableEvent {
  55171. /**
  55172. * If entering vr was successful
  55173. */
  55174. success: boolean;
  55175. }
  55176. /**
  55177. * Helps to quickly add VR support to an existing scene.
  55178. * See https://doc.babylonjs.com/how_to/webvr_helper
  55179. */
  55180. export class VRExperienceHelper {
  55181. /** Options to modify the vr experience helper's behavior. */
  55182. webVROptions: VRExperienceHelperOptions;
  55183. private _scene;
  55184. private _position;
  55185. private _btnVR;
  55186. private _btnVRDisplayed;
  55187. private _webVRsupported;
  55188. private _webVRready;
  55189. private _webVRrequesting;
  55190. private _webVRpresenting;
  55191. private _hasEnteredVR;
  55192. private _fullscreenVRpresenting;
  55193. private _inputElement;
  55194. private _webVRCamera;
  55195. private _vrDeviceOrientationCamera;
  55196. private _deviceOrientationCamera;
  55197. private _existingCamera;
  55198. private _onKeyDown;
  55199. private _onVrDisplayPresentChange;
  55200. private _onVRDisplayChanged;
  55201. private _onVRRequestPresentStart;
  55202. private _onVRRequestPresentComplete;
  55203. /**
  55204. * 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)
  55205. */
  55206. enableGazeEvenWhenNoPointerLock: boolean;
  55207. /**
  55208. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  55209. */
  55210. exitVROnDoubleTap: boolean;
  55211. /**
  55212. * Observable raised right before entering VR.
  55213. */
  55214. onEnteringVRObservable: Observable<VRExperienceHelper>;
  55215. /**
  55216. * Observable raised when entering VR has completed.
  55217. */
  55218. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  55219. /**
  55220. * Observable raised when exiting VR.
  55221. */
  55222. onExitingVRObservable: Observable<VRExperienceHelper>;
  55223. /**
  55224. * Observable raised when controller mesh is loaded.
  55225. */
  55226. onControllerMeshLoadedObservable: Observable<WebVRController>;
  55227. /** Return this.onEnteringVRObservable
  55228. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  55229. */
  55230. get onEnteringVR(): Observable<VRExperienceHelper>;
  55231. /** Return this.onExitingVRObservable
  55232. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  55233. */
  55234. get onExitingVR(): Observable<VRExperienceHelper>;
  55235. /** Return this.onControllerMeshLoadedObservable
  55236. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  55237. */
  55238. get onControllerMeshLoaded(): Observable<WebVRController>;
  55239. private _rayLength;
  55240. private _useCustomVRButton;
  55241. private _teleportationRequested;
  55242. private _teleportActive;
  55243. private _floorMeshName;
  55244. private _floorMeshesCollection;
  55245. private _teleportationMode;
  55246. private _teleportationTime;
  55247. private _teleportationSpeed;
  55248. private _teleportationEasing;
  55249. private _rotationAllowed;
  55250. private _teleportBackwardsVector;
  55251. private _teleportationTarget;
  55252. private _isDefaultTeleportationTarget;
  55253. private _postProcessMove;
  55254. private _teleportationFillColor;
  55255. private _teleportationBorderColor;
  55256. private _rotationAngle;
  55257. private _haloCenter;
  55258. private _cameraGazer;
  55259. private _padSensibilityUp;
  55260. private _padSensibilityDown;
  55261. private _leftController;
  55262. private _rightController;
  55263. private _gazeColor;
  55264. private _laserColor;
  55265. private _pickedLaserColor;
  55266. private _pickedGazeColor;
  55267. /**
  55268. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  55269. */
  55270. onNewMeshSelected: Observable<AbstractMesh>;
  55271. /**
  55272. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  55273. * This observable will provide the mesh and the controller used to select the mesh
  55274. */
  55275. onMeshSelectedWithController: Observable<{
  55276. mesh: AbstractMesh;
  55277. controller: WebVRController;
  55278. }>;
  55279. /**
  55280. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  55281. */
  55282. onNewMeshPicked: Observable<PickingInfo>;
  55283. private _circleEase;
  55284. /**
  55285. * Observable raised before camera teleportation
  55286. */
  55287. onBeforeCameraTeleport: Observable<Vector3>;
  55288. /**
  55289. * Observable raised after camera teleportation
  55290. */
  55291. onAfterCameraTeleport: Observable<Vector3>;
  55292. /**
  55293. * Observable raised when current selected mesh gets unselected
  55294. */
  55295. onSelectedMeshUnselected: Observable<AbstractMesh>;
  55296. private _raySelectionPredicate;
  55297. /**
  55298. * To be optionaly changed by user to define custom ray selection
  55299. */
  55300. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55301. /**
  55302. * To be optionaly changed by user to define custom selection logic (after ray selection)
  55303. */
  55304. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55305. /**
  55306. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  55307. */
  55308. teleportationEnabled: boolean;
  55309. private _defaultHeight;
  55310. private _teleportationInitialized;
  55311. private _interactionsEnabled;
  55312. private _interactionsRequested;
  55313. private _displayGaze;
  55314. private _displayLaserPointer;
  55315. /**
  55316. * The mesh used to display where the user is going to teleport.
  55317. */
  55318. get teleportationTarget(): Mesh;
  55319. /**
  55320. * Sets the mesh to be used to display where the user is going to teleport.
  55321. */
  55322. set teleportationTarget(value: Mesh);
  55323. /**
  55324. * 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
  55325. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  55326. * See https://doc.babylonjs.com/resources/baking_transformations
  55327. */
  55328. get gazeTrackerMesh(): Mesh;
  55329. set gazeTrackerMesh(value: Mesh);
  55330. /**
  55331. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  55332. */
  55333. updateGazeTrackerScale: boolean;
  55334. /**
  55335. * If the gaze trackers color should be updated when selecting meshes
  55336. */
  55337. updateGazeTrackerColor: boolean;
  55338. /**
  55339. * If the controller laser color should be updated when selecting meshes
  55340. */
  55341. updateControllerLaserColor: boolean;
  55342. /**
  55343. * The gaze tracking mesh corresponding to the left controller
  55344. */
  55345. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  55346. /**
  55347. * The gaze tracking mesh corresponding to the right controller
  55348. */
  55349. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  55350. /**
  55351. * If the ray of the gaze should be displayed.
  55352. */
  55353. get displayGaze(): boolean;
  55354. /**
  55355. * Sets if the ray of the gaze should be displayed.
  55356. */
  55357. set displayGaze(value: boolean);
  55358. /**
  55359. * If the ray of the LaserPointer should be displayed.
  55360. */
  55361. get displayLaserPointer(): boolean;
  55362. /**
  55363. * Sets if the ray of the LaserPointer should be displayed.
  55364. */
  55365. set displayLaserPointer(value: boolean);
  55366. /**
  55367. * The deviceOrientationCamera used as the camera when not in VR.
  55368. */
  55369. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  55370. /**
  55371. * Based on the current WebVR support, returns the current VR camera used.
  55372. */
  55373. get currentVRCamera(): Nullable<Camera>;
  55374. /**
  55375. * The webVRCamera which is used when in VR.
  55376. */
  55377. get webVRCamera(): WebVRFreeCamera;
  55378. /**
  55379. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  55380. */
  55381. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  55382. /**
  55383. * The html button that is used to trigger entering into VR.
  55384. */
  55385. get vrButton(): Nullable<HTMLButtonElement>;
  55386. private get _teleportationRequestInitiated();
  55387. /**
  55388. * Defines whether or not Pointer lock should be requested when switching to
  55389. * full screen.
  55390. */
  55391. requestPointerLockOnFullScreen: boolean;
  55392. /**
  55393. * If asking to force XR, this will be populated with the default xr experience
  55394. */
  55395. xr: WebXRDefaultExperience;
  55396. /**
  55397. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  55398. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  55399. */
  55400. xrTestDone: boolean;
  55401. /**
  55402. * Instantiates a VRExperienceHelper.
  55403. * Helps to quickly add VR support to an existing scene.
  55404. * @param scene The scene the VRExperienceHelper belongs to.
  55405. * @param webVROptions Options to modify the vr experience helper's behavior.
  55406. */
  55407. constructor(scene: Scene,
  55408. /** Options to modify the vr experience helper's behavior. */
  55409. webVROptions?: VRExperienceHelperOptions);
  55410. private completeVRInit;
  55411. private _onDefaultMeshLoaded;
  55412. private _onResize;
  55413. private _onFullscreenChange;
  55414. /**
  55415. * Gets a value indicating if we are currently in VR mode.
  55416. */
  55417. get isInVRMode(): boolean;
  55418. private onVrDisplayPresentChange;
  55419. private onVRDisplayChanged;
  55420. private moveButtonToBottomRight;
  55421. private displayVRButton;
  55422. private updateButtonVisibility;
  55423. private _cachedAngularSensibility;
  55424. /**
  55425. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55426. * Otherwise, will use the fullscreen API.
  55427. */
  55428. enterVR(): void;
  55429. /**
  55430. * Attempt to exit VR, or fullscreen.
  55431. */
  55432. exitVR(): void;
  55433. /**
  55434. * The position of the vr experience helper.
  55435. */
  55436. get position(): Vector3;
  55437. /**
  55438. * Sets the position of the vr experience helper.
  55439. */
  55440. set position(value: Vector3);
  55441. /**
  55442. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55443. */
  55444. enableInteractions(): void;
  55445. private get _noControllerIsActive();
  55446. private beforeRender;
  55447. private _isTeleportationFloor;
  55448. /**
  55449. * Adds a floor mesh to be used for teleportation.
  55450. * @param floorMesh the mesh to be used for teleportation.
  55451. */
  55452. addFloorMesh(floorMesh: Mesh): void;
  55453. /**
  55454. * Removes a floor mesh from being used for teleportation.
  55455. * @param floorMesh the mesh to be removed.
  55456. */
  55457. removeFloorMesh(floorMesh: Mesh): void;
  55458. /**
  55459. * Enables interactions and teleportation using the VR controllers and gaze.
  55460. * @param vrTeleportationOptions options to modify teleportation behavior.
  55461. */
  55462. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55463. private _onNewGamepadConnected;
  55464. private _tryEnableInteractionOnController;
  55465. private _onNewGamepadDisconnected;
  55466. private _enableInteractionOnController;
  55467. private _checkTeleportWithRay;
  55468. private _checkRotate;
  55469. private _checkTeleportBackwards;
  55470. private _enableTeleportationOnController;
  55471. private _createTeleportationCircles;
  55472. private _displayTeleportationTarget;
  55473. private _hideTeleportationTarget;
  55474. private _rotateCamera;
  55475. private _moveTeleportationSelectorTo;
  55476. private _workingVector;
  55477. private _workingQuaternion;
  55478. private _workingMatrix;
  55479. /**
  55480. * Time Constant Teleportation Mode
  55481. */
  55482. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55483. /**
  55484. * Speed Constant Teleportation Mode
  55485. */
  55486. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55487. /**
  55488. * Teleports the users feet to the desired location
  55489. * @param location The location where the user's feet should be placed
  55490. */
  55491. teleportCamera(location: Vector3): void;
  55492. private _convertNormalToDirectionOfRay;
  55493. private _castRayAndSelectObject;
  55494. private _notifySelectedMeshUnselected;
  55495. /**
  55496. * Permanently set new colors for the laser pointer
  55497. * @param color the new laser color
  55498. * @param pickedColor the new laser color when picked mesh detected
  55499. */
  55500. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55501. /**
  55502. * Set lighting enabled / disabled on the laser pointer of both controllers
  55503. * @param enabled should the lighting be enabled on the laser pointer
  55504. */
  55505. setLaserLightingState(enabled?: boolean): void;
  55506. /**
  55507. * Permanently set new colors for the gaze pointer
  55508. * @param color the new gaze color
  55509. * @param pickedColor the new gaze color when picked mesh detected
  55510. */
  55511. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55512. /**
  55513. * Sets the color of the laser ray from the vr controllers.
  55514. * @param color new color for the ray.
  55515. */
  55516. changeLaserColor(color: Color3): void;
  55517. /**
  55518. * Sets the color of the ray from the vr headsets gaze.
  55519. * @param color new color for the ray.
  55520. */
  55521. changeGazeColor(color: Color3): void;
  55522. /**
  55523. * Exits VR and disposes of the vr experience helper
  55524. */
  55525. dispose(): void;
  55526. /**
  55527. * Gets the name of the VRExperienceHelper class
  55528. * @returns "VRExperienceHelper"
  55529. */
  55530. getClassName(): string;
  55531. }
  55532. }
  55533. declare module "babylonjs/Cameras/VR/index" {
  55534. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55535. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55536. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55537. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55538. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55539. export * from "babylonjs/Cameras/VR/webVRCamera";
  55540. }
  55541. declare module "babylonjs/Cameras/RigModes/index" {
  55542. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55543. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55544. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55545. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55546. }
  55547. declare module "babylonjs/Cameras/index" {
  55548. export * from "babylonjs/Cameras/Inputs/index";
  55549. export * from "babylonjs/Cameras/cameraInputsManager";
  55550. export * from "babylonjs/Cameras/camera";
  55551. export * from "babylonjs/Cameras/targetCamera";
  55552. export * from "babylonjs/Cameras/freeCamera";
  55553. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55554. export * from "babylonjs/Cameras/touchCamera";
  55555. export * from "babylonjs/Cameras/arcRotateCamera";
  55556. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55557. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55558. export * from "babylonjs/Cameras/flyCamera";
  55559. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55560. export * from "babylonjs/Cameras/followCamera";
  55561. export * from "babylonjs/Cameras/followCameraInputsManager";
  55562. export * from "babylonjs/Cameras/gamepadCamera";
  55563. export * from "babylonjs/Cameras/Stereoscopic/index";
  55564. export * from "babylonjs/Cameras/universalCamera";
  55565. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55566. export * from "babylonjs/Cameras/VR/index";
  55567. export * from "babylonjs/Cameras/RigModes/index";
  55568. }
  55569. declare module "babylonjs/Collisions/index" {
  55570. export * from "babylonjs/Collisions/collider";
  55571. export * from "babylonjs/Collisions/collisionCoordinator";
  55572. export * from "babylonjs/Collisions/pickingInfo";
  55573. export * from "babylonjs/Collisions/intersectionInfo";
  55574. export * from "babylonjs/Collisions/meshCollisionData";
  55575. }
  55576. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55577. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55578. import { Vector3 } from "babylonjs/Maths/math.vector";
  55579. import { Ray } from "babylonjs/Culling/ray";
  55580. import { Plane } from "babylonjs/Maths/math.plane";
  55581. /**
  55582. * Contains an array of blocks representing the octree
  55583. */
  55584. export interface IOctreeContainer<T> {
  55585. /**
  55586. * Blocks within the octree
  55587. */
  55588. blocks: Array<OctreeBlock<T>>;
  55589. }
  55590. /**
  55591. * Class used to store a cell in an octree
  55592. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55593. */
  55594. export class OctreeBlock<T> {
  55595. /**
  55596. * Gets the content of the current block
  55597. */
  55598. entries: T[];
  55599. /**
  55600. * Gets the list of block children
  55601. */
  55602. blocks: Array<OctreeBlock<T>>;
  55603. private _depth;
  55604. private _maxDepth;
  55605. private _capacity;
  55606. private _minPoint;
  55607. private _maxPoint;
  55608. private _boundingVectors;
  55609. private _creationFunc;
  55610. /**
  55611. * Creates a new block
  55612. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  55613. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  55614. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55615. * @param depth defines the current depth of this block in the octree
  55616. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  55617. * @param creationFunc defines a callback to call when an element is added to the block
  55618. */
  55619. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  55620. /**
  55621. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55622. */
  55623. get capacity(): number;
  55624. /**
  55625. * Gets the minimum vector (in world space) of the block's bounding box
  55626. */
  55627. get minPoint(): Vector3;
  55628. /**
  55629. * Gets the maximum vector (in world space) of the block's bounding box
  55630. */
  55631. get maxPoint(): Vector3;
  55632. /**
  55633. * Add a new element to this block
  55634. * @param entry defines the element to add
  55635. */
  55636. addEntry(entry: T): void;
  55637. /**
  55638. * Remove an element from this block
  55639. * @param entry defines the element to remove
  55640. */
  55641. removeEntry(entry: T): void;
  55642. /**
  55643. * Add an array of elements to this block
  55644. * @param entries defines the array of elements to add
  55645. */
  55646. addEntries(entries: T[]): void;
  55647. /**
  55648. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  55649. * @param frustumPlanes defines the frustum planes to test
  55650. * @param selection defines the array to store current content if selection is positive
  55651. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55652. */
  55653. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55654. /**
  55655. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  55656. * @param sphereCenter defines the bounding sphere center
  55657. * @param sphereRadius defines the bounding sphere radius
  55658. * @param selection defines the array to store current content if selection is positive
  55659. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55660. */
  55661. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55662. /**
  55663. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  55664. * @param ray defines the ray to test with
  55665. * @param selection defines the array to store current content if selection is positive
  55666. */
  55667. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  55668. /**
  55669. * Subdivide the content into child blocks (this block will then be empty)
  55670. */
  55671. createInnerBlocks(): void;
  55672. /**
  55673. * @hidden
  55674. */
  55675. 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;
  55676. }
  55677. }
  55678. declare module "babylonjs/Culling/Octrees/octree" {
  55679. import { SmartArray } from "babylonjs/Misc/smartArray";
  55680. import { Vector3 } from "babylonjs/Maths/math.vector";
  55681. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55683. import { Ray } from "babylonjs/Culling/ray";
  55684. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  55685. import { Plane } from "babylonjs/Maths/math.plane";
  55686. /**
  55687. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  55688. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55689. */
  55690. export class Octree<T> {
  55691. /** 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.) */
  55692. maxDepth: number;
  55693. /**
  55694. * Blocks within the octree containing objects
  55695. */
  55696. blocks: Array<OctreeBlock<T>>;
  55697. /**
  55698. * Content stored in the octree
  55699. */
  55700. dynamicContent: T[];
  55701. private _maxBlockCapacity;
  55702. private _selectionContent;
  55703. private _creationFunc;
  55704. /**
  55705. * Creates a octree
  55706. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55707. * @param creationFunc function to be used to instatiate the octree
  55708. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  55709. * @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.)
  55710. */
  55711. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  55712. /** 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.) */
  55713. maxDepth?: number);
  55714. /**
  55715. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  55716. * @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);
  55717. * @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);
  55718. * @param entries meshes to be added to the octree blocks
  55719. */
  55720. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  55721. /**
  55722. * Adds a mesh to the octree
  55723. * @param entry Mesh to add to the octree
  55724. */
  55725. addMesh(entry: T): void;
  55726. /**
  55727. * Remove an element from the octree
  55728. * @param entry defines the element to remove
  55729. */
  55730. removeMesh(entry: T): void;
  55731. /**
  55732. * Selects an array of meshes within the frustum
  55733. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  55734. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  55735. * @returns array of meshes within the frustum
  55736. */
  55737. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  55738. /**
  55739. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  55740. * @param sphereCenter defines the bounding sphere center
  55741. * @param sphereRadius defines the bounding sphere radius
  55742. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55743. * @returns an array of objects that intersect the sphere
  55744. */
  55745. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  55746. /**
  55747. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  55748. * @param ray defines the ray to test with
  55749. * @returns array of intersected objects
  55750. */
  55751. intersectsRay(ray: Ray): SmartArray<T>;
  55752. /**
  55753. * Adds a mesh into the octree block if it intersects the block
  55754. */
  55755. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  55756. /**
  55757. * Adds a submesh into the octree block if it intersects the block
  55758. */
  55759. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  55760. }
  55761. }
  55762. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  55763. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  55764. import { Scene } from "babylonjs/scene";
  55765. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55767. import { Ray } from "babylonjs/Culling/ray";
  55768. import { Octree } from "babylonjs/Culling/Octrees/octree";
  55769. import { Collider } from "babylonjs/Collisions/collider";
  55770. module "babylonjs/scene" {
  55771. interface Scene {
  55772. /**
  55773. * @hidden
  55774. * Backing Filed
  55775. */
  55776. _selectionOctree: Octree<AbstractMesh>;
  55777. /**
  55778. * Gets the octree used to boost mesh selection (picking)
  55779. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55780. */
  55781. selectionOctree: Octree<AbstractMesh>;
  55782. /**
  55783. * Creates or updates the octree used to boost selection (picking)
  55784. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55785. * @param maxCapacity defines the maximum capacity per leaf
  55786. * @param maxDepth defines the maximum depth of the octree
  55787. * @returns an octree of AbstractMesh
  55788. */
  55789. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  55790. }
  55791. }
  55792. module "babylonjs/Meshes/abstractMesh" {
  55793. interface AbstractMesh {
  55794. /**
  55795. * @hidden
  55796. * Backing Field
  55797. */
  55798. _submeshesOctree: Octree<SubMesh>;
  55799. /**
  55800. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  55801. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  55802. * @param maxCapacity defines the maximum size of each block (64 by default)
  55803. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  55804. * @returns the new octree
  55805. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  55806. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55807. */
  55808. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  55809. }
  55810. }
  55811. /**
  55812. * Defines the octree scene component responsible to manage any octrees
  55813. * in a given scene.
  55814. */
  55815. export class OctreeSceneComponent {
  55816. /**
  55817. * The component name help to identify the component in the list of scene components.
  55818. */
  55819. readonly name: string;
  55820. /**
  55821. * The scene the component belongs to.
  55822. */
  55823. scene: Scene;
  55824. /**
  55825. * Indicates if the meshes have been checked to make sure they are isEnabled()
  55826. */
  55827. readonly checksIsEnabled: boolean;
  55828. /**
  55829. * Creates a new instance of the component for the given scene
  55830. * @param scene Defines the scene to register the component in
  55831. */
  55832. constructor(scene: Scene);
  55833. /**
  55834. * Registers the component in a given scene
  55835. */
  55836. register(): void;
  55837. /**
  55838. * Return the list of active meshes
  55839. * @returns the list of active meshes
  55840. */
  55841. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  55842. /**
  55843. * Return the list of active sub meshes
  55844. * @param mesh The mesh to get the candidates sub meshes from
  55845. * @returns the list of active sub meshes
  55846. */
  55847. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  55848. private _tempRay;
  55849. /**
  55850. * Return the list of sub meshes intersecting with a given local ray
  55851. * @param mesh defines the mesh to find the submesh for
  55852. * @param localRay defines the ray in local space
  55853. * @returns the list of intersecting sub meshes
  55854. */
  55855. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  55856. /**
  55857. * Return the list of sub meshes colliding with a collider
  55858. * @param mesh defines the mesh to find the submesh for
  55859. * @param collider defines the collider to evaluate the collision against
  55860. * @returns the list of colliding sub meshes
  55861. */
  55862. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  55863. /**
  55864. * Rebuilds the elements related to this component in case of
  55865. * context lost for instance.
  55866. */
  55867. rebuild(): void;
  55868. /**
  55869. * Disposes the component and the associated ressources.
  55870. */
  55871. dispose(): void;
  55872. }
  55873. }
  55874. declare module "babylonjs/Culling/Octrees/index" {
  55875. export * from "babylonjs/Culling/Octrees/octree";
  55876. export * from "babylonjs/Culling/Octrees/octreeBlock";
  55877. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  55878. }
  55879. declare module "babylonjs/Culling/index" {
  55880. export * from "babylonjs/Culling/boundingBox";
  55881. export * from "babylonjs/Culling/boundingInfo";
  55882. export * from "babylonjs/Culling/boundingSphere";
  55883. export * from "babylonjs/Culling/Octrees/index";
  55884. export * from "babylonjs/Culling/ray";
  55885. }
  55886. declare module "babylonjs/Gizmos/gizmo" {
  55887. import { Nullable } from "babylonjs/types";
  55888. import { IDisposable } from "babylonjs/scene";
  55889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55890. import { Mesh } from "babylonjs/Meshes/mesh";
  55891. import { Node } from "babylonjs/node";
  55892. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55893. /**
  55894. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  55895. */
  55896. export class Gizmo implements IDisposable {
  55897. /** The utility layer the gizmo will be added to */
  55898. gizmoLayer: UtilityLayerRenderer;
  55899. /**
  55900. * The root mesh of the gizmo
  55901. */
  55902. _rootMesh: Mesh;
  55903. private _attachedMesh;
  55904. private _attachedNode;
  55905. /**
  55906. * Ratio for the scale of the gizmo (Default: 1)
  55907. */
  55908. protected _scaleRatio: number;
  55909. /**
  55910. * boolean updated by pointermove when a gizmo mesh is hovered
  55911. */
  55912. protected _isHovered: boolean;
  55913. /**
  55914. * Ratio for the scale of the gizmo (Default: 1)
  55915. */
  55916. set scaleRatio(value: number);
  55917. get scaleRatio(): number;
  55918. /**
  55919. * True when the mouse pointer is hovered a gizmo mesh
  55920. */
  55921. get isHovered(): boolean;
  55922. /**
  55923. * If a custom mesh has been set (Default: false)
  55924. */
  55925. protected _customMeshSet: boolean;
  55926. /**
  55927. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  55928. * * When set, interactions will be enabled
  55929. */
  55930. get attachedMesh(): Nullable<AbstractMesh>;
  55931. set attachedMesh(value: Nullable<AbstractMesh>);
  55932. /**
  55933. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  55934. * * When set, interactions will be enabled
  55935. */
  55936. get attachedNode(): Nullable<Node>;
  55937. set attachedNode(value: Nullable<Node>);
  55938. /**
  55939. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55940. * @param mesh The mesh to replace the default mesh of the gizmo
  55941. */
  55942. setCustomMesh(mesh: Mesh): void;
  55943. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  55944. /**
  55945. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  55946. */
  55947. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55948. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55949. /**
  55950. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  55951. */
  55952. updateGizmoPositionToMatchAttachedMesh: boolean;
  55953. /**
  55954. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  55955. */
  55956. updateScale: boolean;
  55957. protected _interactionsEnabled: boolean;
  55958. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55959. private _beforeRenderObserver;
  55960. private _tempQuaternion;
  55961. private _tempVector;
  55962. private _tempVector2;
  55963. private _tempMatrix1;
  55964. private _tempMatrix2;
  55965. private _rightHandtoLeftHandMatrix;
  55966. /**
  55967. * Creates a gizmo
  55968. * @param gizmoLayer The utility layer the gizmo will be added to
  55969. */
  55970. constructor(
  55971. /** The utility layer the gizmo will be added to */
  55972. gizmoLayer?: UtilityLayerRenderer);
  55973. /**
  55974. * Updates the gizmo to match the attached mesh's position/rotation
  55975. */
  55976. protected _update(): void;
  55977. /**
  55978. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  55979. * @param value Node, TransformNode or mesh
  55980. */
  55981. protected _matrixChanged(): void;
  55982. /**
  55983. * Disposes of the gizmo
  55984. */
  55985. dispose(): void;
  55986. }
  55987. }
  55988. declare module "babylonjs/Gizmos/planeDragGizmo" {
  55989. import { Observable } from "babylonjs/Misc/observable";
  55990. import { Nullable } from "babylonjs/types";
  55991. import { Vector3 } from "babylonjs/Maths/math.vector";
  55992. import { Color3 } from "babylonjs/Maths/math.color";
  55993. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55994. import { Node } from "babylonjs/node";
  55995. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55996. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55997. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55998. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55999. import { Scene } from "babylonjs/scene";
  56000. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56001. /**
  56002. * Single plane drag gizmo
  56003. */
  56004. export class PlaneDragGizmo extends Gizmo {
  56005. /**
  56006. * Drag behavior responsible for the gizmos dragging interactions
  56007. */
  56008. dragBehavior: PointerDragBehavior;
  56009. private _pointerObserver;
  56010. /**
  56011. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56012. */
  56013. snapDistance: number;
  56014. /**
  56015. * Event that fires each time the gizmo snaps to a new location.
  56016. * * snapDistance is the the change in distance
  56017. */
  56018. onSnapObservable: Observable<{
  56019. snapDistance: number;
  56020. }>;
  56021. private _plane;
  56022. private _coloredMaterial;
  56023. private _hoverMaterial;
  56024. private _isEnabled;
  56025. private _parent;
  56026. /** @hidden */
  56027. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  56028. /** @hidden */
  56029. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  56030. /**
  56031. * Creates a PlaneDragGizmo
  56032. * @param gizmoLayer The utility layer the gizmo will be added to
  56033. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  56034. * @param color The color of the gizmo
  56035. */
  56036. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  56037. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56038. /**
  56039. * If the gizmo is enabled
  56040. */
  56041. set isEnabled(value: boolean);
  56042. get isEnabled(): boolean;
  56043. /**
  56044. * Disposes of the gizmo
  56045. */
  56046. dispose(): void;
  56047. }
  56048. }
  56049. declare module "babylonjs/Gizmos/positionGizmo" {
  56050. import { Observable } from "babylonjs/Misc/observable";
  56051. import { Nullable } from "babylonjs/types";
  56052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56053. import { Node } from "babylonjs/node";
  56054. import { Mesh } from "babylonjs/Meshes/mesh";
  56055. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56056. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  56057. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  56058. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56059. /**
  56060. * Gizmo that enables dragging a mesh along 3 axis
  56061. */
  56062. export class PositionGizmo extends Gizmo {
  56063. /**
  56064. * Internal gizmo used for interactions on the x axis
  56065. */
  56066. xGizmo: AxisDragGizmo;
  56067. /**
  56068. * Internal gizmo used for interactions on the y axis
  56069. */
  56070. yGizmo: AxisDragGizmo;
  56071. /**
  56072. * Internal gizmo used for interactions on the z axis
  56073. */
  56074. zGizmo: AxisDragGizmo;
  56075. /**
  56076. * Internal gizmo used for interactions on the yz plane
  56077. */
  56078. xPlaneGizmo: PlaneDragGizmo;
  56079. /**
  56080. * Internal gizmo used for interactions on the xz plane
  56081. */
  56082. yPlaneGizmo: PlaneDragGizmo;
  56083. /**
  56084. * Internal gizmo used for interactions on the xy plane
  56085. */
  56086. zPlaneGizmo: PlaneDragGizmo;
  56087. /**
  56088. * private variables
  56089. */
  56090. private _meshAttached;
  56091. private _nodeAttached;
  56092. private _snapDistance;
  56093. /** Fires an event when any of it's sub gizmos are dragged */
  56094. onDragStartObservable: Observable<unknown>;
  56095. /** Fires an event when any of it's sub gizmos are released from dragging */
  56096. onDragEndObservable: Observable<unknown>;
  56097. /**
  56098. * If set to true, planar drag is enabled
  56099. */
  56100. private _planarGizmoEnabled;
  56101. get attachedMesh(): Nullable<AbstractMesh>;
  56102. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56103. get attachedNode(): Nullable<Node>;
  56104. set attachedNode(node: Nullable<Node>);
  56105. /**
  56106. * True when the mouse pointer is hovering a gizmo mesh
  56107. */
  56108. get isHovered(): boolean;
  56109. /**
  56110. * Creates a PositionGizmo
  56111. * @param gizmoLayer The utility layer the gizmo will be added to
  56112. @param thickness display gizmo axis thickness
  56113. */
  56114. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56115. /**
  56116. * If the planar drag gizmo is enabled
  56117. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  56118. */
  56119. set planarGizmoEnabled(value: boolean);
  56120. get planarGizmoEnabled(): boolean;
  56121. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56122. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56123. /**
  56124. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56125. */
  56126. set snapDistance(value: number);
  56127. get snapDistance(): number;
  56128. /**
  56129. * Ratio for the scale of the gizmo (Default: 1)
  56130. */
  56131. set scaleRatio(value: number);
  56132. get scaleRatio(): number;
  56133. /**
  56134. * Disposes of the gizmo
  56135. */
  56136. dispose(): void;
  56137. /**
  56138. * CustomMeshes are not supported by this gizmo
  56139. * @param mesh The mesh to replace the default mesh of the gizmo
  56140. */
  56141. setCustomMesh(mesh: Mesh): void;
  56142. }
  56143. }
  56144. declare module "babylonjs/Gizmos/axisDragGizmo" {
  56145. import { Observable } from "babylonjs/Misc/observable";
  56146. import { Nullable } from "babylonjs/types";
  56147. import { Vector3 } from "babylonjs/Maths/math.vector";
  56148. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56149. import { Node } from "babylonjs/node";
  56150. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56151. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56152. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56153. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56154. import { Scene } from "babylonjs/scene";
  56155. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56156. import { Color3 } from "babylonjs/Maths/math.color";
  56157. /**
  56158. * Single axis drag gizmo
  56159. */
  56160. export class AxisDragGizmo extends Gizmo {
  56161. /**
  56162. * Drag behavior responsible for the gizmos dragging interactions
  56163. */
  56164. dragBehavior: PointerDragBehavior;
  56165. private _pointerObserver;
  56166. /**
  56167. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56168. */
  56169. snapDistance: number;
  56170. /**
  56171. * Event that fires each time the gizmo snaps to a new location.
  56172. * * snapDistance is the the change in distance
  56173. */
  56174. onSnapObservable: Observable<{
  56175. snapDistance: number;
  56176. }>;
  56177. private _isEnabled;
  56178. private _parent;
  56179. private _arrow;
  56180. private _coloredMaterial;
  56181. private _hoverMaterial;
  56182. /** @hidden */
  56183. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  56184. /** @hidden */
  56185. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  56186. /**
  56187. * Creates an AxisDragGizmo
  56188. * @param gizmoLayer The utility layer the gizmo will be added to
  56189. * @param dragAxis The axis which the gizmo will be able to drag on
  56190. * @param color The color of the gizmo
  56191. * @param thickness display gizmo axis thickness
  56192. */
  56193. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  56194. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56195. /**
  56196. * If the gizmo is enabled
  56197. */
  56198. set isEnabled(value: boolean);
  56199. get isEnabled(): boolean;
  56200. /**
  56201. * Disposes of the gizmo
  56202. */
  56203. dispose(): void;
  56204. }
  56205. }
  56206. declare module "babylonjs/Debug/axesViewer" {
  56207. import { Vector3 } from "babylonjs/Maths/math.vector";
  56208. import { Nullable } from "babylonjs/types";
  56209. import { Scene } from "babylonjs/scene";
  56210. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56211. /**
  56212. * The Axes viewer will show 3 axes in a specific point in space
  56213. */
  56214. export class AxesViewer {
  56215. private _xAxis;
  56216. private _yAxis;
  56217. private _zAxis;
  56218. private _scaleLinesFactor;
  56219. private _instanced;
  56220. /**
  56221. * Gets the hosting scene
  56222. */
  56223. scene: Nullable<Scene>;
  56224. /**
  56225. * Gets or sets a number used to scale line length
  56226. */
  56227. scaleLines: number;
  56228. /** Gets the node hierarchy used to render x-axis */
  56229. get xAxis(): TransformNode;
  56230. /** Gets the node hierarchy used to render y-axis */
  56231. get yAxis(): TransformNode;
  56232. /** Gets the node hierarchy used to render z-axis */
  56233. get zAxis(): TransformNode;
  56234. /**
  56235. * Creates a new AxesViewer
  56236. * @param scene defines the hosting scene
  56237. * @param scaleLines defines a number used to scale line length (1 by default)
  56238. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  56239. * @param xAxis defines the node hierarchy used to render the x-axis
  56240. * @param yAxis defines the node hierarchy used to render the y-axis
  56241. * @param zAxis defines the node hierarchy used to render the z-axis
  56242. */
  56243. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  56244. /**
  56245. * Force the viewer to update
  56246. * @param position defines the position of the viewer
  56247. * @param xaxis defines the x axis of the viewer
  56248. * @param yaxis defines the y axis of the viewer
  56249. * @param zaxis defines the z axis of the viewer
  56250. */
  56251. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  56252. /**
  56253. * Creates an instance of this axes viewer.
  56254. * @returns a new axes viewer with instanced meshes
  56255. */
  56256. createInstance(): AxesViewer;
  56257. /** Releases resources */
  56258. dispose(): void;
  56259. private static _SetRenderingGroupId;
  56260. }
  56261. }
  56262. declare module "babylonjs/Debug/boneAxesViewer" {
  56263. import { Nullable } from "babylonjs/types";
  56264. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  56265. import { Vector3 } from "babylonjs/Maths/math.vector";
  56266. import { Mesh } from "babylonjs/Meshes/mesh";
  56267. import { Bone } from "babylonjs/Bones/bone";
  56268. import { Scene } from "babylonjs/scene";
  56269. /**
  56270. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  56271. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  56272. */
  56273. export class BoneAxesViewer extends AxesViewer {
  56274. /**
  56275. * Gets or sets the target mesh where to display the axes viewer
  56276. */
  56277. mesh: Nullable<Mesh>;
  56278. /**
  56279. * Gets or sets the target bone where to display the axes viewer
  56280. */
  56281. bone: Nullable<Bone>;
  56282. /** Gets current position */
  56283. pos: Vector3;
  56284. /** Gets direction of X axis */
  56285. xaxis: Vector3;
  56286. /** Gets direction of Y axis */
  56287. yaxis: Vector3;
  56288. /** Gets direction of Z axis */
  56289. zaxis: Vector3;
  56290. /**
  56291. * Creates a new BoneAxesViewer
  56292. * @param scene defines the hosting scene
  56293. * @param bone defines the target bone
  56294. * @param mesh defines the target mesh
  56295. * @param scaleLines defines a scaling factor for line length (1 by default)
  56296. */
  56297. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  56298. /**
  56299. * Force the viewer to update
  56300. */
  56301. update(): void;
  56302. /** Releases resources */
  56303. dispose(): void;
  56304. }
  56305. }
  56306. declare module "babylonjs/Debug/debugLayer" {
  56307. import { Scene } from "babylonjs/scene";
  56308. /**
  56309. * Interface used to define scene explorer extensibility option
  56310. */
  56311. export interface IExplorerExtensibilityOption {
  56312. /**
  56313. * Define the option label
  56314. */
  56315. label: string;
  56316. /**
  56317. * Defines the action to execute on click
  56318. */
  56319. action: (entity: any) => void;
  56320. }
  56321. /**
  56322. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  56323. */
  56324. export interface IExplorerExtensibilityGroup {
  56325. /**
  56326. * Defines a predicate to test if a given type mut be extended
  56327. */
  56328. predicate: (entity: any) => boolean;
  56329. /**
  56330. * Gets the list of options added to a type
  56331. */
  56332. entries: IExplorerExtensibilityOption[];
  56333. }
  56334. /**
  56335. * Interface used to define the options to use to create the Inspector
  56336. */
  56337. export interface IInspectorOptions {
  56338. /**
  56339. * Display in overlay mode (default: false)
  56340. */
  56341. overlay?: boolean;
  56342. /**
  56343. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  56344. */
  56345. globalRoot?: HTMLElement;
  56346. /**
  56347. * Display the Scene explorer
  56348. */
  56349. showExplorer?: boolean;
  56350. /**
  56351. * Display the property inspector
  56352. */
  56353. showInspector?: boolean;
  56354. /**
  56355. * Display in embed mode (both panes on the right)
  56356. */
  56357. embedMode?: boolean;
  56358. /**
  56359. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  56360. */
  56361. handleResize?: boolean;
  56362. /**
  56363. * Allow the panes to popup (default: true)
  56364. */
  56365. enablePopup?: boolean;
  56366. /**
  56367. * Allow the panes to be closed by users (default: true)
  56368. */
  56369. enableClose?: boolean;
  56370. /**
  56371. * Optional list of extensibility entries
  56372. */
  56373. explorerExtensibility?: IExplorerExtensibilityGroup[];
  56374. /**
  56375. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  56376. */
  56377. inspectorURL?: string;
  56378. /**
  56379. * Optional initial tab (default to DebugLayerTab.Properties)
  56380. */
  56381. initialTab?: DebugLayerTab;
  56382. }
  56383. module "babylonjs/scene" {
  56384. interface Scene {
  56385. /**
  56386. * @hidden
  56387. * Backing field
  56388. */
  56389. _debugLayer: DebugLayer;
  56390. /**
  56391. * Gets the debug layer (aka Inspector) associated with the scene
  56392. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56393. */
  56394. debugLayer: DebugLayer;
  56395. }
  56396. }
  56397. /**
  56398. * Enum of inspector action tab
  56399. */
  56400. export enum DebugLayerTab {
  56401. /**
  56402. * Properties tag (default)
  56403. */
  56404. Properties = 0,
  56405. /**
  56406. * Debug tab
  56407. */
  56408. Debug = 1,
  56409. /**
  56410. * Statistics tab
  56411. */
  56412. Statistics = 2,
  56413. /**
  56414. * Tools tab
  56415. */
  56416. Tools = 3,
  56417. /**
  56418. * Settings tab
  56419. */
  56420. Settings = 4
  56421. }
  56422. /**
  56423. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56424. * what is happening in your scene
  56425. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56426. */
  56427. export class DebugLayer {
  56428. /**
  56429. * Define the url to get the inspector script from.
  56430. * By default it uses the babylonjs CDN.
  56431. * @ignoreNaming
  56432. */
  56433. static InspectorURL: string;
  56434. private _scene;
  56435. private BJSINSPECTOR;
  56436. private _onPropertyChangedObservable?;
  56437. /**
  56438. * Observable triggered when a property is changed through the inspector.
  56439. */
  56440. get onPropertyChangedObservable(): any;
  56441. /**
  56442. * Instantiates a new debug layer.
  56443. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56444. * what is happening in your scene
  56445. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56446. * @param scene Defines the scene to inspect
  56447. */
  56448. constructor(scene: Scene);
  56449. /** Creates the inspector window. */
  56450. private _createInspector;
  56451. /**
  56452. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  56453. * @param entity defines the entity to select
  56454. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  56455. */
  56456. select(entity: any, lineContainerTitles?: string | string[]): void;
  56457. /** Get the inspector from bundle or global */
  56458. private _getGlobalInspector;
  56459. /**
  56460. * Get if the inspector is visible or not.
  56461. * @returns true if visible otherwise, false
  56462. */
  56463. isVisible(): boolean;
  56464. /**
  56465. * Hide the inspector and close its window.
  56466. */
  56467. hide(): void;
  56468. /**
  56469. * Update the scene in the inspector
  56470. */
  56471. setAsActiveScene(): void;
  56472. /**
  56473. * Launch the debugLayer.
  56474. * @param config Define the configuration of the inspector
  56475. * @return a promise fulfilled when the debug layer is visible
  56476. */
  56477. show(config?: IInspectorOptions): Promise<DebugLayer>;
  56478. }
  56479. }
  56480. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56481. import { Nullable } from "babylonjs/types";
  56482. import { Scene } from "babylonjs/scene";
  56483. import { Vector4 } from "babylonjs/Maths/math.vector";
  56484. import { Color4 } from "babylonjs/Maths/math.color";
  56485. import { Mesh } from "babylonjs/Meshes/mesh";
  56486. /**
  56487. * Class containing static functions to help procedurally build meshes
  56488. */
  56489. export class BoxBuilder {
  56490. /**
  56491. * Creates a box mesh
  56492. * * The parameter `size` sets the size (float) of each box side (default 1)
  56493. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56494. * * 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)
  56495. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56499. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56500. * @param name defines the name of the mesh
  56501. * @param options defines the options used to create the mesh
  56502. * @param scene defines the hosting scene
  56503. * @returns the box mesh
  56504. */
  56505. static CreateBox(name: string, options: {
  56506. size?: number;
  56507. width?: number;
  56508. height?: number;
  56509. depth?: number;
  56510. faceUV?: Vector4[];
  56511. faceColors?: Color4[];
  56512. sideOrientation?: number;
  56513. frontUVs?: Vector4;
  56514. backUVs?: Vector4;
  56515. wrap?: boolean;
  56516. topBaseAt?: number;
  56517. bottomBaseAt?: number;
  56518. updatable?: boolean;
  56519. }, scene?: Nullable<Scene>): Mesh;
  56520. }
  56521. }
  56522. declare module "babylonjs/Debug/physicsViewer" {
  56523. import { Nullable } from "babylonjs/types";
  56524. import { Scene } from "babylonjs/scene";
  56525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56526. import { Mesh } from "babylonjs/Meshes/mesh";
  56527. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56528. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56529. /**
  56530. * Used to show the physics impostor around the specific mesh
  56531. */
  56532. export class PhysicsViewer {
  56533. /** @hidden */
  56534. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  56535. /** @hidden */
  56536. protected _meshes: Array<Nullable<AbstractMesh>>;
  56537. /** @hidden */
  56538. protected _scene: Nullable<Scene>;
  56539. /** @hidden */
  56540. protected _numMeshes: number;
  56541. /** @hidden */
  56542. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  56543. private _renderFunction;
  56544. private _utilityLayer;
  56545. private _debugBoxMesh;
  56546. private _debugSphereMesh;
  56547. private _debugCylinderMesh;
  56548. private _debugMaterial;
  56549. private _debugMeshMeshes;
  56550. /**
  56551. * Creates a new PhysicsViewer
  56552. * @param scene defines the hosting scene
  56553. */
  56554. constructor(scene: Scene);
  56555. /** @hidden */
  56556. protected _updateDebugMeshes(): void;
  56557. /**
  56558. * Renders a specified physic impostor
  56559. * @param impostor defines the impostor to render
  56560. * @param targetMesh defines the mesh represented by the impostor
  56561. * @returns the new debug mesh used to render the impostor
  56562. */
  56563. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  56564. /**
  56565. * Hides a specified physic impostor
  56566. * @param impostor defines the impostor to hide
  56567. */
  56568. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  56569. private _getDebugMaterial;
  56570. private _getDebugBoxMesh;
  56571. private _getDebugSphereMesh;
  56572. private _getDebugCylinderMesh;
  56573. private _getDebugMeshMesh;
  56574. private _getDebugMesh;
  56575. /** Releases all resources */
  56576. dispose(): void;
  56577. }
  56578. }
  56579. declare module "babylonjs/Debug/rayHelper" {
  56580. import { Nullable } from "babylonjs/types";
  56581. import { Ray } from "babylonjs/Culling/ray";
  56582. import { Vector3 } from "babylonjs/Maths/math.vector";
  56583. import { Color3 } from "babylonjs/Maths/math.color";
  56584. import { Scene } from "babylonjs/scene";
  56585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56586. import "babylonjs/Meshes/Builders/linesBuilder";
  56587. /**
  56588. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56589. * in order to better appreciate the issue one might have.
  56590. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56591. */
  56592. export class RayHelper {
  56593. /**
  56594. * Defines the ray we are currently tryin to visualize.
  56595. */
  56596. ray: Nullable<Ray>;
  56597. private _renderPoints;
  56598. private _renderLine;
  56599. private _renderFunction;
  56600. private _scene;
  56601. private _onAfterRenderObserver;
  56602. private _onAfterStepObserver;
  56603. private _attachedToMesh;
  56604. private _meshSpaceDirection;
  56605. private _meshSpaceOrigin;
  56606. /**
  56607. * Helper function to create a colored helper in a scene in one line.
  56608. * @param ray Defines the ray we are currently tryin to visualize
  56609. * @param scene Defines the scene the ray is used in
  56610. * @param color Defines the color we want to see the ray in
  56611. * @returns The newly created ray helper.
  56612. */
  56613. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  56614. /**
  56615. * Instantiate a new ray helper.
  56616. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56617. * in order to better appreciate the issue one might have.
  56618. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56619. * @param ray Defines the ray we are currently tryin to visualize
  56620. */
  56621. constructor(ray: Ray);
  56622. /**
  56623. * Shows the ray we are willing to debug.
  56624. * @param scene Defines the scene the ray needs to be rendered in
  56625. * @param color Defines the color the ray needs to be rendered in
  56626. */
  56627. show(scene: Scene, color?: Color3): void;
  56628. /**
  56629. * Hides the ray we are debugging.
  56630. */
  56631. hide(): void;
  56632. private _render;
  56633. /**
  56634. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  56635. * @param mesh Defines the mesh we want the helper attached to
  56636. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  56637. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  56638. * @param length Defines the length of the ray
  56639. */
  56640. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  56641. /**
  56642. * Detach the ray helper from the mesh it has previously been attached to.
  56643. */
  56644. detachFromMesh(): void;
  56645. private _updateToMesh;
  56646. /**
  56647. * Dispose the helper and release its associated resources.
  56648. */
  56649. dispose(): void;
  56650. }
  56651. }
  56652. declare module "babylonjs/Debug/ISkeletonViewer" {
  56653. import { Skeleton } from "babylonjs/Bones/skeleton";
  56654. import { Color3 } from "babylonjs/Maths/math.color";
  56655. /**
  56656. * Defines the options associated with the creation of a SkeletonViewer.
  56657. */
  56658. export interface ISkeletonViewerOptions {
  56659. /** Should the system pause animations before building the Viewer? */
  56660. pauseAnimations: boolean;
  56661. /** Should the system return the skeleton to rest before building? */
  56662. returnToRest: boolean;
  56663. /** public Display Mode of the Viewer */
  56664. displayMode: number;
  56665. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56666. displayOptions: ISkeletonViewerDisplayOptions;
  56667. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56668. computeBonesUsingShaders: boolean;
  56669. /** Flag ignore non weighted bones */
  56670. useAllBones: boolean;
  56671. }
  56672. /**
  56673. * Defines how to display the various bone meshes for the viewer.
  56674. */
  56675. export interface ISkeletonViewerDisplayOptions {
  56676. /** How far down to start tapering the bone spurs */
  56677. midStep?: number;
  56678. /** How big is the midStep? */
  56679. midStepFactor?: number;
  56680. /** Base for the Sphere Size */
  56681. sphereBaseSize?: number;
  56682. /** The ratio of the sphere to the longest bone in units */
  56683. sphereScaleUnit?: number;
  56684. /** Ratio for the Sphere Size */
  56685. sphereFactor?: number;
  56686. /** Whether a spur should attach its far end to the child bone position */
  56687. spurFollowsChild?: boolean;
  56688. /** Whether to show local axes or not */
  56689. showLocalAxes?: boolean;
  56690. /** Length of each local axis */
  56691. localAxesSize?: number;
  56692. }
  56693. /**
  56694. * Defines the constructor options for the BoneWeight Shader.
  56695. */
  56696. export interface IBoneWeightShaderOptions {
  56697. /** Skeleton to Map */
  56698. skeleton: Skeleton;
  56699. /** Colors for Uninfluenced bones */
  56700. colorBase?: Color3;
  56701. /** Colors for 0.0-0.25 Weight bones */
  56702. colorZero?: Color3;
  56703. /** Color for 0.25-0.5 Weight Influence */
  56704. colorQuarter?: Color3;
  56705. /** Color for 0.5-0.75 Weight Influence */
  56706. colorHalf?: Color3;
  56707. /** Color for 0.75-1 Weight Influence */
  56708. colorFull?: Color3;
  56709. /** Color for Zero Weight Influence */
  56710. targetBoneIndex?: number;
  56711. }
  56712. /**
  56713. * Simple structure of the gradient steps for the Color Map.
  56714. */
  56715. export interface ISkeletonMapShaderColorMapKnot {
  56716. /** Color of the Knot */
  56717. color: Color3;
  56718. /** Location of the Knot */
  56719. location: number;
  56720. }
  56721. /**
  56722. * Defines the constructor options for the SkeletonMap Shader.
  56723. */
  56724. export interface ISkeletonMapShaderOptions {
  56725. /** Skeleton to Map */
  56726. skeleton: Skeleton;
  56727. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  56728. colorMap?: ISkeletonMapShaderColorMapKnot[];
  56729. }
  56730. }
  56731. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  56732. import { Nullable } from "babylonjs/types";
  56733. import { Scene } from "babylonjs/scene";
  56734. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  56735. import { Color4 } from "babylonjs/Maths/math.color";
  56736. import { Mesh } from "babylonjs/Meshes/mesh";
  56737. /**
  56738. * Class containing static functions to help procedurally build meshes
  56739. */
  56740. export class RibbonBuilder {
  56741. /**
  56742. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56743. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56744. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56745. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56746. * * 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
  56747. * * 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
  56748. * * 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
  56749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56750. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56751. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56752. * * 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
  56753. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56754. * * 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
  56755. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56757. * @param name defines the name of the mesh
  56758. * @param options defines the options used to create the mesh
  56759. * @param scene defines the hosting scene
  56760. * @returns the ribbon mesh
  56761. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56762. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56763. */
  56764. static CreateRibbon(name: string, options: {
  56765. pathArray: Vector3[][];
  56766. closeArray?: boolean;
  56767. closePath?: boolean;
  56768. offset?: number;
  56769. updatable?: boolean;
  56770. sideOrientation?: number;
  56771. frontUVs?: Vector4;
  56772. backUVs?: Vector4;
  56773. instance?: Mesh;
  56774. invertUV?: boolean;
  56775. uvs?: Vector2[];
  56776. colors?: Color4[];
  56777. }, scene?: Nullable<Scene>): Mesh;
  56778. }
  56779. }
  56780. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  56781. import { Nullable } from "babylonjs/types";
  56782. import { Scene } from "babylonjs/scene";
  56783. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56784. import { Mesh } from "babylonjs/Meshes/mesh";
  56785. /**
  56786. * Class containing static functions to help procedurally build meshes
  56787. */
  56788. export class ShapeBuilder {
  56789. /**
  56790. * 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.
  56791. * * 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.
  56792. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56793. * * 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.
  56794. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56795. * * 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
  56796. * * 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
  56797. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56799. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56800. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56802. * @param name defines the name of the mesh
  56803. * @param options defines the options used to create the mesh
  56804. * @param scene defines the hosting scene
  56805. * @returns the extruded shape mesh
  56806. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56807. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56808. */
  56809. static ExtrudeShape(name: string, options: {
  56810. shape: Vector3[];
  56811. path: Vector3[];
  56812. scale?: number;
  56813. rotation?: number;
  56814. cap?: number;
  56815. updatable?: boolean;
  56816. sideOrientation?: number;
  56817. frontUVs?: Vector4;
  56818. backUVs?: Vector4;
  56819. instance?: Mesh;
  56820. invertUV?: boolean;
  56821. }, scene?: Nullable<Scene>): Mesh;
  56822. /**
  56823. * Creates an custom extruded shape mesh.
  56824. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56825. * * 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.
  56826. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56827. * * 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
  56828. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56829. * * 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
  56830. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56831. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56832. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56833. * * 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
  56834. * * 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
  56835. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56838. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56840. * @param name defines the name of the mesh
  56841. * @param options defines the options used to create the mesh
  56842. * @param scene defines the hosting scene
  56843. * @returns the custom extruded shape mesh
  56844. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56845. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56846. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56847. */
  56848. static ExtrudeShapeCustom(name: string, options: {
  56849. shape: Vector3[];
  56850. path: Vector3[];
  56851. scaleFunction?: any;
  56852. rotationFunction?: any;
  56853. ribbonCloseArray?: boolean;
  56854. ribbonClosePath?: boolean;
  56855. cap?: number;
  56856. updatable?: boolean;
  56857. sideOrientation?: number;
  56858. frontUVs?: Vector4;
  56859. backUVs?: Vector4;
  56860. instance?: Mesh;
  56861. invertUV?: boolean;
  56862. }, scene?: Nullable<Scene>): Mesh;
  56863. private static _ExtrudeShapeGeneric;
  56864. }
  56865. }
  56866. declare module "babylonjs/Debug/skeletonViewer" {
  56867. import { Color3 } from "babylonjs/Maths/math.color";
  56868. import { Scene } from "babylonjs/scene";
  56869. import { Nullable } from "babylonjs/types";
  56870. import { Skeleton } from "babylonjs/Bones/skeleton";
  56871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56872. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56873. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56874. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  56875. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  56876. /**
  56877. * Class used to render a debug view of a given skeleton
  56878. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  56879. */
  56880. export class SkeletonViewer {
  56881. /** defines the skeleton to render */
  56882. skeleton: Skeleton;
  56883. /** defines the mesh attached to the skeleton */
  56884. mesh: AbstractMesh;
  56885. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56886. autoUpdateBonesMatrices: boolean;
  56887. /** defines the rendering group id to use with the viewer */
  56888. renderingGroupId: number;
  56889. /** is the options for the viewer */
  56890. options: Partial<ISkeletonViewerOptions>;
  56891. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  56892. static readonly DISPLAY_LINES: number;
  56893. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  56894. static readonly DISPLAY_SPHERES: number;
  56895. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  56896. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  56897. /** public static method to create a BoneWeight Shader
  56898. * @param options The constructor options
  56899. * @param scene The scene that the shader is scoped to
  56900. * @returns The created ShaderMaterial
  56901. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  56902. */
  56903. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  56904. /** public static method to create a BoneWeight Shader
  56905. * @param options The constructor options
  56906. * @param scene The scene that the shader is scoped to
  56907. * @returns The created ShaderMaterial
  56908. */
  56909. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  56910. /** private static method to create a BoneWeight Shader
  56911. * @param size The size of the buffer to create (usually the bone count)
  56912. * @param colorMap The gradient data to generate
  56913. * @param scene The scene that the shader is scoped to
  56914. * @returns an Array of floats from the color gradient values
  56915. */
  56916. private static _CreateBoneMapColorBuffer;
  56917. /** If SkeletonViewer scene scope. */
  56918. private _scene;
  56919. /** Gets or sets the color used to render the skeleton */
  56920. color: Color3;
  56921. /** Array of the points of the skeleton fo the line view. */
  56922. private _debugLines;
  56923. /** The SkeletonViewers Mesh. */
  56924. private _debugMesh;
  56925. /** The local axes Meshes. */
  56926. private _localAxes;
  56927. /** If SkeletonViewer is enabled. */
  56928. private _isEnabled;
  56929. /** If SkeletonViewer is ready. */
  56930. private _ready;
  56931. /** SkeletonViewer render observable. */
  56932. private _obs;
  56933. /** The Utility Layer to render the gizmos in. */
  56934. private _utilityLayer;
  56935. private _boneIndices;
  56936. /** Gets the Scene. */
  56937. get scene(): Scene;
  56938. /** Gets the utilityLayer. */
  56939. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  56940. /** Checks Ready Status. */
  56941. get isReady(): Boolean;
  56942. /** Sets Ready Status. */
  56943. set ready(value: boolean);
  56944. /** Gets the debugMesh */
  56945. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  56946. /** Sets the debugMesh */
  56947. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  56948. /** Gets the displayMode */
  56949. get displayMode(): number;
  56950. /** Sets the displayMode */
  56951. set displayMode(value: number);
  56952. /**
  56953. * Creates a new SkeletonViewer
  56954. * @param skeleton defines the skeleton to render
  56955. * @param mesh defines the mesh attached to the skeleton
  56956. * @param scene defines the hosting scene
  56957. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  56958. * @param renderingGroupId defines the rendering group id to use with the viewer
  56959. * @param options All of the extra constructor options for the SkeletonViewer
  56960. */
  56961. constructor(
  56962. /** defines the skeleton to render */
  56963. skeleton: Skeleton,
  56964. /** defines the mesh attached to the skeleton */
  56965. mesh: AbstractMesh,
  56966. /** The Scene scope*/
  56967. scene: Scene,
  56968. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56969. autoUpdateBonesMatrices?: boolean,
  56970. /** defines the rendering group id to use with the viewer */
  56971. renderingGroupId?: number,
  56972. /** is the options for the viewer */
  56973. options?: Partial<ISkeletonViewerOptions>);
  56974. /** The Dynamic bindings for the update functions */
  56975. private _bindObs;
  56976. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  56977. update(): void;
  56978. /** Gets or sets a boolean indicating if the viewer is enabled */
  56979. set isEnabled(value: boolean);
  56980. get isEnabled(): boolean;
  56981. private _getBonePosition;
  56982. private _getLinesForBonesWithLength;
  56983. private _getLinesForBonesNoLength;
  56984. /** function to revert the mesh and scene back to the initial state. */
  56985. private _revert;
  56986. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  56987. private _getAbsoluteBindPoseToRef;
  56988. /** function to build and bind sphere joint points and spur bone representations. */
  56989. private _buildSpheresAndSpurs;
  56990. private _buildLocalAxes;
  56991. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  56992. private _displayLinesUpdate;
  56993. /** Changes the displayMode of the skeleton viewer
  56994. * @param mode The displayMode numerical value
  56995. */
  56996. changeDisplayMode(mode: number): void;
  56997. /** Sets a display option of the skeleton viewer
  56998. *
  56999. * | Option | Type | Default | Description |
  57000. * | ---------------- | ------- | ------- | ----------- |
  57001. * | 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`. |
  57002. * | 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`. |
  57003. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  57004. * | 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`. |
  57005. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  57006. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  57007. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  57008. *
  57009. * @param option String of the option name
  57010. * @param value The numerical option value
  57011. */
  57012. changeDisplayOptions(option: string, value: number): void;
  57013. /** Release associated resources */
  57014. dispose(): void;
  57015. }
  57016. }
  57017. declare module "babylonjs/Debug/index" {
  57018. export * from "babylonjs/Debug/axesViewer";
  57019. export * from "babylonjs/Debug/boneAxesViewer";
  57020. export * from "babylonjs/Debug/debugLayer";
  57021. export * from "babylonjs/Debug/physicsViewer";
  57022. export * from "babylonjs/Debug/rayHelper";
  57023. export * from "babylonjs/Debug/skeletonViewer";
  57024. export * from "babylonjs/Debug/ISkeletonViewer";
  57025. }
  57026. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  57027. /**
  57028. * Enum for Device Types
  57029. */
  57030. export enum DeviceType {
  57031. /** Generic */
  57032. Generic = 0,
  57033. /** Keyboard */
  57034. Keyboard = 1,
  57035. /** Mouse */
  57036. Mouse = 2,
  57037. /** Touch Pointers */
  57038. Touch = 3,
  57039. /** PS4 Dual Shock */
  57040. DualShock = 4,
  57041. /** Xbox */
  57042. Xbox = 5,
  57043. /** Switch Controller */
  57044. Switch = 6
  57045. }
  57046. /**
  57047. * Enum for All Pointers (Touch/Mouse)
  57048. */
  57049. export enum PointerInput {
  57050. /** Horizontal Axis */
  57051. Horizontal = 0,
  57052. /** Vertical Axis */
  57053. Vertical = 1,
  57054. /** Left Click or Touch */
  57055. LeftClick = 2,
  57056. /** Middle Click */
  57057. MiddleClick = 3,
  57058. /** Right Click */
  57059. RightClick = 4,
  57060. /** Browser Back */
  57061. BrowserBack = 5,
  57062. /** Browser Forward */
  57063. BrowserForward = 6
  57064. }
  57065. /**
  57066. * Enum for Dual Shock Gamepad
  57067. */
  57068. export enum DualShockInput {
  57069. /** Cross */
  57070. Cross = 0,
  57071. /** Circle */
  57072. Circle = 1,
  57073. /** Square */
  57074. Square = 2,
  57075. /** Triangle */
  57076. Triangle = 3,
  57077. /** L1 */
  57078. L1 = 4,
  57079. /** R1 */
  57080. R1 = 5,
  57081. /** L2 */
  57082. L2 = 6,
  57083. /** R2 */
  57084. R2 = 7,
  57085. /** Share */
  57086. Share = 8,
  57087. /** Options */
  57088. Options = 9,
  57089. /** L3 */
  57090. L3 = 10,
  57091. /** R3 */
  57092. R3 = 11,
  57093. /** DPadUp */
  57094. DPadUp = 12,
  57095. /** DPadDown */
  57096. DPadDown = 13,
  57097. /** DPadLeft */
  57098. DPadLeft = 14,
  57099. /** DRight */
  57100. DPadRight = 15,
  57101. /** Home */
  57102. Home = 16,
  57103. /** TouchPad */
  57104. TouchPad = 17,
  57105. /** LStickXAxis */
  57106. LStickXAxis = 18,
  57107. /** LStickYAxis */
  57108. LStickYAxis = 19,
  57109. /** RStickXAxis */
  57110. RStickXAxis = 20,
  57111. /** RStickYAxis */
  57112. RStickYAxis = 21
  57113. }
  57114. /**
  57115. * Enum for Xbox Gamepad
  57116. */
  57117. export enum XboxInput {
  57118. /** A */
  57119. A = 0,
  57120. /** B */
  57121. B = 1,
  57122. /** X */
  57123. X = 2,
  57124. /** Y */
  57125. Y = 3,
  57126. /** LB */
  57127. LB = 4,
  57128. /** RB */
  57129. RB = 5,
  57130. /** LT */
  57131. LT = 6,
  57132. /** RT */
  57133. RT = 7,
  57134. /** Back */
  57135. Back = 8,
  57136. /** Start */
  57137. Start = 9,
  57138. /** LS */
  57139. LS = 10,
  57140. /** RS */
  57141. RS = 11,
  57142. /** DPadUp */
  57143. DPadUp = 12,
  57144. /** DPadDown */
  57145. DPadDown = 13,
  57146. /** DPadLeft */
  57147. DPadLeft = 14,
  57148. /** DRight */
  57149. DPadRight = 15,
  57150. /** Home */
  57151. Home = 16,
  57152. /** LStickXAxis */
  57153. LStickXAxis = 17,
  57154. /** LStickYAxis */
  57155. LStickYAxis = 18,
  57156. /** RStickXAxis */
  57157. RStickXAxis = 19,
  57158. /** RStickYAxis */
  57159. RStickYAxis = 20
  57160. }
  57161. /**
  57162. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  57163. */
  57164. export enum SwitchInput {
  57165. /** B */
  57166. B = 0,
  57167. /** A */
  57168. A = 1,
  57169. /** Y */
  57170. Y = 2,
  57171. /** X */
  57172. X = 3,
  57173. /** L */
  57174. L = 4,
  57175. /** R */
  57176. R = 5,
  57177. /** ZL */
  57178. ZL = 6,
  57179. /** ZR */
  57180. ZR = 7,
  57181. /** Minus */
  57182. Minus = 8,
  57183. /** Plus */
  57184. Plus = 9,
  57185. /** LS */
  57186. LS = 10,
  57187. /** RS */
  57188. RS = 11,
  57189. /** DPadUp */
  57190. DPadUp = 12,
  57191. /** DPadDown */
  57192. DPadDown = 13,
  57193. /** DPadLeft */
  57194. DPadLeft = 14,
  57195. /** DRight */
  57196. DPadRight = 15,
  57197. /** Home */
  57198. Home = 16,
  57199. /** Capture */
  57200. Capture = 17,
  57201. /** LStickXAxis */
  57202. LStickXAxis = 18,
  57203. /** LStickYAxis */
  57204. LStickYAxis = 19,
  57205. /** RStickXAxis */
  57206. RStickXAxis = 20,
  57207. /** RStickYAxis */
  57208. RStickYAxis = 21
  57209. }
  57210. }
  57211. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  57212. import { Engine } from "babylonjs/Engines/engine";
  57213. import { IDisposable } from "babylonjs/scene";
  57214. import { Nullable } from "babylonjs/types";
  57215. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57216. /**
  57217. * This class will take all inputs from Keyboard, Pointer, and
  57218. * any Gamepads and provide a polling system that all devices
  57219. * will use. This class assumes that there will only be one
  57220. * pointer device and one keyboard.
  57221. */
  57222. export class DeviceInputSystem implements IDisposable {
  57223. /**
  57224. * Returns onDeviceConnected callback property
  57225. * @returns Callback with function to execute when a device is connected
  57226. */
  57227. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  57228. /**
  57229. * Sets callback function when a device is connected and executes against all connected devices
  57230. * @param callback Function to execute when a device is connected
  57231. */
  57232. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  57233. /**
  57234. * Callback to be triggered when a device is disconnected
  57235. */
  57236. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  57237. /**
  57238. * Callback to be triggered when event driven input is updated
  57239. */
  57240. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  57241. private _inputs;
  57242. private _gamepads;
  57243. private _keyboardActive;
  57244. private _pointerActive;
  57245. private _elementToAttachTo;
  57246. private _keyboardDownEvent;
  57247. private _keyboardUpEvent;
  57248. private _pointerMoveEvent;
  57249. private _pointerDownEvent;
  57250. private _pointerUpEvent;
  57251. private _gamepadConnectedEvent;
  57252. private _gamepadDisconnectedEvent;
  57253. private _onDeviceConnected;
  57254. private static _MAX_KEYCODES;
  57255. private static _MAX_POINTER_INPUTS;
  57256. private constructor();
  57257. /**
  57258. * Creates a new DeviceInputSystem instance
  57259. * @param engine Engine to pull input element from
  57260. * @returns The new instance
  57261. */
  57262. static Create(engine: Engine): DeviceInputSystem;
  57263. /**
  57264. * Checks for current device input value, given an id and input index
  57265. * @param deviceName Id of connected device
  57266. * @param inputIndex Index of device input
  57267. * @returns Current value of input
  57268. */
  57269. /**
  57270. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  57271. * @param deviceType Enum specifiying device type
  57272. * @param deviceSlot "Slot" or index that device is referenced in
  57273. * @param inputIndex Id of input to be checked
  57274. * @returns Current value of input
  57275. */
  57276. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  57277. /**
  57278. * Dispose of all the eventlisteners
  57279. */
  57280. dispose(): void;
  57281. /**
  57282. * Checks for existing connections to devices and register them, if necessary
  57283. * Currently handles gamepads and mouse
  57284. */
  57285. private _checkForConnectedDevices;
  57286. /**
  57287. * Add a gamepad to the DeviceInputSystem
  57288. * @param gamepad A single DOM Gamepad object
  57289. */
  57290. private _addGamePad;
  57291. /**
  57292. * Add pointer device to DeviceInputSystem
  57293. * @param deviceType Type of Pointer to add
  57294. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  57295. * @param currentX Current X at point of adding
  57296. * @param currentY Current Y at point of adding
  57297. */
  57298. private _addPointerDevice;
  57299. /**
  57300. * Add device and inputs to device array
  57301. * @param deviceType Enum specifiying device type
  57302. * @param deviceSlot "Slot" or index that device is referenced in
  57303. * @param numberOfInputs Number of input entries to create for given device
  57304. */
  57305. private _registerDevice;
  57306. /**
  57307. * Given a specific device name, remove that device from the device map
  57308. * @param deviceType Enum specifiying device type
  57309. * @param deviceSlot "Slot" or index that device is referenced in
  57310. */
  57311. private _unregisterDevice;
  57312. /**
  57313. * Handle all actions that come from keyboard interaction
  57314. */
  57315. private _handleKeyActions;
  57316. /**
  57317. * Handle all actions that come from pointer interaction
  57318. */
  57319. private _handlePointerActions;
  57320. /**
  57321. * Handle all actions that come from gamepad interaction
  57322. */
  57323. private _handleGamepadActions;
  57324. /**
  57325. * Update all non-event based devices with each frame
  57326. * @param deviceType Enum specifiying device type
  57327. * @param deviceSlot "Slot" or index that device is referenced in
  57328. * @param inputIndex Id of input to be checked
  57329. */
  57330. private _updateDevice;
  57331. /**
  57332. * Gets DeviceType from the device name
  57333. * @param deviceName Name of Device from DeviceInputSystem
  57334. * @returns DeviceType enum value
  57335. */
  57336. private _getGamepadDeviceType;
  57337. }
  57338. }
  57339. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  57340. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57341. /**
  57342. * Type to handle enforcement of inputs
  57343. */
  57344. 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;
  57345. }
  57346. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  57347. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  57348. import { Engine } from "babylonjs/Engines/engine";
  57349. import { IDisposable } from "babylonjs/scene";
  57350. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57351. import { Nullable } from "babylonjs/types";
  57352. import { Observable } from "babylonjs/Misc/observable";
  57353. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57354. /**
  57355. * Class that handles all input for a specific device
  57356. */
  57357. export class DeviceSource<T extends DeviceType> {
  57358. /** Type of device */
  57359. readonly deviceType: DeviceType;
  57360. /** "Slot" or index that device is referenced in */
  57361. readonly deviceSlot: number;
  57362. /**
  57363. * Observable to handle device input changes per device
  57364. */
  57365. readonly onInputChangedObservable: Observable<{
  57366. inputIndex: DeviceInput<T>;
  57367. previousState: Nullable<number>;
  57368. currentState: Nullable<number>;
  57369. }>;
  57370. private readonly _deviceInputSystem;
  57371. /**
  57372. * Default Constructor
  57373. * @param deviceInputSystem Reference to DeviceInputSystem
  57374. * @param deviceType Type of device
  57375. * @param deviceSlot "Slot" or index that device is referenced in
  57376. */
  57377. constructor(deviceInputSystem: DeviceInputSystem,
  57378. /** Type of device */
  57379. deviceType: DeviceType,
  57380. /** "Slot" or index that device is referenced in */
  57381. deviceSlot?: number);
  57382. /**
  57383. * Get input for specific input
  57384. * @param inputIndex index of specific input on device
  57385. * @returns Input value from DeviceInputSystem
  57386. */
  57387. getInput(inputIndex: DeviceInput<T>): number;
  57388. }
  57389. /**
  57390. * Class to keep track of devices
  57391. */
  57392. export class DeviceSourceManager implements IDisposable {
  57393. /**
  57394. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  57395. */
  57396. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  57397. /**
  57398. * Observable to be triggered when after a device is disconnected
  57399. */
  57400. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  57401. private readonly _devices;
  57402. private readonly _firstDevice;
  57403. private readonly _deviceInputSystem;
  57404. /**
  57405. * Default Constructor
  57406. * @param engine engine to pull input element from
  57407. */
  57408. constructor(engine: Engine);
  57409. /**
  57410. * Gets a DeviceSource, given a type and slot
  57411. * @param deviceType Enum specifying device type
  57412. * @param deviceSlot "Slot" or index that device is referenced in
  57413. * @returns DeviceSource object
  57414. */
  57415. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  57416. /**
  57417. * Gets an array of DeviceSource objects for a given device type
  57418. * @param deviceType Enum specifying device type
  57419. * @returns Array of DeviceSource objects
  57420. */
  57421. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  57422. /**
  57423. * Returns a read-only list of all available devices
  57424. * @returns Read-only array with active devices
  57425. */
  57426. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  57427. /**
  57428. * Dispose of DeviceInputSystem and other parts
  57429. */
  57430. dispose(): void;
  57431. /**
  57432. * Function to add device name to device list
  57433. * @param deviceType Enum specifying device type
  57434. * @param deviceSlot "Slot" or index that device is referenced in
  57435. */
  57436. private _addDevice;
  57437. /**
  57438. * Function to remove device name to device list
  57439. * @param deviceType Enum specifying device type
  57440. * @param deviceSlot "Slot" or index that device is referenced in
  57441. */
  57442. private _removeDevice;
  57443. /**
  57444. * Updates array storing first connected device of each type
  57445. * @param type Type of Device
  57446. */
  57447. private _updateFirstDevices;
  57448. }
  57449. }
  57450. declare module "babylonjs/DeviceInput/index" {
  57451. export * from "babylonjs/DeviceInput/deviceInputSystem";
  57452. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57453. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57454. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57455. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57456. }
  57457. declare module "babylonjs/Engines/nullEngine" {
  57458. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  57459. import { Engine } from "babylonjs/Engines/engine";
  57460. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  57461. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  57462. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57463. import { Effect } from "babylonjs/Materials/effect";
  57464. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  57465. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57466. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  57467. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  57468. /**
  57469. * Options to create the null engine
  57470. */
  57471. export class NullEngineOptions {
  57472. /**
  57473. * Render width (Default: 512)
  57474. */
  57475. renderWidth: number;
  57476. /**
  57477. * Render height (Default: 256)
  57478. */
  57479. renderHeight: number;
  57480. /**
  57481. * Texture size (Default: 512)
  57482. */
  57483. textureSize: number;
  57484. /**
  57485. * If delta time between frames should be constant
  57486. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57487. */
  57488. deterministicLockstep: boolean;
  57489. /**
  57490. * Maximum about of steps between frames (Default: 4)
  57491. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57492. */
  57493. lockstepMaxSteps: number;
  57494. /**
  57495. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  57496. */
  57497. useHighPrecisionMatrix?: boolean;
  57498. }
  57499. /**
  57500. * The null engine class provides support for headless version of babylon.js.
  57501. * This can be used in server side scenario or for testing purposes
  57502. */
  57503. export class NullEngine extends Engine {
  57504. private _options;
  57505. /**
  57506. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  57507. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57508. * @returns true if engine is in deterministic lock step mode
  57509. */
  57510. isDeterministicLockStep(): boolean;
  57511. /**
  57512. * Gets the max steps when engine is running in deterministic lock step
  57513. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57514. * @returns the max steps
  57515. */
  57516. getLockstepMaxSteps(): number;
  57517. /**
  57518. * Gets the current hardware scaling level.
  57519. * By default the hardware scaling level is computed from the window device ratio.
  57520. * 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.
  57521. * @returns a number indicating the current hardware scaling level
  57522. */
  57523. getHardwareScalingLevel(): number;
  57524. constructor(options?: NullEngineOptions);
  57525. /**
  57526. * Creates a vertex buffer
  57527. * @param vertices the data for the vertex buffer
  57528. * @returns the new WebGL static buffer
  57529. */
  57530. createVertexBuffer(vertices: FloatArray): DataBuffer;
  57531. /**
  57532. * Creates a new index buffer
  57533. * @param indices defines the content of the index buffer
  57534. * @param updatable defines if the index buffer must be updatable
  57535. * @returns a new webGL buffer
  57536. */
  57537. createIndexBuffer(indices: IndicesArray): DataBuffer;
  57538. /**
  57539. * Clear the current render buffer or the current render target (if any is set up)
  57540. * @param color defines the color to use
  57541. * @param backBuffer defines if the back buffer must be cleared
  57542. * @param depth defines if the depth buffer must be cleared
  57543. * @param stencil defines if the stencil buffer must be cleared
  57544. */
  57545. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57546. /**
  57547. * Gets the current render width
  57548. * @param useScreen defines if screen size must be used (or the current render target if any)
  57549. * @returns a number defining the current render width
  57550. */
  57551. getRenderWidth(useScreen?: boolean): number;
  57552. /**
  57553. * Gets the current render height
  57554. * @param useScreen defines if screen size must be used (or the current render target if any)
  57555. * @returns a number defining the current render height
  57556. */
  57557. getRenderHeight(useScreen?: boolean): number;
  57558. /**
  57559. * Set the WebGL's viewport
  57560. * @param viewport defines the viewport element to be used
  57561. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  57562. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  57563. */
  57564. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  57565. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  57566. /**
  57567. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  57568. * @param pipelineContext defines the pipeline context to use
  57569. * @param uniformsNames defines the list of uniform names
  57570. * @returns an array of webGL uniform locations
  57571. */
  57572. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  57573. /**
  57574. * Gets the lsit of active attributes for a given webGL program
  57575. * @param pipelineContext defines the pipeline context to use
  57576. * @param attributesNames defines the list of attribute names to get
  57577. * @returns an array of indices indicating the offset of each attribute
  57578. */
  57579. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57580. /**
  57581. * Binds an effect to the webGL context
  57582. * @param effect defines the effect to bind
  57583. */
  57584. bindSamplers(effect: Effect): void;
  57585. /**
  57586. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  57587. * @param effect defines the effect to activate
  57588. */
  57589. enableEffect(effect: Effect): void;
  57590. /**
  57591. * Set various states to the webGL context
  57592. * @param culling defines backface culling state
  57593. * @param zOffset defines the value to apply to zOffset (0 by default)
  57594. * @param force defines if states must be applied even if cache is up to date
  57595. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  57596. */
  57597. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57598. /**
  57599. * Set the value of an uniform to an array of int32
  57600. * @param uniform defines the webGL uniform location where to store the value
  57601. * @param array defines the array of int32 to store
  57602. * @returns true if value was set
  57603. */
  57604. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57605. /**
  57606. * Set the value of an uniform to an array of int32 (stored as vec2)
  57607. * @param uniform defines the webGL uniform location where to store the value
  57608. * @param array defines the array of int32 to store
  57609. * @returns true if value was set
  57610. */
  57611. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57612. /**
  57613. * Set the value of an uniform to an array of int32 (stored as vec3)
  57614. * @param uniform defines the webGL uniform location where to store the value
  57615. * @param array defines the array of int32 to store
  57616. * @returns true if value was set
  57617. */
  57618. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57619. /**
  57620. * Set the value of an uniform to an array of int32 (stored as vec4)
  57621. * @param uniform defines the webGL uniform location where to store the value
  57622. * @param array defines the array of int32 to store
  57623. * @returns true if value was set
  57624. */
  57625. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57626. /**
  57627. * Set the value of an uniform to an array of float32
  57628. * @param uniform defines the webGL uniform location where to store the value
  57629. * @param array defines the array of float32 to store
  57630. * @returns true if value was set
  57631. */
  57632. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57633. /**
  57634. * Set the value of an uniform to an array of float32 (stored as vec2)
  57635. * @param uniform defines the webGL uniform location where to store the value
  57636. * @param array defines the array of float32 to store
  57637. * @returns true if value was set
  57638. */
  57639. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57640. /**
  57641. * Set the value of an uniform to an array of float32 (stored as vec3)
  57642. * @param uniform defines the webGL uniform location where to store the value
  57643. * @param array defines the array of float32 to store
  57644. * @returns true if value was set
  57645. */
  57646. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57647. /**
  57648. * Set the value of an uniform to an array of float32 (stored as vec4)
  57649. * @param uniform defines the webGL uniform location where to store the value
  57650. * @param array defines the array of float32 to store
  57651. * @returns true if value was set
  57652. */
  57653. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57654. /**
  57655. * Set the value of an uniform to an array of number
  57656. * @param uniform defines the webGL uniform location where to store the value
  57657. * @param array defines the array of number to store
  57658. * @returns true if value was set
  57659. */
  57660. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57661. /**
  57662. * Set the value of an uniform to an array of number (stored as vec2)
  57663. * @param uniform defines the webGL uniform location where to store the value
  57664. * @param array defines the array of number to store
  57665. * @returns true if value was set
  57666. */
  57667. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57668. /**
  57669. * Set the value of an uniform to an array of number (stored as vec3)
  57670. * @param uniform defines the webGL uniform location where to store the value
  57671. * @param array defines the array of number to store
  57672. * @returns true if value was set
  57673. */
  57674. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57675. /**
  57676. * Set the value of an uniform to an array of number (stored as vec4)
  57677. * @param uniform defines the webGL uniform location where to store the value
  57678. * @param array defines the array of number to store
  57679. * @returns true if value was set
  57680. */
  57681. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57682. /**
  57683. * Set the value of an uniform to an array of float32 (stored as matrices)
  57684. * @param uniform defines the webGL uniform location where to store the value
  57685. * @param matrices defines the array of float32 to store
  57686. * @returns true if value was set
  57687. */
  57688. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57689. /**
  57690. * Set the value of an uniform to a matrix (3x3)
  57691. * @param uniform defines the webGL uniform location where to store the value
  57692. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  57693. * @returns true if value was set
  57694. */
  57695. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57696. /**
  57697. * Set the value of an uniform to a matrix (2x2)
  57698. * @param uniform defines the webGL uniform location where to store the value
  57699. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  57700. * @returns true if value was set
  57701. */
  57702. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57703. /**
  57704. * Set the value of an uniform to a number (float)
  57705. * @param uniform defines the webGL uniform location where to store the value
  57706. * @param value defines the float number to store
  57707. * @returns true if value was set
  57708. */
  57709. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57710. /**
  57711. * Set the value of an uniform to a vec2
  57712. * @param uniform defines the webGL uniform location where to store the value
  57713. * @param x defines the 1st component of the value
  57714. * @param y defines the 2nd component of the value
  57715. * @returns true if value was set
  57716. */
  57717. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57718. /**
  57719. * Set the value of an uniform to a vec3
  57720. * @param uniform defines the webGL uniform location where to store the value
  57721. * @param x defines the 1st component of the value
  57722. * @param y defines the 2nd component of the value
  57723. * @param z defines the 3rd component of the value
  57724. * @returns true if value was set
  57725. */
  57726. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57727. /**
  57728. * Set the value of an uniform to a boolean
  57729. * @param uniform defines the webGL uniform location where to store the value
  57730. * @param bool defines the boolean to store
  57731. * @returns true if value was set
  57732. */
  57733. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  57734. /**
  57735. * Set the value of an uniform to a vec4
  57736. * @param uniform defines the webGL uniform location where to store the value
  57737. * @param x defines the 1st component of the value
  57738. * @param y defines the 2nd component of the value
  57739. * @param z defines the 3rd component of the value
  57740. * @param w defines the 4th component of the value
  57741. * @returns true if value was set
  57742. */
  57743. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57744. /**
  57745. * Sets the current alpha mode
  57746. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  57747. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57748. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57749. */
  57750. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57751. /**
  57752. * Bind webGl buffers directly to the webGL context
  57753. * @param vertexBuffers defines the vertex buffer to bind
  57754. * @param indexBuffer defines the index buffer to bind
  57755. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  57756. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  57757. * @param effect defines the effect associated with the vertex buffer
  57758. */
  57759. bindBuffers(vertexBuffers: {
  57760. [key: string]: VertexBuffer;
  57761. }, indexBuffer: DataBuffer, effect: Effect): void;
  57762. /**
  57763. * Force the entire cache to be cleared
  57764. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  57765. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  57766. */
  57767. wipeCaches(bruteForce?: boolean): void;
  57768. /**
  57769. * Send a draw order
  57770. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  57771. * @param indexStart defines the starting index
  57772. * @param indexCount defines the number of index to draw
  57773. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57774. */
  57775. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  57776. /**
  57777. * Draw a list of indexed primitives
  57778. * @param fillMode defines the primitive to use
  57779. * @param indexStart defines the starting index
  57780. * @param indexCount defines the number of index to draw
  57781. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57782. */
  57783. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57784. /**
  57785. * Draw a list of unindexed primitives
  57786. * @param fillMode defines the primitive to use
  57787. * @param verticesStart defines the index of first vertex to draw
  57788. * @param verticesCount defines the count of vertices to draw
  57789. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57790. */
  57791. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57792. /** @hidden */
  57793. _createTexture(): WebGLTexture;
  57794. /** @hidden */
  57795. _releaseTexture(texture: InternalTexture): void;
  57796. /**
  57797. * Usually called from Texture.ts.
  57798. * Passed information to create a WebGLTexture
  57799. * @param urlArg defines a value which contains one of the following:
  57800. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57801. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57802. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57803. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57804. * @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)
  57805. * @param scene needed for loading to the correct scene
  57806. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57807. * @param onLoad optional callback to be called upon successful completion
  57808. * @param onError optional callback to be called upon failure
  57809. * @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
  57810. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57811. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57812. * @param forcedExtension defines the extension to use to pick the right loader
  57813. * @param mimeType defines an optional mime type
  57814. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57815. */
  57816. 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;
  57817. /**
  57818. * Creates a new render target texture
  57819. * @param size defines the size of the texture
  57820. * @param options defines the options used to create the texture
  57821. * @returns a new render target texture stored in an InternalTexture
  57822. */
  57823. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  57824. /**
  57825. * Update the sampling mode of a given texture
  57826. * @param samplingMode defines the required sampling mode
  57827. * @param texture defines the texture to update
  57828. */
  57829. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57830. /**
  57831. * Binds the frame buffer to the specified texture.
  57832. * @param texture The texture to render to or null for the default canvas
  57833. * @param faceIndex The face of the texture to render to in case of cube texture
  57834. * @param requiredWidth The width of the target to render to
  57835. * @param requiredHeight The height of the target to render to
  57836. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  57837. * @param lodLevel defines le lod level to bind to the frame buffer
  57838. */
  57839. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57840. /**
  57841. * Unbind the current render target texture from the webGL context
  57842. * @param texture defines the render target texture to unbind
  57843. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  57844. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  57845. */
  57846. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57847. /**
  57848. * Creates a dynamic vertex buffer
  57849. * @param vertices the data for the dynamic vertex buffer
  57850. * @returns the new WebGL dynamic buffer
  57851. */
  57852. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  57853. /**
  57854. * Update the content of a dynamic texture
  57855. * @param texture defines the texture to update
  57856. * @param canvas defines the canvas containing the source
  57857. * @param invertY defines if data must be stored with Y axis inverted
  57858. * @param premulAlpha defines if alpha is stored as premultiplied
  57859. * @param format defines the format of the data
  57860. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57861. */
  57862. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57863. /**
  57864. * Gets a boolean indicating if all created effects are ready
  57865. * @returns true if all effects are ready
  57866. */
  57867. areAllEffectsReady(): boolean;
  57868. /**
  57869. * @hidden
  57870. * Get the current error code of the webGL context
  57871. * @returns the error code
  57872. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  57873. */
  57874. getError(): number;
  57875. /** @hidden */
  57876. _getUnpackAlignement(): number;
  57877. /** @hidden */
  57878. _unpackFlipY(value: boolean): void;
  57879. /**
  57880. * Update a dynamic index buffer
  57881. * @param indexBuffer defines the target index buffer
  57882. * @param indices defines the data to update
  57883. * @param offset defines the offset in the target index buffer where update should start
  57884. */
  57885. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  57886. /**
  57887. * Updates a dynamic vertex buffer.
  57888. * @param vertexBuffer the vertex buffer to update
  57889. * @param vertices the data used to update the vertex buffer
  57890. * @param byteOffset the byte offset of the data (optional)
  57891. * @param byteLength the byte length of the data (optional)
  57892. */
  57893. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  57894. /** @hidden */
  57895. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  57896. /** @hidden */
  57897. _bindTexture(channel: number, texture: InternalTexture): void;
  57898. protected _deleteBuffer(buffer: WebGLBuffer): void;
  57899. /**
  57900. * 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
  57901. */
  57902. releaseEffects(): void;
  57903. displayLoadingUI(): void;
  57904. hideLoadingUI(): void;
  57905. /** @hidden */
  57906. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57907. /** @hidden */
  57908. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57909. /** @hidden */
  57910. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57911. /** @hidden */
  57912. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57913. }
  57914. }
  57915. declare module "babylonjs/Instrumentation/timeToken" {
  57916. import { Nullable } from "babylonjs/types";
  57917. /**
  57918. * @hidden
  57919. **/
  57920. export class _TimeToken {
  57921. _startTimeQuery: Nullable<WebGLQuery>;
  57922. _endTimeQuery: Nullable<WebGLQuery>;
  57923. _timeElapsedQuery: Nullable<WebGLQuery>;
  57924. _timeElapsedQueryEnded: boolean;
  57925. }
  57926. }
  57927. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  57928. import { Nullable, int } from "babylonjs/types";
  57929. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  57930. /** @hidden */
  57931. export class _OcclusionDataStorage {
  57932. /** @hidden */
  57933. occlusionInternalRetryCounter: number;
  57934. /** @hidden */
  57935. isOcclusionQueryInProgress: boolean;
  57936. /** @hidden */
  57937. isOccluded: boolean;
  57938. /** @hidden */
  57939. occlusionRetryCount: number;
  57940. /** @hidden */
  57941. occlusionType: number;
  57942. /** @hidden */
  57943. occlusionQueryAlgorithmType: number;
  57944. }
  57945. module "babylonjs/Engines/engine" {
  57946. interface Engine {
  57947. /**
  57948. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  57949. * @return the new query
  57950. */
  57951. createQuery(): WebGLQuery;
  57952. /**
  57953. * Delete and release a webGL query
  57954. * @param query defines the query to delete
  57955. * @return the current engine
  57956. */
  57957. deleteQuery(query: WebGLQuery): Engine;
  57958. /**
  57959. * Check if a given query has resolved and got its value
  57960. * @param query defines the query to check
  57961. * @returns true if the query got its value
  57962. */
  57963. isQueryResultAvailable(query: WebGLQuery): boolean;
  57964. /**
  57965. * Gets the value of a given query
  57966. * @param query defines the query to check
  57967. * @returns the value of the query
  57968. */
  57969. getQueryResult(query: WebGLQuery): number;
  57970. /**
  57971. * Initiates an occlusion query
  57972. * @param algorithmType defines the algorithm to use
  57973. * @param query defines the query to use
  57974. * @returns the current engine
  57975. * @see https://doc.babylonjs.com/features/occlusionquery
  57976. */
  57977. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  57978. /**
  57979. * Ends an occlusion query
  57980. * @see https://doc.babylonjs.com/features/occlusionquery
  57981. * @param algorithmType defines the algorithm to use
  57982. * @returns the current engine
  57983. */
  57984. endOcclusionQuery(algorithmType: number): Engine;
  57985. /**
  57986. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  57987. * Please note that only one query can be issued at a time
  57988. * @returns a time token used to track the time span
  57989. */
  57990. startTimeQuery(): Nullable<_TimeToken>;
  57991. /**
  57992. * Ends a time query
  57993. * @param token defines the token used to measure the time span
  57994. * @returns the time spent (in ns)
  57995. */
  57996. endTimeQuery(token: _TimeToken): int;
  57997. /** @hidden */
  57998. _currentNonTimestampToken: Nullable<_TimeToken>;
  57999. /** @hidden */
  58000. _createTimeQuery(): WebGLQuery;
  58001. /** @hidden */
  58002. _deleteTimeQuery(query: WebGLQuery): void;
  58003. /** @hidden */
  58004. _getGlAlgorithmType(algorithmType: number): number;
  58005. /** @hidden */
  58006. _getTimeQueryResult(query: WebGLQuery): any;
  58007. /** @hidden */
  58008. _getTimeQueryAvailability(query: WebGLQuery): any;
  58009. }
  58010. }
  58011. module "babylonjs/Meshes/abstractMesh" {
  58012. interface AbstractMesh {
  58013. /**
  58014. * Backing filed
  58015. * @hidden
  58016. */
  58017. __occlusionDataStorage: _OcclusionDataStorage;
  58018. /**
  58019. * Access property
  58020. * @hidden
  58021. */
  58022. _occlusionDataStorage: _OcclusionDataStorage;
  58023. /**
  58024. * 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.
  58025. * The default value is -1 which means don't break the query and wait till the result
  58026. * @see https://doc.babylonjs.com/features/occlusionquery
  58027. */
  58028. occlusionRetryCount: number;
  58029. /**
  58030. * 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:
  58031. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  58032. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  58033. * * 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.
  58034. * @see https://doc.babylonjs.com/features/occlusionquery
  58035. */
  58036. occlusionType: number;
  58037. /**
  58038. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  58039. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  58040. * * 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.
  58041. * @see https://doc.babylonjs.com/features/occlusionquery
  58042. */
  58043. occlusionQueryAlgorithmType: number;
  58044. /**
  58045. * 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
  58046. * @see https://doc.babylonjs.com/features/occlusionquery
  58047. */
  58048. isOccluded: boolean;
  58049. /**
  58050. * Flag to check the progress status of the query
  58051. * @see https://doc.babylonjs.com/features/occlusionquery
  58052. */
  58053. isOcclusionQueryInProgress: boolean;
  58054. }
  58055. }
  58056. }
  58057. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  58058. import { Nullable } from "babylonjs/types";
  58059. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58060. /** @hidden */
  58061. export var _forceTransformFeedbackToBundle: boolean;
  58062. module "babylonjs/Engines/engine" {
  58063. interface Engine {
  58064. /**
  58065. * Creates a webGL transform feedback object
  58066. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  58067. * @returns the webGL transform feedback object
  58068. */
  58069. createTransformFeedback(): WebGLTransformFeedback;
  58070. /**
  58071. * Delete a webGL transform feedback object
  58072. * @param value defines the webGL transform feedback object to delete
  58073. */
  58074. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  58075. /**
  58076. * Bind a webGL transform feedback object to the webgl context
  58077. * @param value defines the webGL transform feedback object to bind
  58078. */
  58079. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  58080. /**
  58081. * Begins a transform feedback operation
  58082. * @param usePoints defines if points or triangles must be used
  58083. */
  58084. beginTransformFeedback(usePoints: boolean): void;
  58085. /**
  58086. * Ends a transform feedback operation
  58087. */
  58088. endTransformFeedback(): void;
  58089. /**
  58090. * Specify the varyings to use with transform feedback
  58091. * @param program defines the associated webGL program
  58092. * @param value defines the list of strings representing the varying names
  58093. */
  58094. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  58095. /**
  58096. * Bind a webGL buffer for a transform feedback operation
  58097. * @param value defines the webGL buffer to bind
  58098. */
  58099. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  58100. }
  58101. }
  58102. }
  58103. declare module "babylonjs/Engines/Extensions/engine.views" {
  58104. import { Camera } from "babylonjs/Cameras/camera";
  58105. import { Nullable } from "babylonjs/types";
  58106. /**
  58107. * Class used to define an additional view for the engine
  58108. * @see https://doc.babylonjs.com/how_to/multi_canvases
  58109. */
  58110. export class EngineView {
  58111. /** Defines the canvas where to render the view */
  58112. target: HTMLCanvasElement;
  58113. /** Defines an optional camera used to render the view (will use active camera else) */
  58114. camera?: Camera;
  58115. }
  58116. module "babylonjs/Engines/engine" {
  58117. interface Engine {
  58118. /**
  58119. * Gets or sets the HTML element to use for attaching events
  58120. */
  58121. inputElement: Nullable<HTMLElement>;
  58122. /**
  58123. * Gets the current engine view
  58124. * @see https://doc.babylonjs.com/how_to/multi_canvases
  58125. */
  58126. activeView: Nullable<EngineView>;
  58127. /** Gets or sets the list of views */
  58128. views: EngineView[];
  58129. /**
  58130. * Register a new child canvas
  58131. * @param canvas defines the canvas to register
  58132. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  58133. * @returns the associated view
  58134. */
  58135. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  58136. /**
  58137. * Remove a registered child canvas
  58138. * @param canvas defines the canvas to remove
  58139. * @returns the current engine
  58140. */
  58141. unRegisterView(canvas: HTMLCanvasElement): Engine;
  58142. }
  58143. }
  58144. }
  58145. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  58146. import { Nullable } from "babylonjs/types";
  58147. module "babylonjs/Engines/engine" {
  58148. interface Engine {
  58149. /** @hidden */
  58150. _excludedCompressedTextures: string[];
  58151. /** @hidden */
  58152. _textureFormatInUse: string;
  58153. /**
  58154. * Gets the list of texture formats supported
  58155. */
  58156. readonly texturesSupported: Array<string>;
  58157. /**
  58158. * Gets the texture format in use
  58159. */
  58160. readonly textureFormatInUse: Nullable<string>;
  58161. /**
  58162. * Set the compressed texture extensions or file names to skip.
  58163. *
  58164. * @param skippedFiles defines the list of those texture files you want to skip
  58165. * Example: [".dds", ".env", "myfile.png"]
  58166. */
  58167. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  58168. /**
  58169. * Set the compressed texture format to use, based on the formats you have, and the formats
  58170. * supported by the hardware / browser.
  58171. *
  58172. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  58173. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  58174. * to API arguments needed to compressed textures. This puts the burden on the container
  58175. * generator to house the arcane code for determining these for current & future formats.
  58176. *
  58177. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58178. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58179. *
  58180. * Note: The result of this call is not taken into account when a texture is base64.
  58181. *
  58182. * @param formatsAvailable defines the list of those format families you have created
  58183. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  58184. *
  58185. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  58186. * @returns The extension selected.
  58187. */
  58188. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  58189. }
  58190. }
  58191. }
  58192. declare module "babylonjs/Engines/Extensions/index" {
  58193. export * from "babylonjs/Engines/Extensions/engine.alpha";
  58194. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  58195. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  58196. export * from "babylonjs/Engines/Extensions/engine.multiview";
  58197. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  58198. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58199. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  58200. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  58201. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  58202. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  58203. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  58204. export * from "babylonjs/Engines/Extensions/engine.webVR";
  58205. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  58206. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  58207. export * from "babylonjs/Engines/Extensions/engine.views";
  58208. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  58209. import "babylonjs/Engines/Extensions/engine.textureSelector";
  58210. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  58211. }
  58212. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  58213. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58214. /** @hidden */
  58215. export var rgbdEncodePixelShader: {
  58216. name: string;
  58217. shader: string;
  58218. };
  58219. }
  58220. declare module "babylonjs/Misc/environmentTextureTools" {
  58221. import { Nullable } from "babylonjs/types";
  58222. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58223. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58224. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58225. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  58226. import "babylonjs/Engines/Extensions/engine.readTexture";
  58227. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58228. import "babylonjs/Shaders/rgbdEncode.fragment";
  58229. import "babylonjs/Shaders/rgbdDecode.fragment";
  58230. /**
  58231. * Raw texture data and descriptor sufficient for WebGL texture upload
  58232. */
  58233. export interface EnvironmentTextureInfo {
  58234. /**
  58235. * Version of the environment map
  58236. */
  58237. version: number;
  58238. /**
  58239. * Width of image
  58240. */
  58241. width: number;
  58242. /**
  58243. * Irradiance information stored in the file.
  58244. */
  58245. irradiance: any;
  58246. /**
  58247. * Specular information stored in the file.
  58248. */
  58249. specular: any;
  58250. }
  58251. /**
  58252. * Defines One Image in the file. It requires only the position in the file
  58253. * as well as the length.
  58254. */
  58255. interface BufferImageData {
  58256. /**
  58257. * Length of the image data.
  58258. */
  58259. length: number;
  58260. /**
  58261. * Position of the data from the null terminator delimiting the end of the JSON.
  58262. */
  58263. position: number;
  58264. }
  58265. /**
  58266. * Defines the specular data enclosed in the file.
  58267. * This corresponds to the version 1 of the data.
  58268. */
  58269. export interface EnvironmentTextureSpecularInfoV1 {
  58270. /**
  58271. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  58272. */
  58273. specularDataPosition?: number;
  58274. /**
  58275. * This contains all the images data needed to reconstruct the cubemap.
  58276. */
  58277. mipmaps: Array<BufferImageData>;
  58278. /**
  58279. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  58280. */
  58281. lodGenerationScale: number;
  58282. }
  58283. /**
  58284. * Sets of helpers addressing the serialization and deserialization of environment texture
  58285. * stored in a BabylonJS env file.
  58286. * Those files are usually stored as .env files.
  58287. */
  58288. export class EnvironmentTextureTools {
  58289. /**
  58290. * Magic number identifying the env file.
  58291. */
  58292. private static _MagicBytes;
  58293. /**
  58294. * Gets the environment info from an env file.
  58295. * @param data The array buffer containing the .env bytes.
  58296. * @returns the environment file info (the json header) if successfully parsed.
  58297. */
  58298. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  58299. /**
  58300. * Creates an environment texture from a loaded cube texture.
  58301. * @param texture defines the cube texture to convert in env file
  58302. * @return a promise containing the environment data if succesfull.
  58303. */
  58304. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  58305. /**
  58306. * Creates a JSON representation of the spherical data.
  58307. * @param texture defines the texture containing the polynomials
  58308. * @return the JSON representation of the spherical info
  58309. */
  58310. private static _CreateEnvTextureIrradiance;
  58311. /**
  58312. * Creates the ArrayBufferViews used for initializing environment texture image data.
  58313. * @param data the image data
  58314. * @param info parameters that determine what views will be created for accessing the underlying buffer
  58315. * @return the views described by info providing access to the underlying buffer
  58316. */
  58317. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  58318. /**
  58319. * Uploads the texture info contained in the env file to the GPU.
  58320. * @param texture defines the internal texture to upload to
  58321. * @param data defines the data to load
  58322. * @param info defines the texture info retrieved through the GetEnvInfo method
  58323. * @returns a promise
  58324. */
  58325. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  58326. private static _OnImageReadyAsync;
  58327. /**
  58328. * Uploads the levels of image data to the GPU.
  58329. * @param texture defines the internal texture to upload to
  58330. * @param imageData defines the array buffer views of image data [mipmap][face]
  58331. * @returns a promise
  58332. */
  58333. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  58334. /**
  58335. * Uploads spherical polynomials information to the texture.
  58336. * @param texture defines the texture we are trying to upload the information to
  58337. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  58338. */
  58339. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  58340. /** @hidden */
  58341. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58342. }
  58343. }
  58344. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  58345. /**
  58346. * Class used to inline functions in shader code
  58347. */
  58348. export class ShaderCodeInliner {
  58349. private static readonly _RegexpFindFunctionNameAndType;
  58350. private _sourceCode;
  58351. private _functionDescr;
  58352. private _numMaxIterations;
  58353. /** Gets or sets the token used to mark the functions to inline */
  58354. inlineToken: string;
  58355. /** Gets or sets the debug mode */
  58356. debug: boolean;
  58357. /** Gets the code after the inlining process */
  58358. get code(): string;
  58359. /**
  58360. * Initializes the inliner
  58361. * @param sourceCode shader code source to inline
  58362. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  58363. */
  58364. constructor(sourceCode: string, numMaxIterations?: number);
  58365. /**
  58366. * Start the processing of the shader code
  58367. */
  58368. processCode(): void;
  58369. private _collectFunctions;
  58370. private _processInlining;
  58371. private _extractBetweenMarkers;
  58372. private _skipWhitespaces;
  58373. private _removeComments;
  58374. private _replaceFunctionCallsByCode;
  58375. private _findBackward;
  58376. private _escapeRegExp;
  58377. private _replaceNames;
  58378. }
  58379. }
  58380. declare module "babylonjs/Engines/nativeEngine" {
  58381. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  58382. import { Engine } from "babylonjs/Engines/engine";
  58383. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  58384. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58385. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58386. import { Effect } from "babylonjs/Materials/effect";
  58387. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58388. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  58389. import { IColor4Like } from "babylonjs/Maths/math.like";
  58390. import { Scene } from "babylonjs/scene";
  58391. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  58392. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  58393. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  58394. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  58395. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  58396. /**
  58397. * Container for accessors for natively-stored mesh data buffers.
  58398. */
  58399. class NativeDataBuffer extends DataBuffer {
  58400. /**
  58401. * Accessor value used to identify/retrieve a natively-stored index buffer.
  58402. */
  58403. nativeIndexBuffer?: any;
  58404. /**
  58405. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  58406. */
  58407. nativeVertexBuffer?: any;
  58408. }
  58409. /** @hidden */
  58410. class NativeTexture extends InternalTexture {
  58411. getInternalTexture(): InternalTexture;
  58412. getViewCount(): number;
  58413. }
  58414. /** @hidden */
  58415. export class NativeEngine extends Engine {
  58416. private readonly _native;
  58417. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  58418. private readonly INVALID_HANDLE;
  58419. private _boundBuffersVertexArray;
  58420. private _currentDepthTest;
  58421. getHardwareScalingLevel(): number;
  58422. constructor();
  58423. dispose(): void;
  58424. /**
  58425. * Can be used to override the current requestAnimationFrame requester.
  58426. * @hidden
  58427. */
  58428. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  58429. /**
  58430. * Override default engine behavior.
  58431. * @param color
  58432. * @param backBuffer
  58433. * @param depth
  58434. * @param stencil
  58435. */
  58436. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  58437. /**
  58438. * Gets host document
  58439. * @returns the host document object
  58440. */
  58441. getHostDocument(): Nullable<Document>;
  58442. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58443. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  58444. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  58445. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  58446. [key: string]: VertexBuffer;
  58447. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58448. bindBuffers(vertexBuffers: {
  58449. [key: string]: VertexBuffer;
  58450. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58451. recordVertexArrayObject(vertexBuffers: {
  58452. [key: string]: VertexBuffer;
  58453. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  58454. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58455. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58456. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58457. /**
  58458. * Draw a list of indexed primitives
  58459. * @param fillMode defines the primitive to use
  58460. * @param indexStart defines the starting index
  58461. * @param indexCount defines the number of index to draw
  58462. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58463. */
  58464. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58465. /**
  58466. * Draw a list of unindexed primitives
  58467. * @param fillMode defines the primitive to use
  58468. * @param verticesStart defines the index of first vertex to draw
  58469. * @param verticesCount defines the count of vertices to draw
  58470. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58471. */
  58472. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58473. createPipelineContext(): IPipelineContext;
  58474. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  58475. /** @hidden */
  58476. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  58477. /** @hidden */
  58478. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  58479. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58480. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58481. protected _setProgram(program: WebGLProgram): void;
  58482. _releaseEffect(effect: Effect): void;
  58483. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  58484. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  58485. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  58486. bindSamplers(effect: Effect): void;
  58487. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  58488. getRenderWidth(useScreen?: boolean): number;
  58489. getRenderHeight(useScreen?: boolean): number;
  58490. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  58491. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58492. /**
  58493. * Set the z offset to apply to current rendering
  58494. * @param value defines the offset to apply
  58495. */
  58496. setZOffset(value: number): void;
  58497. /**
  58498. * Gets the current value of the zOffset
  58499. * @returns the current zOffset state
  58500. */
  58501. getZOffset(): number;
  58502. /**
  58503. * Enable or disable depth buffering
  58504. * @param enable defines the state to set
  58505. */
  58506. setDepthBuffer(enable: boolean): void;
  58507. /**
  58508. * Gets a boolean indicating if depth writing is enabled
  58509. * @returns the current depth writing state
  58510. */
  58511. getDepthWrite(): boolean;
  58512. setDepthFunctionToGreater(): void;
  58513. setDepthFunctionToGreaterOrEqual(): void;
  58514. setDepthFunctionToLess(): void;
  58515. setDepthFunctionToLessOrEqual(): void;
  58516. /**
  58517. * Enable or disable depth writing
  58518. * @param enable defines the state to set
  58519. */
  58520. setDepthWrite(enable: boolean): void;
  58521. /**
  58522. * Enable or disable color writing
  58523. * @param enable defines the state to set
  58524. */
  58525. setColorWrite(enable: boolean): void;
  58526. /**
  58527. * Gets a boolean indicating if color writing is enabled
  58528. * @returns the current color writing state
  58529. */
  58530. getColorWrite(): boolean;
  58531. /**
  58532. * Sets alpha constants used by some alpha blending modes
  58533. * @param r defines the red component
  58534. * @param g defines the green component
  58535. * @param b defines the blue component
  58536. * @param a defines the alpha component
  58537. */
  58538. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  58539. /**
  58540. * Sets the current alpha mode
  58541. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  58542. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58543. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58544. */
  58545. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58546. /**
  58547. * Gets the current alpha mode
  58548. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58549. * @returns the current alpha mode
  58550. */
  58551. getAlphaMode(): number;
  58552. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  58553. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58554. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58555. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58556. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58557. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58558. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58559. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58560. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58561. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58562. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58563. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58564. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58565. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58566. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58567. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58568. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58569. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58570. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58571. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58572. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  58573. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  58574. wipeCaches(bruteForce?: boolean): void;
  58575. _createTexture(): WebGLTexture;
  58576. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  58577. /**
  58578. * Update the content of a dynamic texture
  58579. * @param texture defines the texture to update
  58580. * @param canvas defines the canvas containing the source
  58581. * @param invertY defines if data must be stored with Y axis inverted
  58582. * @param premulAlpha defines if alpha is stored as premultiplied
  58583. * @param format defines the format of the data
  58584. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58585. */
  58586. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58587. /**
  58588. * Usually called from Texture.ts.
  58589. * Passed information to create a WebGLTexture
  58590. * @param url defines a value which contains one of the following:
  58591. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58592. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58593. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58594. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58595. * @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)
  58596. * @param scene needed for loading to the correct scene
  58597. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58598. * @param onLoad optional callback to be called upon successful completion
  58599. * @param onError optional callback to be called upon failure
  58600. * @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
  58601. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58602. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58603. * @param forcedExtension defines the extension to use to pick the right loader
  58604. * @param mimeType defines an optional mime type
  58605. * @param loaderOptions options to be passed to the loader
  58606. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58607. */
  58608. 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;
  58609. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  58610. _releaseFramebufferObjects(texture: InternalTexture): void;
  58611. /**
  58612. * Creates a cube texture
  58613. * @param rootUrl defines the url where the files to load is located
  58614. * @param scene defines the current scene
  58615. * @param files defines the list of files to load (1 per face)
  58616. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  58617. * @param onLoad defines an optional callback raised when the texture is loaded
  58618. * @param onError defines an optional callback raised if there is an issue to load the texture
  58619. * @param format defines the format of the data
  58620. * @param forcedExtension defines the extension to use to pick the right loader
  58621. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  58622. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58623. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58624. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  58625. * @returns the cube texture as an InternalTexture
  58626. */
  58627. 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;
  58628. createRenderTargetTexture(size: number | {
  58629. width: number;
  58630. height: number;
  58631. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  58632. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58633. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58634. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58635. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  58636. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  58637. /**
  58638. * Updates a dynamic vertex buffer.
  58639. * @param vertexBuffer the vertex buffer to update
  58640. * @param data the data used to update the vertex buffer
  58641. * @param byteOffset the byte offset of the data (optional)
  58642. * @param byteLength the byte length of the data (optional)
  58643. */
  58644. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  58645. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  58646. private _updateAnisotropicLevel;
  58647. private _getAddressMode;
  58648. /** @hidden */
  58649. _bindTexture(channel: number, texture: InternalTexture): void;
  58650. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  58651. releaseEffects(): void;
  58652. /** @hidden */
  58653. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58654. /** @hidden */
  58655. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58656. /** @hidden */
  58657. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58658. /** @hidden */
  58659. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  58660. private _getNativeSamplingMode;
  58661. private _getNativeTextureFormat;
  58662. private _getNativeAlphaMode;
  58663. private _getNativeAttribType;
  58664. }
  58665. }
  58666. declare module "babylonjs/Engines/index" {
  58667. export * from "babylonjs/Engines/constants";
  58668. export * from "babylonjs/Engines/engineCapabilities";
  58669. export * from "babylonjs/Engines/instancingAttributeInfo";
  58670. export * from "babylonjs/Engines/thinEngine";
  58671. export * from "babylonjs/Engines/engine";
  58672. export * from "babylonjs/Engines/engineStore";
  58673. export * from "babylonjs/Engines/nullEngine";
  58674. export * from "babylonjs/Engines/Extensions/index";
  58675. export * from "babylonjs/Engines/IPipelineContext";
  58676. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  58677. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  58678. export * from "babylonjs/Engines/nativeEngine";
  58679. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  58680. export * from "babylonjs/Engines/performanceConfigurator";
  58681. }
  58682. declare module "babylonjs/Events/clipboardEvents" {
  58683. /**
  58684. * Gather the list of clipboard event types as constants.
  58685. */
  58686. export class ClipboardEventTypes {
  58687. /**
  58688. * The clipboard event is fired when a copy command is active (pressed).
  58689. */
  58690. static readonly COPY: number;
  58691. /**
  58692. * The clipboard event is fired when a cut command is active (pressed).
  58693. */
  58694. static readonly CUT: number;
  58695. /**
  58696. * The clipboard event is fired when a paste command is active (pressed).
  58697. */
  58698. static readonly PASTE: number;
  58699. }
  58700. /**
  58701. * This class is used to store clipboard related info for the onClipboardObservable event.
  58702. */
  58703. export class ClipboardInfo {
  58704. /**
  58705. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58706. */
  58707. type: number;
  58708. /**
  58709. * Defines the related dom event
  58710. */
  58711. event: ClipboardEvent;
  58712. /**
  58713. *Creates an instance of ClipboardInfo.
  58714. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  58715. * @param event Defines the related dom event
  58716. */
  58717. constructor(
  58718. /**
  58719. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58720. */
  58721. type: number,
  58722. /**
  58723. * Defines the related dom event
  58724. */
  58725. event: ClipboardEvent);
  58726. /**
  58727. * Get the clipboard event's type from the keycode.
  58728. * @param keyCode Defines the keyCode for the current keyboard event.
  58729. * @return {number}
  58730. */
  58731. static GetTypeFromCharacter(keyCode: number): number;
  58732. }
  58733. }
  58734. declare module "babylonjs/Events/index" {
  58735. export * from "babylonjs/Events/keyboardEvents";
  58736. export * from "babylonjs/Events/pointerEvents";
  58737. export * from "babylonjs/Events/clipboardEvents";
  58738. }
  58739. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  58740. import { Scene } from "babylonjs/scene";
  58741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58742. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58743. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58744. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58745. /**
  58746. * Google Daydream controller
  58747. */
  58748. export class DaydreamController extends WebVRController {
  58749. /**
  58750. * Base Url for the controller model.
  58751. */
  58752. static MODEL_BASE_URL: string;
  58753. /**
  58754. * File name for the controller model.
  58755. */
  58756. static MODEL_FILENAME: string;
  58757. /**
  58758. * Gamepad Id prefix used to identify Daydream Controller.
  58759. */
  58760. static readonly GAMEPAD_ID_PREFIX: string;
  58761. /**
  58762. * Creates a new DaydreamController from a gamepad
  58763. * @param vrGamepad the gamepad that the controller should be created from
  58764. */
  58765. constructor(vrGamepad: any);
  58766. /**
  58767. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58768. * @param scene scene in which to add meshes
  58769. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58770. */
  58771. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58772. /**
  58773. * Called once for each button that changed state since the last frame
  58774. * @param buttonIdx Which button index changed
  58775. * @param state New state of the button
  58776. * @param changes Which properties on the state changed since last frame
  58777. */
  58778. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58779. }
  58780. }
  58781. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  58782. import { Scene } from "babylonjs/scene";
  58783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58784. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58785. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58786. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58787. /**
  58788. * Gear VR Controller
  58789. */
  58790. export class GearVRController extends WebVRController {
  58791. /**
  58792. * Base Url for the controller model.
  58793. */
  58794. static MODEL_BASE_URL: string;
  58795. /**
  58796. * File name for the controller model.
  58797. */
  58798. static MODEL_FILENAME: string;
  58799. /**
  58800. * Gamepad Id prefix used to identify this controller.
  58801. */
  58802. static readonly GAMEPAD_ID_PREFIX: string;
  58803. private readonly _buttonIndexToObservableNameMap;
  58804. /**
  58805. * Creates a new GearVRController from a gamepad
  58806. * @param vrGamepad the gamepad that the controller should be created from
  58807. */
  58808. constructor(vrGamepad: any);
  58809. /**
  58810. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58811. * @param scene scene in which to add meshes
  58812. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58813. */
  58814. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58815. /**
  58816. * Called once for each button that changed state since the last frame
  58817. * @param buttonIdx Which button index changed
  58818. * @param state New state of the button
  58819. * @param changes Which properties on the state changed since last frame
  58820. */
  58821. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58822. }
  58823. }
  58824. declare module "babylonjs/Gamepads/Controllers/genericController" {
  58825. import { Scene } from "babylonjs/scene";
  58826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58827. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58828. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58829. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58830. /**
  58831. * Generic Controller
  58832. */
  58833. export class GenericController extends WebVRController {
  58834. /**
  58835. * Base Url for the controller model.
  58836. */
  58837. static readonly MODEL_BASE_URL: string;
  58838. /**
  58839. * File name for the controller model.
  58840. */
  58841. static readonly MODEL_FILENAME: string;
  58842. /**
  58843. * Creates a new GenericController from a gamepad
  58844. * @param vrGamepad the gamepad that the controller should be created from
  58845. */
  58846. constructor(vrGamepad: any);
  58847. /**
  58848. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58849. * @param scene scene in which to add meshes
  58850. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58851. */
  58852. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58853. /**
  58854. * Called once for each button that changed state since the last frame
  58855. * @param buttonIdx Which button index changed
  58856. * @param state New state of the button
  58857. * @param changes Which properties on the state changed since last frame
  58858. */
  58859. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58860. }
  58861. }
  58862. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  58863. import { Observable } from "babylonjs/Misc/observable";
  58864. import { Scene } from "babylonjs/scene";
  58865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58866. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58867. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58868. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58869. /**
  58870. * Oculus Touch Controller
  58871. */
  58872. export class OculusTouchController extends WebVRController {
  58873. /**
  58874. * Base Url for the controller model.
  58875. */
  58876. static MODEL_BASE_URL: string;
  58877. /**
  58878. * File name for the left controller model.
  58879. */
  58880. static MODEL_LEFT_FILENAME: string;
  58881. /**
  58882. * File name for the right controller model.
  58883. */
  58884. static MODEL_RIGHT_FILENAME: string;
  58885. /**
  58886. * Base Url for the Quest controller model.
  58887. */
  58888. static QUEST_MODEL_BASE_URL: string;
  58889. /**
  58890. * @hidden
  58891. * If the controllers are running on a device that needs the updated Quest controller models
  58892. */
  58893. static _IsQuest: boolean;
  58894. /**
  58895. * Fired when the secondary trigger on this controller is modified
  58896. */
  58897. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  58898. /**
  58899. * Fired when the thumb rest on this controller is modified
  58900. */
  58901. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  58902. /**
  58903. * Creates a new OculusTouchController from a gamepad
  58904. * @param vrGamepad the gamepad that the controller should be created from
  58905. */
  58906. constructor(vrGamepad: any);
  58907. /**
  58908. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58909. * @param scene scene in which to add meshes
  58910. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58911. */
  58912. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58913. /**
  58914. * Fired when the A button on this controller is modified
  58915. */
  58916. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58917. /**
  58918. * Fired when the B button on this controller is modified
  58919. */
  58920. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58921. /**
  58922. * Fired when the X button on this controller is modified
  58923. */
  58924. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58925. /**
  58926. * Fired when the Y button on this controller is modified
  58927. */
  58928. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58929. /**
  58930. * Called once for each button that changed state since the last frame
  58931. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  58932. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  58933. * 2) secondary trigger (same)
  58934. * 3) A (right) X (left), touch, pressed = value
  58935. * 4) B / Y
  58936. * 5) thumb rest
  58937. * @param buttonIdx Which button index changed
  58938. * @param state New state of the button
  58939. * @param changes Which properties on the state changed since last frame
  58940. */
  58941. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58942. }
  58943. }
  58944. declare module "babylonjs/Gamepads/Controllers/viveController" {
  58945. import { Scene } from "babylonjs/scene";
  58946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58947. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58948. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58949. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58950. import { Observable } from "babylonjs/Misc/observable";
  58951. /**
  58952. * Vive Controller
  58953. */
  58954. export class ViveController extends WebVRController {
  58955. /**
  58956. * Base Url for the controller model.
  58957. */
  58958. static MODEL_BASE_URL: string;
  58959. /**
  58960. * File name for the controller model.
  58961. */
  58962. static MODEL_FILENAME: string;
  58963. /**
  58964. * Creates a new ViveController from a gamepad
  58965. * @param vrGamepad the gamepad that the controller should be created from
  58966. */
  58967. constructor(vrGamepad: any);
  58968. /**
  58969. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58970. * @param scene scene in which to add meshes
  58971. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58972. */
  58973. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58974. /**
  58975. * Fired when the left button on this controller is modified
  58976. */
  58977. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58978. /**
  58979. * Fired when the right button on this controller is modified
  58980. */
  58981. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58982. /**
  58983. * Fired when the menu button on this controller is modified
  58984. */
  58985. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58986. /**
  58987. * Called once for each button that changed state since the last frame
  58988. * Vive mapping:
  58989. * 0: touchpad
  58990. * 1: trigger
  58991. * 2: left AND right buttons
  58992. * 3: menu button
  58993. * @param buttonIdx Which button index changed
  58994. * @param state New state of the button
  58995. * @param changes Which properties on the state changed since last frame
  58996. */
  58997. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58998. }
  58999. }
  59000. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  59001. import { Observable } from "babylonjs/Misc/observable";
  59002. import { Scene } from "babylonjs/scene";
  59003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59004. import { Ray } from "babylonjs/Culling/ray";
  59005. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59006. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59007. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59008. /**
  59009. * Defines the WindowsMotionController object that the state of the windows motion controller
  59010. */
  59011. export class WindowsMotionController extends WebVRController {
  59012. /**
  59013. * The base url used to load the left and right controller models
  59014. */
  59015. static MODEL_BASE_URL: string;
  59016. /**
  59017. * The name of the left controller model file
  59018. */
  59019. static MODEL_LEFT_FILENAME: string;
  59020. /**
  59021. * The name of the right controller model file
  59022. */
  59023. static MODEL_RIGHT_FILENAME: string;
  59024. /**
  59025. * The controller name prefix for this controller type
  59026. */
  59027. static readonly GAMEPAD_ID_PREFIX: string;
  59028. /**
  59029. * The controller id pattern for this controller type
  59030. */
  59031. private static readonly GAMEPAD_ID_PATTERN;
  59032. private _loadedMeshInfo;
  59033. protected readonly _mapping: {
  59034. buttons: string[];
  59035. buttonMeshNames: {
  59036. trigger: string;
  59037. menu: string;
  59038. grip: string;
  59039. thumbstick: string;
  59040. trackpad: string;
  59041. };
  59042. buttonObservableNames: {
  59043. trigger: string;
  59044. menu: string;
  59045. grip: string;
  59046. thumbstick: string;
  59047. trackpad: string;
  59048. };
  59049. axisMeshNames: string[];
  59050. pointingPoseMeshName: string;
  59051. };
  59052. /**
  59053. * Fired when the trackpad on this controller is clicked
  59054. */
  59055. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  59056. /**
  59057. * Fired when the trackpad on this controller is modified
  59058. */
  59059. onTrackpadValuesChangedObservable: Observable<StickValues>;
  59060. /**
  59061. * The current x and y values of this controller's trackpad
  59062. */
  59063. trackpad: StickValues;
  59064. /**
  59065. * Creates a new WindowsMotionController from a gamepad
  59066. * @param vrGamepad the gamepad that the controller should be created from
  59067. */
  59068. constructor(vrGamepad: any);
  59069. /**
  59070. * Fired when the trigger on this controller is modified
  59071. */
  59072. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59073. /**
  59074. * Fired when the menu button on this controller is modified
  59075. */
  59076. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59077. /**
  59078. * Fired when the grip button on this controller is modified
  59079. */
  59080. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59081. /**
  59082. * Fired when the thumbstick button on this controller is modified
  59083. */
  59084. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59085. /**
  59086. * Fired when the touchpad button on this controller is modified
  59087. */
  59088. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59089. /**
  59090. * Fired when the touchpad values on this controller are modified
  59091. */
  59092. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  59093. protected _updateTrackpad(): void;
  59094. /**
  59095. * Called once per frame by the engine.
  59096. */
  59097. update(): void;
  59098. /**
  59099. * Called once for each button that changed state since the last frame
  59100. * @param buttonIdx Which button index changed
  59101. * @param state New state of the button
  59102. * @param changes Which properties on the state changed since last frame
  59103. */
  59104. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59105. /**
  59106. * Moves the buttons on the controller mesh based on their current state
  59107. * @param buttonName the name of the button to move
  59108. * @param buttonValue the value of the button which determines the buttons new position
  59109. */
  59110. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  59111. /**
  59112. * Moves the axis on the controller mesh based on its current state
  59113. * @param axis the index of the axis
  59114. * @param axisValue the value of the axis which determines the meshes new position
  59115. * @hidden
  59116. */
  59117. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  59118. /**
  59119. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59120. * @param scene scene in which to add meshes
  59121. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59122. */
  59123. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  59124. /**
  59125. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  59126. * can be transformed by button presses and axes values, based on this._mapping.
  59127. *
  59128. * @param scene scene in which the meshes exist
  59129. * @param meshes list of meshes that make up the controller model to process
  59130. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  59131. */
  59132. private processModel;
  59133. private createMeshInfo;
  59134. /**
  59135. * Gets the ray of the controller in the direction the controller is pointing
  59136. * @param length the length the resulting ray should be
  59137. * @returns a ray in the direction the controller is pointing
  59138. */
  59139. getForwardRay(length?: number): Ray;
  59140. /**
  59141. * Disposes of the controller
  59142. */
  59143. dispose(): void;
  59144. }
  59145. /**
  59146. * This class represents a new windows motion controller in XR.
  59147. */
  59148. export class XRWindowsMotionController extends WindowsMotionController {
  59149. /**
  59150. * Changing the original WIndowsMotionController mapping to fir the new mapping
  59151. */
  59152. protected readonly _mapping: {
  59153. buttons: string[];
  59154. buttonMeshNames: {
  59155. trigger: string;
  59156. menu: string;
  59157. grip: string;
  59158. thumbstick: string;
  59159. trackpad: string;
  59160. };
  59161. buttonObservableNames: {
  59162. trigger: string;
  59163. menu: string;
  59164. grip: string;
  59165. thumbstick: string;
  59166. trackpad: string;
  59167. };
  59168. axisMeshNames: string[];
  59169. pointingPoseMeshName: string;
  59170. };
  59171. /**
  59172. * Construct a new XR-Based windows motion controller
  59173. *
  59174. * @param gamepadInfo the gamepad object from the browser
  59175. */
  59176. constructor(gamepadInfo: any);
  59177. /**
  59178. * holds the thumbstick values (X,Y)
  59179. */
  59180. thumbstickValues: StickValues;
  59181. /**
  59182. * Fired when the thumbstick on this controller is clicked
  59183. */
  59184. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  59185. /**
  59186. * Fired when the thumbstick on this controller is modified
  59187. */
  59188. onThumbstickValuesChangedObservable: Observable<StickValues>;
  59189. /**
  59190. * Fired when the touchpad button on this controller is modified
  59191. */
  59192. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  59193. /**
  59194. * Fired when the touchpad values on this controller are modified
  59195. */
  59196. onTrackpadValuesChangedObservable: Observable<StickValues>;
  59197. /**
  59198. * Fired when the thumbstick button on this controller is modified
  59199. * here to prevent breaking changes
  59200. */
  59201. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59202. /**
  59203. * updating the thumbstick(!) and not the trackpad.
  59204. * This is named this way due to the difference between WebVR and XR and to avoid
  59205. * changing the parent class.
  59206. */
  59207. protected _updateTrackpad(): void;
  59208. /**
  59209. * Disposes the class with joy
  59210. */
  59211. dispose(): void;
  59212. }
  59213. }
  59214. declare module "babylonjs/Gamepads/Controllers/index" {
  59215. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  59216. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  59217. export * from "babylonjs/Gamepads/Controllers/genericController";
  59218. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  59219. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59220. export * from "babylonjs/Gamepads/Controllers/viveController";
  59221. export * from "babylonjs/Gamepads/Controllers/webVRController";
  59222. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  59223. }
  59224. declare module "babylonjs/Gamepads/index" {
  59225. export * from "babylonjs/Gamepads/Controllers/index";
  59226. export * from "babylonjs/Gamepads/gamepad";
  59227. export * from "babylonjs/Gamepads/gamepadManager";
  59228. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  59229. export * from "babylonjs/Gamepads/xboxGamepad";
  59230. export * from "babylonjs/Gamepads/dualShockGamepad";
  59231. }
  59232. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  59233. import { Scene } from "babylonjs/scene";
  59234. import { Vector4 } from "babylonjs/Maths/math.vector";
  59235. import { Color4 } from "babylonjs/Maths/math.color";
  59236. import { Mesh } from "babylonjs/Meshes/mesh";
  59237. import { Nullable } from "babylonjs/types";
  59238. /**
  59239. * Class containing static functions to help procedurally build meshes
  59240. */
  59241. export class PolyhedronBuilder {
  59242. /**
  59243. * Creates a polyhedron mesh
  59244. * * 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
  59245. * * The parameter `size` (positive float, default 1) sets the polygon size
  59246. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59247. * * 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`
  59248. * * 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
  59249. * * 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)`)
  59250. * * 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
  59251. * * 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
  59252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59253. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59255. * @param name defines the name of the mesh
  59256. * @param options defines the options used to create the mesh
  59257. * @param scene defines the hosting scene
  59258. * @returns the polyhedron mesh
  59259. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59260. */
  59261. static CreatePolyhedron(name: string, options: {
  59262. type?: number;
  59263. size?: number;
  59264. sizeX?: number;
  59265. sizeY?: number;
  59266. sizeZ?: number;
  59267. custom?: any;
  59268. faceUV?: Vector4[];
  59269. faceColors?: Color4[];
  59270. flat?: boolean;
  59271. updatable?: boolean;
  59272. sideOrientation?: number;
  59273. frontUVs?: Vector4;
  59274. backUVs?: Vector4;
  59275. }, scene?: Nullable<Scene>): Mesh;
  59276. }
  59277. }
  59278. declare module "babylonjs/Gizmos/scaleGizmo" {
  59279. import { Observable } from "babylonjs/Misc/observable";
  59280. import { Nullable } from "babylonjs/types";
  59281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59282. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59283. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  59284. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59285. import { Node } from "babylonjs/node";
  59286. /**
  59287. * Gizmo that enables scaling a mesh along 3 axis
  59288. */
  59289. export class ScaleGizmo extends Gizmo {
  59290. /**
  59291. * Internal gizmo used for interactions on the x axis
  59292. */
  59293. xGizmo: AxisScaleGizmo;
  59294. /**
  59295. * Internal gizmo used for interactions on the y axis
  59296. */
  59297. yGizmo: AxisScaleGizmo;
  59298. /**
  59299. * Internal gizmo used for interactions on the z axis
  59300. */
  59301. zGizmo: AxisScaleGizmo;
  59302. /**
  59303. * Internal gizmo used to scale all axis equally
  59304. */
  59305. uniformScaleGizmo: AxisScaleGizmo;
  59306. private _meshAttached;
  59307. private _nodeAttached;
  59308. private _snapDistance;
  59309. private _uniformScalingMesh;
  59310. private _octahedron;
  59311. private _sensitivity;
  59312. /** Fires an event when any of it's sub gizmos are dragged */
  59313. onDragStartObservable: Observable<unknown>;
  59314. /** Fires an event when any of it's sub gizmos are released from dragging */
  59315. onDragEndObservable: Observable<unknown>;
  59316. get attachedMesh(): Nullable<AbstractMesh>;
  59317. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59318. get attachedNode(): Nullable<Node>;
  59319. set attachedNode(node: Nullable<Node>);
  59320. /**
  59321. * True when the mouse pointer is hovering a gizmo mesh
  59322. */
  59323. get isHovered(): boolean;
  59324. /**
  59325. * Creates a ScaleGizmo
  59326. * @param gizmoLayer The utility layer the gizmo will be added to
  59327. * @param thickness display gizmo axis thickness
  59328. */
  59329. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  59330. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59331. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59332. /**
  59333. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59334. */
  59335. set snapDistance(value: number);
  59336. get snapDistance(): number;
  59337. /**
  59338. * Ratio for the scale of the gizmo (Default: 1)
  59339. */
  59340. set scaleRatio(value: number);
  59341. get scaleRatio(): number;
  59342. /**
  59343. * Sensitivity factor for dragging (Default: 1)
  59344. */
  59345. set sensitivity(value: number);
  59346. get sensitivity(): number;
  59347. /**
  59348. * Disposes of the gizmo
  59349. */
  59350. dispose(): void;
  59351. }
  59352. }
  59353. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  59354. import { Observable } from "babylonjs/Misc/observable";
  59355. import { Nullable } from "babylonjs/types";
  59356. import { Vector3 } from "babylonjs/Maths/math.vector";
  59357. import { Node } from "babylonjs/node";
  59358. import { Mesh } from "babylonjs/Meshes/mesh";
  59359. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59360. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59361. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59362. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59363. import { Color3 } from "babylonjs/Maths/math.color";
  59364. /**
  59365. * Single axis scale gizmo
  59366. */
  59367. export class AxisScaleGizmo extends Gizmo {
  59368. /**
  59369. * Drag behavior responsible for the gizmos dragging interactions
  59370. */
  59371. dragBehavior: PointerDragBehavior;
  59372. private _pointerObserver;
  59373. /**
  59374. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59375. */
  59376. snapDistance: number;
  59377. /**
  59378. * Event that fires each time the gizmo snaps to a new location.
  59379. * * snapDistance is the the change in distance
  59380. */
  59381. onSnapObservable: Observable<{
  59382. snapDistance: number;
  59383. }>;
  59384. /**
  59385. * If the scaling operation should be done on all axis (default: false)
  59386. */
  59387. uniformScaling: boolean;
  59388. /**
  59389. * Custom sensitivity value for the drag strength
  59390. */
  59391. sensitivity: number;
  59392. private _isEnabled;
  59393. private _parent;
  59394. private _arrow;
  59395. private _coloredMaterial;
  59396. private _hoverMaterial;
  59397. /**
  59398. * Creates an AxisScaleGizmo
  59399. * @param gizmoLayer The utility layer the gizmo will be added to
  59400. * @param dragAxis The axis which the gizmo will be able to scale on
  59401. * @param color The color of the gizmo
  59402. * @param thickness display gizmo axis thickness
  59403. */
  59404. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  59405. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59406. /**
  59407. * If the gizmo is enabled
  59408. */
  59409. set isEnabled(value: boolean);
  59410. get isEnabled(): boolean;
  59411. /**
  59412. * Disposes of the gizmo
  59413. */
  59414. dispose(): void;
  59415. /**
  59416. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59417. * @param mesh The mesh to replace the default mesh of the gizmo
  59418. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  59419. */
  59420. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  59421. }
  59422. }
  59423. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  59424. import { Observable } from "babylonjs/Misc/observable";
  59425. import { Nullable } from "babylonjs/types";
  59426. import { Vector3 } from "babylonjs/Maths/math.vector";
  59427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59428. import { Mesh } from "babylonjs/Meshes/mesh";
  59429. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59430. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59431. import { Color3 } from "babylonjs/Maths/math.color";
  59432. import "babylonjs/Meshes/Builders/boxBuilder";
  59433. /**
  59434. * Bounding box gizmo
  59435. */
  59436. export class BoundingBoxGizmo extends Gizmo {
  59437. private _lineBoundingBox;
  59438. private _rotateSpheresParent;
  59439. private _scaleBoxesParent;
  59440. private _boundingDimensions;
  59441. private _renderObserver;
  59442. private _pointerObserver;
  59443. private _scaleDragSpeed;
  59444. private _tmpQuaternion;
  59445. private _tmpVector;
  59446. private _tmpRotationMatrix;
  59447. /**
  59448. * 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)
  59449. */
  59450. ignoreChildren: boolean;
  59451. /**
  59452. * 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)
  59453. */
  59454. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  59455. /**
  59456. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  59457. */
  59458. rotationSphereSize: number;
  59459. /**
  59460. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  59461. */
  59462. scaleBoxSize: number;
  59463. /**
  59464. * 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)
  59465. */
  59466. fixedDragMeshScreenSize: boolean;
  59467. /**
  59468. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  59469. */
  59470. fixedDragMeshScreenSizeDistanceFactor: number;
  59471. /**
  59472. * Fired when a rotation sphere or scale box is dragged
  59473. */
  59474. onDragStartObservable: Observable<{}>;
  59475. /**
  59476. * Fired when a scale box is dragged
  59477. */
  59478. onScaleBoxDragObservable: Observable<{}>;
  59479. /**
  59480. * Fired when a scale box drag is ended
  59481. */
  59482. onScaleBoxDragEndObservable: Observable<{}>;
  59483. /**
  59484. * Fired when a rotation sphere is dragged
  59485. */
  59486. onRotationSphereDragObservable: Observable<{}>;
  59487. /**
  59488. * Fired when a rotation sphere drag is ended
  59489. */
  59490. onRotationSphereDragEndObservable: Observable<{}>;
  59491. /**
  59492. * 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)
  59493. */
  59494. scalePivot: Nullable<Vector3>;
  59495. /**
  59496. * Mesh used as a pivot to rotate the attached node
  59497. */
  59498. private _anchorMesh;
  59499. private _existingMeshScale;
  59500. private _dragMesh;
  59501. private pointerDragBehavior;
  59502. private coloredMaterial;
  59503. private hoverColoredMaterial;
  59504. /**
  59505. * Sets the color of the bounding box gizmo
  59506. * @param color the color to set
  59507. */
  59508. setColor(color: Color3): void;
  59509. /**
  59510. * Creates an BoundingBoxGizmo
  59511. * @param gizmoLayer The utility layer the gizmo will be added to
  59512. * @param color The color of the gizmo
  59513. */
  59514. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  59515. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  59516. private _selectNode;
  59517. /**
  59518. * Updates the bounding box information for the Gizmo
  59519. */
  59520. updateBoundingBox(): void;
  59521. private _updateRotationSpheres;
  59522. private _updateScaleBoxes;
  59523. /**
  59524. * Enables rotation on the specified axis and disables rotation on the others
  59525. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  59526. */
  59527. setEnabledRotationAxis(axis: string): void;
  59528. /**
  59529. * Enables/disables scaling
  59530. * @param enable if scaling should be enabled
  59531. * @param homogeneousScaling defines if scaling should only be homogeneous
  59532. */
  59533. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  59534. private _updateDummy;
  59535. /**
  59536. * Enables a pointer drag behavior on the bounding box of the gizmo
  59537. */
  59538. enableDragBehavior(): void;
  59539. /**
  59540. * Disposes of the gizmo
  59541. */
  59542. dispose(): void;
  59543. /**
  59544. * 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)
  59545. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  59546. * @returns the bounding box mesh with the passed in mesh as a child
  59547. */
  59548. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  59549. /**
  59550. * CustomMeshes are not supported by this gizmo
  59551. * @param mesh The mesh to replace the default mesh of the gizmo
  59552. */
  59553. setCustomMesh(mesh: Mesh): void;
  59554. }
  59555. }
  59556. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59557. import { Observable } from "babylonjs/Misc/observable";
  59558. import { Nullable } from "babylonjs/types";
  59559. import { Vector3 } from "babylonjs/Maths/math.vector";
  59560. import { Color3 } from "babylonjs/Maths/math.color";
  59561. import { Node } from "babylonjs/node";
  59562. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59563. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59564. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59565. import "babylonjs/Meshes/Builders/linesBuilder";
  59566. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59567. /**
  59568. * Single plane rotation gizmo
  59569. */
  59570. export class PlaneRotationGizmo extends Gizmo {
  59571. /**
  59572. * Drag behavior responsible for the gizmos dragging interactions
  59573. */
  59574. dragBehavior: PointerDragBehavior;
  59575. private _pointerObserver;
  59576. /**
  59577. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59578. */
  59579. snapDistance: number;
  59580. /**
  59581. * Event that fires each time the gizmo snaps to a new location.
  59582. * * snapDistance is the the change in distance
  59583. */
  59584. onSnapObservable: Observable<{
  59585. snapDistance: number;
  59586. }>;
  59587. private _isEnabled;
  59588. private _parent;
  59589. /**
  59590. * Creates a PlaneRotationGizmo
  59591. * @param gizmoLayer The utility layer the gizmo will be added to
  59592. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59593. * @param color The color of the gizmo
  59594. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59595. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59596. * @param thickness display gizmo axis thickness
  59597. */
  59598. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59599. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59600. /**
  59601. * If the gizmo is enabled
  59602. */
  59603. set isEnabled(value: boolean);
  59604. get isEnabled(): boolean;
  59605. /**
  59606. * Disposes of the gizmo
  59607. */
  59608. dispose(): void;
  59609. }
  59610. }
  59611. declare module "babylonjs/Gizmos/rotationGizmo" {
  59612. import { Observable } from "babylonjs/Misc/observable";
  59613. import { Nullable } from "babylonjs/types";
  59614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59615. import { Mesh } from "babylonjs/Meshes/mesh";
  59616. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59617. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59618. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59619. import { Node } from "babylonjs/node";
  59620. /**
  59621. * Gizmo that enables rotating a mesh along 3 axis
  59622. */
  59623. export class RotationGizmo extends Gizmo {
  59624. /**
  59625. * Internal gizmo used for interactions on the x axis
  59626. */
  59627. xGizmo: PlaneRotationGizmo;
  59628. /**
  59629. * Internal gizmo used for interactions on the y axis
  59630. */
  59631. yGizmo: PlaneRotationGizmo;
  59632. /**
  59633. * Internal gizmo used for interactions on the z axis
  59634. */
  59635. zGizmo: PlaneRotationGizmo;
  59636. /** Fires an event when any of it's sub gizmos are dragged */
  59637. onDragStartObservable: Observable<unknown>;
  59638. /** Fires an event when any of it's sub gizmos are released from dragging */
  59639. onDragEndObservable: Observable<unknown>;
  59640. private _meshAttached;
  59641. private _nodeAttached;
  59642. get attachedMesh(): Nullable<AbstractMesh>;
  59643. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59644. get attachedNode(): Nullable<Node>;
  59645. set attachedNode(node: Nullable<Node>);
  59646. protected _checkBillboardTransform(): void;
  59647. /**
  59648. * True when the mouse pointer is hovering a gizmo mesh
  59649. */
  59650. get isHovered(): boolean;
  59651. /**
  59652. * Creates a RotationGizmo
  59653. * @param gizmoLayer The utility layer the gizmo will be added to
  59654. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59655. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59656. * @param thickness display gizmo axis thickness
  59657. */
  59658. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  59659. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59660. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59661. /**
  59662. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59663. */
  59664. set snapDistance(value: number);
  59665. get snapDistance(): number;
  59666. /**
  59667. * Ratio for the scale of the gizmo (Default: 1)
  59668. */
  59669. set scaleRatio(value: number);
  59670. get scaleRatio(): number;
  59671. /**
  59672. * Disposes of the gizmo
  59673. */
  59674. dispose(): void;
  59675. /**
  59676. * CustomMeshes are not supported by this gizmo
  59677. * @param mesh The mesh to replace the default mesh of the gizmo
  59678. */
  59679. setCustomMesh(mesh: Mesh): void;
  59680. }
  59681. }
  59682. declare module "babylonjs/Gizmos/gizmoManager" {
  59683. import { Observable } from "babylonjs/Misc/observable";
  59684. import { Nullable } from "babylonjs/types";
  59685. import { Scene, IDisposable } from "babylonjs/scene";
  59686. import { Node } from "babylonjs/node";
  59687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59688. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59689. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  59690. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59691. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59692. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59693. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  59694. /**
  59695. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  59696. */
  59697. export class GizmoManager implements IDisposable {
  59698. private scene;
  59699. /**
  59700. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  59701. */
  59702. gizmos: {
  59703. positionGizmo: Nullable<PositionGizmo>;
  59704. rotationGizmo: Nullable<RotationGizmo>;
  59705. scaleGizmo: Nullable<ScaleGizmo>;
  59706. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  59707. };
  59708. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  59709. clearGizmoOnEmptyPointerEvent: boolean;
  59710. /** Fires an event when the manager is attached to a mesh */
  59711. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  59712. /** Fires an event when the manager is attached to a node */
  59713. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  59714. private _gizmosEnabled;
  59715. private _pointerObserver;
  59716. private _attachedMesh;
  59717. private _attachedNode;
  59718. private _boundingBoxColor;
  59719. private _defaultUtilityLayer;
  59720. private _defaultKeepDepthUtilityLayer;
  59721. private _thickness;
  59722. /**
  59723. * When bounding box gizmo is enabled, this can be used to track drag/end events
  59724. */
  59725. boundingBoxDragBehavior: SixDofDragBehavior;
  59726. /**
  59727. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  59728. */
  59729. attachableMeshes: Nullable<Array<AbstractMesh>>;
  59730. /**
  59731. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  59732. */
  59733. attachableNodes: Nullable<Array<Node>>;
  59734. /**
  59735. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  59736. */
  59737. usePointerToAttachGizmos: boolean;
  59738. /**
  59739. * Utility layer that the bounding box gizmo belongs to
  59740. */
  59741. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  59742. /**
  59743. * Utility layer that all gizmos besides bounding box belong to
  59744. */
  59745. get utilityLayer(): UtilityLayerRenderer;
  59746. /**
  59747. * True when the mouse pointer is hovering a gizmo mesh
  59748. */
  59749. get isHovered(): boolean;
  59750. /**
  59751. * Instatiates a gizmo manager
  59752. * @param scene the scene to overlay the gizmos on top of
  59753. * @param thickness display gizmo axis thickness
  59754. */
  59755. constructor(scene: Scene, thickness?: number);
  59756. /**
  59757. * Attaches a set of gizmos to the specified mesh
  59758. * @param mesh The mesh the gizmo's should be attached to
  59759. */
  59760. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59761. /**
  59762. * Attaches a set of gizmos to the specified node
  59763. * @param node The node the gizmo's should be attached to
  59764. */
  59765. attachToNode(node: Nullable<Node>): void;
  59766. /**
  59767. * If the position gizmo is enabled
  59768. */
  59769. set positionGizmoEnabled(value: boolean);
  59770. get positionGizmoEnabled(): boolean;
  59771. /**
  59772. * If the rotation gizmo is enabled
  59773. */
  59774. set rotationGizmoEnabled(value: boolean);
  59775. get rotationGizmoEnabled(): boolean;
  59776. /**
  59777. * If the scale gizmo is enabled
  59778. */
  59779. set scaleGizmoEnabled(value: boolean);
  59780. get scaleGizmoEnabled(): boolean;
  59781. /**
  59782. * If the boundingBox gizmo is enabled
  59783. */
  59784. set boundingBoxGizmoEnabled(value: boolean);
  59785. get boundingBoxGizmoEnabled(): boolean;
  59786. /**
  59787. * Disposes of the gizmo manager
  59788. */
  59789. dispose(): void;
  59790. }
  59791. }
  59792. declare module "babylonjs/Lights/directionalLight" {
  59793. import { Camera } from "babylonjs/Cameras/camera";
  59794. import { Scene } from "babylonjs/scene";
  59795. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59797. import { Light } from "babylonjs/Lights/light";
  59798. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59799. import { Effect } from "babylonjs/Materials/effect";
  59800. /**
  59801. * A directional light is defined by a direction (what a surprise!).
  59802. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  59803. * 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.
  59804. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59805. */
  59806. export class DirectionalLight extends ShadowLight {
  59807. private _shadowFrustumSize;
  59808. /**
  59809. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  59810. */
  59811. get shadowFrustumSize(): number;
  59812. /**
  59813. * Specifies a fix frustum size for the shadow generation.
  59814. */
  59815. set shadowFrustumSize(value: number);
  59816. private _shadowOrthoScale;
  59817. /**
  59818. * Gets the shadow projection scale against the optimal computed one.
  59819. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59820. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59821. */
  59822. get shadowOrthoScale(): number;
  59823. /**
  59824. * Sets the shadow projection scale against the optimal computed one.
  59825. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59826. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59827. */
  59828. set shadowOrthoScale(value: number);
  59829. /**
  59830. * Automatically compute the projection matrix to best fit (including all the casters)
  59831. * on each frame.
  59832. */
  59833. autoUpdateExtends: boolean;
  59834. /**
  59835. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  59836. * on each frame. autoUpdateExtends must be set to true for this to work
  59837. */
  59838. autoCalcShadowZBounds: boolean;
  59839. private _orthoLeft;
  59840. private _orthoRight;
  59841. private _orthoTop;
  59842. private _orthoBottom;
  59843. /**
  59844. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  59845. * The directional light is emitted from everywhere in the given direction.
  59846. * It can cast shadows.
  59847. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59848. * @param name The friendly name of the light
  59849. * @param direction The direction of the light
  59850. * @param scene The scene the light belongs to
  59851. */
  59852. constructor(name: string, direction: Vector3, scene: Scene);
  59853. /**
  59854. * Returns the string "DirectionalLight".
  59855. * @return The class name
  59856. */
  59857. getClassName(): string;
  59858. /**
  59859. * Returns the integer 1.
  59860. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59861. */
  59862. getTypeID(): number;
  59863. /**
  59864. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  59865. * Returns the DirectionalLight Shadow projection matrix.
  59866. */
  59867. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59868. /**
  59869. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  59870. * Returns the DirectionalLight Shadow projection matrix.
  59871. */
  59872. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  59873. /**
  59874. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  59875. * Returns the DirectionalLight Shadow projection matrix.
  59876. */
  59877. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59878. protected _buildUniformLayout(): void;
  59879. /**
  59880. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  59881. * @param effect The effect to update
  59882. * @param lightIndex The index of the light in the effect to update
  59883. * @returns The directional light
  59884. */
  59885. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  59886. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  59887. /**
  59888. * Gets the minZ used for shadow according to both the scene and the light.
  59889. *
  59890. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59891. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59892. * @param activeCamera The camera we are returning the min for
  59893. * @returns the depth min z
  59894. */
  59895. getDepthMinZ(activeCamera: Camera): number;
  59896. /**
  59897. * Gets the maxZ used for shadow according to both the scene and the light.
  59898. *
  59899. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59900. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59901. * @param activeCamera The camera we are returning the max for
  59902. * @returns the depth max z
  59903. */
  59904. getDepthMaxZ(activeCamera: Camera): number;
  59905. /**
  59906. * Prepares the list of defines specific to the light type.
  59907. * @param defines the list of defines
  59908. * @param lightIndex defines the index of the light for the effect
  59909. */
  59910. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59911. }
  59912. }
  59913. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  59914. import { Mesh } from "babylonjs/Meshes/mesh";
  59915. /**
  59916. * Class containing static functions to help procedurally build meshes
  59917. */
  59918. export class HemisphereBuilder {
  59919. /**
  59920. * Creates a hemisphere mesh
  59921. * @param name defines the name of the mesh
  59922. * @param options defines the options used to create the mesh
  59923. * @param scene defines the hosting scene
  59924. * @returns the hemisphere mesh
  59925. */
  59926. static CreateHemisphere(name: string, options: {
  59927. segments?: number;
  59928. diameter?: number;
  59929. sideOrientation?: number;
  59930. }, scene: any): Mesh;
  59931. }
  59932. }
  59933. declare module "babylonjs/Lights/spotLight" {
  59934. import { Nullable } from "babylonjs/types";
  59935. import { Scene } from "babylonjs/scene";
  59936. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59938. import { Effect } from "babylonjs/Materials/effect";
  59939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59940. import { Light } from "babylonjs/Lights/light";
  59941. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59942. /**
  59943. * A spot light is defined by a position, a direction, an angle, and an exponent.
  59944. * These values define a cone of light starting from the position, emitting toward the direction.
  59945. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  59946. * and the exponent defines the speed of the decay of the light with distance (reach).
  59947. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59948. */
  59949. export class SpotLight extends ShadowLight {
  59950. private _angle;
  59951. private _innerAngle;
  59952. private _cosHalfAngle;
  59953. private _lightAngleScale;
  59954. private _lightAngleOffset;
  59955. /**
  59956. * Gets the cone angle of the spot light in Radians.
  59957. */
  59958. get angle(): number;
  59959. /**
  59960. * Sets the cone angle of the spot light in Radians.
  59961. */
  59962. set angle(value: number);
  59963. /**
  59964. * Only used in gltf falloff mode, this defines the angle where
  59965. * the directional falloff will start before cutting at angle which could be seen
  59966. * as outer angle.
  59967. */
  59968. get innerAngle(): number;
  59969. /**
  59970. * Only used in gltf falloff mode, this defines the angle where
  59971. * the directional falloff will start before cutting at angle which could be seen
  59972. * as outer angle.
  59973. */
  59974. set innerAngle(value: number);
  59975. private _shadowAngleScale;
  59976. /**
  59977. * Allows scaling the angle of the light for shadow generation only.
  59978. */
  59979. get shadowAngleScale(): number;
  59980. /**
  59981. * Allows scaling the angle of the light for shadow generation only.
  59982. */
  59983. set shadowAngleScale(value: number);
  59984. /**
  59985. * The light decay speed with the distance from the emission spot.
  59986. */
  59987. exponent: number;
  59988. private _projectionTextureMatrix;
  59989. /**
  59990. * Allows reading the projecton texture
  59991. */
  59992. get projectionTextureMatrix(): Matrix;
  59993. protected _projectionTextureLightNear: number;
  59994. /**
  59995. * Gets the near clip of the Spotlight for texture projection.
  59996. */
  59997. get projectionTextureLightNear(): number;
  59998. /**
  59999. * Sets the near clip of the Spotlight for texture projection.
  60000. */
  60001. set projectionTextureLightNear(value: number);
  60002. protected _projectionTextureLightFar: number;
  60003. /**
  60004. * Gets the far clip of the Spotlight for texture projection.
  60005. */
  60006. get projectionTextureLightFar(): number;
  60007. /**
  60008. * Sets the far clip of the Spotlight for texture projection.
  60009. */
  60010. set projectionTextureLightFar(value: number);
  60011. protected _projectionTextureUpDirection: Vector3;
  60012. /**
  60013. * Gets the Up vector of the Spotlight for texture projection.
  60014. */
  60015. get projectionTextureUpDirection(): Vector3;
  60016. /**
  60017. * Sets the Up vector of the Spotlight for texture projection.
  60018. */
  60019. set projectionTextureUpDirection(value: Vector3);
  60020. private _projectionTexture;
  60021. /**
  60022. * Gets the projection texture of the light.
  60023. */
  60024. get projectionTexture(): Nullable<BaseTexture>;
  60025. /**
  60026. * Sets the projection texture of the light.
  60027. */
  60028. set projectionTexture(value: Nullable<BaseTexture>);
  60029. private _projectionTextureViewLightDirty;
  60030. private _projectionTextureProjectionLightDirty;
  60031. private _projectionTextureDirty;
  60032. private _projectionTextureViewTargetVector;
  60033. private _projectionTextureViewLightMatrix;
  60034. private _projectionTextureProjectionLightMatrix;
  60035. private _projectionTextureScalingMatrix;
  60036. /**
  60037. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60038. * It can cast shadows.
  60039. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60040. * @param name The light friendly name
  60041. * @param position The position of the spot light in the scene
  60042. * @param direction The direction of the light in the scene
  60043. * @param angle The cone angle of the light in Radians
  60044. * @param exponent The light decay speed with the distance from the emission spot
  60045. * @param scene The scene the lights belongs to
  60046. */
  60047. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60048. /**
  60049. * Returns the string "SpotLight".
  60050. * @returns the class name
  60051. */
  60052. getClassName(): string;
  60053. /**
  60054. * Returns the integer 2.
  60055. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60056. */
  60057. getTypeID(): number;
  60058. /**
  60059. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60060. */
  60061. protected _setDirection(value: Vector3): void;
  60062. /**
  60063. * Overrides the position setter to recompute the projection texture view light Matrix.
  60064. */
  60065. protected _setPosition(value: Vector3): void;
  60066. /**
  60067. * 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.
  60068. * Returns the SpotLight.
  60069. */
  60070. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60071. protected _computeProjectionTextureViewLightMatrix(): void;
  60072. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60073. /**
  60074. * Main function for light texture projection matrix computing.
  60075. */
  60076. protected _computeProjectionTextureMatrix(): void;
  60077. protected _buildUniformLayout(): void;
  60078. private _computeAngleValues;
  60079. /**
  60080. * Sets the passed Effect "effect" with the Light textures.
  60081. * @param effect The effect to update
  60082. * @param lightIndex The index of the light in the effect to update
  60083. * @returns The light
  60084. */
  60085. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60086. /**
  60087. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60088. * @param effect The effect to update
  60089. * @param lightIndex The index of the light in the effect to update
  60090. * @returns The spot light
  60091. */
  60092. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60093. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60094. /**
  60095. * Disposes the light and the associated resources.
  60096. */
  60097. dispose(): void;
  60098. /**
  60099. * Prepares the list of defines specific to the light type.
  60100. * @param defines the list of defines
  60101. * @param lightIndex defines the index of the light for the effect
  60102. */
  60103. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60104. }
  60105. }
  60106. declare module "babylonjs/Gizmos/lightGizmo" {
  60107. import { Nullable } from "babylonjs/types";
  60108. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60109. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60110. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60111. import { Light } from "babylonjs/Lights/light";
  60112. import { Observable } from "babylonjs/Misc/observable";
  60113. /**
  60114. * Gizmo that enables viewing a light
  60115. */
  60116. export class LightGizmo extends Gizmo {
  60117. private _lightMesh;
  60118. private _material;
  60119. private _cachedPosition;
  60120. private _cachedForward;
  60121. private _attachedMeshParent;
  60122. private _pointerObserver;
  60123. /**
  60124. * Event that fires each time the gizmo is clicked
  60125. */
  60126. onClickedObservable: Observable<Light>;
  60127. /**
  60128. * Creates a LightGizmo
  60129. * @param gizmoLayer The utility layer the gizmo will be added to
  60130. */
  60131. constructor(gizmoLayer?: UtilityLayerRenderer);
  60132. private _light;
  60133. /**
  60134. * The light that the gizmo is attached to
  60135. */
  60136. set light(light: Nullable<Light>);
  60137. get light(): Nullable<Light>;
  60138. /**
  60139. * Gets the material used to render the light gizmo
  60140. */
  60141. get material(): StandardMaterial;
  60142. /**
  60143. * @hidden
  60144. * Updates the gizmo to match the attached mesh's position/rotation
  60145. */
  60146. protected _update(): void;
  60147. private static _Scale;
  60148. /**
  60149. * Creates the lines for a light mesh
  60150. */
  60151. private static _CreateLightLines;
  60152. /**
  60153. * Disposes of the light gizmo
  60154. */
  60155. dispose(): void;
  60156. private static _CreateHemisphericLightMesh;
  60157. private static _CreatePointLightMesh;
  60158. private static _CreateSpotLightMesh;
  60159. private static _CreateDirectionalLightMesh;
  60160. }
  60161. }
  60162. declare module "babylonjs/Gizmos/cameraGizmo" {
  60163. import { Nullable } from "babylonjs/types";
  60164. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60165. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60166. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60167. import { Camera } from "babylonjs/Cameras/camera";
  60168. import { Observable } from "babylonjs/Misc/observable";
  60169. /**
  60170. * Gizmo that enables viewing a camera
  60171. */
  60172. export class CameraGizmo extends Gizmo {
  60173. private _cameraMesh;
  60174. private _cameraLinesMesh;
  60175. private _material;
  60176. private _pointerObserver;
  60177. /**
  60178. * Event that fires each time the gizmo is clicked
  60179. */
  60180. onClickedObservable: Observable<Camera>;
  60181. /**
  60182. * Creates a CameraGizmo
  60183. * @param gizmoLayer The utility layer the gizmo will be added to
  60184. */
  60185. constructor(gizmoLayer?: UtilityLayerRenderer);
  60186. private _camera;
  60187. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  60188. get displayFrustum(): boolean;
  60189. set displayFrustum(value: boolean);
  60190. /**
  60191. * The camera that the gizmo is attached to
  60192. */
  60193. set camera(camera: Nullable<Camera>);
  60194. get camera(): Nullable<Camera>;
  60195. /**
  60196. * Gets the material used to render the camera gizmo
  60197. */
  60198. get material(): StandardMaterial;
  60199. /**
  60200. * @hidden
  60201. * Updates the gizmo to match the attached mesh's position/rotation
  60202. */
  60203. protected _update(): void;
  60204. private static _Scale;
  60205. private _invProjection;
  60206. /**
  60207. * Disposes of the camera gizmo
  60208. */
  60209. dispose(): void;
  60210. private static _CreateCameraMesh;
  60211. private static _CreateCameraFrustum;
  60212. }
  60213. }
  60214. declare module "babylonjs/Gizmos/index" {
  60215. export * from "babylonjs/Gizmos/axisDragGizmo";
  60216. export * from "babylonjs/Gizmos/axisScaleGizmo";
  60217. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  60218. export * from "babylonjs/Gizmos/gizmo";
  60219. export * from "babylonjs/Gizmos/gizmoManager";
  60220. export * from "babylonjs/Gizmos/planeRotationGizmo";
  60221. export * from "babylonjs/Gizmos/positionGizmo";
  60222. export * from "babylonjs/Gizmos/rotationGizmo";
  60223. export * from "babylonjs/Gizmos/scaleGizmo";
  60224. export * from "babylonjs/Gizmos/lightGizmo";
  60225. export * from "babylonjs/Gizmos/cameraGizmo";
  60226. export * from "babylonjs/Gizmos/planeDragGizmo";
  60227. }
  60228. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  60229. /** @hidden */
  60230. export var backgroundFragmentDeclaration: {
  60231. name: string;
  60232. shader: string;
  60233. };
  60234. }
  60235. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  60236. /** @hidden */
  60237. export var backgroundUboDeclaration: {
  60238. name: string;
  60239. shader: string;
  60240. };
  60241. }
  60242. declare module "babylonjs/Shaders/background.fragment" {
  60243. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  60244. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60245. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60246. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60247. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60248. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60249. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60250. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  60251. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  60252. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60253. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  60254. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  60255. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60256. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  60257. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  60258. /** @hidden */
  60259. export var backgroundPixelShader: {
  60260. name: string;
  60261. shader: string;
  60262. };
  60263. }
  60264. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  60265. /** @hidden */
  60266. export var backgroundVertexDeclaration: {
  60267. name: string;
  60268. shader: string;
  60269. };
  60270. }
  60271. declare module "babylonjs/Shaders/background.vertex" {
  60272. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  60273. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60274. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60275. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60276. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60277. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  60278. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  60279. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60280. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60281. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60282. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60283. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60284. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  60285. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60286. /** @hidden */
  60287. export var backgroundVertexShader: {
  60288. name: string;
  60289. shader: string;
  60290. };
  60291. }
  60292. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  60293. import { Nullable, int, float } from "babylonjs/types";
  60294. import { Scene } from "babylonjs/scene";
  60295. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60296. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60298. import { Mesh } from "babylonjs/Meshes/mesh";
  60299. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60300. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  60301. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  60302. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60303. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  60304. import { Color3 } from "babylonjs/Maths/math.color";
  60305. import "babylonjs/Shaders/background.fragment";
  60306. import "babylonjs/Shaders/background.vertex";
  60307. /**
  60308. * Background material used to create an efficient environement around your scene.
  60309. */
  60310. export class BackgroundMaterial extends PushMaterial {
  60311. /**
  60312. * Standard reflectance value at parallel view angle.
  60313. */
  60314. static StandardReflectance0: number;
  60315. /**
  60316. * Standard reflectance value at grazing angle.
  60317. */
  60318. static StandardReflectance90: number;
  60319. protected _primaryColor: Color3;
  60320. /**
  60321. * Key light Color (multiply against the environement texture)
  60322. */
  60323. primaryColor: Color3;
  60324. protected __perceptualColor: Nullable<Color3>;
  60325. /**
  60326. * Experimental Internal Use Only.
  60327. *
  60328. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60329. * This acts as a helper to set the primary color to a more "human friendly" value.
  60330. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60331. * output color as close as possible from the chosen value.
  60332. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60333. * part of lighting setup.)
  60334. */
  60335. get _perceptualColor(): Nullable<Color3>;
  60336. set _perceptualColor(value: Nullable<Color3>);
  60337. protected _primaryColorShadowLevel: float;
  60338. /**
  60339. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60340. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60341. */
  60342. get primaryColorShadowLevel(): float;
  60343. set primaryColorShadowLevel(value: float);
  60344. protected _primaryColorHighlightLevel: float;
  60345. /**
  60346. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60347. * The primary color is used at the level chosen to define what the white area would look.
  60348. */
  60349. get primaryColorHighlightLevel(): float;
  60350. set primaryColorHighlightLevel(value: float);
  60351. protected _reflectionTexture: Nullable<BaseTexture>;
  60352. /**
  60353. * Reflection Texture used in the material.
  60354. * Should be author in a specific way for the best result (refer to the documentation).
  60355. */
  60356. reflectionTexture: Nullable<BaseTexture>;
  60357. protected _reflectionBlur: float;
  60358. /**
  60359. * Reflection Texture level of blur.
  60360. *
  60361. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60362. * texture twice.
  60363. */
  60364. reflectionBlur: float;
  60365. protected _diffuseTexture: Nullable<BaseTexture>;
  60366. /**
  60367. * Diffuse Texture used in the material.
  60368. * Should be author in a specific way for the best result (refer to the documentation).
  60369. */
  60370. diffuseTexture: Nullable<BaseTexture>;
  60371. protected _shadowLights: Nullable<IShadowLight[]>;
  60372. /**
  60373. * Specify the list of lights casting shadow on the material.
  60374. * All scene shadow lights will be included if null.
  60375. */
  60376. shadowLights: Nullable<IShadowLight[]>;
  60377. protected _shadowLevel: float;
  60378. /**
  60379. * Helps adjusting the shadow to a softer level if required.
  60380. * 0 means black shadows and 1 means no shadows.
  60381. */
  60382. shadowLevel: float;
  60383. protected _sceneCenter: Vector3;
  60384. /**
  60385. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60386. * It is usually zero but might be interesting to modify according to your setup.
  60387. */
  60388. sceneCenter: Vector3;
  60389. protected _opacityFresnel: boolean;
  60390. /**
  60391. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60392. * This helps ensuring a nice transition when the camera goes under the ground.
  60393. */
  60394. opacityFresnel: boolean;
  60395. protected _reflectionFresnel: boolean;
  60396. /**
  60397. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60398. * This helps adding a mirror texture on the ground.
  60399. */
  60400. reflectionFresnel: boolean;
  60401. protected _reflectionFalloffDistance: number;
  60402. /**
  60403. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60404. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60405. */
  60406. reflectionFalloffDistance: number;
  60407. protected _reflectionAmount: number;
  60408. /**
  60409. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60410. */
  60411. reflectionAmount: number;
  60412. protected _reflectionReflectance0: number;
  60413. /**
  60414. * This specifies the weight of the reflection at grazing angle.
  60415. */
  60416. reflectionReflectance0: number;
  60417. protected _reflectionReflectance90: number;
  60418. /**
  60419. * This specifies the weight of the reflection at a perpendicular point of view.
  60420. */
  60421. reflectionReflectance90: number;
  60422. /**
  60423. * Sets the reflection reflectance fresnel values according to the default standard
  60424. * empirically know to work well :-)
  60425. */
  60426. set reflectionStandardFresnelWeight(value: number);
  60427. protected _useRGBColor: boolean;
  60428. /**
  60429. * Helps to directly use the maps channels instead of their level.
  60430. */
  60431. useRGBColor: boolean;
  60432. protected _enableNoise: boolean;
  60433. /**
  60434. * This helps reducing the banding effect that could occur on the background.
  60435. */
  60436. enableNoise: boolean;
  60437. /**
  60438. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60439. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60440. * Recommended to be keep at 1.0 except for special cases.
  60441. */
  60442. get fovMultiplier(): number;
  60443. set fovMultiplier(value: number);
  60444. private _fovMultiplier;
  60445. /**
  60446. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60447. */
  60448. useEquirectangularFOV: boolean;
  60449. private _maxSimultaneousLights;
  60450. /**
  60451. * Number of Simultaneous lights allowed on the material.
  60452. */
  60453. maxSimultaneousLights: int;
  60454. private _shadowOnly;
  60455. /**
  60456. * Make the material only render shadows
  60457. */
  60458. shadowOnly: boolean;
  60459. /**
  60460. * Default configuration related to image processing available in the Background Material.
  60461. */
  60462. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60463. /**
  60464. * Keep track of the image processing observer to allow dispose and replace.
  60465. */
  60466. private _imageProcessingObserver;
  60467. /**
  60468. * Attaches a new image processing configuration to the PBR Material.
  60469. * @param configuration (if null the scene configuration will be use)
  60470. */
  60471. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60472. /**
  60473. * Gets the image processing configuration used either in this material.
  60474. */
  60475. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  60476. /**
  60477. * Sets the Default image processing configuration used either in the this material.
  60478. *
  60479. * If sets to null, the scene one is in use.
  60480. */
  60481. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  60482. /**
  60483. * Gets wether the color curves effect is enabled.
  60484. */
  60485. get cameraColorCurvesEnabled(): boolean;
  60486. /**
  60487. * Sets wether the color curves effect is enabled.
  60488. */
  60489. set cameraColorCurvesEnabled(value: boolean);
  60490. /**
  60491. * Gets wether the color grading effect is enabled.
  60492. */
  60493. get cameraColorGradingEnabled(): boolean;
  60494. /**
  60495. * Gets wether the color grading effect is enabled.
  60496. */
  60497. set cameraColorGradingEnabled(value: boolean);
  60498. /**
  60499. * Gets wether tonemapping is enabled or not.
  60500. */
  60501. get cameraToneMappingEnabled(): boolean;
  60502. /**
  60503. * Sets wether tonemapping is enabled or not
  60504. */
  60505. set cameraToneMappingEnabled(value: boolean);
  60506. /**
  60507. * The camera exposure used on this material.
  60508. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60509. * This corresponds to a photographic exposure.
  60510. */
  60511. get cameraExposure(): float;
  60512. /**
  60513. * The camera exposure used on this material.
  60514. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60515. * This corresponds to a photographic exposure.
  60516. */
  60517. set cameraExposure(value: float);
  60518. /**
  60519. * Gets The camera contrast used on this material.
  60520. */
  60521. get cameraContrast(): float;
  60522. /**
  60523. * Sets The camera contrast used on this material.
  60524. */
  60525. set cameraContrast(value: float);
  60526. /**
  60527. * Gets the Color Grading 2D Lookup Texture.
  60528. */
  60529. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60530. /**
  60531. * Sets the Color Grading 2D Lookup Texture.
  60532. */
  60533. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60534. /**
  60535. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60536. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60537. * 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;
  60538. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60539. */
  60540. get cameraColorCurves(): Nullable<ColorCurves>;
  60541. /**
  60542. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60543. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60544. * 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;
  60545. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60546. */
  60547. set cameraColorCurves(value: Nullable<ColorCurves>);
  60548. /**
  60549. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  60550. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  60551. */
  60552. switchToBGR: boolean;
  60553. private _renderTargets;
  60554. private _reflectionControls;
  60555. private _white;
  60556. private _primaryShadowColor;
  60557. private _primaryHighlightColor;
  60558. /**
  60559. * Instantiates a Background Material in the given scene
  60560. * @param name The friendly name of the material
  60561. * @param scene The scene to add the material to
  60562. */
  60563. constructor(name: string, scene: Scene);
  60564. /**
  60565. * Gets a boolean indicating that current material needs to register RTT
  60566. */
  60567. get hasRenderTargetTextures(): boolean;
  60568. /**
  60569. * The entire material has been created in order to prevent overdraw.
  60570. * @returns false
  60571. */
  60572. needAlphaTesting(): boolean;
  60573. /**
  60574. * The entire material has been created in order to prevent overdraw.
  60575. * @returns true if blending is enable
  60576. */
  60577. needAlphaBlending(): boolean;
  60578. /**
  60579. * Checks wether the material is ready to be rendered for a given mesh.
  60580. * @param mesh The mesh to render
  60581. * @param subMesh The submesh to check against
  60582. * @param useInstances Specify wether or not the material is used with instances
  60583. * @returns true if all the dependencies are ready (Textures, Effects...)
  60584. */
  60585. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60586. /**
  60587. * Compute the primary color according to the chosen perceptual color.
  60588. */
  60589. private _computePrimaryColorFromPerceptualColor;
  60590. /**
  60591. * Compute the highlights and shadow colors according to their chosen levels.
  60592. */
  60593. private _computePrimaryColors;
  60594. /**
  60595. * Build the uniform buffer used in the material.
  60596. */
  60597. buildUniformLayout(): void;
  60598. /**
  60599. * Unbind the material.
  60600. */
  60601. unbind(): void;
  60602. /**
  60603. * Bind only the world matrix to the material.
  60604. * @param world The world matrix to bind.
  60605. */
  60606. bindOnlyWorldMatrix(world: Matrix): void;
  60607. /**
  60608. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  60609. * @param world The world matrix to bind.
  60610. * @param subMesh The submesh to bind for.
  60611. */
  60612. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60613. /**
  60614. * Checks to see if a texture is used in the material.
  60615. * @param texture - Base texture to use.
  60616. * @returns - Boolean specifying if a texture is used in the material.
  60617. */
  60618. hasTexture(texture: BaseTexture): boolean;
  60619. /**
  60620. * Dispose the material.
  60621. * @param forceDisposeEffect Force disposal of the associated effect.
  60622. * @param forceDisposeTextures Force disposal of the associated textures.
  60623. */
  60624. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  60625. /**
  60626. * Clones the material.
  60627. * @param name The cloned name.
  60628. * @returns The cloned material.
  60629. */
  60630. clone(name: string): BackgroundMaterial;
  60631. /**
  60632. * Serializes the current material to its JSON representation.
  60633. * @returns The JSON representation.
  60634. */
  60635. serialize(): any;
  60636. /**
  60637. * Gets the class name of the material
  60638. * @returns "BackgroundMaterial"
  60639. */
  60640. getClassName(): string;
  60641. /**
  60642. * Parse a JSON input to create back a background material.
  60643. * @param source The JSON data to parse
  60644. * @param scene The scene to create the parsed material in
  60645. * @param rootUrl The root url of the assets the material depends upon
  60646. * @returns the instantiated BackgroundMaterial.
  60647. */
  60648. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  60649. }
  60650. }
  60651. declare module "babylonjs/Helpers/environmentHelper" {
  60652. import { Observable } from "babylonjs/Misc/observable";
  60653. import { Nullable } from "babylonjs/types";
  60654. import { Scene } from "babylonjs/scene";
  60655. import { Vector3 } from "babylonjs/Maths/math.vector";
  60656. import { Color3 } from "babylonjs/Maths/math.color";
  60657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60658. import { Mesh } from "babylonjs/Meshes/mesh";
  60659. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60660. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  60661. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60662. import "babylonjs/Meshes/Builders/planeBuilder";
  60663. import "babylonjs/Meshes/Builders/boxBuilder";
  60664. /**
  60665. * Represents the different options available during the creation of
  60666. * a Environment helper.
  60667. *
  60668. * This can control the default ground, skybox and image processing setup of your scene.
  60669. */
  60670. export interface IEnvironmentHelperOptions {
  60671. /**
  60672. * Specifies whether or not to create a ground.
  60673. * True by default.
  60674. */
  60675. createGround: boolean;
  60676. /**
  60677. * Specifies the ground size.
  60678. * 15 by default.
  60679. */
  60680. groundSize: number;
  60681. /**
  60682. * The texture used on the ground for the main color.
  60683. * Comes from the BabylonJS CDN by default.
  60684. *
  60685. * Remarks: Can be either a texture or a url.
  60686. */
  60687. groundTexture: string | BaseTexture;
  60688. /**
  60689. * The color mixed in the ground texture by default.
  60690. * BabylonJS clearColor by default.
  60691. */
  60692. groundColor: Color3;
  60693. /**
  60694. * Specifies the ground opacity.
  60695. * 1 by default.
  60696. */
  60697. groundOpacity: number;
  60698. /**
  60699. * Enables the ground to receive shadows.
  60700. * True by default.
  60701. */
  60702. enableGroundShadow: boolean;
  60703. /**
  60704. * Helps preventing the shadow to be fully black on the ground.
  60705. * 0.5 by default.
  60706. */
  60707. groundShadowLevel: number;
  60708. /**
  60709. * Creates a mirror texture attach to the ground.
  60710. * false by default.
  60711. */
  60712. enableGroundMirror: boolean;
  60713. /**
  60714. * Specifies the ground mirror size ratio.
  60715. * 0.3 by default as the default kernel is 64.
  60716. */
  60717. groundMirrorSizeRatio: number;
  60718. /**
  60719. * Specifies the ground mirror blur kernel size.
  60720. * 64 by default.
  60721. */
  60722. groundMirrorBlurKernel: number;
  60723. /**
  60724. * Specifies the ground mirror visibility amount.
  60725. * 1 by default
  60726. */
  60727. groundMirrorAmount: number;
  60728. /**
  60729. * Specifies the ground mirror reflectance weight.
  60730. * This uses the standard weight of the background material to setup the fresnel effect
  60731. * of the mirror.
  60732. * 1 by default.
  60733. */
  60734. groundMirrorFresnelWeight: number;
  60735. /**
  60736. * Specifies the ground mirror Falloff distance.
  60737. * This can helps reducing the size of the reflection.
  60738. * 0 by Default.
  60739. */
  60740. groundMirrorFallOffDistance: number;
  60741. /**
  60742. * Specifies the ground mirror texture type.
  60743. * Unsigned Int by Default.
  60744. */
  60745. groundMirrorTextureType: number;
  60746. /**
  60747. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  60748. * the shown objects.
  60749. */
  60750. groundYBias: number;
  60751. /**
  60752. * Specifies whether or not to create a skybox.
  60753. * True by default.
  60754. */
  60755. createSkybox: boolean;
  60756. /**
  60757. * Specifies the skybox size.
  60758. * 20 by default.
  60759. */
  60760. skyboxSize: number;
  60761. /**
  60762. * The texture used on the skybox for the main color.
  60763. * Comes from the BabylonJS CDN by default.
  60764. *
  60765. * Remarks: Can be either a texture or a url.
  60766. */
  60767. skyboxTexture: string | BaseTexture;
  60768. /**
  60769. * The color mixed in the skybox texture by default.
  60770. * BabylonJS clearColor by default.
  60771. */
  60772. skyboxColor: Color3;
  60773. /**
  60774. * The background rotation around the Y axis of the scene.
  60775. * This helps aligning the key lights of your scene with the background.
  60776. * 0 by default.
  60777. */
  60778. backgroundYRotation: number;
  60779. /**
  60780. * Compute automatically the size of the elements to best fit with the scene.
  60781. */
  60782. sizeAuto: boolean;
  60783. /**
  60784. * Default position of the rootMesh if autoSize is not true.
  60785. */
  60786. rootPosition: Vector3;
  60787. /**
  60788. * Sets up the image processing in the scene.
  60789. * true by default.
  60790. */
  60791. setupImageProcessing: boolean;
  60792. /**
  60793. * The texture used as your environment texture in the scene.
  60794. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  60795. *
  60796. * Remarks: Can be either a texture or a url.
  60797. */
  60798. environmentTexture: string | BaseTexture;
  60799. /**
  60800. * The value of the exposure to apply to the scene.
  60801. * 0.6 by default if setupImageProcessing is true.
  60802. */
  60803. cameraExposure: number;
  60804. /**
  60805. * The value of the contrast to apply to the scene.
  60806. * 1.6 by default if setupImageProcessing is true.
  60807. */
  60808. cameraContrast: number;
  60809. /**
  60810. * Specifies whether or not tonemapping should be enabled in the scene.
  60811. * true by default if setupImageProcessing is true.
  60812. */
  60813. toneMappingEnabled: boolean;
  60814. }
  60815. /**
  60816. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  60817. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  60818. * It also helps with the default setup of your imageProcessing configuration.
  60819. */
  60820. export class EnvironmentHelper {
  60821. /**
  60822. * Default ground texture URL.
  60823. */
  60824. private static _groundTextureCDNUrl;
  60825. /**
  60826. * Default skybox texture URL.
  60827. */
  60828. private static _skyboxTextureCDNUrl;
  60829. /**
  60830. * Default environment texture URL.
  60831. */
  60832. private static _environmentTextureCDNUrl;
  60833. /**
  60834. * Creates the default options for the helper.
  60835. */
  60836. private static _getDefaultOptions;
  60837. private _rootMesh;
  60838. /**
  60839. * Gets the root mesh created by the helper.
  60840. */
  60841. get rootMesh(): Mesh;
  60842. private _skybox;
  60843. /**
  60844. * Gets the skybox created by the helper.
  60845. */
  60846. get skybox(): Nullable<Mesh>;
  60847. private _skyboxTexture;
  60848. /**
  60849. * Gets the skybox texture created by the helper.
  60850. */
  60851. get skyboxTexture(): Nullable<BaseTexture>;
  60852. private _skyboxMaterial;
  60853. /**
  60854. * Gets the skybox material created by the helper.
  60855. */
  60856. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  60857. private _ground;
  60858. /**
  60859. * Gets the ground mesh created by the helper.
  60860. */
  60861. get ground(): Nullable<Mesh>;
  60862. private _groundTexture;
  60863. /**
  60864. * Gets the ground texture created by the helper.
  60865. */
  60866. get groundTexture(): Nullable<BaseTexture>;
  60867. private _groundMirror;
  60868. /**
  60869. * Gets the ground mirror created by the helper.
  60870. */
  60871. get groundMirror(): Nullable<MirrorTexture>;
  60872. /**
  60873. * Gets the ground mirror render list to helps pushing the meshes
  60874. * you wish in the ground reflection.
  60875. */
  60876. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  60877. private _groundMaterial;
  60878. /**
  60879. * Gets the ground material created by the helper.
  60880. */
  60881. get groundMaterial(): Nullable<BackgroundMaterial>;
  60882. /**
  60883. * Stores the creation options.
  60884. */
  60885. private readonly _scene;
  60886. private _options;
  60887. /**
  60888. * This observable will be notified with any error during the creation of the environment,
  60889. * mainly texture creation errors.
  60890. */
  60891. onErrorObservable: Observable<{
  60892. message?: string;
  60893. exception?: any;
  60894. }>;
  60895. /**
  60896. * constructor
  60897. * @param options Defines the options we want to customize the helper
  60898. * @param scene The scene to add the material to
  60899. */
  60900. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  60901. /**
  60902. * Updates the background according to the new options
  60903. * @param options
  60904. */
  60905. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  60906. /**
  60907. * Sets the primary color of all the available elements.
  60908. * @param color the main color to affect to the ground and the background
  60909. */
  60910. setMainColor(color: Color3): void;
  60911. /**
  60912. * Setup the image processing according to the specified options.
  60913. */
  60914. private _setupImageProcessing;
  60915. /**
  60916. * Setup the environment texture according to the specified options.
  60917. */
  60918. private _setupEnvironmentTexture;
  60919. /**
  60920. * Setup the background according to the specified options.
  60921. */
  60922. private _setupBackground;
  60923. /**
  60924. * Get the scene sizes according to the setup.
  60925. */
  60926. private _getSceneSize;
  60927. /**
  60928. * Setup the ground according to the specified options.
  60929. */
  60930. private _setupGround;
  60931. /**
  60932. * Setup the ground material according to the specified options.
  60933. */
  60934. private _setupGroundMaterial;
  60935. /**
  60936. * Setup the ground diffuse texture according to the specified options.
  60937. */
  60938. private _setupGroundDiffuseTexture;
  60939. /**
  60940. * Setup the ground mirror texture according to the specified options.
  60941. */
  60942. private _setupGroundMirrorTexture;
  60943. /**
  60944. * Setup the ground to receive the mirror texture.
  60945. */
  60946. private _setupMirrorInGroundMaterial;
  60947. /**
  60948. * Setup the skybox according to the specified options.
  60949. */
  60950. private _setupSkybox;
  60951. /**
  60952. * Setup the skybox material according to the specified options.
  60953. */
  60954. private _setupSkyboxMaterial;
  60955. /**
  60956. * Setup the skybox reflection texture according to the specified options.
  60957. */
  60958. private _setupSkyboxReflectionTexture;
  60959. private _errorHandler;
  60960. /**
  60961. * Dispose all the elements created by the Helper.
  60962. */
  60963. dispose(): void;
  60964. }
  60965. }
  60966. declare module "babylonjs/Helpers/textureDome" {
  60967. import { Scene } from "babylonjs/scene";
  60968. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60969. import { Mesh } from "babylonjs/Meshes/mesh";
  60970. import { Texture } from "babylonjs/Materials/Textures/texture";
  60971. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60972. import "babylonjs/Meshes/Builders/sphereBuilder";
  60973. import { Nullable } from "babylonjs/types";
  60974. import { Observable } from "babylonjs/Misc/observable";
  60975. /**
  60976. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  60977. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  60978. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60979. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60980. */
  60981. export abstract class TextureDome<T extends Texture> extends TransformNode {
  60982. protected onError: Nullable<(message?: string, exception?: any) => void>;
  60983. /**
  60984. * Define the source as a Monoscopic panoramic 360/180.
  60985. */
  60986. static readonly MODE_MONOSCOPIC: number;
  60987. /**
  60988. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  60989. */
  60990. static readonly MODE_TOPBOTTOM: number;
  60991. /**
  60992. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  60993. */
  60994. static readonly MODE_SIDEBYSIDE: number;
  60995. private _halfDome;
  60996. private _crossEye;
  60997. protected _useDirectMapping: boolean;
  60998. /**
  60999. * The texture being displayed on the sphere
  61000. */
  61001. protected _texture: T;
  61002. /**
  61003. * Gets the texture being displayed on the sphere
  61004. */
  61005. get texture(): T;
  61006. /**
  61007. * Sets the texture being displayed on the sphere
  61008. */
  61009. set texture(newTexture: T);
  61010. /**
  61011. * The skybox material
  61012. */
  61013. protected _material: BackgroundMaterial;
  61014. /**
  61015. * The surface used for the dome
  61016. */
  61017. protected _mesh: Mesh;
  61018. /**
  61019. * Gets the mesh used for the dome.
  61020. */
  61021. get mesh(): Mesh;
  61022. /**
  61023. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61024. */
  61025. private _halfDomeMask;
  61026. /**
  61027. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61028. * Also see the options.resolution property.
  61029. */
  61030. get fovMultiplier(): number;
  61031. set fovMultiplier(value: number);
  61032. protected _textureMode: number;
  61033. /**
  61034. * Gets or set the current texture mode for the texture. It can be:
  61035. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61036. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61037. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61038. */
  61039. get textureMode(): number;
  61040. /**
  61041. * Sets the current texture mode for the texture. It can be:
  61042. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61043. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61044. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61045. */
  61046. set textureMode(value: number);
  61047. /**
  61048. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61049. */
  61050. get halfDome(): boolean;
  61051. /**
  61052. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61053. */
  61054. set halfDome(enabled: boolean);
  61055. /**
  61056. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61057. */
  61058. set crossEye(enabled: boolean);
  61059. /**
  61060. * Is it a cross-eye texture?
  61061. */
  61062. get crossEye(): boolean;
  61063. /**
  61064. * The background material of this dome.
  61065. */
  61066. get material(): BackgroundMaterial;
  61067. /**
  61068. * Oberserver used in Stereoscopic VR Mode.
  61069. */
  61070. private _onBeforeCameraRenderObserver;
  61071. /**
  61072. * Observable raised when an error occured while loading the 360 image
  61073. */
  61074. onLoadErrorObservable: Observable<string>;
  61075. /**
  61076. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61077. * @param name Element's name, child elements will append suffixes for their own names.
  61078. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61079. * @param options An object containing optional or exposed sub element properties
  61080. */
  61081. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61082. resolution?: number;
  61083. clickToPlay?: boolean;
  61084. autoPlay?: boolean;
  61085. loop?: boolean;
  61086. size?: number;
  61087. poster?: string;
  61088. faceForward?: boolean;
  61089. useDirectMapping?: boolean;
  61090. halfDomeMode?: boolean;
  61091. crossEyeMode?: boolean;
  61092. generateMipMaps?: boolean;
  61093. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61094. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61095. protected _changeTextureMode(value: number): void;
  61096. /**
  61097. * Releases resources associated with this node.
  61098. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61099. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61100. */
  61101. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61102. }
  61103. }
  61104. declare module "babylonjs/Helpers/photoDome" {
  61105. import { Scene } from "babylonjs/scene";
  61106. import { Texture } from "babylonjs/Materials/Textures/texture";
  61107. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61108. /**
  61109. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61110. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61111. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61112. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61113. */
  61114. export class PhotoDome extends TextureDome<Texture> {
  61115. /**
  61116. * Define the image as a Monoscopic panoramic 360 image.
  61117. */
  61118. static readonly MODE_MONOSCOPIC: number;
  61119. /**
  61120. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61121. */
  61122. static readonly MODE_TOPBOTTOM: number;
  61123. /**
  61124. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61125. */
  61126. static readonly MODE_SIDEBYSIDE: number;
  61127. /**
  61128. * Gets or sets the texture being displayed on the sphere
  61129. */
  61130. get photoTexture(): Texture;
  61131. /**
  61132. * sets the texture being displayed on the sphere
  61133. */
  61134. set photoTexture(value: Texture);
  61135. /**
  61136. * Gets the current video mode for the video. It can be:
  61137. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61138. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61139. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61140. */
  61141. get imageMode(): number;
  61142. /**
  61143. * Sets the current video mode for the video. It can be:
  61144. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61145. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61146. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61147. */
  61148. set imageMode(value: number);
  61149. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61150. }
  61151. }
  61152. declare module "babylonjs/Misc/dds" {
  61153. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  61154. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61155. import { Nullable } from "babylonjs/types";
  61156. import { Scene } from "babylonjs/scene";
  61157. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  61158. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61159. /**
  61160. * Direct draw surface info
  61161. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61162. */
  61163. export interface DDSInfo {
  61164. /**
  61165. * Width of the texture
  61166. */
  61167. width: number;
  61168. /**
  61169. * Width of the texture
  61170. */
  61171. height: number;
  61172. /**
  61173. * Number of Mipmaps for the texture
  61174. * @see https://en.wikipedia.org/wiki/Mipmap
  61175. */
  61176. mipmapCount: number;
  61177. /**
  61178. * If the textures format is a known fourCC format
  61179. * @see https://www.fourcc.org/
  61180. */
  61181. isFourCC: boolean;
  61182. /**
  61183. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61184. */
  61185. isRGB: boolean;
  61186. /**
  61187. * If the texture is a lumincance format
  61188. */
  61189. isLuminance: boolean;
  61190. /**
  61191. * If this is a cube texture
  61192. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61193. */
  61194. isCube: boolean;
  61195. /**
  61196. * If the texture is a compressed format eg. FOURCC_DXT1
  61197. */
  61198. isCompressed: boolean;
  61199. /**
  61200. * The dxgiFormat of the texture
  61201. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61202. */
  61203. dxgiFormat: number;
  61204. /**
  61205. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61206. */
  61207. textureType: number;
  61208. /**
  61209. * Sphericle polynomial created for the dds texture
  61210. */
  61211. sphericalPolynomial?: SphericalPolynomial;
  61212. }
  61213. /**
  61214. * Class used to provide DDS decompression tools
  61215. */
  61216. export class DDSTools {
  61217. /**
  61218. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  61219. */
  61220. static StoreLODInAlphaChannel: boolean;
  61221. /**
  61222. * Gets DDS information from an array buffer
  61223. * @param data defines the array buffer view to read data from
  61224. * @returns the DDS information
  61225. */
  61226. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  61227. private static _FloatView;
  61228. private static _Int32View;
  61229. private static _ToHalfFloat;
  61230. private static _FromHalfFloat;
  61231. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  61232. private static _GetHalfFloatRGBAArrayBuffer;
  61233. private static _GetFloatRGBAArrayBuffer;
  61234. private static _GetFloatAsUIntRGBAArrayBuffer;
  61235. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  61236. private static _GetRGBAArrayBuffer;
  61237. private static _ExtractLongWordOrder;
  61238. private static _GetRGBArrayBuffer;
  61239. private static _GetLuminanceArrayBuffer;
  61240. /**
  61241. * Uploads DDS Levels to a Babylon Texture
  61242. * @hidden
  61243. */
  61244. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  61245. }
  61246. module "babylonjs/Engines/thinEngine" {
  61247. interface ThinEngine {
  61248. /**
  61249. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  61250. * @param rootUrl defines the url where the file to load is located
  61251. * @param scene defines the current scene
  61252. * @param lodScale defines scale to apply to the mip map selection
  61253. * @param lodOffset defines offset to apply to the mip map selection
  61254. * @param onLoad defines an optional callback raised when the texture is loaded
  61255. * @param onError defines an optional callback raised if there is an issue to load the texture
  61256. * @param format defines the format of the data
  61257. * @param forcedExtension defines the extension to use to pick the right loader
  61258. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  61259. * @returns the cube texture as an InternalTexture
  61260. */
  61261. 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;
  61262. }
  61263. }
  61264. }
  61265. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  61266. import { Nullable } from "babylonjs/types";
  61267. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61268. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61269. /**
  61270. * Implementation of the DDS Texture Loader.
  61271. * @hidden
  61272. */
  61273. export class _DDSTextureLoader implements IInternalTextureLoader {
  61274. /**
  61275. * Defines wether the loader supports cascade loading the different faces.
  61276. */
  61277. readonly supportCascades: boolean;
  61278. /**
  61279. * This returns if the loader support the current file information.
  61280. * @param extension defines the file extension of the file being loaded
  61281. * @returns true if the loader can load the specified file
  61282. */
  61283. canLoad(extension: string): boolean;
  61284. /**
  61285. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61286. * @param data contains the texture data
  61287. * @param texture defines the BabylonJS internal texture
  61288. * @param createPolynomials will be true if polynomials have been requested
  61289. * @param onLoad defines the callback to trigger once the texture is ready
  61290. * @param onError defines the callback to trigger in case of error
  61291. */
  61292. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61293. /**
  61294. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61295. * @param data contains the texture data
  61296. * @param texture defines the BabylonJS internal texture
  61297. * @param callback defines the method to call once ready to upload
  61298. */
  61299. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61300. }
  61301. }
  61302. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  61303. import { Nullable } from "babylonjs/types";
  61304. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61305. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61306. /**
  61307. * Implementation of the ENV Texture Loader.
  61308. * @hidden
  61309. */
  61310. export class _ENVTextureLoader implements IInternalTextureLoader {
  61311. /**
  61312. * Defines wether the loader supports cascade loading the different faces.
  61313. */
  61314. readonly supportCascades: boolean;
  61315. /**
  61316. * This returns if the loader support the current file information.
  61317. * @param extension defines the file extension of the file being loaded
  61318. * @returns true if the loader can load the specified file
  61319. */
  61320. canLoad(extension: string): boolean;
  61321. /**
  61322. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61323. * @param data contains the texture data
  61324. * @param texture defines the BabylonJS internal texture
  61325. * @param createPolynomials will be true if polynomials have been requested
  61326. * @param onLoad defines the callback to trigger once the texture is ready
  61327. * @param onError defines the callback to trigger in case of error
  61328. */
  61329. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61330. /**
  61331. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61332. * @param data contains the texture data
  61333. * @param texture defines the BabylonJS internal texture
  61334. * @param callback defines the method to call once ready to upload
  61335. */
  61336. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61337. }
  61338. }
  61339. declare module "babylonjs/Misc/khronosTextureContainer" {
  61340. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61341. /**
  61342. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61343. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61344. */
  61345. export class KhronosTextureContainer {
  61346. /** contents of the KTX container file */
  61347. data: ArrayBufferView;
  61348. private static HEADER_LEN;
  61349. private static COMPRESSED_2D;
  61350. private static COMPRESSED_3D;
  61351. private static TEX_2D;
  61352. private static TEX_3D;
  61353. /**
  61354. * Gets the openGL type
  61355. */
  61356. glType: number;
  61357. /**
  61358. * Gets the openGL type size
  61359. */
  61360. glTypeSize: number;
  61361. /**
  61362. * Gets the openGL format
  61363. */
  61364. glFormat: number;
  61365. /**
  61366. * Gets the openGL internal format
  61367. */
  61368. glInternalFormat: number;
  61369. /**
  61370. * Gets the base internal format
  61371. */
  61372. glBaseInternalFormat: number;
  61373. /**
  61374. * Gets image width in pixel
  61375. */
  61376. pixelWidth: number;
  61377. /**
  61378. * Gets image height in pixel
  61379. */
  61380. pixelHeight: number;
  61381. /**
  61382. * Gets image depth in pixels
  61383. */
  61384. pixelDepth: number;
  61385. /**
  61386. * Gets the number of array elements
  61387. */
  61388. numberOfArrayElements: number;
  61389. /**
  61390. * Gets the number of faces
  61391. */
  61392. numberOfFaces: number;
  61393. /**
  61394. * Gets the number of mipmap levels
  61395. */
  61396. numberOfMipmapLevels: number;
  61397. /**
  61398. * Gets the bytes of key value data
  61399. */
  61400. bytesOfKeyValueData: number;
  61401. /**
  61402. * Gets the load type
  61403. */
  61404. loadType: number;
  61405. /**
  61406. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61407. */
  61408. isInvalid: boolean;
  61409. /**
  61410. * Creates a new KhronosTextureContainer
  61411. * @param data contents of the KTX container file
  61412. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61413. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61414. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61415. */
  61416. constructor(
  61417. /** contents of the KTX container file */
  61418. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61419. /**
  61420. * Uploads KTX content to a Babylon Texture.
  61421. * It is assumed that the texture has already been created & is currently bound
  61422. * @hidden
  61423. */
  61424. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61425. private _upload2DCompressedLevels;
  61426. /**
  61427. * Checks if the given data starts with a KTX file identifier.
  61428. * @param data the data to check
  61429. * @returns true if the data is a KTX file or false otherwise
  61430. */
  61431. static IsValid(data: ArrayBufferView): boolean;
  61432. }
  61433. }
  61434. declare module "babylonjs/Misc/workerPool" {
  61435. import { IDisposable } from "babylonjs/scene";
  61436. /**
  61437. * Helper class to push actions to a pool of workers.
  61438. */
  61439. export class WorkerPool implements IDisposable {
  61440. private _workerInfos;
  61441. private _pendingActions;
  61442. /**
  61443. * Constructor
  61444. * @param workers Array of workers to use for actions
  61445. */
  61446. constructor(workers: Array<Worker>);
  61447. /**
  61448. * Terminates all workers and clears any pending actions.
  61449. */
  61450. dispose(): void;
  61451. /**
  61452. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61453. * pended until a worker has completed its action.
  61454. * @param action The action to perform. Call onComplete when the action is complete.
  61455. */
  61456. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61457. private _execute;
  61458. }
  61459. }
  61460. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61461. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61462. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61463. /**
  61464. * Class for loading KTX2 files
  61465. */
  61466. export class KhronosTextureContainer2 {
  61467. private static _WorkerPoolPromise?;
  61468. private static _Initialized;
  61469. private static _Ktx2Decoder;
  61470. /**
  61471. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61472. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61473. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61474. * Urls you can change:
  61475. * URLConfig.jsDecoderModule
  61476. * URLConfig.wasmUASTCToASTC
  61477. * URLConfig.wasmUASTCToBC7
  61478. * URLConfig.wasmUASTCToRGBA_UNORM
  61479. * URLConfig.wasmUASTCToRGBA_SRGB
  61480. * URLConfig.jsMSCTranscoder
  61481. * URLConfig.wasmMSCTranscoder
  61482. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  61483. */
  61484. static URLConfig: {
  61485. jsDecoderModule: string;
  61486. wasmUASTCToASTC: null;
  61487. wasmUASTCToBC7: null;
  61488. wasmUASTCToRGBA_UNORM: null;
  61489. wasmUASTCToRGBA_SRGB: null;
  61490. jsMSCTranscoder: null;
  61491. wasmMSCTranscoder: null;
  61492. };
  61493. /**
  61494. * Default number of workers used to handle data decoding
  61495. */
  61496. static DefaultNumWorkers: number;
  61497. private static GetDefaultNumWorkers;
  61498. private _engine;
  61499. private static _CreateWorkerPool;
  61500. /**
  61501. * Constructor
  61502. * @param engine The engine to use
  61503. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61504. */
  61505. constructor(engine: ThinEngine, numWorkers?: number);
  61506. /** @hidden */
  61507. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  61508. /**
  61509. * Stop all async operations and release resources.
  61510. */
  61511. dispose(): void;
  61512. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  61513. /**
  61514. * Checks if the given data starts with a KTX2 file identifier.
  61515. * @param data the data to check
  61516. * @returns true if the data is a KTX2 file or false otherwise
  61517. */
  61518. static IsValid(data: ArrayBufferView): boolean;
  61519. }
  61520. }
  61521. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  61522. import { Nullable } from "babylonjs/types";
  61523. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61524. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61525. /**
  61526. * Implementation of the KTX Texture Loader.
  61527. * @hidden
  61528. */
  61529. export class _KTXTextureLoader implements IInternalTextureLoader {
  61530. /**
  61531. * Defines wether the loader supports cascade loading the different faces.
  61532. */
  61533. readonly supportCascades: boolean;
  61534. /**
  61535. * This returns if the loader support the current file information.
  61536. * @param extension defines the file extension of the file being loaded
  61537. * @param mimeType defines the optional mime type of the file being loaded
  61538. * @returns true if the loader can load the specified file
  61539. */
  61540. canLoad(extension: string, mimeType?: string): boolean;
  61541. /**
  61542. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61543. * @param data contains the texture data
  61544. * @param texture defines the BabylonJS internal texture
  61545. * @param createPolynomials will be true if polynomials have been requested
  61546. * @param onLoad defines the callback to trigger once the texture is ready
  61547. * @param onError defines the callback to trigger in case of error
  61548. */
  61549. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61550. /**
  61551. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61552. * @param data contains the texture data
  61553. * @param texture defines the BabylonJS internal texture
  61554. * @param callback defines the method to call once ready to upload
  61555. */
  61556. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  61557. }
  61558. }
  61559. declare module "babylonjs/Helpers/sceneHelpers" {
  61560. import { Nullable } from "babylonjs/types";
  61561. import { Mesh } from "babylonjs/Meshes/mesh";
  61562. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61563. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  61564. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  61565. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  61566. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  61567. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  61568. import "babylonjs/Meshes/Builders/boxBuilder";
  61569. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  61570. /** @hidden */
  61571. export var _forceSceneHelpersToBundle: boolean;
  61572. module "babylonjs/scene" {
  61573. interface Scene {
  61574. /**
  61575. * Creates a default light for the scene.
  61576. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  61577. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  61578. */
  61579. createDefaultLight(replace?: boolean): void;
  61580. /**
  61581. * Creates a default camera for the scene.
  61582. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  61583. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61584. * @param replace has default false, when true replaces the active camera in the scene
  61585. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  61586. */
  61587. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61588. /**
  61589. * Creates a default camera and a default light.
  61590. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  61591. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61592. * @param replace has the default false, when true replaces the active camera/light in the scene
  61593. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  61594. */
  61595. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61596. /**
  61597. * Creates a new sky box
  61598. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  61599. * @param environmentTexture defines the texture to use as environment texture
  61600. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  61601. * @param scale defines the overall scale of the skybox
  61602. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  61603. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  61604. * @returns a new mesh holding the sky box
  61605. */
  61606. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  61607. /**
  61608. * Creates a new environment
  61609. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  61610. * @param options defines the options you can use to configure the environment
  61611. * @returns the new EnvironmentHelper
  61612. */
  61613. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  61614. /**
  61615. * Creates a new VREXperienceHelper
  61616. * @see https://doc.babylonjs.com/how_to/webvr_helper
  61617. * @param webVROptions defines the options used to create the new VREXperienceHelper
  61618. * @returns a new VREXperienceHelper
  61619. */
  61620. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  61621. /**
  61622. * Creates a new WebXRDefaultExperience
  61623. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  61624. * @param options experience options
  61625. * @returns a promise for a new WebXRDefaultExperience
  61626. */
  61627. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  61628. }
  61629. }
  61630. }
  61631. declare module "babylonjs/Helpers/videoDome" {
  61632. import { Scene } from "babylonjs/scene";
  61633. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  61634. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61635. /**
  61636. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  61637. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  61638. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  61639. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61640. */
  61641. export class VideoDome extends TextureDome<VideoTexture> {
  61642. /**
  61643. * Define the video source as a Monoscopic panoramic 360 video.
  61644. */
  61645. static readonly MODE_MONOSCOPIC: number;
  61646. /**
  61647. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  61648. */
  61649. static readonly MODE_TOPBOTTOM: number;
  61650. /**
  61651. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  61652. */
  61653. static readonly MODE_SIDEBYSIDE: number;
  61654. /**
  61655. * Get the video texture associated with this video dome
  61656. */
  61657. get videoTexture(): VideoTexture;
  61658. /**
  61659. * Get the video mode of this dome
  61660. */
  61661. get videoMode(): number;
  61662. /**
  61663. * Set the video mode of this dome.
  61664. * @see textureMode
  61665. */
  61666. set videoMode(value: number);
  61667. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  61668. }
  61669. }
  61670. declare module "babylonjs/Helpers/index" {
  61671. export * from "babylonjs/Helpers/environmentHelper";
  61672. export * from "babylonjs/Helpers/photoDome";
  61673. export * from "babylonjs/Helpers/sceneHelpers";
  61674. export * from "babylonjs/Helpers/videoDome";
  61675. }
  61676. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  61677. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61678. import { IDisposable } from "babylonjs/scene";
  61679. import { Engine } from "babylonjs/Engines/engine";
  61680. /**
  61681. * This class can be used to get instrumentation data from a Babylon engine
  61682. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61683. */
  61684. export class EngineInstrumentation implements IDisposable {
  61685. /**
  61686. * Define the instrumented engine.
  61687. */
  61688. engine: Engine;
  61689. private _captureGPUFrameTime;
  61690. private _gpuFrameTimeToken;
  61691. private _gpuFrameTime;
  61692. private _captureShaderCompilationTime;
  61693. private _shaderCompilationTime;
  61694. private _onBeginFrameObserver;
  61695. private _onEndFrameObserver;
  61696. private _onBeforeShaderCompilationObserver;
  61697. private _onAfterShaderCompilationObserver;
  61698. /**
  61699. * Gets the perf counter used for GPU frame time
  61700. */
  61701. get gpuFrameTimeCounter(): PerfCounter;
  61702. /**
  61703. * Gets the GPU frame time capture status
  61704. */
  61705. get captureGPUFrameTime(): boolean;
  61706. /**
  61707. * Enable or disable the GPU frame time capture
  61708. */
  61709. set captureGPUFrameTime(value: boolean);
  61710. /**
  61711. * Gets the perf counter used for shader compilation time
  61712. */
  61713. get shaderCompilationTimeCounter(): PerfCounter;
  61714. /**
  61715. * Gets the shader compilation time capture status
  61716. */
  61717. get captureShaderCompilationTime(): boolean;
  61718. /**
  61719. * Enable or disable the shader compilation time capture
  61720. */
  61721. set captureShaderCompilationTime(value: boolean);
  61722. /**
  61723. * Instantiates a new engine instrumentation.
  61724. * This class can be used to get instrumentation data from a Babylon engine
  61725. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61726. * @param engine Defines the engine to instrument
  61727. */
  61728. constructor(
  61729. /**
  61730. * Define the instrumented engine.
  61731. */
  61732. engine: Engine);
  61733. /**
  61734. * Dispose and release associated resources.
  61735. */
  61736. dispose(): void;
  61737. }
  61738. }
  61739. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  61740. import { Scene, IDisposable } from "babylonjs/scene";
  61741. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61742. /**
  61743. * This class can be used to get instrumentation data from a Babylon engine
  61744. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61745. */
  61746. export class SceneInstrumentation implements IDisposable {
  61747. /**
  61748. * Defines the scene to instrument
  61749. */
  61750. scene: Scene;
  61751. private _captureActiveMeshesEvaluationTime;
  61752. private _activeMeshesEvaluationTime;
  61753. private _captureRenderTargetsRenderTime;
  61754. private _renderTargetsRenderTime;
  61755. private _captureFrameTime;
  61756. private _frameTime;
  61757. private _captureRenderTime;
  61758. private _renderTime;
  61759. private _captureInterFrameTime;
  61760. private _interFrameTime;
  61761. private _captureParticlesRenderTime;
  61762. private _particlesRenderTime;
  61763. private _captureSpritesRenderTime;
  61764. private _spritesRenderTime;
  61765. private _capturePhysicsTime;
  61766. private _physicsTime;
  61767. private _captureAnimationsTime;
  61768. private _animationsTime;
  61769. private _captureCameraRenderTime;
  61770. private _cameraRenderTime;
  61771. private _onBeforeActiveMeshesEvaluationObserver;
  61772. private _onAfterActiveMeshesEvaluationObserver;
  61773. private _onBeforeRenderTargetsRenderObserver;
  61774. private _onAfterRenderTargetsRenderObserver;
  61775. private _onAfterRenderObserver;
  61776. private _onBeforeDrawPhaseObserver;
  61777. private _onAfterDrawPhaseObserver;
  61778. private _onBeforeAnimationsObserver;
  61779. private _onBeforeParticlesRenderingObserver;
  61780. private _onAfterParticlesRenderingObserver;
  61781. private _onBeforeSpritesRenderingObserver;
  61782. private _onAfterSpritesRenderingObserver;
  61783. private _onBeforePhysicsObserver;
  61784. private _onAfterPhysicsObserver;
  61785. private _onAfterAnimationsObserver;
  61786. private _onBeforeCameraRenderObserver;
  61787. private _onAfterCameraRenderObserver;
  61788. /**
  61789. * Gets the perf counter used for active meshes evaluation time
  61790. */
  61791. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  61792. /**
  61793. * Gets the active meshes evaluation time capture status
  61794. */
  61795. get captureActiveMeshesEvaluationTime(): boolean;
  61796. /**
  61797. * Enable or disable the active meshes evaluation time capture
  61798. */
  61799. set captureActiveMeshesEvaluationTime(value: boolean);
  61800. /**
  61801. * Gets the perf counter used for render targets render time
  61802. */
  61803. get renderTargetsRenderTimeCounter(): PerfCounter;
  61804. /**
  61805. * Gets the render targets render time capture status
  61806. */
  61807. get captureRenderTargetsRenderTime(): boolean;
  61808. /**
  61809. * Enable or disable the render targets render time capture
  61810. */
  61811. set captureRenderTargetsRenderTime(value: boolean);
  61812. /**
  61813. * Gets the perf counter used for particles render time
  61814. */
  61815. get particlesRenderTimeCounter(): PerfCounter;
  61816. /**
  61817. * Gets the particles render time capture status
  61818. */
  61819. get captureParticlesRenderTime(): boolean;
  61820. /**
  61821. * Enable or disable the particles render time capture
  61822. */
  61823. set captureParticlesRenderTime(value: boolean);
  61824. /**
  61825. * Gets the perf counter used for sprites render time
  61826. */
  61827. get spritesRenderTimeCounter(): PerfCounter;
  61828. /**
  61829. * Gets the sprites render time capture status
  61830. */
  61831. get captureSpritesRenderTime(): boolean;
  61832. /**
  61833. * Enable or disable the sprites render time capture
  61834. */
  61835. set captureSpritesRenderTime(value: boolean);
  61836. /**
  61837. * Gets the perf counter used for physics time
  61838. */
  61839. get physicsTimeCounter(): PerfCounter;
  61840. /**
  61841. * Gets the physics time capture status
  61842. */
  61843. get capturePhysicsTime(): boolean;
  61844. /**
  61845. * Enable or disable the physics time capture
  61846. */
  61847. set capturePhysicsTime(value: boolean);
  61848. /**
  61849. * Gets the perf counter used for animations time
  61850. */
  61851. get animationsTimeCounter(): PerfCounter;
  61852. /**
  61853. * Gets the animations time capture status
  61854. */
  61855. get captureAnimationsTime(): boolean;
  61856. /**
  61857. * Enable or disable the animations time capture
  61858. */
  61859. set captureAnimationsTime(value: boolean);
  61860. /**
  61861. * Gets the perf counter used for frame time capture
  61862. */
  61863. get frameTimeCounter(): PerfCounter;
  61864. /**
  61865. * Gets the frame time capture status
  61866. */
  61867. get captureFrameTime(): boolean;
  61868. /**
  61869. * Enable or disable the frame time capture
  61870. */
  61871. set captureFrameTime(value: boolean);
  61872. /**
  61873. * Gets the perf counter used for inter-frames time capture
  61874. */
  61875. get interFrameTimeCounter(): PerfCounter;
  61876. /**
  61877. * Gets the inter-frames time capture status
  61878. */
  61879. get captureInterFrameTime(): boolean;
  61880. /**
  61881. * Enable or disable the inter-frames time capture
  61882. */
  61883. set captureInterFrameTime(value: boolean);
  61884. /**
  61885. * Gets the perf counter used for render time capture
  61886. */
  61887. get renderTimeCounter(): PerfCounter;
  61888. /**
  61889. * Gets the render time capture status
  61890. */
  61891. get captureRenderTime(): boolean;
  61892. /**
  61893. * Enable or disable the render time capture
  61894. */
  61895. set captureRenderTime(value: boolean);
  61896. /**
  61897. * Gets the perf counter used for camera render time capture
  61898. */
  61899. get cameraRenderTimeCounter(): PerfCounter;
  61900. /**
  61901. * Gets the camera render time capture status
  61902. */
  61903. get captureCameraRenderTime(): boolean;
  61904. /**
  61905. * Enable or disable the camera render time capture
  61906. */
  61907. set captureCameraRenderTime(value: boolean);
  61908. /**
  61909. * Gets the perf counter used for draw calls
  61910. */
  61911. get drawCallsCounter(): PerfCounter;
  61912. /**
  61913. * Instantiates a new scene instrumentation.
  61914. * This class can be used to get instrumentation data from a Babylon engine
  61915. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61916. * @param scene Defines the scene to instrument
  61917. */
  61918. constructor(
  61919. /**
  61920. * Defines the scene to instrument
  61921. */
  61922. scene: Scene);
  61923. /**
  61924. * Dispose and release associated resources.
  61925. */
  61926. dispose(): void;
  61927. }
  61928. }
  61929. declare module "babylonjs/Instrumentation/index" {
  61930. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61931. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61932. export * from "babylonjs/Instrumentation/timeToken";
  61933. }
  61934. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61935. /** @hidden */
  61936. export var glowMapGenerationPixelShader: {
  61937. name: string;
  61938. shader: string;
  61939. };
  61940. }
  61941. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61942. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61943. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61944. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61945. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61946. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61947. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61948. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61949. /** @hidden */
  61950. export var glowMapGenerationVertexShader: {
  61951. name: string;
  61952. shader: string;
  61953. };
  61954. }
  61955. declare module "babylonjs/Layers/effectLayer" {
  61956. import { Observable } from "babylonjs/Misc/observable";
  61957. import { Nullable } from "babylonjs/types";
  61958. import { Camera } from "babylonjs/Cameras/camera";
  61959. import { Scene } from "babylonjs/scene";
  61960. import { ISize } from "babylonjs/Maths/math.size";
  61961. import { Color4 } from "babylonjs/Maths/math.color";
  61962. import { Engine } from "babylonjs/Engines/engine";
  61963. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61965. import { Mesh } from "babylonjs/Meshes/mesh";
  61966. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61968. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61969. import { Effect } from "babylonjs/Materials/effect";
  61970. import { Material } from "babylonjs/Materials/material";
  61971. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61972. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61973. /**
  61974. * Effect layer options. This helps customizing the behaviour
  61975. * of the effect layer.
  61976. */
  61977. export interface IEffectLayerOptions {
  61978. /**
  61979. * Multiplication factor apply to the canvas size to compute the render target size
  61980. * used to generated the objects (the smaller the faster).
  61981. */
  61982. mainTextureRatio: number;
  61983. /**
  61984. * Enforces a fixed size texture to ensure effect stability across devices.
  61985. */
  61986. mainTextureFixedSize?: number;
  61987. /**
  61988. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61989. */
  61990. alphaBlendingMode: number;
  61991. /**
  61992. * The camera attached to the layer.
  61993. */
  61994. camera: Nullable<Camera>;
  61995. /**
  61996. * The rendering group to draw the layer in.
  61997. */
  61998. renderingGroupId: number;
  61999. }
  62000. /**
  62001. * The effect layer Helps adding post process effect blended with the main pass.
  62002. *
  62003. * This can be for instance use to generate glow or higlight effects on the scene.
  62004. *
  62005. * The effect layer class can not be used directly and is intented to inherited from to be
  62006. * customized per effects.
  62007. */
  62008. export abstract class EffectLayer {
  62009. private _vertexBuffers;
  62010. private _indexBuffer;
  62011. private _cachedDefines;
  62012. private _effectLayerMapGenerationEffect;
  62013. private _effectLayerOptions;
  62014. private _mergeEffect;
  62015. protected _scene: Scene;
  62016. protected _engine: Engine;
  62017. protected _maxSize: number;
  62018. protected _mainTextureDesiredSize: ISize;
  62019. protected _mainTexture: RenderTargetTexture;
  62020. protected _shouldRender: boolean;
  62021. protected _postProcesses: PostProcess[];
  62022. protected _textures: BaseTexture[];
  62023. protected _emissiveTextureAndColor: {
  62024. texture: Nullable<BaseTexture>;
  62025. color: Color4;
  62026. };
  62027. /**
  62028. * The name of the layer
  62029. */
  62030. name: string;
  62031. /**
  62032. * The clear color of the texture used to generate the glow map.
  62033. */
  62034. neutralColor: Color4;
  62035. /**
  62036. * Specifies whether the highlight layer is enabled or not.
  62037. */
  62038. isEnabled: boolean;
  62039. /**
  62040. * Gets the camera attached to the layer.
  62041. */
  62042. get camera(): Nullable<Camera>;
  62043. /**
  62044. * Gets the rendering group id the layer should render in.
  62045. */
  62046. get renderingGroupId(): number;
  62047. set renderingGroupId(renderingGroupId: number);
  62048. /**
  62049. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62050. */
  62051. disableBoundingBoxesFromEffectLayer: boolean;
  62052. /**
  62053. * An event triggered when the effect layer has been disposed.
  62054. */
  62055. onDisposeObservable: Observable<EffectLayer>;
  62056. /**
  62057. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62058. */
  62059. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62060. /**
  62061. * An event triggered when the generated texture is being merged in the scene.
  62062. */
  62063. onBeforeComposeObservable: Observable<EffectLayer>;
  62064. /**
  62065. * An event triggered when the mesh is rendered into the effect render target.
  62066. */
  62067. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62068. /**
  62069. * An event triggered after the mesh has been rendered into the effect render target.
  62070. */
  62071. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62072. /**
  62073. * An event triggered when the generated texture has been merged in the scene.
  62074. */
  62075. onAfterComposeObservable: Observable<EffectLayer>;
  62076. /**
  62077. * An event triggered when the efffect layer changes its size.
  62078. */
  62079. onSizeChangedObservable: Observable<EffectLayer>;
  62080. /** @hidden */
  62081. static _SceneComponentInitialization: (scene: Scene) => void;
  62082. /**
  62083. * Instantiates a new effect Layer and references it in the scene.
  62084. * @param name The name of the layer
  62085. * @param scene The scene to use the layer in
  62086. */
  62087. constructor(
  62088. /** The Friendly of the effect in the scene */
  62089. name: string, scene: Scene);
  62090. /**
  62091. * Get the effect name of the layer.
  62092. * @return The effect name
  62093. */
  62094. abstract getEffectName(): string;
  62095. /**
  62096. * Checks for the readiness of the element composing the layer.
  62097. * @param subMesh the mesh to check for
  62098. * @param useInstances specify whether or not to use instances to render the mesh
  62099. * @return true if ready otherwise, false
  62100. */
  62101. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62102. /**
  62103. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62104. * @returns true if the effect requires stencil during the main canvas render pass.
  62105. */
  62106. abstract needStencil(): boolean;
  62107. /**
  62108. * Create the merge effect. This is the shader use to blit the information back
  62109. * to the main canvas at the end of the scene rendering.
  62110. * @returns The effect containing the shader used to merge the effect on the main canvas
  62111. */
  62112. protected abstract _createMergeEffect(): Effect;
  62113. /**
  62114. * Creates the render target textures and post processes used in the effect layer.
  62115. */
  62116. protected abstract _createTextureAndPostProcesses(): void;
  62117. /**
  62118. * Implementation specific of rendering the generating effect on the main canvas.
  62119. * @param effect The effect used to render through
  62120. */
  62121. protected abstract _internalRender(effect: Effect): void;
  62122. /**
  62123. * Sets the required values for both the emissive texture and and the main color.
  62124. */
  62125. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62126. /**
  62127. * Free any resources and references associated to a mesh.
  62128. * Internal use
  62129. * @param mesh The mesh to free.
  62130. */
  62131. abstract _disposeMesh(mesh: Mesh): void;
  62132. /**
  62133. * Serializes this layer (Glow or Highlight for example)
  62134. * @returns a serialized layer object
  62135. */
  62136. abstract serialize?(): any;
  62137. /**
  62138. * Initializes the effect layer with the required options.
  62139. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62140. */
  62141. protected _init(options: Partial<IEffectLayerOptions>): void;
  62142. /**
  62143. * Generates the index buffer of the full screen quad blending to the main canvas.
  62144. */
  62145. private _generateIndexBuffer;
  62146. /**
  62147. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62148. */
  62149. private _generateVertexBuffer;
  62150. /**
  62151. * Sets the main texture desired size which is the closest power of two
  62152. * of the engine canvas size.
  62153. */
  62154. private _setMainTextureSize;
  62155. /**
  62156. * Creates the main texture for the effect layer.
  62157. */
  62158. protected _createMainTexture(): void;
  62159. /**
  62160. * Adds specific effects defines.
  62161. * @param defines The defines to add specifics to.
  62162. */
  62163. protected _addCustomEffectDefines(defines: string[]): void;
  62164. /**
  62165. * Checks for the readiness of the element composing the layer.
  62166. * @param subMesh the mesh to check for
  62167. * @param useInstances specify whether or not to use instances to render the mesh
  62168. * @param emissiveTexture the associated emissive texture used to generate the glow
  62169. * @return true if ready otherwise, false
  62170. */
  62171. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62172. /**
  62173. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62174. */
  62175. render(): void;
  62176. /**
  62177. * Determine if a given mesh will be used in the current effect.
  62178. * @param mesh mesh to test
  62179. * @returns true if the mesh will be used
  62180. */
  62181. hasMesh(mesh: AbstractMesh): boolean;
  62182. /**
  62183. * Returns true if the layer contains information to display, otherwise false.
  62184. * @returns true if the glow layer should be rendered
  62185. */
  62186. shouldRender(): boolean;
  62187. /**
  62188. * Returns true if the mesh should render, otherwise false.
  62189. * @param mesh The mesh to render
  62190. * @returns true if it should render otherwise false
  62191. */
  62192. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62193. /**
  62194. * Returns true if the mesh can be rendered, otherwise false.
  62195. * @param mesh The mesh to render
  62196. * @param material The material used on the mesh
  62197. * @returns true if it can be rendered otherwise false
  62198. */
  62199. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62200. /**
  62201. * Returns true if the mesh should render, otherwise false.
  62202. * @param mesh The mesh to render
  62203. * @returns true if it should render otherwise false
  62204. */
  62205. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62206. /**
  62207. * Renders the submesh passed in parameter to the generation map.
  62208. */
  62209. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62210. /**
  62211. * Defines whether the current material of the mesh should be use to render the effect.
  62212. * @param mesh defines the current mesh to render
  62213. */
  62214. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62215. /**
  62216. * Rebuild the required buffers.
  62217. * @hidden Internal use only.
  62218. */
  62219. _rebuild(): void;
  62220. /**
  62221. * Dispose only the render target textures and post process.
  62222. */
  62223. private _disposeTextureAndPostProcesses;
  62224. /**
  62225. * Dispose the highlight layer and free resources.
  62226. */
  62227. dispose(): void;
  62228. /**
  62229. * Gets the class name of the effect layer
  62230. * @returns the string with the class name of the effect layer
  62231. */
  62232. getClassName(): string;
  62233. /**
  62234. * Creates an effect layer from parsed effect layer data
  62235. * @param parsedEffectLayer defines effect layer data
  62236. * @param scene defines the current scene
  62237. * @param rootUrl defines the root URL containing the effect layer information
  62238. * @returns a parsed effect Layer
  62239. */
  62240. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62241. }
  62242. }
  62243. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  62244. import { Scene } from "babylonjs/scene";
  62245. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62246. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62247. import { AbstractScene } from "babylonjs/abstractScene";
  62248. module "babylonjs/abstractScene" {
  62249. interface AbstractScene {
  62250. /**
  62251. * The list of effect layers (highlights/glow) added to the scene
  62252. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62253. * @see https://doc.babylonjs.com/how_to/glow_layer
  62254. */
  62255. effectLayers: Array<EffectLayer>;
  62256. /**
  62257. * Removes the given effect layer from this scene.
  62258. * @param toRemove defines the effect layer to remove
  62259. * @returns the index of the removed effect layer
  62260. */
  62261. removeEffectLayer(toRemove: EffectLayer): number;
  62262. /**
  62263. * Adds the given effect layer to this scene
  62264. * @param newEffectLayer defines the effect layer to add
  62265. */
  62266. addEffectLayer(newEffectLayer: EffectLayer): void;
  62267. }
  62268. }
  62269. /**
  62270. * Defines the layer scene component responsible to manage any effect layers
  62271. * in a given scene.
  62272. */
  62273. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62274. /**
  62275. * The component name helpfull to identify the component in the list of scene components.
  62276. */
  62277. readonly name: string;
  62278. /**
  62279. * The scene the component belongs to.
  62280. */
  62281. scene: Scene;
  62282. private _engine;
  62283. private _renderEffects;
  62284. private _needStencil;
  62285. private _previousStencilState;
  62286. /**
  62287. * Creates a new instance of the component for the given scene
  62288. * @param scene Defines the scene to register the component in
  62289. */
  62290. constructor(scene: Scene);
  62291. /**
  62292. * Registers the component in a given scene
  62293. */
  62294. register(): void;
  62295. /**
  62296. * Rebuilds the elements related to this component in case of
  62297. * context lost for instance.
  62298. */
  62299. rebuild(): void;
  62300. /**
  62301. * Serializes the component data to the specified json object
  62302. * @param serializationObject The object to serialize to
  62303. */
  62304. serialize(serializationObject: any): void;
  62305. /**
  62306. * Adds all the elements from the container to the scene
  62307. * @param container the container holding the elements
  62308. */
  62309. addFromContainer(container: AbstractScene): void;
  62310. /**
  62311. * Removes all the elements in the container from the scene
  62312. * @param container contains the elements to remove
  62313. * @param dispose if the removed element should be disposed (default: false)
  62314. */
  62315. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62316. /**
  62317. * Disposes the component and the associated ressources.
  62318. */
  62319. dispose(): void;
  62320. private _isReadyForMesh;
  62321. private _renderMainTexture;
  62322. private _setStencil;
  62323. private _setStencilBack;
  62324. private _draw;
  62325. private _drawCamera;
  62326. private _drawRenderingGroup;
  62327. }
  62328. }
  62329. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  62330. /** @hidden */
  62331. export var glowMapMergePixelShader: {
  62332. name: string;
  62333. shader: string;
  62334. };
  62335. }
  62336. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  62337. /** @hidden */
  62338. export var glowMapMergeVertexShader: {
  62339. name: string;
  62340. shader: string;
  62341. };
  62342. }
  62343. declare module "babylonjs/Layers/glowLayer" {
  62344. import { Nullable } from "babylonjs/types";
  62345. import { Camera } from "babylonjs/Cameras/camera";
  62346. import { Scene } from "babylonjs/scene";
  62347. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62349. import { Mesh } from "babylonjs/Meshes/mesh";
  62350. import { Texture } from "babylonjs/Materials/Textures/texture";
  62351. import { Effect } from "babylonjs/Materials/effect";
  62352. import { Material } from "babylonjs/Materials/material";
  62353. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62354. import { Color4 } from "babylonjs/Maths/math.color";
  62355. import "babylonjs/Shaders/glowMapMerge.fragment";
  62356. import "babylonjs/Shaders/glowMapMerge.vertex";
  62357. import "babylonjs/Layers/effectLayerSceneComponent";
  62358. module "babylonjs/abstractScene" {
  62359. interface AbstractScene {
  62360. /**
  62361. * Return a the first highlight layer of the scene with a given name.
  62362. * @param name The name of the highlight layer to look for.
  62363. * @return The highlight layer if found otherwise null.
  62364. */
  62365. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62366. }
  62367. }
  62368. /**
  62369. * Glow layer options. This helps customizing the behaviour
  62370. * of the glow layer.
  62371. */
  62372. export interface IGlowLayerOptions {
  62373. /**
  62374. * Multiplication factor apply to the canvas size to compute the render target size
  62375. * used to generated the glowing objects (the smaller the faster).
  62376. */
  62377. mainTextureRatio: number;
  62378. /**
  62379. * Enforces a fixed size texture to ensure resize independant blur.
  62380. */
  62381. mainTextureFixedSize?: number;
  62382. /**
  62383. * How big is the kernel of the blur texture.
  62384. */
  62385. blurKernelSize: number;
  62386. /**
  62387. * The camera attached to the layer.
  62388. */
  62389. camera: Nullable<Camera>;
  62390. /**
  62391. * Enable MSAA by chosing the number of samples.
  62392. */
  62393. mainTextureSamples?: number;
  62394. /**
  62395. * The rendering group to draw the layer in.
  62396. */
  62397. renderingGroupId: number;
  62398. }
  62399. /**
  62400. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62401. *
  62402. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62403. *
  62404. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62405. */
  62406. export class GlowLayer extends EffectLayer {
  62407. /**
  62408. * Effect Name of the layer.
  62409. */
  62410. static readonly EffectName: string;
  62411. /**
  62412. * The default blur kernel size used for the glow.
  62413. */
  62414. static DefaultBlurKernelSize: number;
  62415. /**
  62416. * The default texture size ratio used for the glow.
  62417. */
  62418. static DefaultTextureRatio: number;
  62419. /**
  62420. * Sets the kernel size of the blur.
  62421. */
  62422. set blurKernelSize(value: number);
  62423. /**
  62424. * Gets the kernel size of the blur.
  62425. */
  62426. get blurKernelSize(): number;
  62427. /**
  62428. * Sets the glow intensity.
  62429. */
  62430. set intensity(value: number);
  62431. /**
  62432. * Gets the glow intensity.
  62433. */
  62434. get intensity(): number;
  62435. private _options;
  62436. private _intensity;
  62437. private _horizontalBlurPostprocess1;
  62438. private _verticalBlurPostprocess1;
  62439. private _horizontalBlurPostprocess2;
  62440. private _verticalBlurPostprocess2;
  62441. private _blurTexture1;
  62442. private _blurTexture2;
  62443. private _postProcesses1;
  62444. private _postProcesses2;
  62445. private _includedOnlyMeshes;
  62446. private _excludedMeshes;
  62447. private _meshesUsingTheirOwnMaterials;
  62448. /**
  62449. * Callback used to let the user override the color selection on a per mesh basis
  62450. */
  62451. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62452. /**
  62453. * Callback used to let the user override the texture selection on a per mesh basis
  62454. */
  62455. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62456. /**
  62457. * Instantiates a new glow Layer and references it to the scene.
  62458. * @param name The name of the layer
  62459. * @param scene The scene to use the layer in
  62460. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62461. */
  62462. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62463. /**
  62464. * Get the effect name of the layer.
  62465. * @return The effect name
  62466. */
  62467. getEffectName(): string;
  62468. /**
  62469. * Create the merge effect. This is the shader use to blit the information back
  62470. * to the main canvas at the end of the scene rendering.
  62471. */
  62472. protected _createMergeEffect(): Effect;
  62473. /**
  62474. * Creates the render target textures and post processes used in the glow layer.
  62475. */
  62476. protected _createTextureAndPostProcesses(): void;
  62477. /**
  62478. * Checks for the readiness of the element composing the layer.
  62479. * @param subMesh the mesh to check for
  62480. * @param useInstances specify wether or not to use instances to render the mesh
  62481. * @param emissiveTexture the associated emissive texture used to generate the glow
  62482. * @return true if ready otherwise, false
  62483. */
  62484. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62485. /**
  62486. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62487. */
  62488. needStencil(): boolean;
  62489. /**
  62490. * Returns true if the mesh can be rendered, otherwise false.
  62491. * @param mesh The mesh to render
  62492. * @param material The material used on the mesh
  62493. * @returns true if it can be rendered otherwise false
  62494. */
  62495. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62496. /**
  62497. * Implementation specific of rendering the generating effect on the main canvas.
  62498. * @param effect The effect used to render through
  62499. */
  62500. protected _internalRender(effect: Effect): void;
  62501. /**
  62502. * Sets the required values for both the emissive texture and and the main color.
  62503. */
  62504. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62505. /**
  62506. * Returns true if the mesh should render, otherwise false.
  62507. * @param mesh The mesh to render
  62508. * @returns true if it should render otherwise false
  62509. */
  62510. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62511. /**
  62512. * Adds specific effects defines.
  62513. * @param defines The defines to add specifics to.
  62514. */
  62515. protected _addCustomEffectDefines(defines: string[]): void;
  62516. /**
  62517. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62518. * @param mesh The mesh to exclude from the glow layer
  62519. */
  62520. addExcludedMesh(mesh: Mesh): void;
  62521. /**
  62522. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62523. * @param mesh The mesh to remove
  62524. */
  62525. removeExcludedMesh(mesh: Mesh): void;
  62526. /**
  62527. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62528. * @param mesh The mesh to include in the glow layer
  62529. */
  62530. addIncludedOnlyMesh(mesh: Mesh): void;
  62531. /**
  62532. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62533. * @param mesh The mesh to remove
  62534. */
  62535. removeIncludedOnlyMesh(mesh: Mesh): void;
  62536. /**
  62537. * Determine if a given mesh will be used in the glow layer
  62538. * @param mesh The mesh to test
  62539. * @returns true if the mesh will be highlighted by the current glow layer
  62540. */
  62541. hasMesh(mesh: AbstractMesh): boolean;
  62542. /**
  62543. * Defines whether the current material of the mesh should be use to render the effect.
  62544. * @param mesh defines the current mesh to render
  62545. */
  62546. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62547. /**
  62548. * Add a mesh to be rendered through its own material and not with emissive only.
  62549. * @param mesh The mesh for which we need to use its material
  62550. */
  62551. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  62552. /**
  62553. * Remove a mesh from being rendered through its own material and not with emissive only.
  62554. * @param mesh The mesh for which we need to not use its material
  62555. */
  62556. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  62557. /**
  62558. * Free any resources and references associated to a mesh.
  62559. * Internal use
  62560. * @param mesh The mesh to free.
  62561. * @hidden
  62562. */
  62563. _disposeMesh(mesh: Mesh): void;
  62564. /**
  62565. * Gets the class name of the effect layer
  62566. * @returns the string with the class name of the effect layer
  62567. */
  62568. getClassName(): string;
  62569. /**
  62570. * Serializes this glow layer
  62571. * @returns a serialized glow layer object
  62572. */
  62573. serialize(): any;
  62574. /**
  62575. * Creates a Glow Layer from parsed glow layer data
  62576. * @param parsedGlowLayer defines glow layer data
  62577. * @param scene defines the current scene
  62578. * @param rootUrl defines the root URL containing the glow layer information
  62579. * @returns a parsed Glow Layer
  62580. */
  62581. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  62582. }
  62583. }
  62584. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  62585. /** @hidden */
  62586. export var glowBlurPostProcessPixelShader: {
  62587. name: string;
  62588. shader: string;
  62589. };
  62590. }
  62591. declare module "babylonjs/Layers/highlightLayer" {
  62592. import { Observable } from "babylonjs/Misc/observable";
  62593. import { Nullable } from "babylonjs/types";
  62594. import { Camera } from "babylonjs/Cameras/camera";
  62595. import { Scene } from "babylonjs/scene";
  62596. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62598. import { Mesh } from "babylonjs/Meshes/mesh";
  62599. import { Effect } from "babylonjs/Materials/effect";
  62600. import { Material } from "babylonjs/Materials/material";
  62601. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62602. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62603. import "babylonjs/Shaders/glowMapMerge.fragment";
  62604. import "babylonjs/Shaders/glowMapMerge.vertex";
  62605. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  62606. module "babylonjs/abstractScene" {
  62607. interface AbstractScene {
  62608. /**
  62609. * Return a the first highlight layer of the scene with a given name.
  62610. * @param name The name of the highlight layer to look for.
  62611. * @return The highlight layer if found otherwise null.
  62612. */
  62613. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  62614. }
  62615. }
  62616. /**
  62617. * Highlight layer options. This helps customizing the behaviour
  62618. * of the highlight layer.
  62619. */
  62620. export interface IHighlightLayerOptions {
  62621. /**
  62622. * Multiplication factor apply to the canvas size to compute the render target size
  62623. * used to generated the glowing objects (the smaller the faster).
  62624. */
  62625. mainTextureRatio: number;
  62626. /**
  62627. * Enforces a fixed size texture to ensure resize independant blur.
  62628. */
  62629. mainTextureFixedSize?: number;
  62630. /**
  62631. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  62632. * of the picture to blur (the smaller the faster).
  62633. */
  62634. blurTextureSizeRatio: number;
  62635. /**
  62636. * How big in texel of the blur texture is the vertical blur.
  62637. */
  62638. blurVerticalSize: number;
  62639. /**
  62640. * How big in texel of the blur texture is the horizontal blur.
  62641. */
  62642. blurHorizontalSize: number;
  62643. /**
  62644. * Alpha blending mode used to apply the blur. Default is combine.
  62645. */
  62646. alphaBlendingMode: number;
  62647. /**
  62648. * The camera attached to the layer.
  62649. */
  62650. camera: Nullable<Camera>;
  62651. /**
  62652. * Should we display highlight as a solid stroke?
  62653. */
  62654. isStroke?: boolean;
  62655. /**
  62656. * The rendering group to draw the layer in.
  62657. */
  62658. renderingGroupId: number;
  62659. }
  62660. /**
  62661. * The highlight layer Helps adding a glow effect around a mesh.
  62662. *
  62663. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  62664. * glowy meshes to your scene.
  62665. *
  62666. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  62667. */
  62668. export class HighlightLayer extends EffectLayer {
  62669. name: string;
  62670. /**
  62671. * Effect Name of the highlight layer.
  62672. */
  62673. static readonly EffectName: string;
  62674. /**
  62675. * The neutral color used during the preparation of the glow effect.
  62676. * This is black by default as the blend operation is a blend operation.
  62677. */
  62678. static NeutralColor: Color4;
  62679. /**
  62680. * Stencil value used for glowing meshes.
  62681. */
  62682. static GlowingMeshStencilReference: number;
  62683. /**
  62684. * Stencil value used for the other meshes in the scene.
  62685. */
  62686. static NormalMeshStencilReference: number;
  62687. /**
  62688. * Specifies whether or not the inner glow is ACTIVE in the layer.
  62689. */
  62690. innerGlow: boolean;
  62691. /**
  62692. * Specifies whether or not the outer glow is ACTIVE in the layer.
  62693. */
  62694. outerGlow: boolean;
  62695. /**
  62696. * Specifies the horizontal size of the blur.
  62697. */
  62698. set blurHorizontalSize(value: number);
  62699. /**
  62700. * Specifies the vertical size of the blur.
  62701. */
  62702. set blurVerticalSize(value: number);
  62703. /**
  62704. * Gets the horizontal size of the blur.
  62705. */
  62706. get blurHorizontalSize(): number;
  62707. /**
  62708. * Gets the vertical size of the blur.
  62709. */
  62710. get blurVerticalSize(): number;
  62711. /**
  62712. * An event triggered when the highlight layer is being blurred.
  62713. */
  62714. onBeforeBlurObservable: Observable<HighlightLayer>;
  62715. /**
  62716. * An event triggered when the highlight layer has been blurred.
  62717. */
  62718. onAfterBlurObservable: Observable<HighlightLayer>;
  62719. private _instanceGlowingMeshStencilReference;
  62720. private _options;
  62721. private _downSamplePostprocess;
  62722. private _horizontalBlurPostprocess;
  62723. private _verticalBlurPostprocess;
  62724. private _blurTexture;
  62725. private _meshes;
  62726. private _excludedMeshes;
  62727. /**
  62728. * Instantiates a new highlight Layer and references it to the scene..
  62729. * @param name The name of the layer
  62730. * @param scene The scene to use the layer in
  62731. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  62732. */
  62733. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  62734. /**
  62735. * Get the effect name of the layer.
  62736. * @return The effect name
  62737. */
  62738. getEffectName(): string;
  62739. /**
  62740. * Create the merge effect. This is the shader use to blit the information back
  62741. * to the main canvas at the end of the scene rendering.
  62742. */
  62743. protected _createMergeEffect(): Effect;
  62744. /**
  62745. * Creates the render target textures and post processes used in the highlight layer.
  62746. */
  62747. protected _createTextureAndPostProcesses(): void;
  62748. /**
  62749. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  62750. */
  62751. needStencil(): boolean;
  62752. /**
  62753. * Checks for the readiness of the element composing the layer.
  62754. * @param subMesh the mesh to check for
  62755. * @param useInstances specify wether or not to use instances to render the mesh
  62756. * @param emissiveTexture the associated emissive texture used to generate the glow
  62757. * @return true if ready otherwise, false
  62758. */
  62759. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62760. /**
  62761. * Implementation specific of rendering the generating effect on the main canvas.
  62762. * @param effect The effect used to render through
  62763. */
  62764. protected _internalRender(effect: Effect): void;
  62765. /**
  62766. * Returns true if the layer contains information to display, otherwise false.
  62767. */
  62768. shouldRender(): boolean;
  62769. /**
  62770. * Returns true if the mesh should render, otherwise false.
  62771. * @param mesh The mesh to render
  62772. * @returns true if it should render otherwise false
  62773. */
  62774. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62775. /**
  62776. * Returns true if the mesh can be rendered, otherwise false.
  62777. * @param mesh The mesh to render
  62778. * @param material The material used on the mesh
  62779. * @returns true if it can be rendered otherwise false
  62780. */
  62781. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62782. /**
  62783. * Adds specific effects defines.
  62784. * @param defines The defines to add specifics to.
  62785. */
  62786. protected _addCustomEffectDefines(defines: string[]): void;
  62787. /**
  62788. * Sets the required values for both the emissive texture and and the main color.
  62789. */
  62790. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62791. /**
  62792. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  62793. * @param mesh The mesh to exclude from the highlight layer
  62794. */
  62795. addExcludedMesh(mesh: Mesh): void;
  62796. /**
  62797. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  62798. * @param mesh The mesh to highlight
  62799. */
  62800. removeExcludedMesh(mesh: Mesh): void;
  62801. /**
  62802. * Determine if a given mesh will be highlighted by the current HighlightLayer
  62803. * @param mesh mesh to test
  62804. * @returns true if the mesh will be highlighted by the current HighlightLayer
  62805. */
  62806. hasMesh(mesh: AbstractMesh): boolean;
  62807. /**
  62808. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  62809. * @param mesh The mesh to highlight
  62810. * @param color The color of the highlight
  62811. * @param glowEmissiveOnly Extract the glow from the emissive texture
  62812. */
  62813. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  62814. /**
  62815. * Remove a mesh from the highlight layer in order to make it stop glowing.
  62816. * @param mesh The mesh to highlight
  62817. */
  62818. removeMesh(mesh: Mesh): void;
  62819. /**
  62820. * Remove all the meshes currently referenced in the highlight layer
  62821. */
  62822. removeAllMeshes(): void;
  62823. /**
  62824. * Force the stencil to the normal expected value for none glowing parts
  62825. */
  62826. private _defaultStencilReference;
  62827. /**
  62828. * Free any resources and references associated to a mesh.
  62829. * Internal use
  62830. * @param mesh The mesh to free.
  62831. * @hidden
  62832. */
  62833. _disposeMesh(mesh: Mesh): void;
  62834. /**
  62835. * Dispose the highlight layer and free resources.
  62836. */
  62837. dispose(): void;
  62838. /**
  62839. * Gets the class name of the effect layer
  62840. * @returns the string with the class name of the effect layer
  62841. */
  62842. getClassName(): string;
  62843. /**
  62844. * Serializes this Highlight layer
  62845. * @returns a serialized Highlight layer object
  62846. */
  62847. serialize(): any;
  62848. /**
  62849. * Creates a Highlight layer from parsed Highlight layer data
  62850. * @param parsedHightlightLayer defines the Highlight layer data
  62851. * @param scene defines the current scene
  62852. * @param rootUrl defines the root URL containing the Highlight layer information
  62853. * @returns a parsed Highlight layer
  62854. */
  62855. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  62856. }
  62857. }
  62858. declare module "babylonjs/Layers/layerSceneComponent" {
  62859. import { Scene } from "babylonjs/scene";
  62860. import { ISceneComponent } from "babylonjs/sceneComponent";
  62861. import { Layer } from "babylonjs/Layers/layer";
  62862. import { AbstractScene } from "babylonjs/abstractScene";
  62863. module "babylonjs/abstractScene" {
  62864. interface AbstractScene {
  62865. /**
  62866. * The list of layers (background and foreground) of the scene
  62867. */
  62868. layers: Array<Layer>;
  62869. }
  62870. }
  62871. /**
  62872. * Defines the layer scene component responsible to manage any layers
  62873. * in a given scene.
  62874. */
  62875. export class LayerSceneComponent implements ISceneComponent {
  62876. /**
  62877. * The component name helpfull to identify the component in the list of scene components.
  62878. */
  62879. readonly name: string;
  62880. /**
  62881. * The scene the component belongs to.
  62882. */
  62883. scene: Scene;
  62884. private _engine;
  62885. /**
  62886. * Creates a new instance of the component for the given scene
  62887. * @param scene Defines the scene to register the component in
  62888. */
  62889. constructor(scene: Scene);
  62890. /**
  62891. * Registers the component in a given scene
  62892. */
  62893. register(): void;
  62894. /**
  62895. * Rebuilds the elements related to this component in case of
  62896. * context lost for instance.
  62897. */
  62898. rebuild(): void;
  62899. /**
  62900. * Disposes the component and the associated ressources.
  62901. */
  62902. dispose(): void;
  62903. private _draw;
  62904. private _drawCameraPredicate;
  62905. private _drawCameraBackground;
  62906. private _drawCameraForeground;
  62907. private _drawRenderTargetPredicate;
  62908. private _drawRenderTargetBackground;
  62909. private _drawRenderTargetForeground;
  62910. /**
  62911. * Adds all the elements from the container to the scene
  62912. * @param container the container holding the elements
  62913. */
  62914. addFromContainer(container: AbstractScene): void;
  62915. /**
  62916. * Removes all the elements in the container from the scene
  62917. * @param container contains the elements to remove
  62918. * @param dispose if the removed element should be disposed (default: false)
  62919. */
  62920. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62921. }
  62922. }
  62923. declare module "babylonjs/Shaders/layer.fragment" {
  62924. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62925. /** @hidden */
  62926. export var layerPixelShader: {
  62927. name: string;
  62928. shader: string;
  62929. };
  62930. }
  62931. declare module "babylonjs/Shaders/layer.vertex" {
  62932. /** @hidden */
  62933. export var layerVertexShader: {
  62934. name: string;
  62935. shader: string;
  62936. };
  62937. }
  62938. declare module "babylonjs/Layers/layer" {
  62939. import { Observable } from "babylonjs/Misc/observable";
  62940. import { Nullable } from "babylonjs/types";
  62941. import { Scene } from "babylonjs/scene";
  62942. import { Vector2 } from "babylonjs/Maths/math.vector";
  62943. import { Color4 } from "babylonjs/Maths/math.color";
  62944. import { Texture } from "babylonjs/Materials/Textures/texture";
  62945. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62946. import "babylonjs/Shaders/layer.fragment";
  62947. import "babylonjs/Shaders/layer.vertex";
  62948. /**
  62949. * This represents a full screen 2d layer.
  62950. * This can be useful to display a picture in the background of your scene for instance.
  62951. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62952. */
  62953. export class Layer {
  62954. /**
  62955. * Define the name of the layer.
  62956. */
  62957. name: string;
  62958. /**
  62959. * Define the texture the layer should display.
  62960. */
  62961. texture: Nullable<Texture>;
  62962. /**
  62963. * Is the layer in background or foreground.
  62964. */
  62965. isBackground: boolean;
  62966. /**
  62967. * Define the color of the layer (instead of texture).
  62968. */
  62969. color: Color4;
  62970. /**
  62971. * Define the scale of the layer in order to zoom in out of the texture.
  62972. */
  62973. scale: Vector2;
  62974. /**
  62975. * Define an offset for the layer in order to shift the texture.
  62976. */
  62977. offset: Vector2;
  62978. /**
  62979. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62980. */
  62981. alphaBlendingMode: number;
  62982. /**
  62983. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62984. * Alpha test will not mix with the background color in case of transparency.
  62985. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62986. */
  62987. alphaTest: boolean;
  62988. /**
  62989. * Define a mask to restrict the layer to only some of the scene cameras.
  62990. */
  62991. layerMask: number;
  62992. /**
  62993. * Define the list of render target the layer is visible into.
  62994. */
  62995. renderTargetTextures: RenderTargetTexture[];
  62996. /**
  62997. * Define if the layer is only used in renderTarget or if it also
  62998. * renders in the main frame buffer of the canvas.
  62999. */
  63000. renderOnlyInRenderTargetTextures: boolean;
  63001. private _scene;
  63002. private _vertexBuffers;
  63003. private _indexBuffer;
  63004. private _effect;
  63005. private _previousDefines;
  63006. /**
  63007. * An event triggered when the layer is disposed.
  63008. */
  63009. onDisposeObservable: Observable<Layer>;
  63010. private _onDisposeObserver;
  63011. /**
  63012. * Back compatibility with callback before the onDisposeObservable existed.
  63013. * The set callback will be triggered when the layer has been disposed.
  63014. */
  63015. set onDispose(callback: () => void);
  63016. /**
  63017. * An event triggered before rendering the scene
  63018. */
  63019. onBeforeRenderObservable: Observable<Layer>;
  63020. private _onBeforeRenderObserver;
  63021. /**
  63022. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63023. * The set callback will be triggered just before rendering the layer.
  63024. */
  63025. set onBeforeRender(callback: () => void);
  63026. /**
  63027. * An event triggered after rendering the scene
  63028. */
  63029. onAfterRenderObservable: Observable<Layer>;
  63030. private _onAfterRenderObserver;
  63031. /**
  63032. * Back compatibility with callback before the onAfterRenderObservable existed.
  63033. * The set callback will be triggered just after rendering the layer.
  63034. */
  63035. set onAfterRender(callback: () => void);
  63036. /**
  63037. * Instantiates a new layer.
  63038. * This represents a full screen 2d layer.
  63039. * This can be useful to display a picture in the background of your scene for instance.
  63040. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63041. * @param name Define the name of the layer in the scene
  63042. * @param imgUrl Define the url of the texture to display in the layer
  63043. * @param scene Define the scene the layer belongs to
  63044. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63045. * @param color Defines a color for the layer
  63046. */
  63047. constructor(
  63048. /**
  63049. * Define the name of the layer.
  63050. */
  63051. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63052. private _createIndexBuffer;
  63053. /** @hidden */
  63054. _rebuild(): void;
  63055. /**
  63056. * Renders the layer in the scene.
  63057. */
  63058. render(): void;
  63059. /**
  63060. * Disposes and releases the associated ressources.
  63061. */
  63062. dispose(): void;
  63063. }
  63064. }
  63065. declare module "babylonjs/Layers/index" {
  63066. export * from "babylonjs/Layers/effectLayer";
  63067. export * from "babylonjs/Layers/effectLayerSceneComponent";
  63068. export * from "babylonjs/Layers/glowLayer";
  63069. export * from "babylonjs/Layers/highlightLayer";
  63070. export * from "babylonjs/Layers/layer";
  63071. export * from "babylonjs/Layers/layerSceneComponent";
  63072. }
  63073. declare module "babylonjs/Shaders/lensFlare.fragment" {
  63074. /** @hidden */
  63075. export var lensFlarePixelShader: {
  63076. name: string;
  63077. shader: string;
  63078. };
  63079. }
  63080. declare module "babylonjs/Shaders/lensFlare.vertex" {
  63081. /** @hidden */
  63082. export var lensFlareVertexShader: {
  63083. name: string;
  63084. shader: string;
  63085. };
  63086. }
  63087. declare module "babylonjs/LensFlares/lensFlareSystem" {
  63088. import { Scene } from "babylonjs/scene";
  63089. import { Vector3 } from "babylonjs/Maths/math.vector";
  63090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63091. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  63092. import "babylonjs/Shaders/lensFlare.fragment";
  63093. import "babylonjs/Shaders/lensFlare.vertex";
  63094. import { Viewport } from "babylonjs/Maths/math.viewport";
  63095. /**
  63096. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63097. * It is usually composed of several `lensFlare`.
  63098. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63099. */
  63100. export class LensFlareSystem {
  63101. /**
  63102. * Define the name of the lens flare system
  63103. */
  63104. name: string;
  63105. /**
  63106. * List of lens flares used in this system.
  63107. */
  63108. lensFlares: LensFlare[];
  63109. /**
  63110. * Define a limit from the border the lens flare can be visible.
  63111. */
  63112. borderLimit: number;
  63113. /**
  63114. * Define a viewport border we do not want to see the lens flare in.
  63115. */
  63116. viewportBorder: number;
  63117. /**
  63118. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63119. */
  63120. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63121. /**
  63122. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63123. */
  63124. layerMask: number;
  63125. /**
  63126. * Define the id of the lens flare system in the scene.
  63127. * (equal to name by default)
  63128. */
  63129. id: string;
  63130. private _scene;
  63131. private _emitter;
  63132. private _vertexBuffers;
  63133. private _indexBuffer;
  63134. private _effect;
  63135. private _positionX;
  63136. private _positionY;
  63137. private _isEnabled;
  63138. /** @hidden */
  63139. static _SceneComponentInitialization: (scene: Scene) => void;
  63140. /**
  63141. * Instantiates a lens flare system.
  63142. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63143. * It is usually composed of several `lensFlare`.
  63144. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63145. * @param name Define the name of the lens flare system in the scene
  63146. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63147. * @param scene Define the scene the lens flare system belongs to
  63148. */
  63149. constructor(
  63150. /**
  63151. * Define the name of the lens flare system
  63152. */
  63153. name: string, emitter: any, scene: Scene);
  63154. /**
  63155. * Define if the lens flare system is enabled.
  63156. */
  63157. get isEnabled(): boolean;
  63158. set isEnabled(value: boolean);
  63159. /**
  63160. * Get the scene the effects belongs to.
  63161. * @returns the scene holding the lens flare system
  63162. */
  63163. getScene(): Scene;
  63164. /**
  63165. * Get the emitter of the lens flare system.
  63166. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63167. * @returns the emitter of the lens flare system
  63168. */
  63169. getEmitter(): any;
  63170. /**
  63171. * Set the emitter of the lens flare system.
  63172. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63173. * @param newEmitter Define the new emitter of the system
  63174. */
  63175. setEmitter(newEmitter: any): void;
  63176. /**
  63177. * Get the lens flare system emitter position.
  63178. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63179. * @returns the position
  63180. */
  63181. getEmitterPosition(): Vector3;
  63182. /**
  63183. * @hidden
  63184. */
  63185. computeEffectivePosition(globalViewport: Viewport): boolean;
  63186. /** @hidden */
  63187. _isVisible(): boolean;
  63188. /**
  63189. * @hidden
  63190. */
  63191. render(): boolean;
  63192. /**
  63193. * Dispose and release the lens flare with its associated resources.
  63194. */
  63195. dispose(): void;
  63196. /**
  63197. * Parse a lens flare system from a JSON repressentation
  63198. * @param parsedLensFlareSystem Define the JSON to parse
  63199. * @param scene Define the scene the parsed system should be instantiated in
  63200. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63201. * @returns the parsed system
  63202. */
  63203. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63204. /**
  63205. * Serialize the current Lens Flare System into a JSON representation.
  63206. * @returns the serialized JSON
  63207. */
  63208. serialize(): any;
  63209. }
  63210. }
  63211. declare module "babylonjs/LensFlares/lensFlare" {
  63212. import { Nullable } from "babylonjs/types";
  63213. import { Color3 } from "babylonjs/Maths/math.color";
  63214. import { Texture } from "babylonjs/Materials/Textures/texture";
  63215. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63216. /**
  63217. * This represents one of the lens effect in a `lensFlareSystem`.
  63218. * It controls one of the indiviual texture used in the effect.
  63219. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63220. */
  63221. export class LensFlare {
  63222. /**
  63223. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63224. */
  63225. size: number;
  63226. /**
  63227. * 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.
  63228. */
  63229. position: number;
  63230. /**
  63231. * Define the lens color.
  63232. */
  63233. color: Color3;
  63234. /**
  63235. * Define the lens texture.
  63236. */
  63237. texture: Nullable<Texture>;
  63238. /**
  63239. * Define the alpha mode to render this particular lens.
  63240. */
  63241. alphaMode: number;
  63242. private _system;
  63243. /**
  63244. * Creates a new Lens Flare.
  63245. * This represents one of the lens effect in a `lensFlareSystem`.
  63246. * It controls one of the indiviual texture used in the effect.
  63247. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63248. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63249. * @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.
  63250. * @param color Define the lens color
  63251. * @param imgUrl Define the lens texture url
  63252. * @param system Define the `lensFlareSystem` this flare is part of
  63253. * @returns The newly created Lens Flare
  63254. */
  63255. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63256. /**
  63257. * Instantiates a new Lens Flare.
  63258. * This represents one of the lens effect in a `lensFlareSystem`.
  63259. * It controls one of the indiviual texture used in the effect.
  63260. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63261. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63262. * @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.
  63263. * @param color Define the lens color
  63264. * @param imgUrl Define the lens texture url
  63265. * @param system Define the `lensFlareSystem` this flare is part of
  63266. */
  63267. constructor(
  63268. /**
  63269. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63270. */
  63271. size: number,
  63272. /**
  63273. * 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.
  63274. */
  63275. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63276. /**
  63277. * Dispose and release the lens flare with its associated resources.
  63278. */
  63279. dispose(): void;
  63280. }
  63281. }
  63282. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  63283. import { Nullable } from "babylonjs/types";
  63284. import { Scene } from "babylonjs/scene";
  63285. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63286. import { AbstractScene } from "babylonjs/abstractScene";
  63287. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63288. module "babylonjs/abstractScene" {
  63289. interface AbstractScene {
  63290. /**
  63291. * The list of lens flare system added to the scene
  63292. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63293. */
  63294. lensFlareSystems: Array<LensFlareSystem>;
  63295. /**
  63296. * Removes the given lens flare system from this scene.
  63297. * @param toRemove The lens flare system to remove
  63298. * @returns The index of the removed lens flare system
  63299. */
  63300. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63301. /**
  63302. * Adds the given lens flare system to this scene
  63303. * @param newLensFlareSystem The lens flare system to add
  63304. */
  63305. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63306. /**
  63307. * Gets a lens flare system using its name
  63308. * @param name defines the name to look for
  63309. * @returns the lens flare system or null if not found
  63310. */
  63311. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63312. /**
  63313. * Gets a lens flare system using its id
  63314. * @param id defines the id to look for
  63315. * @returns the lens flare system or null if not found
  63316. */
  63317. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63318. }
  63319. }
  63320. /**
  63321. * Defines the lens flare scene component responsible to manage any lens flares
  63322. * in a given scene.
  63323. */
  63324. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63325. /**
  63326. * The component name helpfull to identify the component in the list of scene components.
  63327. */
  63328. readonly name: string;
  63329. /**
  63330. * The scene the component belongs to.
  63331. */
  63332. scene: Scene;
  63333. /**
  63334. * Creates a new instance of the component for the given scene
  63335. * @param scene Defines the scene to register the component in
  63336. */
  63337. constructor(scene: Scene);
  63338. /**
  63339. * Registers the component in a given scene
  63340. */
  63341. register(): void;
  63342. /**
  63343. * Rebuilds the elements related to this component in case of
  63344. * context lost for instance.
  63345. */
  63346. rebuild(): void;
  63347. /**
  63348. * Adds all the elements from the container to the scene
  63349. * @param container the container holding the elements
  63350. */
  63351. addFromContainer(container: AbstractScene): void;
  63352. /**
  63353. * Removes all the elements in the container from the scene
  63354. * @param container contains the elements to remove
  63355. * @param dispose if the removed element should be disposed (default: false)
  63356. */
  63357. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63358. /**
  63359. * Serializes the component data to the specified json object
  63360. * @param serializationObject The object to serialize to
  63361. */
  63362. serialize(serializationObject: any): void;
  63363. /**
  63364. * Disposes the component and the associated ressources.
  63365. */
  63366. dispose(): void;
  63367. private _draw;
  63368. }
  63369. }
  63370. declare module "babylonjs/LensFlares/index" {
  63371. export * from "babylonjs/LensFlares/lensFlare";
  63372. export * from "babylonjs/LensFlares/lensFlareSystem";
  63373. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  63374. }
  63375. declare module "babylonjs/Shaders/depth.fragment" {
  63376. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63377. /** @hidden */
  63378. export var depthPixelShader: {
  63379. name: string;
  63380. shader: string;
  63381. };
  63382. }
  63383. declare module "babylonjs/Shaders/depth.vertex" {
  63384. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63385. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63386. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63387. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63388. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63389. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63390. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63391. /** @hidden */
  63392. export var depthVertexShader: {
  63393. name: string;
  63394. shader: string;
  63395. };
  63396. }
  63397. declare module "babylonjs/Rendering/depthRenderer" {
  63398. import { Nullable } from "babylonjs/types";
  63399. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63400. import { Scene } from "babylonjs/scene";
  63401. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63402. import { Camera } from "babylonjs/Cameras/camera";
  63403. import "babylonjs/Shaders/depth.fragment";
  63404. import "babylonjs/Shaders/depth.vertex";
  63405. /**
  63406. * This represents a depth renderer in Babylon.
  63407. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63408. */
  63409. export class DepthRenderer {
  63410. private _scene;
  63411. private _depthMap;
  63412. private _effect;
  63413. private readonly _storeNonLinearDepth;
  63414. private readonly _clearColor;
  63415. /** Get if the depth renderer is using packed depth or not */
  63416. readonly isPacked: boolean;
  63417. private _cachedDefines;
  63418. private _camera;
  63419. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63420. enabled: boolean;
  63421. /**
  63422. * Specifiess that the depth renderer will only be used within
  63423. * the camera it is created for.
  63424. * This can help forcing its rendering during the camera processing.
  63425. */
  63426. useOnlyInActiveCamera: boolean;
  63427. /** @hidden */
  63428. static _SceneComponentInitialization: (scene: Scene) => void;
  63429. /**
  63430. * Instantiates a depth renderer
  63431. * @param scene The scene the renderer belongs to
  63432. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63433. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63434. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63435. */
  63436. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63437. /**
  63438. * Creates the depth rendering effect and checks if the effect is ready.
  63439. * @param subMesh The submesh to be used to render the depth map of
  63440. * @param useInstances If multiple world instances should be used
  63441. * @returns if the depth renderer is ready to render the depth map
  63442. */
  63443. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63444. /**
  63445. * Gets the texture which the depth map will be written to.
  63446. * @returns The depth map texture
  63447. */
  63448. getDepthMap(): RenderTargetTexture;
  63449. /**
  63450. * Disposes of the depth renderer.
  63451. */
  63452. dispose(): void;
  63453. }
  63454. }
  63455. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  63456. /** @hidden */
  63457. export var minmaxReduxPixelShader: {
  63458. name: string;
  63459. shader: string;
  63460. };
  63461. }
  63462. declare module "babylonjs/Misc/minMaxReducer" {
  63463. import { Nullable } from "babylonjs/types";
  63464. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63465. import { Camera } from "babylonjs/Cameras/camera";
  63466. import { Observer } from "babylonjs/Misc/observable";
  63467. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63468. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63469. import { Observable } from "babylonjs/Misc/observable";
  63470. import "babylonjs/Shaders/minmaxRedux.fragment";
  63471. /**
  63472. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63473. * and maximum values from all values of the texture.
  63474. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63475. * The source values are read from the red channel of the texture.
  63476. */
  63477. export class MinMaxReducer {
  63478. /**
  63479. * Observable triggered when the computation has been performed
  63480. */
  63481. onAfterReductionPerformed: Observable<{
  63482. min: number;
  63483. max: number;
  63484. }>;
  63485. protected _camera: Camera;
  63486. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63487. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63488. protected _postProcessManager: PostProcessManager;
  63489. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63490. protected _forceFullscreenViewport: boolean;
  63491. /**
  63492. * Creates a min/max reducer
  63493. * @param camera The camera to use for the post processes
  63494. */
  63495. constructor(camera: Camera);
  63496. /**
  63497. * Gets the texture used to read the values from.
  63498. */
  63499. get sourceTexture(): Nullable<RenderTargetTexture>;
  63500. /**
  63501. * Sets the source texture to read the values from.
  63502. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63503. * because in such textures '1' value must not be taken into account to compute the maximum
  63504. * as this value is used to clear the texture.
  63505. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63506. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63507. * @param depthRedux Indicates if the texture is a depth texture or not
  63508. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63509. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63510. */
  63511. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63512. /**
  63513. * Defines the refresh rate of the computation.
  63514. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63515. */
  63516. get refreshRate(): number;
  63517. set refreshRate(value: number);
  63518. protected _activated: boolean;
  63519. /**
  63520. * Gets the activation status of the reducer
  63521. */
  63522. get activated(): boolean;
  63523. /**
  63524. * Activates the reduction computation.
  63525. * When activated, the observers registered in onAfterReductionPerformed are
  63526. * called after the compuation is performed
  63527. */
  63528. activate(): void;
  63529. /**
  63530. * Deactivates the reduction computation.
  63531. */
  63532. deactivate(): void;
  63533. /**
  63534. * Disposes the min/max reducer
  63535. * @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.
  63536. */
  63537. dispose(disposeAll?: boolean): void;
  63538. }
  63539. }
  63540. declare module "babylonjs/Misc/depthReducer" {
  63541. import { Nullable } from "babylonjs/types";
  63542. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63543. import { Camera } from "babylonjs/Cameras/camera";
  63544. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63545. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  63546. /**
  63547. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63548. */
  63549. export class DepthReducer extends MinMaxReducer {
  63550. private _depthRenderer;
  63551. private _depthRendererId;
  63552. /**
  63553. * Gets the depth renderer used for the computation.
  63554. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63555. */
  63556. get depthRenderer(): Nullable<DepthRenderer>;
  63557. /**
  63558. * Creates a depth reducer
  63559. * @param camera The camera used to render the depth texture
  63560. */
  63561. constructor(camera: Camera);
  63562. /**
  63563. * Sets the depth renderer to use to generate the depth map
  63564. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63565. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63566. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63567. */
  63568. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63569. /** @hidden */
  63570. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63571. /**
  63572. * Activates the reduction computation.
  63573. * When activated, the observers registered in onAfterReductionPerformed are
  63574. * called after the compuation is performed
  63575. */
  63576. activate(): void;
  63577. /**
  63578. * Deactivates the reduction computation.
  63579. */
  63580. deactivate(): void;
  63581. /**
  63582. * Disposes the depth reducer
  63583. * @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.
  63584. */
  63585. dispose(disposeAll?: boolean): void;
  63586. }
  63587. }
  63588. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  63589. import { Nullable } from "babylonjs/types";
  63590. import { Scene } from "babylonjs/scene";
  63591. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63592. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63594. import { Effect } from "babylonjs/Materials/effect";
  63595. import "babylonjs/Shaders/shadowMap.fragment";
  63596. import "babylonjs/Shaders/shadowMap.vertex";
  63597. import "babylonjs/Shaders/depthBoxBlur.fragment";
  63598. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  63599. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63600. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63601. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63602. /**
  63603. * A CSM implementation allowing casting shadows on large scenes.
  63604. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63605. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  63606. */
  63607. export class CascadedShadowGenerator extends ShadowGenerator {
  63608. private static readonly frustumCornersNDCSpace;
  63609. /**
  63610. * Name of the CSM class
  63611. */
  63612. static CLASSNAME: string;
  63613. /**
  63614. * Defines the default number of cascades used by the CSM.
  63615. */
  63616. static readonly DEFAULT_CASCADES_COUNT: number;
  63617. /**
  63618. * Defines the minimum number of cascades used by the CSM.
  63619. */
  63620. static readonly MIN_CASCADES_COUNT: number;
  63621. /**
  63622. * Defines the maximum number of cascades used by the CSM.
  63623. */
  63624. static readonly MAX_CASCADES_COUNT: number;
  63625. protected _validateFilter(filter: number): number;
  63626. /**
  63627. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  63628. */
  63629. penumbraDarkness: number;
  63630. private _numCascades;
  63631. /**
  63632. * Gets or set the number of cascades used by the CSM.
  63633. */
  63634. get numCascades(): number;
  63635. set numCascades(value: number);
  63636. /**
  63637. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  63638. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  63639. */
  63640. stabilizeCascades: boolean;
  63641. private _freezeShadowCastersBoundingInfo;
  63642. private _freezeShadowCastersBoundingInfoObservable;
  63643. /**
  63644. * Enables or disables the shadow casters bounding info computation.
  63645. * If your shadow casters don't move, you can disable this feature.
  63646. * If it is enabled, the bounding box computation is done every frame.
  63647. */
  63648. get freezeShadowCastersBoundingInfo(): boolean;
  63649. set freezeShadowCastersBoundingInfo(freeze: boolean);
  63650. private _scbiMin;
  63651. private _scbiMax;
  63652. protected _computeShadowCastersBoundingInfo(): void;
  63653. protected _shadowCastersBoundingInfo: BoundingInfo;
  63654. /**
  63655. * Gets or sets the shadow casters bounding info.
  63656. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  63657. * so that the system won't overwrite the bounds you provide
  63658. */
  63659. get shadowCastersBoundingInfo(): BoundingInfo;
  63660. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  63661. protected _breaksAreDirty: boolean;
  63662. protected _minDistance: number;
  63663. protected _maxDistance: number;
  63664. /**
  63665. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  63666. *
  63667. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  63668. * If you don't know these values, simply leave them to their defaults and don't call this function.
  63669. * @param min minimal distance for the breaks (default to 0.)
  63670. * @param max maximal distance for the breaks (default to 1.)
  63671. */
  63672. setMinMaxDistance(min: number, max: number): void;
  63673. /** Gets the minimal distance used in the cascade break computation */
  63674. get minDistance(): number;
  63675. /** Gets the maximal distance used in the cascade break computation */
  63676. get maxDistance(): number;
  63677. /**
  63678. * Gets the class name of that object
  63679. * @returns "CascadedShadowGenerator"
  63680. */
  63681. getClassName(): string;
  63682. private _cascadeMinExtents;
  63683. private _cascadeMaxExtents;
  63684. /**
  63685. * Gets a cascade minimum extents
  63686. * @param cascadeIndex index of the cascade
  63687. * @returns the minimum cascade extents
  63688. */
  63689. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  63690. /**
  63691. * Gets a cascade maximum extents
  63692. * @param cascadeIndex index of the cascade
  63693. * @returns the maximum cascade extents
  63694. */
  63695. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  63696. private _cascades;
  63697. private _currentLayer;
  63698. private _viewSpaceFrustumsZ;
  63699. private _viewMatrices;
  63700. private _projectionMatrices;
  63701. private _transformMatrices;
  63702. private _transformMatricesAsArray;
  63703. private _frustumLengths;
  63704. private _lightSizeUVCorrection;
  63705. private _depthCorrection;
  63706. private _frustumCornersWorldSpace;
  63707. private _frustumCenter;
  63708. private _shadowCameraPos;
  63709. private _shadowMaxZ;
  63710. /**
  63711. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  63712. * It defaults to camera.maxZ
  63713. */
  63714. get shadowMaxZ(): number;
  63715. /**
  63716. * Sets the shadow max z distance.
  63717. */
  63718. set shadowMaxZ(value: number);
  63719. protected _debug: boolean;
  63720. /**
  63721. * Gets or sets the debug flag.
  63722. * When enabled, the cascades are materialized by different colors on the screen.
  63723. */
  63724. get debug(): boolean;
  63725. set debug(dbg: boolean);
  63726. private _depthClamp;
  63727. /**
  63728. * Gets or sets the depth clamping value.
  63729. *
  63730. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  63731. * to account for the shadow casters far away.
  63732. *
  63733. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  63734. */
  63735. get depthClamp(): boolean;
  63736. set depthClamp(value: boolean);
  63737. private _cascadeBlendPercentage;
  63738. /**
  63739. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  63740. * It defaults to 0.1 (10% blending).
  63741. */
  63742. get cascadeBlendPercentage(): number;
  63743. set cascadeBlendPercentage(value: number);
  63744. private _lambda;
  63745. /**
  63746. * Gets or set the lambda parameter.
  63747. * This parameter is used to split the camera frustum and create the cascades.
  63748. * 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.
  63749. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  63750. */
  63751. get lambda(): number;
  63752. set lambda(value: number);
  63753. /**
  63754. * Gets the view matrix corresponding to a given cascade
  63755. * @param cascadeNum cascade to retrieve the view matrix from
  63756. * @returns the cascade view matrix
  63757. */
  63758. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  63759. /**
  63760. * Gets the projection matrix corresponding to a given cascade
  63761. * @param cascadeNum cascade to retrieve the projection matrix from
  63762. * @returns the cascade projection matrix
  63763. */
  63764. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  63765. /**
  63766. * Gets the transformation matrix corresponding to a given cascade
  63767. * @param cascadeNum cascade to retrieve the transformation matrix from
  63768. * @returns the cascade transformation matrix
  63769. */
  63770. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  63771. private _depthRenderer;
  63772. /**
  63773. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  63774. *
  63775. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  63776. *
  63777. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  63778. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  63779. * @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
  63780. */
  63781. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  63782. private _depthReducer;
  63783. private _autoCalcDepthBounds;
  63784. /**
  63785. * Gets or sets the autoCalcDepthBounds property.
  63786. *
  63787. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  63788. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  63789. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  63790. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  63791. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  63792. */
  63793. get autoCalcDepthBounds(): boolean;
  63794. set autoCalcDepthBounds(value: boolean);
  63795. /**
  63796. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  63797. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63798. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  63799. * for setting the refresh rate on the renderer yourself!
  63800. */
  63801. get autoCalcDepthBoundsRefreshRate(): number;
  63802. set autoCalcDepthBoundsRefreshRate(value: number);
  63803. /**
  63804. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  63805. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  63806. * you change the camera near/far planes!
  63807. */
  63808. splitFrustum(): void;
  63809. private _splitFrustum;
  63810. private _computeMatrices;
  63811. private _computeFrustumInWorldSpace;
  63812. private _computeCascadeFrustum;
  63813. /**
  63814. * Support test.
  63815. */
  63816. static get IsSupported(): boolean;
  63817. /** @hidden */
  63818. static _SceneComponentInitialization: (scene: Scene) => void;
  63819. /**
  63820. * Creates a Cascaded Shadow Generator object.
  63821. * A ShadowGenerator is the required tool to use the shadows.
  63822. * Each directional light casting shadows needs to use its own ShadowGenerator.
  63823. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63824. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  63825. * @param light The directional light object generating the shadows.
  63826. * @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.
  63827. */
  63828. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  63829. protected _initializeGenerator(): void;
  63830. protected _createTargetRenderTexture(): void;
  63831. protected _initializeShadowMap(): void;
  63832. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  63833. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  63834. /**
  63835. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  63836. * @param defines Defines of the material we want to update
  63837. * @param lightIndex Index of the light in the enabled light list of the material
  63838. */
  63839. prepareDefines(defines: any, lightIndex: number): void;
  63840. /**
  63841. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  63842. * defined in the generator but impacting the effect).
  63843. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  63844. * @param effect The effect we are binfing the information for
  63845. */
  63846. bindShadowLight(lightIndex: string, effect: Effect): void;
  63847. /**
  63848. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  63849. * (eq to view projection * shadow projection matrices)
  63850. * @returns The transform matrix used to create the shadow map
  63851. */
  63852. getTransformMatrix(): Matrix;
  63853. /**
  63854. * Disposes the ShadowGenerator.
  63855. * Returns nothing.
  63856. */
  63857. dispose(): void;
  63858. /**
  63859. * Serializes the shadow generator setup to a json object.
  63860. * @returns The serialized JSON object
  63861. */
  63862. serialize(): any;
  63863. /**
  63864. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  63865. * @param parsedShadowGenerator The JSON object to parse
  63866. * @param scene The scene to create the shadow map for
  63867. * @returns The parsed shadow generator
  63868. */
  63869. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  63870. }
  63871. }
  63872. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  63873. import { Scene } from "babylonjs/scene";
  63874. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63875. import { AbstractScene } from "babylonjs/abstractScene";
  63876. /**
  63877. * Defines the shadow generator component responsible to manage any shadow generators
  63878. * in a given scene.
  63879. */
  63880. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  63881. /**
  63882. * The component name helpfull to identify the component in the list of scene components.
  63883. */
  63884. readonly name: string;
  63885. /**
  63886. * The scene the component belongs to.
  63887. */
  63888. scene: Scene;
  63889. /**
  63890. * Creates a new instance of the component for the given scene
  63891. * @param scene Defines the scene to register the component in
  63892. */
  63893. constructor(scene: Scene);
  63894. /**
  63895. * Registers the component in a given scene
  63896. */
  63897. register(): void;
  63898. /**
  63899. * Rebuilds the elements related to this component in case of
  63900. * context lost for instance.
  63901. */
  63902. rebuild(): void;
  63903. /**
  63904. * Serializes the component data to the specified json object
  63905. * @param serializationObject The object to serialize to
  63906. */
  63907. serialize(serializationObject: any): void;
  63908. /**
  63909. * Adds all the elements from the container to the scene
  63910. * @param container the container holding the elements
  63911. */
  63912. addFromContainer(container: AbstractScene): void;
  63913. /**
  63914. * Removes all the elements in the container from the scene
  63915. * @param container contains the elements to remove
  63916. * @param dispose if the removed element should be disposed (default: false)
  63917. */
  63918. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63919. /**
  63920. * Rebuilds the elements related to this component in case of
  63921. * context lost for instance.
  63922. */
  63923. dispose(): void;
  63924. private _gatherRenderTargets;
  63925. }
  63926. }
  63927. declare module "babylonjs/Lights/Shadows/index" {
  63928. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63929. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63930. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63931. }
  63932. declare module "babylonjs/Lights/pointLight" {
  63933. import { Scene } from "babylonjs/scene";
  63934. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63936. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63937. import { Effect } from "babylonjs/Materials/effect";
  63938. /**
  63939. * A point light is a light defined by an unique point in world space.
  63940. * The light is emitted in every direction from this point.
  63941. * A good example of a point light is a standard light bulb.
  63942. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63943. */
  63944. export class PointLight extends ShadowLight {
  63945. private _shadowAngle;
  63946. /**
  63947. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63948. * This specifies what angle the shadow will use to be created.
  63949. *
  63950. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63951. */
  63952. get shadowAngle(): number;
  63953. /**
  63954. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63955. * This specifies what angle the shadow will use to be created.
  63956. *
  63957. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63958. */
  63959. set shadowAngle(value: number);
  63960. /**
  63961. * Gets the direction if it has been set.
  63962. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63963. */
  63964. get direction(): Vector3;
  63965. /**
  63966. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63967. */
  63968. set direction(value: Vector3);
  63969. /**
  63970. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63971. * A PointLight emits the light in every direction.
  63972. * It can cast shadows.
  63973. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63974. * ```javascript
  63975. * var pointLight = new PointLight("pl", camera.position, scene);
  63976. * ```
  63977. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63978. * @param name The light friendly name
  63979. * @param position The position of the point light in the scene
  63980. * @param scene The scene the lights belongs to
  63981. */
  63982. constructor(name: string, position: Vector3, scene: Scene);
  63983. /**
  63984. * Returns the string "PointLight"
  63985. * @returns the class name
  63986. */
  63987. getClassName(): string;
  63988. /**
  63989. * Returns the integer 0.
  63990. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63991. */
  63992. getTypeID(): number;
  63993. /**
  63994. * Specifies wether or not the shadowmap should be a cube texture.
  63995. * @returns true if the shadowmap needs to be a cube texture.
  63996. */
  63997. needCube(): boolean;
  63998. /**
  63999. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64000. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64001. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64002. */
  64003. getShadowDirection(faceIndex?: number): Vector3;
  64004. /**
  64005. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64006. * - fov = PI / 2
  64007. * - aspect ratio : 1.0
  64008. * - z-near and far equal to the active camera minZ and maxZ.
  64009. * Returns the PointLight.
  64010. */
  64011. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64012. protected _buildUniformLayout(): void;
  64013. /**
  64014. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64015. * @param effect The effect to update
  64016. * @param lightIndex The index of the light in the effect to update
  64017. * @returns The point light
  64018. */
  64019. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64020. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64021. /**
  64022. * Prepares the list of defines specific to the light type.
  64023. * @param defines the list of defines
  64024. * @param lightIndex defines the index of the light for the effect
  64025. */
  64026. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64027. }
  64028. }
  64029. declare module "babylonjs/Lights/index" {
  64030. export * from "babylonjs/Lights/light";
  64031. export * from "babylonjs/Lights/shadowLight";
  64032. export * from "babylonjs/Lights/Shadows/index";
  64033. export * from "babylonjs/Lights/directionalLight";
  64034. export * from "babylonjs/Lights/hemisphericLight";
  64035. export * from "babylonjs/Lights/pointLight";
  64036. export * from "babylonjs/Lights/spotLight";
  64037. }
  64038. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  64039. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64040. /**
  64041. * Header information of HDR texture files.
  64042. */
  64043. export interface HDRInfo {
  64044. /**
  64045. * The height of the texture in pixels.
  64046. */
  64047. height: number;
  64048. /**
  64049. * The width of the texture in pixels.
  64050. */
  64051. width: number;
  64052. /**
  64053. * The index of the beginning of the data in the binary file.
  64054. */
  64055. dataPosition: number;
  64056. }
  64057. /**
  64058. * This groups tools to convert HDR texture to native colors array.
  64059. */
  64060. export class HDRTools {
  64061. private static Ldexp;
  64062. private static Rgbe2float;
  64063. private static readStringLine;
  64064. /**
  64065. * Reads header information from an RGBE texture stored in a native array.
  64066. * More information on this format are available here:
  64067. * https://en.wikipedia.org/wiki/RGBE_image_format
  64068. *
  64069. * @param uint8array The binary file stored in native array.
  64070. * @return The header information.
  64071. */
  64072. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64073. /**
  64074. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64075. * This RGBE texture needs to store the information as a panorama.
  64076. *
  64077. * More information on this format are available here:
  64078. * https://en.wikipedia.org/wiki/RGBE_image_format
  64079. *
  64080. * @param buffer The binary file stored in an array buffer.
  64081. * @param size The expected size of the extracted cubemap.
  64082. * @return The Cube Map information.
  64083. */
  64084. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64085. /**
  64086. * Returns the pixels data extracted from an RGBE texture.
  64087. * This pixels will be stored left to right up to down in the R G B order in one array.
  64088. *
  64089. * More information on this format are available here:
  64090. * https://en.wikipedia.org/wiki/RGBE_image_format
  64091. *
  64092. * @param uint8array The binary file stored in an array buffer.
  64093. * @param hdrInfo The header information of the file.
  64094. * @return The pixels data in RGB right to left up to down order.
  64095. */
  64096. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64097. private static RGBE_ReadPixels_RLE;
  64098. private static RGBE_ReadPixels_NOT_RLE;
  64099. }
  64100. }
  64101. declare module "babylonjs/Materials/effectRenderer" {
  64102. import { Nullable } from "babylonjs/types";
  64103. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64104. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64105. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64106. import { Viewport } from "babylonjs/Maths/math.viewport";
  64107. import { Observable } from "babylonjs/Misc/observable";
  64108. import { Effect } from "babylonjs/Materials/effect";
  64109. import "babylonjs/Shaders/postprocess.vertex";
  64110. /**
  64111. * Effect Render Options
  64112. */
  64113. export interface IEffectRendererOptions {
  64114. /**
  64115. * Defines the vertices positions.
  64116. */
  64117. positions?: number[];
  64118. /**
  64119. * Defines the indices.
  64120. */
  64121. indices?: number[];
  64122. }
  64123. /**
  64124. * Helper class to render one or more effects.
  64125. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64126. */
  64127. export class EffectRenderer {
  64128. private engine;
  64129. private static _DefaultOptions;
  64130. private _vertexBuffers;
  64131. private _indexBuffer;
  64132. private _fullscreenViewport;
  64133. /**
  64134. * Creates an effect renderer
  64135. * @param engine the engine to use for rendering
  64136. * @param options defines the options of the effect renderer
  64137. */
  64138. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64139. /**
  64140. * Sets the current viewport in normalized coordinates 0-1
  64141. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64142. */
  64143. setViewport(viewport?: Viewport): void;
  64144. /**
  64145. * Binds the embedded attributes buffer to the effect.
  64146. * @param effect Defines the effect to bind the attributes for
  64147. */
  64148. bindBuffers(effect: Effect): void;
  64149. /**
  64150. * Sets the current effect wrapper to use during draw.
  64151. * The effect needs to be ready before calling this api.
  64152. * This also sets the default full screen position attribute.
  64153. * @param effectWrapper Defines the effect to draw with
  64154. */
  64155. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64156. /**
  64157. * Restores engine states
  64158. */
  64159. restoreStates(): void;
  64160. /**
  64161. * Draws a full screen quad.
  64162. */
  64163. draw(): void;
  64164. private isRenderTargetTexture;
  64165. /**
  64166. * renders one or more effects to a specified texture
  64167. * @param effectWrapper the effect to renderer
  64168. * @param outputTexture texture to draw to, if null it will render to the screen.
  64169. */
  64170. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64171. /**
  64172. * Disposes of the effect renderer
  64173. */
  64174. dispose(): void;
  64175. }
  64176. /**
  64177. * Options to create an EffectWrapper
  64178. */
  64179. interface EffectWrapperCreationOptions {
  64180. /**
  64181. * Engine to use to create the effect
  64182. */
  64183. engine: ThinEngine;
  64184. /**
  64185. * Fragment shader for the effect
  64186. */
  64187. fragmentShader: string;
  64188. /**
  64189. * Use the shader store instead of direct source code
  64190. */
  64191. useShaderStore?: boolean;
  64192. /**
  64193. * Vertex shader for the effect
  64194. */
  64195. vertexShader?: string;
  64196. /**
  64197. * Attributes to use in the shader
  64198. */
  64199. attributeNames?: Array<string>;
  64200. /**
  64201. * Uniforms to use in the shader
  64202. */
  64203. uniformNames?: Array<string>;
  64204. /**
  64205. * Texture sampler names to use in the shader
  64206. */
  64207. samplerNames?: Array<string>;
  64208. /**
  64209. * Defines to use in the shader
  64210. */
  64211. defines?: Array<string>;
  64212. /**
  64213. * Callback when effect is compiled
  64214. */
  64215. onCompiled?: Nullable<(effect: Effect) => void>;
  64216. /**
  64217. * The friendly name of the effect displayed in Spector.
  64218. */
  64219. name?: string;
  64220. }
  64221. /**
  64222. * Wraps an effect to be used for rendering
  64223. */
  64224. export class EffectWrapper {
  64225. /**
  64226. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64227. */
  64228. onApplyObservable: Observable<{}>;
  64229. /**
  64230. * The underlying effect
  64231. */
  64232. effect: Effect;
  64233. /**
  64234. * Creates an effect to be renderer
  64235. * @param creationOptions options to create the effect
  64236. */
  64237. constructor(creationOptions: EffectWrapperCreationOptions);
  64238. /**
  64239. * Disposes of the effect wrapper
  64240. */
  64241. dispose(): void;
  64242. }
  64243. }
  64244. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  64245. /** @hidden */
  64246. export var hdrFilteringVertexShader: {
  64247. name: string;
  64248. shader: string;
  64249. };
  64250. }
  64251. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  64252. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64253. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  64254. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  64255. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  64256. /** @hidden */
  64257. export var hdrFilteringPixelShader: {
  64258. name: string;
  64259. shader: string;
  64260. };
  64261. }
  64262. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  64263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64264. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64265. import { Nullable } from "babylonjs/types";
  64266. import "babylonjs/Shaders/hdrFiltering.vertex";
  64267. import "babylonjs/Shaders/hdrFiltering.fragment";
  64268. /**
  64269. * Options for texture filtering
  64270. */
  64271. interface IHDRFilteringOptions {
  64272. /**
  64273. * Scales pixel intensity for the input HDR map.
  64274. */
  64275. hdrScale?: number;
  64276. /**
  64277. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64278. */
  64279. quality?: number;
  64280. }
  64281. /**
  64282. * Filters HDR maps to get correct renderings of PBR reflections
  64283. */
  64284. export class HDRFiltering {
  64285. private _engine;
  64286. private _effectRenderer;
  64287. private _effectWrapper;
  64288. private _lodGenerationOffset;
  64289. private _lodGenerationScale;
  64290. /**
  64291. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64292. * you care about baking speed.
  64293. */
  64294. quality: number;
  64295. /**
  64296. * Scales pixel intensity for the input HDR map.
  64297. */
  64298. hdrScale: number;
  64299. /**
  64300. * Instantiates HDR filter for reflection maps
  64301. *
  64302. * @param engine Thin engine
  64303. * @param options Options
  64304. */
  64305. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64306. private _createRenderTarget;
  64307. private _prefilterInternal;
  64308. private _createEffect;
  64309. /**
  64310. * Get a value indicating if the filter is ready to be used
  64311. * @param texture Texture to filter
  64312. * @returns true if the filter is ready
  64313. */
  64314. isReady(texture: BaseTexture): boolean;
  64315. /**
  64316. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64317. * Prefiltering will be invoked at the end of next rendering pass.
  64318. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64319. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64320. * @param texture Texture to filter
  64321. * @param onFinished Callback when filtering is done
  64322. * @return Promise called when prefiltering is done
  64323. */
  64324. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  64325. }
  64326. }
  64327. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  64328. import { Nullable } from "babylonjs/types";
  64329. import { Scene } from "babylonjs/scene";
  64330. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64332. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64333. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64334. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  64335. /**
  64336. * This represents a texture coming from an HDR input.
  64337. *
  64338. * The only supported format is currently panorama picture stored in RGBE format.
  64339. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64340. */
  64341. export class HDRCubeTexture extends BaseTexture {
  64342. private static _facesMapping;
  64343. private _generateHarmonics;
  64344. private _noMipmap;
  64345. private _prefilterOnLoad;
  64346. private _textureMatrix;
  64347. private _size;
  64348. private _onLoad;
  64349. private _onError;
  64350. /**
  64351. * The texture URL.
  64352. */
  64353. url: string;
  64354. protected _isBlocking: boolean;
  64355. /**
  64356. * Sets wether or not the texture is blocking during loading.
  64357. */
  64358. set isBlocking(value: boolean);
  64359. /**
  64360. * Gets wether or not the texture is blocking during loading.
  64361. */
  64362. get isBlocking(): boolean;
  64363. protected _rotationY: number;
  64364. /**
  64365. * Sets texture matrix rotation angle around Y axis in radians.
  64366. */
  64367. set rotationY(value: number);
  64368. /**
  64369. * Gets texture matrix rotation angle around Y axis radians.
  64370. */
  64371. get rotationY(): number;
  64372. /**
  64373. * Gets or sets the center of the bounding box associated with the cube texture
  64374. * It must define where the camera used to render the texture was set
  64375. */
  64376. boundingBoxPosition: Vector3;
  64377. private _boundingBoxSize;
  64378. /**
  64379. * Gets or sets the size of the bounding box associated with the cube texture
  64380. * When defined, the cubemap will switch to local mode
  64381. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64382. * @example https://www.babylonjs-playground.com/#RNASML
  64383. */
  64384. set boundingBoxSize(value: Vector3);
  64385. get boundingBoxSize(): Vector3;
  64386. /**
  64387. * Instantiates an HDRTexture from the following parameters.
  64388. *
  64389. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64390. * @param sceneOrEngine The scene or engine the texture will be used in
  64391. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64392. * @param noMipmap Forces to not generate the mipmap if true
  64393. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64394. * @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)
  64395. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64396. */
  64397. 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>);
  64398. /**
  64399. * Get the current class name of the texture useful for serialization or dynamic coding.
  64400. * @returns "HDRCubeTexture"
  64401. */
  64402. getClassName(): string;
  64403. /**
  64404. * Occurs when the file is raw .hdr file.
  64405. */
  64406. private loadTexture;
  64407. clone(): HDRCubeTexture;
  64408. delayLoad(): void;
  64409. /**
  64410. * Get the texture reflection matrix used to rotate/transform the reflection.
  64411. * @returns the reflection matrix
  64412. */
  64413. getReflectionTextureMatrix(): Matrix;
  64414. /**
  64415. * Set the texture reflection matrix used to rotate/transform the reflection.
  64416. * @param value Define the reflection matrix to set
  64417. */
  64418. setReflectionTextureMatrix(value: Matrix): void;
  64419. /**
  64420. * Parses a JSON representation of an HDR Texture in order to create the texture
  64421. * @param parsedTexture Define the JSON representation
  64422. * @param scene Define the scene the texture should be created in
  64423. * @param rootUrl Define the root url in case we need to load relative dependencies
  64424. * @returns the newly created texture after parsing
  64425. */
  64426. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64427. serialize(): any;
  64428. }
  64429. }
  64430. declare module "babylonjs/Physics/physicsEngine" {
  64431. import { Nullable } from "babylonjs/types";
  64432. import { Vector3 } from "babylonjs/Maths/math.vector";
  64433. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64434. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  64435. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  64436. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64437. /**
  64438. * Class used to control physics engine
  64439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64440. */
  64441. export class PhysicsEngine implements IPhysicsEngine {
  64442. private _physicsPlugin;
  64443. /**
  64444. * Global value used to control the smallest number supported by the simulation
  64445. */
  64446. static Epsilon: number;
  64447. private _impostors;
  64448. private _joints;
  64449. private _subTimeStep;
  64450. /**
  64451. * Gets the gravity vector used by the simulation
  64452. */
  64453. gravity: Vector3;
  64454. /**
  64455. * Factory used to create the default physics plugin.
  64456. * @returns The default physics plugin
  64457. */
  64458. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64459. /**
  64460. * Creates a new Physics Engine
  64461. * @param gravity defines the gravity vector used by the simulation
  64462. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64463. */
  64464. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64465. /**
  64466. * Sets the gravity vector used by the simulation
  64467. * @param gravity defines the gravity vector to use
  64468. */
  64469. setGravity(gravity: Vector3): void;
  64470. /**
  64471. * Set the time step of the physics engine.
  64472. * Default is 1/60.
  64473. * To slow it down, enter 1/600 for example.
  64474. * To speed it up, 1/30
  64475. * @param newTimeStep defines the new timestep to apply to this world.
  64476. */
  64477. setTimeStep(newTimeStep?: number): void;
  64478. /**
  64479. * Get the time step of the physics engine.
  64480. * @returns the current time step
  64481. */
  64482. getTimeStep(): number;
  64483. /**
  64484. * Set the sub time step of the physics engine.
  64485. * Default is 0 meaning there is no sub steps
  64486. * To increase physics resolution precision, set a small value (like 1 ms)
  64487. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64488. */
  64489. setSubTimeStep(subTimeStep?: number): void;
  64490. /**
  64491. * Get the sub time step of the physics engine.
  64492. * @returns the current sub time step
  64493. */
  64494. getSubTimeStep(): number;
  64495. /**
  64496. * Release all resources
  64497. */
  64498. dispose(): void;
  64499. /**
  64500. * Gets the name of the current physics plugin
  64501. * @returns the name of the plugin
  64502. */
  64503. getPhysicsPluginName(): string;
  64504. /**
  64505. * Adding a new impostor for the impostor tracking.
  64506. * This will be done by the impostor itself.
  64507. * @param impostor the impostor to add
  64508. */
  64509. addImpostor(impostor: PhysicsImpostor): void;
  64510. /**
  64511. * Remove an impostor from the engine.
  64512. * This impostor and its mesh will not longer be updated by the physics engine.
  64513. * @param impostor the impostor to remove
  64514. */
  64515. removeImpostor(impostor: PhysicsImpostor): void;
  64516. /**
  64517. * Add a joint to the physics engine
  64518. * @param mainImpostor defines the main impostor to which the joint is added.
  64519. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64520. * @param joint defines the joint that will connect both impostors.
  64521. */
  64522. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64523. /**
  64524. * Removes a joint from the simulation
  64525. * @param mainImpostor defines the impostor used with the joint
  64526. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64527. * @param joint defines the joint to remove
  64528. */
  64529. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64530. /**
  64531. * Called by the scene. No need to call it.
  64532. * @param delta defines the timespam between frames
  64533. */
  64534. _step(delta: number): void;
  64535. /**
  64536. * Gets the current plugin used to run the simulation
  64537. * @returns current plugin
  64538. */
  64539. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64540. /**
  64541. * Gets the list of physic impostors
  64542. * @returns an array of PhysicsImpostor
  64543. */
  64544. getImpostors(): Array<PhysicsImpostor>;
  64545. /**
  64546. * Gets the impostor for a physics enabled object
  64547. * @param object defines the object impersonated by the impostor
  64548. * @returns the PhysicsImpostor or null if not found
  64549. */
  64550. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64551. /**
  64552. * Gets the impostor for a physics body object
  64553. * @param body defines physics body used by the impostor
  64554. * @returns the PhysicsImpostor or null if not found
  64555. */
  64556. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64557. /**
  64558. * Does a raycast in the physics world
  64559. * @param from when should the ray start?
  64560. * @param to when should the ray end?
  64561. * @returns PhysicsRaycastResult
  64562. */
  64563. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64564. }
  64565. }
  64566. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  64567. import { Nullable } from "babylonjs/types";
  64568. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64570. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64571. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64572. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64573. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64574. /** @hidden */
  64575. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64576. private _useDeltaForWorldStep;
  64577. world: any;
  64578. name: string;
  64579. private _physicsMaterials;
  64580. private _fixedTimeStep;
  64581. private _cannonRaycastResult;
  64582. private _raycastResult;
  64583. private _physicsBodysToRemoveAfterStep;
  64584. private _firstFrame;
  64585. BJSCANNON: any;
  64586. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64587. setGravity(gravity: Vector3): void;
  64588. setTimeStep(timeStep: number): void;
  64589. getTimeStep(): number;
  64590. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64591. private _removeMarkedPhysicsBodiesFromWorld;
  64592. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64593. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64594. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64595. private _processChildMeshes;
  64596. removePhysicsBody(impostor: PhysicsImpostor): void;
  64597. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64598. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64599. private _addMaterial;
  64600. private _checkWithEpsilon;
  64601. private _createShape;
  64602. private _createHeightmap;
  64603. private _minus90X;
  64604. private _plus90X;
  64605. private _tmpPosition;
  64606. private _tmpDeltaPosition;
  64607. private _tmpUnityRotation;
  64608. private _updatePhysicsBodyTransformation;
  64609. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64610. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64611. isSupported(): boolean;
  64612. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64613. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64614. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64615. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64616. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64617. getBodyMass(impostor: PhysicsImpostor): number;
  64618. getBodyFriction(impostor: PhysicsImpostor): number;
  64619. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64620. getBodyRestitution(impostor: PhysicsImpostor): number;
  64621. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64622. sleepBody(impostor: PhysicsImpostor): void;
  64623. wakeUpBody(impostor: PhysicsImpostor): void;
  64624. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  64625. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64626. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64627. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64628. getRadius(impostor: PhysicsImpostor): number;
  64629. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64630. dispose(): void;
  64631. private _extendNamespace;
  64632. /**
  64633. * Does a raycast in the physics world
  64634. * @param from when should the ray start?
  64635. * @param to when should the ray end?
  64636. * @returns PhysicsRaycastResult
  64637. */
  64638. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64639. }
  64640. }
  64641. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  64642. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64643. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64644. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64646. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64647. import { Nullable } from "babylonjs/types";
  64648. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64649. /** @hidden */
  64650. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  64651. private _useDeltaForWorldStep;
  64652. world: any;
  64653. name: string;
  64654. BJSOIMO: any;
  64655. private _raycastResult;
  64656. private _fixedTimeStep;
  64657. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  64658. setGravity(gravity: Vector3): void;
  64659. setTimeStep(timeStep: number): void;
  64660. getTimeStep(): number;
  64661. private _tmpImpostorsArray;
  64662. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64663. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64664. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64665. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64666. private _tmpPositionVector;
  64667. removePhysicsBody(impostor: PhysicsImpostor): void;
  64668. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64669. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64670. isSupported(): boolean;
  64671. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64672. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64673. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64674. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64675. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64676. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64677. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64678. getBodyMass(impostor: PhysicsImpostor): number;
  64679. getBodyFriction(impostor: PhysicsImpostor): number;
  64680. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64681. getBodyRestitution(impostor: PhysicsImpostor): number;
  64682. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64683. sleepBody(impostor: PhysicsImpostor): void;
  64684. wakeUpBody(impostor: PhysicsImpostor): void;
  64685. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64686. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  64687. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  64688. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64689. getRadius(impostor: PhysicsImpostor): number;
  64690. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64691. dispose(): void;
  64692. /**
  64693. * Does a raycast in the physics world
  64694. * @param from when should the ray start?
  64695. * @param to when should the ray end?
  64696. * @returns PhysicsRaycastResult
  64697. */
  64698. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64699. }
  64700. }
  64701. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  64702. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  64703. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64704. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64705. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64706. import { Nullable } from "babylonjs/types";
  64707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64708. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64709. /**
  64710. * AmmoJS Physics plugin
  64711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64712. * @see https://github.com/kripken/ammo.js/
  64713. */
  64714. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  64715. private _useDeltaForWorldStep;
  64716. /**
  64717. * Reference to the Ammo library
  64718. */
  64719. bjsAMMO: any;
  64720. /**
  64721. * Created ammoJS world which physics bodies are added to
  64722. */
  64723. world: any;
  64724. /**
  64725. * Name of the plugin
  64726. */
  64727. name: string;
  64728. private _timeStep;
  64729. private _fixedTimeStep;
  64730. private _maxSteps;
  64731. private _tmpQuaternion;
  64732. private _tmpAmmoTransform;
  64733. private _tmpAmmoQuaternion;
  64734. private _tmpAmmoConcreteContactResultCallback;
  64735. private _collisionConfiguration;
  64736. private _dispatcher;
  64737. private _overlappingPairCache;
  64738. private _solver;
  64739. private _softBodySolver;
  64740. private _tmpAmmoVectorA;
  64741. private _tmpAmmoVectorB;
  64742. private _tmpAmmoVectorC;
  64743. private _tmpAmmoVectorD;
  64744. private _tmpContactCallbackResult;
  64745. private _tmpAmmoVectorRCA;
  64746. private _tmpAmmoVectorRCB;
  64747. private _raycastResult;
  64748. private _tmpContactPoint;
  64749. private static readonly DISABLE_COLLISION_FLAG;
  64750. private static readonly KINEMATIC_FLAG;
  64751. private static readonly DISABLE_DEACTIVATION_FLAG;
  64752. /**
  64753. * Initializes the ammoJS plugin
  64754. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  64755. * @param ammoInjection can be used to inject your own ammo reference
  64756. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  64757. */
  64758. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  64759. /**
  64760. * Sets the gravity of the physics world (m/(s^2))
  64761. * @param gravity Gravity to set
  64762. */
  64763. setGravity(gravity: Vector3): void;
  64764. /**
  64765. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  64766. * @param timeStep timestep to use in seconds
  64767. */
  64768. setTimeStep(timeStep: number): void;
  64769. /**
  64770. * 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)
  64771. * @param fixedTimeStep fixedTimeStep to use in seconds
  64772. */
  64773. setFixedTimeStep(fixedTimeStep: number): void;
  64774. /**
  64775. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  64776. * @param maxSteps the maximum number of steps by the physics engine per frame
  64777. */
  64778. setMaxSteps(maxSteps: number): void;
  64779. /**
  64780. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  64781. * @returns the current timestep in seconds
  64782. */
  64783. getTimeStep(): number;
  64784. /**
  64785. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  64786. */
  64787. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  64788. private _isImpostorInContact;
  64789. private _isImpostorPairInContact;
  64790. private _stepSimulation;
  64791. /**
  64792. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  64793. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  64794. * After the step the babylon meshes are set to the position of the physics imposters
  64795. * @param delta amount of time to step forward
  64796. * @param impostors array of imposters to update before/after the step
  64797. */
  64798. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64799. /**
  64800. * Update babylon mesh to match physics world object
  64801. * @param impostor imposter to match
  64802. */
  64803. private _afterSoftStep;
  64804. /**
  64805. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64806. * @param impostor imposter to match
  64807. */
  64808. private _ropeStep;
  64809. /**
  64810. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64811. * @param impostor imposter to match
  64812. */
  64813. private _softbodyOrClothStep;
  64814. private _tmpMatrix;
  64815. /**
  64816. * Applies an impulse on the imposter
  64817. * @param impostor imposter to apply impulse to
  64818. * @param force amount of force to be applied to the imposter
  64819. * @param contactPoint the location to apply the impulse on the imposter
  64820. */
  64821. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64822. /**
  64823. * Applies a force on the imposter
  64824. * @param impostor imposter to apply force
  64825. * @param force amount of force to be applied to the imposter
  64826. * @param contactPoint the location to apply the force on the imposter
  64827. */
  64828. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64829. /**
  64830. * Creates a physics body using the plugin
  64831. * @param impostor the imposter to create the physics body on
  64832. */
  64833. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64834. /**
  64835. * Removes the physics body from the imposter and disposes of the body's memory
  64836. * @param impostor imposter to remove the physics body from
  64837. */
  64838. removePhysicsBody(impostor: PhysicsImpostor): void;
  64839. /**
  64840. * Generates a joint
  64841. * @param impostorJoint the imposter joint to create the joint with
  64842. */
  64843. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64844. /**
  64845. * Removes a joint
  64846. * @param impostorJoint the imposter joint to remove the joint from
  64847. */
  64848. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64849. private _addMeshVerts;
  64850. /**
  64851. * Initialise the soft body vertices to match its object's (mesh) vertices
  64852. * Softbody vertices (nodes) are in world space and to match this
  64853. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  64854. * @param impostor to create the softbody for
  64855. */
  64856. private _softVertexData;
  64857. /**
  64858. * Create an impostor's soft body
  64859. * @param impostor to create the softbody for
  64860. */
  64861. private _createSoftbody;
  64862. /**
  64863. * Create cloth for an impostor
  64864. * @param impostor to create the softbody for
  64865. */
  64866. private _createCloth;
  64867. /**
  64868. * Create rope for an impostor
  64869. * @param impostor to create the softbody for
  64870. */
  64871. private _createRope;
  64872. /**
  64873. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  64874. * @param impostor to create the custom physics shape for
  64875. */
  64876. private _createCustom;
  64877. private _addHullVerts;
  64878. private _createShape;
  64879. /**
  64880. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  64881. * @param impostor imposter containing the physics body and babylon object
  64882. */
  64883. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64884. /**
  64885. * Sets the babylon object's position/rotation from the physics body's position/rotation
  64886. * @param impostor imposter containing the physics body and babylon object
  64887. * @param newPosition new position
  64888. * @param newRotation new rotation
  64889. */
  64890. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64891. /**
  64892. * If this plugin is supported
  64893. * @returns true if its supported
  64894. */
  64895. isSupported(): boolean;
  64896. /**
  64897. * Sets the linear velocity of the physics body
  64898. * @param impostor imposter to set the velocity on
  64899. * @param velocity velocity to set
  64900. */
  64901. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64902. /**
  64903. * Sets the angular velocity of the physics body
  64904. * @param impostor imposter to set the velocity on
  64905. * @param velocity velocity to set
  64906. */
  64907. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64908. /**
  64909. * gets the linear velocity
  64910. * @param impostor imposter to get linear velocity from
  64911. * @returns linear velocity
  64912. */
  64913. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64914. /**
  64915. * gets the angular velocity
  64916. * @param impostor imposter to get angular velocity from
  64917. * @returns angular velocity
  64918. */
  64919. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64920. /**
  64921. * Sets the mass of physics body
  64922. * @param impostor imposter to set the mass on
  64923. * @param mass mass to set
  64924. */
  64925. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64926. /**
  64927. * Gets the mass of the physics body
  64928. * @param impostor imposter to get the mass from
  64929. * @returns mass
  64930. */
  64931. getBodyMass(impostor: PhysicsImpostor): number;
  64932. /**
  64933. * Gets friction of the impostor
  64934. * @param impostor impostor to get friction from
  64935. * @returns friction value
  64936. */
  64937. getBodyFriction(impostor: PhysicsImpostor): number;
  64938. /**
  64939. * Sets friction of the impostor
  64940. * @param impostor impostor to set friction on
  64941. * @param friction friction value
  64942. */
  64943. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64944. /**
  64945. * Gets restitution of the impostor
  64946. * @param impostor impostor to get restitution from
  64947. * @returns restitution value
  64948. */
  64949. getBodyRestitution(impostor: PhysicsImpostor): number;
  64950. /**
  64951. * Sets resitution of the impostor
  64952. * @param impostor impostor to set resitution on
  64953. * @param restitution resitution value
  64954. */
  64955. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64956. /**
  64957. * Gets pressure inside the impostor
  64958. * @param impostor impostor to get pressure from
  64959. * @returns pressure value
  64960. */
  64961. getBodyPressure(impostor: PhysicsImpostor): number;
  64962. /**
  64963. * Sets pressure inside a soft body impostor
  64964. * Cloth and rope must remain 0 pressure
  64965. * @param impostor impostor to set pressure on
  64966. * @param pressure pressure value
  64967. */
  64968. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64969. /**
  64970. * Gets stiffness of the impostor
  64971. * @param impostor impostor to get stiffness from
  64972. * @returns pressure value
  64973. */
  64974. getBodyStiffness(impostor: PhysicsImpostor): number;
  64975. /**
  64976. * Sets stiffness of the impostor
  64977. * @param impostor impostor to set stiffness on
  64978. * @param stiffness stiffness value from 0 to 1
  64979. */
  64980. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64981. /**
  64982. * Gets velocityIterations of the impostor
  64983. * @param impostor impostor to get velocity iterations from
  64984. * @returns velocityIterations value
  64985. */
  64986. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64987. /**
  64988. * Sets velocityIterations of the impostor
  64989. * @param impostor impostor to set velocity iterations on
  64990. * @param velocityIterations velocityIterations value
  64991. */
  64992. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64993. /**
  64994. * Gets positionIterations of the impostor
  64995. * @param impostor impostor to get position iterations from
  64996. * @returns positionIterations value
  64997. */
  64998. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64999. /**
  65000. * Sets positionIterations of the impostor
  65001. * @param impostor impostor to set position on
  65002. * @param positionIterations positionIterations value
  65003. */
  65004. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65005. /**
  65006. * Append an anchor to a cloth object
  65007. * @param impostor is the cloth impostor to add anchor to
  65008. * @param otherImpostor is the rigid impostor to anchor to
  65009. * @param width ratio across width from 0 to 1
  65010. * @param height ratio up height from 0 to 1
  65011. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65012. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65013. */
  65014. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65015. /**
  65016. * Append an hook to a rope object
  65017. * @param impostor is the rope impostor to add hook to
  65018. * @param otherImpostor is the rigid impostor to hook to
  65019. * @param length ratio along the rope from 0 to 1
  65020. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65021. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65022. */
  65023. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65024. /**
  65025. * Sleeps the physics body and stops it from being active
  65026. * @param impostor impostor to sleep
  65027. */
  65028. sleepBody(impostor: PhysicsImpostor): void;
  65029. /**
  65030. * Activates the physics body
  65031. * @param impostor impostor to activate
  65032. */
  65033. wakeUpBody(impostor: PhysicsImpostor): void;
  65034. /**
  65035. * Updates the distance parameters of the joint
  65036. * @param joint joint to update
  65037. * @param maxDistance maximum distance of the joint
  65038. * @param minDistance minimum distance of the joint
  65039. */
  65040. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65041. /**
  65042. * Sets a motor on the joint
  65043. * @param joint joint to set motor on
  65044. * @param speed speed of the motor
  65045. * @param maxForce maximum force of the motor
  65046. * @param motorIndex index of the motor
  65047. */
  65048. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65049. /**
  65050. * Sets the motors limit
  65051. * @param joint joint to set limit on
  65052. * @param upperLimit upper limit
  65053. * @param lowerLimit lower limit
  65054. */
  65055. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65056. /**
  65057. * Syncs the position and rotation of a mesh with the impostor
  65058. * @param mesh mesh to sync
  65059. * @param impostor impostor to update the mesh with
  65060. */
  65061. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65062. /**
  65063. * Gets the radius of the impostor
  65064. * @param impostor impostor to get radius from
  65065. * @returns the radius
  65066. */
  65067. getRadius(impostor: PhysicsImpostor): number;
  65068. /**
  65069. * Gets the box size of the impostor
  65070. * @param impostor impostor to get box size from
  65071. * @param result the resulting box size
  65072. */
  65073. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65074. /**
  65075. * Disposes of the impostor
  65076. */
  65077. dispose(): void;
  65078. /**
  65079. * Does a raycast in the physics world
  65080. * @param from when should the ray start?
  65081. * @param to when should the ray end?
  65082. * @returns PhysicsRaycastResult
  65083. */
  65084. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65085. }
  65086. }
  65087. declare module "babylonjs/Probes/reflectionProbe" {
  65088. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65089. import { Vector3 } from "babylonjs/Maths/math.vector";
  65090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65091. import { Nullable } from "babylonjs/types";
  65092. import { Scene } from "babylonjs/scene";
  65093. module "babylonjs/abstractScene" {
  65094. interface AbstractScene {
  65095. /**
  65096. * The list of reflection probes added to the scene
  65097. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65098. */
  65099. reflectionProbes: Array<ReflectionProbe>;
  65100. /**
  65101. * Removes the given reflection probe from this scene.
  65102. * @param toRemove The reflection probe to remove
  65103. * @returns The index of the removed reflection probe
  65104. */
  65105. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65106. /**
  65107. * Adds the given reflection probe to this scene.
  65108. * @param newReflectionProbe The reflection probe to add
  65109. */
  65110. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65111. }
  65112. }
  65113. /**
  65114. * Class used to generate realtime reflection / refraction cube textures
  65115. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65116. */
  65117. export class ReflectionProbe {
  65118. /** defines the name of the probe */
  65119. name: string;
  65120. private _scene;
  65121. private _renderTargetTexture;
  65122. private _projectionMatrix;
  65123. private _viewMatrix;
  65124. private _target;
  65125. private _add;
  65126. private _attachedMesh;
  65127. private _invertYAxis;
  65128. /** Gets or sets probe position (center of the cube map) */
  65129. position: Vector3;
  65130. /**
  65131. * Creates a new reflection probe
  65132. * @param name defines the name of the probe
  65133. * @param size defines the texture resolution (for each face)
  65134. * @param scene defines the hosting scene
  65135. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65136. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65137. */
  65138. constructor(
  65139. /** defines the name of the probe */
  65140. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65141. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65142. get samples(): number;
  65143. set samples(value: number);
  65144. /** Gets or sets the refresh rate to use (on every frame by default) */
  65145. get refreshRate(): number;
  65146. set refreshRate(value: number);
  65147. /**
  65148. * Gets the hosting scene
  65149. * @returns a Scene
  65150. */
  65151. getScene(): Scene;
  65152. /** Gets the internal CubeTexture used to render to */
  65153. get cubeTexture(): RenderTargetTexture;
  65154. /** Gets the list of meshes to render */
  65155. get renderList(): Nullable<AbstractMesh[]>;
  65156. /**
  65157. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65158. * @param mesh defines the mesh to attach to
  65159. */
  65160. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65161. /**
  65162. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65163. * @param renderingGroupId The rendering group id corresponding to its index
  65164. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65165. */
  65166. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65167. /**
  65168. * Clean all associated resources
  65169. */
  65170. dispose(): void;
  65171. /**
  65172. * Converts the reflection probe information to a readable string for debug purpose.
  65173. * @param fullDetails Supports for multiple levels of logging within scene loading
  65174. * @returns the human readable reflection probe info
  65175. */
  65176. toString(fullDetails?: boolean): string;
  65177. /**
  65178. * Get the class name of the relfection probe.
  65179. * @returns "ReflectionProbe"
  65180. */
  65181. getClassName(): string;
  65182. /**
  65183. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65184. * @returns The JSON representation of the texture
  65185. */
  65186. serialize(): any;
  65187. /**
  65188. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65189. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65190. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65191. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65192. * @returns The parsed reflection probe if successful
  65193. */
  65194. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65195. }
  65196. }
  65197. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  65198. /** @hidden */
  65199. export var _BabylonLoaderRegistered: boolean;
  65200. /**
  65201. * Helps setting up some configuration for the babylon file loader.
  65202. */
  65203. export class BabylonFileLoaderConfiguration {
  65204. /**
  65205. * The loader does not allow injecting custom physix engine into the plugins.
  65206. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65207. * So you could set this variable to your engine import to make it work.
  65208. */
  65209. static LoaderInjectedPhysicsEngine: any;
  65210. }
  65211. }
  65212. declare module "babylonjs/Loading/Plugins/index" {
  65213. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  65214. }
  65215. declare module "babylonjs/Loading/index" {
  65216. export * from "babylonjs/Loading/loadingScreen";
  65217. export * from "babylonjs/Loading/Plugins/index";
  65218. export * from "babylonjs/Loading/sceneLoader";
  65219. export * from "babylonjs/Loading/sceneLoaderFlags";
  65220. }
  65221. declare module "babylonjs/Materials/Background/index" {
  65222. export * from "babylonjs/Materials/Background/backgroundMaterial";
  65223. }
  65224. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  65225. import { Scene } from "babylonjs/scene";
  65226. import { Color3 } from "babylonjs/Maths/math.color";
  65227. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65228. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65229. /**
  65230. * The Physically based simple base material of BJS.
  65231. *
  65232. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65233. * It is used as the base class for both the specGloss and metalRough conventions.
  65234. */
  65235. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65236. /**
  65237. * Number of Simultaneous lights allowed on the material.
  65238. */
  65239. maxSimultaneousLights: number;
  65240. /**
  65241. * If sets to true, disables all the lights affecting the material.
  65242. */
  65243. disableLighting: boolean;
  65244. /**
  65245. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65246. */
  65247. environmentTexture: BaseTexture;
  65248. /**
  65249. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65250. */
  65251. invertNormalMapX: boolean;
  65252. /**
  65253. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65254. */
  65255. invertNormalMapY: boolean;
  65256. /**
  65257. * Normal map used in the model.
  65258. */
  65259. normalTexture: BaseTexture;
  65260. /**
  65261. * Emissivie color used to self-illuminate the model.
  65262. */
  65263. emissiveColor: Color3;
  65264. /**
  65265. * Emissivie texture used to self-illuminate the model.
  65266. */
  65267. emissiveTexture: BaseTexture;
  65268. /**
  65269. * Occlusion Channel Strenght.
  65270. */
  65271. occlusionStrength: number;
  65272. /**
  65273. * Occlusion Texture of the material (adding extra occlusion effects).
  65274. */
  65275. occlusionTexture: BaseTexture;
  65276. /**
  65277. * Defines the alpha limits in alpha test mode.
  65278. */
  65279. alphaCutOff: number;
  65280. /**
  65281. * Gets the current double sided mode.
  65282. */
  65283. get doubleSided(): boolean;
  65284. /**
  65285. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65286. */
  65287. set doubleSided(value: boolean);
  65288. /**
  65289. * Stores the pre-calculated light information of a mesh in a texture.
  65290. */
  65291. lightmapTexture: BaseTexture;
  65292. /**
  65293. * If true, the light map contains occlusion information instead of lighting info.
  65294. */
  65295. useLightmapAsShadowmap: boolean;
  65296. /**
  65297. * Instantiates a new PBRMaterial instance.
  65298. *
  65299. * @param name The material name
  65300. * @param scene The scene the material will be use in.
  65301. */
  65302. constructor(name: string, scene: Scene);
  65303. getClassName(): string;
  65304. }
  65305. }
  65306. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  65307. import { Scene } from "babylonjs/scene";
  65308. import { Color3 } from "babylonjs/Maths/math.color";
  65309. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65310. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65311. /**
  65312. * The PBR material of BJS following the metal roughness convention.
  65313. *
  65314. * This fits to the PBR convention in the GLTF definition:
  65315. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65316. */
  65317. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65318. /**
  65319. * The base color has two different interpretations depending on the value of metalness.
  65320. * When the material is a metal, the base color is the specific measured reflectance value
  65321. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65322. * of the material.
  65323. */
  65324. baseColor: Color3;
  65325. /**
  65326. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65327. * well as opacity information in the alpha channel.
  65328. */
  65329. baseTexture: BaseTexture;
  65330. /**
  65331. * Specifies the metallic scalar value of the material.
  65332. * Can also be used to scale the metalness values of the metallic texture.
  65333. */
  65334. metallic: number;
  65335. /**
  65336. * Specifies the roughness scalar value of the material.
  65337. * Can also be used to scale the roughness values of the metallic texture.
  65338. */
  65339. roughness: number;
  65340. /**
  65341. * Texture containing both the metallic value in the B channel and the
  65342. * roughness value in the G channel to keep better precision.
  65343. */
  65344. metallicRoughnessTexture: BaseTexture;
  65345. /**
  65346. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65347. *
  65348. * @param name The material name
  65349. * @param scene The scene the material will be use in.
  65350. */
  65351. constructor(name: string, scene: Scene);
  65352. /**
  65353. * Return the currrent class name of the material.
  65354. */
  65355. getClassName(): string;
  65356. /**
  65357. * Makes a duplicate of the current material.
  65358. * @param name - name to use for the new material.
  65359. */
  65360. clone(name: string): PBRMetallicRoughnessMaterial;
  65361. /**
  65362. * Serialize the material to a parsable JSON object.
  65363. */
  65364. serialize(): any;
  65365. /**
  65366. * Parses a JSON object correponding to the serialize function.
  65367. */
  65368. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65369. }
  65370. }
  65371. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  65372. import { Scene } from "babylonjs/scene";
  65373. import { Color3 } from "babylonjs/Maths/math.color";
  65374. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65375. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65376. /**
  65377. * The PBR material of BJS following the specular glossiness convention.
  65378. *
  65379. * This fits to the PBR convention in the GLTF definition:
  65380. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65381. */
  65382. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65383. /**
  65384. * Specifies the diffuse color of the material.
  65385. */
  65386. diffuseColor: Color3;
  65387. /**
  65388. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65389. * channel.
  65390. */
  65391. diffuseTexture: BaseTexture;
  65392. /**
  65393. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65394. */
  65395. specularColor: Color3;
  65396. /**
  65397. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65398. */
  65399. glossiness: number;
  65400. /**
  65401. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65402. */
  65403. specularGlossinessTexture: BaseTexture;
  65404. /**
  65405. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65406. *
  65407. * @param name The material name
  65408. * @param scene The scene the material will be use in.
  65409. */
  65410. constructor(name: string, scene: Scene);
  65411. /**
  65412. * Return the currrent class name of the material.
  65413. */
  65414. getClassName(): string;
  65415. /**
  65416. * Makes a duplicate of the current material.
  65417. * @param name - name to use for the new material.
  65418. */
  65419. clone(name: string): PBRSpecularGlossinessMaterial;
  65420. /**
  65421. * Serialize the material to a parsable JSON object.
  65422. */
  65423. serialize(): any;
  65424. /**
  65425. * Parses a JSON object correponding to the serialize function.
  65426. */
  65427. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65428. }
  65429. }
  65430. declare module "babylonjs/Materials/PBR/index" {
  65431. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65432. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65433. export * from "babylonjs/Materials/PBR/pbrMaterial";
  65434. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  65435. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  65436. }
  65437. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  65438. import { Nullable } from "babylonjs/types";
  65439. import { Scene } from "babylonjs/scene";
  65440. import { Matrix } from "babylonjs/Maths/math.vector";
  65441. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65442. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65443. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65444. /**
  65445. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65446. * It can help converting any input color in a desired output one. This can then be used to create effects
  65447. * from sepia, black and white to sixties or futuristic rendering...
  65448. *
  65449. * The only supported format is currently 3dl.
  65450. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65451. */
  65452. export class ColorGradingTexture extends BaseTexture {
  65453. /**
  65454. * The texture URL.
  65455. */
  65456. url: string;
  65457. /**
  65458. * Empty line regex stored for GC.
  65459. */
  65460. private static _noneEmptyLineRegex;
  65461. private _textureMatrix;
  65462. private _onLoad;
  65463. /**
  65464. * Instantiates a ColorGradingTexture from the following parameters.
  65465. *
  65466. * @param url The location of the color gradind data (currently only supporting 3dl)
  65467. * @param sceneOrEngine The scene or engine the texture will be used in
  65468. * @param onLoad defines a callback triggered when the texture has been loaded
  65469. */
  65470. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65471. /**
  65472. * Fires the onload event from the constructor if requested.
  65473. */
  65474. private _triggerOnLoad;
  65475. /**
  65476. * Returns the texture matrix used in most of the material.
  65477. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65478. */
  65479. getTextureMatrix(): Matrix;
  65480. /**
  65481. * Occurs when the file being loaded is a .3dl LUT file.
  65482. */
  65483. private load3dlTexture;
  65484. /**
  65485. * Starts the loading process of the texture.
  65486. */
  65487. private loadTexture;
  65488. /**
  65489. * Clones the color gradind texture.
  65490. */
  65491. clone(): ColorGradingTexture;
  65492. /**
  65493. * Called during delayed load for textures.
  65494. */
  65495. delayLoad(): void;
  65496. /**
  65497. * Parses a color grading texture serialized by Babylon.
  65498. * @param parsedTexture The texture information being parsedTexture
  65499. * @param scene The scene to load the texture in
  65500. * @param rootUrl The root url of the data assets to load
  65501. * @return A color gradind texture
  65502. */
  65503. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65504. /**
  65505. * Serializes the LUT texture to json format.
  65506. */
  65507. serialize(): any;
  65508. }
  65509. }
  65510. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  65511. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65512. import { Scene } from "babylonjs/scene";
  65513. import { Nullable } from "babylonjs/types";
  65514. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65515. /**
  65516. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65517. */
  65518. export class EquiRectangularCubeTexture extends BaseTexture {
  65519. /** The six faces of the cube. */
  65520. private static _FacesMapping;
  65521. private _noMipmap;
  65522. private _onLoad;
  65523. private _onError;
  65524. /** The size of the cubemap. */
  65525. private _size;
  65526. /** The buffer of the image. */
  65527. private _buffer;
  65528. /** The width of the input image. */
  65529. private _width;
  65530. /** The height of the input image. */
  65531. private _height;
  65532. /** The URL to the image. */
  65533. url: string;
  65534. /**
  65535. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65536. * @param url The location of the image
  65537. * @param scene The scene the texture will be used in
  65538. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65539. * @param noMipmap Forces to not generate the mipmap if true
  65540. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65541. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65542. * @param onLoad — defines a callback called when texture is loaded
  65543. * @param onError — defines a callback called if there is an error
  65544. */
  65545. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65546. /**
  65547. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65548. */
  65549. private loadImage;
  65550. /**
  65551. * Convert the image buffer into a cubemap and create a CubeTexture.
  65552. */
  65553. private loadTexture;
  65554. /**
  65555. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65556. * @param buffer The ArrayBuffer that should be converted.
  65557. * @returns The buffer as Float32Array.
  65558. */
  65559. private getFloat32ArrayFromArrayBuffer;
  65560. /**
  65561. * Get the current class name of the texture useful for serialization or dynamic coding.
  65562. * @returns "EquiRectangularCubeTexture"
  65563. */
  65564. getClassName(): string;
  65565. /**
  65566. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65567. * @returns A clone of the current EquiRectangularCubeTexture.
  65568. */
  65569. clone(): EquiRectangularCubeTexture;
  65570. }
  65571. }
  65572. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  65573. import { Nullable } from "babylonjs/types";
  65574. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65575. import { Matrix } from "babylonjs/Maths/math.vector";
  65576. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  65577. import "babylonjs/Engines/Extensions/engine.videoTexture";
  65578. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65579. import { Scene } from "babylonjs/scene";
  65580. /**
  65581. * Defines the options related to the creation of an HtmlElementTexture
  65582. */
  65583. export interface IHtmlElementTextureOptions {
  65584. /**
  65585. * Defines wether mip maps should be created or not.
  65586. */
  65587. generateMipMaps?: boolean;
  65588. /**
  65589. * Defines the sampling mode of the texture.
  65590. */
  65591. samplingMode?: number;
  65592. /**
  65593. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65594. */
  65595. engine: Nullable<ThinEngine>;
  65596. /**
  65597. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65598. */
  65599. scene: Nullable<Scene>;
  65600. }
  65601. /**
  65602. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65603. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65604. * is automatically managed.
  65605. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65606. * in your application.
  65607. *
  65608. * As the update is not automatic, you need to call them manually.
  65609. */
  65610. export class HtmlElementTexture extends BaseTexture {
  65611. /**
  65612. * The texture URL.
  65613. */
  65614. element: HTMLVideoElement | HTMLCanvasElement;
  65615. private static readonly DefaultOptions;
  65616. private _textureMatrix;
  65617. private _isVideo;
  65618. private _generateMipMaps;
  65619. private _samplingMode;
  65620. /**
  65621. * Instantiates a HtmlElementTexture from the following parameters.
  65622. *
  65623. * @param name Defines the name of the texture
  65624. * @param element Defines the video or canvas the texture is filled with
  65625. * @param options Defines the other none mandatory texture creation options
  65626. */
  65627. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65628. private _createInternalTexture;
  65629. /**
  65630. * Returns the texture matrix used in most of the material.
  65631. */
  65632. getTextureMatrix(): Matrix;
  65633. /**
  65634. * Updates the content of the texture.
  65635. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65636. */
  65637. update(invertY?: Nullable<boolean>): void;
  65638. }
  65639. }
  65640. declare module "babylonjs/Misc/tga" {
  65641. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65642. /**
  65643. * Based on jsTGALoader - Javascript loader for TGA file
  65644. * By Vincent Thibault
  65645. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65646. */
  65647. export class TGATools {
  65648. private static _TYPE_INDEXED;
  65649. private static _TYPE_RGB;
  65650. private static _TYPE_GREY;
  65651. private static _TYPE_RLE_INDEXED;
  65652. private static _TYPE_RLE_RGB;
  65653. private static _TYPE_RLE_GREY;
  65654. private static _ORIGIN_MASK;
  65655. private static _ORIGIN_SHIFT;
  65656. private static _ORIGIN_BL;
  65657. private static _ORIGIN_BR;
  65658. private static _ORIGIN_UL;
  65659. private static _ORIGIN_UR;
  65660. /**
  65661. * Gets the header of a TGA file
  65662. * @param data defines the TGA data
  65663. * @returns the header
  65664. */
  65665. static GetTGAHeader(data: Uint8Array): any;
  65666. /**
  65667. * Uploads TGA content to a Babylon Texture
  65668. * @hidden
  65669. */
  65670. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65671. /** @hidden */
  65672. 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;
  65673. /** @hidden */
  65674. 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;
  65675. /** @hidden */
  65676. 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;
  65677. /** @hidden */
  65678. 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;
  65679. /** @hidden */
  65680. 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;
  65681. /** @hidden */
  65682. 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;
  65683. }
  65684. }
  65685. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  65686. import { Nullable } from "babylonjs/types";
  65687. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65688. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65689. /**
  65690. * Implementation of the TGA Texture Loader.
  65691. * @hidden
  65692. */
  65693. export class _TGATextureLoader implements IInternalTextureLoader {
  65694. /**
  65695. * Defines wether the loader supports cascade loading the different faces.
  65696. */
  65697. readonly supportCascades: boolean;
  65698. /**
  65699. * This returns if the loader support the current file information.
  65700. * @param extension defines the file extension of the file being loaded
  65701. * @returns true if the loader can load the specified file
  65702. */
  65703. canLoad(extension: string): boolean;
  65704. /**
  65705. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65706. * @param data contains the texture data
  65707. * @param texture defines the BabylonJS internal texture
  65708. * @param createPolynomials will be true if polynomials have been requested
  65709. * @param onLoad defines the callback to trigger once the texture is ready
  65710. * @param onError defines the callback to trigger in case of error
  65711. */
  65712. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65713. /**
  65714. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65715. * @param data contains the texture data
  65716. * @param texture defines the BabylonJS internal texture
  65717. * @param callback defines the method to call once ready to upload
  65718. */
  65719. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65720. }
  65721. }
  65722. declare module "babylonjs/Misc/basis" {
  65723. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65724. /**
  65725. * Info about the .basis files
  65726. */
  65727. class BasisFileInfo {
  65728. /**
  65729. * If the file has alpha
  65730. */
  65731. hasAlpha: boolean;
  65732. /**
  65733. * Info about each image of the basis file
  65734. */
  65735. images: Array<{
  65736. levels: Array<{
  65737. width: number;
  65738. height: number;
  65739. transcodedPixels: ArrayBufferView;
  65740. }>;
  65741. }>;
  65742. }
  65743. /**
  65744. * Result of transcoding a basis file
  65745. */
  65746. class TranscodeResult {
  65747. /**
  65748. * Info about the .basis file
  65749. */
  65750. fileInfo: BasisFileInfo;
  65751. /**
  65752. * Format to use when loading the file
  65753. */
  65754. format: number;
  65755. }
  65756. /**
  65757. * Configuration options for the Basis transcoder
  65758. */
  65759. export class BasisTranscodeConfiguration {
  65760. /**
  65761. * Supported compression formats used to determine the supported output format of the transcoder
  65762. */
  65763. supportedCompressionFormats?: {
  65764. /**
  65765. * etc1 compression format
  65766. */
  65767. etc1?: boolean;
  65768. /**
  65769. * s3tc compression format
  65770. */
  65771. s3tc?: boolean;
  65772. /**
  65773. * pvrtc compression format
  65774. */
  65775. pvrtc?: boolean;
  65776. /**
  65777. * etc2 compression format
  65778. */
  65779. etc2?: boolean;
  65780. };
  65781. /**
  65782. * If mipmap levels should be loaded for transcoded images (Default: true)
  65783. */
  65784. loadMipmapLevels?: boolean;
  65785. /**
  65786. * Index of a single image to load (Default: all images)
  65787. */
  65788. loadSingleImage?: number;
  65789. }
  65790. /**
  65791. * Used to load .Basis files
  65792. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65793. */
  65794. export class BasisTools {
  65795. private static _IgnoreSupportedFormats;
  65796. /**
  65797. * URL to use when loading the basis transcoder
  65798. */
  65799. static JSModuleURL: string;
  65800. /**
  65801. * URL to use when loading the wasm module for the transcoder
  65802. */
  65803. static WasmModuleURL: string;
  65804. /**
  65805. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65806. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65807. * @returns internal format corresponding to the Basis format
  65808. */
  65809. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65810. private static _WorkerPromise;
  65811. private static _Worker;
  65812. private static _actionId;
  65813. private static _CreateWorkerAsync;
  65814. /**
  65815. * Transcodes a loaded image file to compressed pixel data
  65816. * @param data image data to transcode
  65817. * @param config configuration options for the transcoding
  65818. * @returns a promise resulting in the transcoded image
  65819. */
  65820. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  65821. /**
  65822. * Loads a texture from the transcode result
  65823. * @param texture texture load to
  65824. * @param transcodeResult the result of transcoding the basis file to load from
  65825. */
  65826. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  65827. }
  65828. }
  65829. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  65830. import { Nullable } from "babylonjs/types";
  65831. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65832. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65833. /**
  65834. * Loader for .basis file format
  65835. */
  65836. export class _BasisTextureLoader implements IInternalTextureLoader {
  65837. /**
  65838. * Defines whether the loader supports cascade loading the different faces.
  65839. */
  65840. readonly supportCascades: boolean;
  65841. /**
  65842. * This returns if the loader support the current file information.
  65843. * @param extension defines the file extension of the file being loaded
  65844. * @returns true if the loader can load the specified file
  65845. */
  65846. canLoad(extension: string): boolean;
  65847. /**
  65848. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65849. * @param data contains the texture data
  65850. * @param texture defines the BabylonJS internal texture
  65851. * @param createPolynomials will be true if polynomials have been requested
  65852. * @param onLoad defines the callback to trigger once the texture is ready
  65853. * @param onError defines the callback to trigger in case of error
  65854. */
  65855. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65856. /**
  65857. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65858. * @param data contains the texture data
  65859. * @param texture defines the BabylonJS internal texture
  65860. * @param callback defines the method to call once ready to upload
  65861. */
  65862. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65863. }
  65864. }
  65865. declare module "babylonjs/Materials/Textures/Loaders/index" {
  65866. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65867. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65868. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65869. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  65870. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  65871. }
  65872. declare module "babylonjs/Materials/Textures/Packer/frame" {
  65873. import { Vector2 } from "babylonjs/Maths/math.vector";
  65874. /**
  65875. * Defines the basic options interface of a TexturePacker Frame
  65876. */
  65877. export interface ITexturePackerFrame {
  65878. /**
  65879. * The frame ID
  65880. */
  65881. id: number;
  65882. /**
  65883. * The frames Scale
  65884. */
  65885. scale: Vector2;
  65886. /**
  65887. * The Frames offset
  65888. */
  65889. offset: Vector2;
  65890. }
  65891. /**
  65892. * This is a support class for frame Data on texture packer sets.
  65893. */
  65894. export class TexturePackerFrame implements ITexturePackerFrame {
  65895. /**
  65896. * The frame ID
  65897. */
  65898. id: number;
  65899. /**
  65900. * The frames Scale
  65901. */
  65902. scale: Vector2;
  65903. /**
  65904. * The Frames offset
  65905. */
  65906. offset: Vector2;
  65907. /**
  65908. * Initializes a texture package frame.
  65909. * @param id The numerical frame identifier
  65910. * @param scale Scalar Vector2 for UV frame
  65911. * @param offset Vector2 for the frame position in UV units.
  65912. * @returns TexturePackerFrame
  65913. */
  65914. constructor(id: number, scale: Vector2, offset: Vector2);
  65915. }
  65916. }
  65917. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65919. import { Scene } from "babylonjs/scene";
  65920. import { Nullable } from "babylonjs/types";
  65921. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65922. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65923. /**
  65924. * Defines the basic options interface of a TexturePacker
  65925. */
  65926. export interface ITexturePackerOptions {
  65927. /**
  65928. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65929. */
  65930. map?: string[];
  65931. /**
  65932. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65933. */
  65934. uvsIn?: string;
  65935. /**
  65936. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65937. */
  65938. uvsOut?: string;
  65939. /**
  65940. * number representing the layout style. Defaults to LAYOUT_STRIP
  65941. */
  65942. layout?: number;
  65943. /**
  65944. * number of columns if using custom column count layout(2). This defaults to 4.
  65945. */
  65946. colnum?: number;
  65947. /**
  65948. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65949. */
  65950. updateInputMeshes?: boolean;
  65951. /**
  65952. * boolean flag to dispose all the source textures. Defaults to true.
  65953. */
  65954. disposeSources?: boolean;
  65955. /**
  65956. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65957. */
  65958. fillBlanks?: boolean;
  65959. /**
  65960. * string value representing the context fill style color. Defaults to 'black'.
  65961. */
  65962. customFillColor?: string;
  65963. /**
  65964. * Width and Height Value of each Frame in the TexturePacker Sets
  65965. */
  65966. frameSize?: number;
  65967. /**
  65968. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65969. */
  65970. paddingRatio?: number;
  65971. /**
  65972. * Number that declares the fill method for the padding gutter.
  65973. */
  65974. paddingMode?: number;
  65975. /**
  65976. * If in SUBUV_COLOR padding mode what color to use.
  65977. */
  65978. paddingColor?: Color3 | Color4;
  65979. }
  65980. /**
  65981. * Defines the basic interface of a TexturePacker JSON File
  65982. */
  65983. export interface ITexturePackerJSON {
  65984. /**
  65985. * The frame ID
  65986. */
  65987. name: string;
  65988. /**
  65989. * The base64 channel data
  65990. */
  65991. sets: any;
  65992. /**
  65993. * The options of the Packer
  65994. */
  65995. options: ITexturePackerOptions;
  65996. /**
  65997. * The frame data of the Packer
  65998. */
  65999. frames: Array<number>;
  66000. }
  66001. /**
  66002. * This is a support class that generates a series of packed texture sets.
  66003. * @see https://doc.babylonjs.com/babylon101/materials
  66004. */
  66005. export class TexturePacker {
  66006. /** Packer Layout Constant 0 */
  66007. static readonly LAYOUT_STRIP: number;
  66008. /** Packer Layout Constant 1 */
  66009. static readonly LAYOUT_POWER2: number;
  66010. /** Packer Layout Constant 2 */
  66011. static readonly LAYOUT_COLNUM: number;
  66012. /** Packer Layout Constant 0 */
  66013. static readonly SUBUV_WRAP: number;
  66014. /** Packer Layout Constant 1 */
  66015. static readonly SUBUV_EXTEND: number;
  66016. /** Packer Layout Constant 2 */
  66017. static readonly SUBUV_COLOR: number;
  66018. /** The Name of the Texture Package */
  66019. name: string;
  66020. /** The scene scope of the TexturePacker */
  66021. scene: Scene;
  66022. /** The Meshes to target */
  66023. meshes: AbstractMesh[];
  66024. /** Arguments passed with the Constructor */
  66025. options: ITexturePackerOptions;
  66026. /** The promise that is started upon initialization */
  66027. promise: Nullable<Promise<TexturePacker | string>>;
  66028. /** The Container object for the channel sets that are generated */
  66029. sets: object;
  66030. /** The Container array for the frames that are generated */
  66031. frames: TexturePackerFrame[];
  66032. /** The expected number of textures the system is parsing. */
  66033. private _expecting;
  66034. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66035. private _paddingValue;
  66036. /**
  66037. * Initializes a texture package series from an array of meshes or a single mesh.
  66038. * @param name The name of the package
  66039. * @param meshes The target meshes to compose the package from
  66040. * @param options The arguments that texture packer should follow while building.
  66041. * @param scene The scene which the textures are scoped to.
  66042. * @returns TexturePacker
  66043. */
  66044. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66045. /**
  66046. * Starts the package process
  66047. * @param resolve The promises resolution function
  66048. * @returns TexturePacker
  66049. */
  66050. private _createFrames;
  66051. /**
  66052. * Calculates the Size of the Channel Sets
  66053. * @returns Vector2
  66054. */
  66055. private _calculateSize;
  66056. /**
  66057. * Calculates the UV data for the frames.
  66058. * @param baseSize the base frameSize
  66059. * @param padding the base frame padding
  66060. * @param dtSize size of the Dynamic Texture for that channel
  66061. * @param dtUnits is 1/dtSize
  66062. * @param update flag to update the input meshes
  66063. */
  66064. private _calculateMeshUVFrames;
  66065. /**
  66066. * Calculates the frames Offset.
  66067. * @param index of the frame
  66068. * @returns Vector2
  66069. */
  66070. private _getFrameOffset;
  66071. /**
  66072. * Updates a Mesh to the frame data
  66073. * @param mesh that is the target
  66074. * @param frameID or the frame index
  66075. */
  66076. private _updateMeshUV;
  66077. /**
  66078. * Updates a Meshes materials to use the texture packer channels
  66079. * @param m is the mesh to target
  66080. * @param force all channels on the packer to be set.
  66081. */
  66082. private _updateTextureReferences;
  66083. /**
  66084. * Public method to set a Mesh to a frame
  66085. * @param m that is the target
  66086. * @param frameID or the frame index
  66087. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66088. */
  66089. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66090. /**
  66091. * Starts the async promise to compile the texture packer.
  66092. * @returns Promise<void>
  66093. */
  66094. processAsync(): Promise<void>;
  66095. /**
  66096. * Disposes all textures associated with this packer
  66097. */
  66098. dispose(): void;
  66099. /**
  66100. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66101. * @param imageType is the image type to use.
  66102. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66103. */
  66104. download(imageType?: string, quality?: number): void;
  66105. /**
  66106. * Public method to load a texturePacker JSON file.
  66107. * @param data of the JSON file in string format.
  66108. */
  66109. updateFromJSON(data: string): void;
  66110. }
  66111. }
  66112. declare module "babylonjs/Materials/Textures/Packer/index" {
  66113. export * from "babylonjs/Materials/Textures/Packer/packer";
  66114. export * from "babylonjs/Materials/Textures/Packer/frame";
  66115. }
  66116. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  66117. import { Scene } from "babylonjs/scene";
  66118. import { Texture } from "babylonjs/Materials/Textures/texture";
  66119. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66120. /**
  66121. * 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.
  66122. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66123. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66124. */
  66125. export class CustomProceduralTexture extends ProceduralTexture {
  66126. private _animate;
  66127. private _time;
  66128. private _config;
  66129. private _texturePath;
  66130. /**
  66131. * Instantiates a new Custom Procedural Texture.
  66132. * 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.
  66133. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66134. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66135. * @param name Define the name of the texture
  66136. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66137. * @param size Define the size of the texture to create
  66138. * @param scene Define the scene the texture belongs to
  66139. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66140. * @param generateMipMaps Define if the texture should creates mip maps or not
  66141. */
  66142. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66143. private _loadJson;
  66144. /**
  66145. * Is the texture ready to be used ? (rendered at least once)
  66146. * @returns true if ready, otherwise, false.
  66147. */
  66148. isReady(): boolean;
  66149. /**
  66150. * Render the texture to its associated render target.
  66151. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66152. */
  66153. render(useCameraPostProcess?: boolean): void;
  66154. /**
  66155. * Update the list of dependant textures samplers in the shader.
  66156. */
  66157. updateTextures(): void;
  66158. /**
  66159. * Update the uniform values of the procedural texture in the shader.
  66160. */
  66161. updateShaderUniforms(): void;
  66162. /**
  66163. * Define if the texture animates or not.
  66164. */
  66165. get animate(): boolean;
  66166. set animate(value: boolean);
  66167. }
  66168. }
  66169. declare module "babylonjs/Shaders/noise.fragment" {
  66170. /** @hidden */
  66171. export var noisePixelShader: {
  66172. name: string;
  66173. shader: string;
  66174. };
  66175. }
  66176. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  66177. import { Nullable } from "babylonjs/types";
  66178. import { Scene } from "babylonjs/scene";
  66179. import { Texture } from "babylonjs/Materials/Textures/texture";
  66180. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66181. import "babylonjs/Shaders/noise.fragment";
  66182. /**
  66183. * Class used to generate noise procedural textures
  66184. */
  66185. export class NoiseProceduralTexture extends ProceduralTexture {
  66186. /** Gets or sets the start time (default is 0) */
  66187. time: number;
  66188. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66189. brightness: number;
  66190. /** Defines the number of octaves to process */
  66191. octaves: number;
  66192. /** Defines the level of persistence (0.8 by default) */
  66193. persistence: number;
  66194. /** Gets or sets animation speed factor (default is 1) */
  66195. animationSpeedFactor: number;
  66196. /**
  66197. * Creates a new NoiseProceduralTexture
  66198. * @param name defines the name fo the texture
  66199. * @param size defines the size of the texture (default is 256)
  66200. * @param scene defines the hosting scene
  66201. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66202. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66203. */
  66204. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66205. private _updateShaderUniforms;
  66206. protected _getDefines(): string;
  66207. /** Generate the current state of the procedural texture */
  66208. render(useCameraPostProcess?: boolean): void;
  66209. /**
  66210. * Serializes this noise procedural texture
  66211. * @returns a serialized noise procedural texture object
  66212. */
  66213. serialize(): any;
  66214. /**
  66215. * Clone the texture.
  66216. * @returns the cloned texture
  66217. */
  66218. clone(): NoiseProceduralTexture;
  66219. /**
  66220. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66221. * @param parsedTexture defines parsed texture data
  66222. * @param scene defines the current scene
  66223. * @param rootUrl defines the root URL containing noise procedural texture information
  66224. * @returns a parsed NoiseProceduralTexture
  66225. */
  66226. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66227. }
  66228. }
  66229. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  66230. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  66231. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  66232. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66233. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  66234. }
  66235. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  66236. import { Nullable } from "babylonjs/types";
  66237. import { Scene } from "babylonjs/scene";
  66238. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  66239. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66240. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66241. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66242. /**
  66243. * Raw cube texture where the raw buffers are passed in
  66244. */
  66245. export class RawCubeTexture extends CubeTexture {
  66246. /**
  66247. * Creates a cube texture where the raw buffers are passed in.
  66248. * @param scene defines the scene the texture is attached to
  66249. * @param data defines the array of data to use to create each face
  66250. * @param size defines the size of the textures
  66251. * @param format defines the format of the data
  66252. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66253. * @param generateMipMaps defines if the engine should generate the mip levels
  66254. * @param invertY defines if data must be stored with Y axis inverted
  66255. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66256. * @param compression defines the compression used (null by default)
  66257. */
  66258. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66259. /**
  66260. * Updates the raw cube texture.
  66261. * @param data defines the data to store
  66262. * @param format defines the data format
  66263. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66264. * @param invertY defines if data must be stored with Y axis inverted
  66265. * @param compression defines the compression used (null by default)
  66266. * @param level defines which level of the texture to update
  66267. */
  66268. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66269. /**
  66270. * Updates a raw cube texture with RGBD encoded data.
  66271. * @param data defines the array of data [mipmap][face] to use to create each face
  66272. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66273. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66274. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66275. * @returns a promsie that resolves when the operation is complete
  66276. */
  66277. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66278. /**
  66279. * Clones the raw cube texture.
  66280. * @return a new cube texture
  66281. */
  66282. clone(): CubeTexture;
  66283. /** @hidden */
  66284. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66285. }
  66286. }
  66287. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  66288. import { Scene } from "babylonjs/scene";
  66289. import { Texture } from "babylonjs/Materials/Textures/texture";
  66290. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66291. /**
  66292. * Class used to store 2D array textures containing user data
  66293. */
  66294. export class RawTexture2DArray extends Texture {
  66295. /** Gets or sets the texture format to use */
  66296. format: number;
  66297. /**
  66298. * Create a new RawTexture2DArray
  66299. * @param data defines the data of the texture
  66300. * @param width defines the width of the texture
  66301. * @param height defines the height of the texture
  66302. * @param depth defines the number of layers of the texture
  66303. * @param format defines the texture format to use
  66304. * @param scene defines the hosting scene
  66305. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66306. * @param invertY defines if texture must be stored with Y axis inverted
  66307. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66308. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66309. */
  66310. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66311. /** Gets or sets the texture format to use */
  66312. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66313. /**
  66314. * Update the texture with new data
  66315. * @param data defines the data to store in the texture
  66316. */
  66317. update(data: ArrayBufferView): void;
  66318. }
  66319. }
  66320. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  66321. import { Scene } from "babylonjs/scene";
  66322. import { Texture } from "babylonjs/Materials/Textures/texture";
  66323. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66324. /**
  66325. * Class used to store 3D textures containing user data
  66326. */
  66327. export class RawTexture3D extends Texture {
  66328. /** Gets or sets the texture format to use */
  66329. format: number;
  66330. /**
  66331. * Create a new RawTexture3D
  66332. * @param data defines the data of the texture
  66333. * @param width defines the width of the texture
  66334. * @param height defines the height of the texture
  66335. * @param depth defines the depth of the texture
  66336. * @param format defines the texture format to use
  66337. * @param scene defines the hosting scene
  66338. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66339. * @param invertY defines if texture must be stored with Y axis inverted
  66340. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66341. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66342. */
  66343. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66344. /** Gets or sets the texture format to use */
  66345. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66346. /**
  66347. * Update the texture with new data
  66348. * @param data defines the data to store in the texture
  66349. */
  66350. update(data: ArrayBufferView): void;
  66351. }
  66352. }
  66353. declare module "babylonjs/Materials/Textures/refractionTexture" {
  66354. import { Scene } from "babylonjs/scene";
  66355. import { Plane } from "babylonjs/Maths/math.plane";
  66356. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66357. /**
  66358. * Creates a refraction texture used by refraction channel of the standard material.
  66359. * It is like a mirror but to see through a material.
  66360. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66361. */
  66362. export class RefractionTexture extends RenderTargetTexture {
  66363. /**
  66364. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66365. * 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.
  66366. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66367. */
  66368. refractionPlane: Plane;
  66369. /**
  66370. * Define how deep under the surface we should see.
  66371. */
  66372. depth: number;
  66373. /**
  66374. * Creates a refraction texture used by refraction channel of the standard material.
  66375. * It is like a mirror but to see through a material.
  66376. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66377. * @param name Define the texture name
  66378. * @param size Define the size of the underlying texture
  66379. * @param scene Define the scene the refraction belongs to
  66380. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66381. */
  66382. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66383. /**
  66384. * Clone the refraction texture.
  66385. * @returns the cloned texture
  66386. */
  66387. clone(): RefractionTexture;
  66388. /**
  66389. * Serialize the texture to a JSON representation you could use in Parse later on
  66390. * @returns the serialized JSON representation
  66391. */
  66392. serialize(): any;
  66393. }
  66394. }
  66395. declare module "babylonjs/Materials/Textures/index" {
  66396. export * from "babylonjs/Materials/Textures/baseTexture";
  66397. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  66398. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  66399. export * from "babylonjs/Materials/Textures/cubeTexture";
  66400. export * from "babylonjs/Materials/Textures/dynamicTexture";
  66401. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66402. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  66403. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  66404. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  66405. export * from "babylonjs/Materials/Textures/internalTexture";
  66406. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  66407. export * from "babylonjs/Materials/Textures/Loaders/index";
  66408. export * from "babylonjs/Materials/Textures/mirrorTexture";
  66409. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  66410. export * from "babylonjs/Materials/Textures/Packer/index";
  66411. export * from "babylonjs/Materials/Textures/Procedurals/index";
  66412. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  66413. export * from "babylonjs/Materials/Textures/rawTexture";
  66414. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  66415. export * from "babylonjs/Materials/Textures/rawTexture3D";
  66416. export * from "babylonjs/Materials/Textures/refractionTexture";
  66417. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  66418. export * from "babylonjs/Materials/Textures/texture";
  66419. export * from "babylonjs/Materials/Textures/videoTexture";
  66420. }
  66421. declare module "babylonjs/Materials/Node/Enums/index" {
  66422. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  66423. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  66424. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  66425. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  66426. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  66427. }
  66428. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  66429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66432. import { Mesh } from "babylonjs/Meshes/mesh";
  66433. import { Effect } from "babylonjs/Materials/effect";
  66434. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66435. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66436. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66437. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66438. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66439. /**
  66440. * Block used to add support for vertex skinning (bones)
  66441. */
  66442. export class BonesBlock extends NodeMaterialBlock {
  66443. /**
  66444. * Creates a new BonesBlock
  66445. * @param name defines the block name
  66446. */
  66447. constructor(name: string);
  66448. /**
  66449. * Initialize the block and prepare the context for build
  66450. * @param state defines the state that will be used for the build
  66451. */
  66452. initialize(state: NodeMaterialBuildState): void;
  66453. /**
  66454. * Gets the current class name
  66455. * @returns the class name
  66456. */
  66457. getClassName(): string;
  66458. /**
  66459. * Gets the matrix indices input component
  66460. */
  66461. get matricesIndices(): NodeMaterialConnectionPoint;
  66462. /**
  66463. * Gets the matrix weights input component
  66464. */
  66465. get matricesWeights(): NodeMaterialConnectionPoint;
  66466. /**
  66467. * Gets the extra matrix indices input component
  66468. */
  66469. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66470. /**
  66471. * Gets the extra matrix weights input component
  66472. */
  66473. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66474. /**
  66475. * Gets the world input component
  66476. */
  66477. get world(): NodeMaterialConnectionPoint;
  66478. /**
  66479. * Gets the output component
  66480. */
  66481. get output(): NodeMaterialConnectionPoint;
  66482. autoConfigure(material: NodeMaterial): void;
  66483. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66484. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66485. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66486. protected _buildBlock(state: NodeMaterialBuildState): this;
  66487. }
  66488. }
  66489. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  66490. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66491. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66492. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66494. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66495. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66496. /**
  66497. * Block used to add support for instances
  66498. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66499. */
  66500. export class InstancesBlock extends NodeMaterialBlock {
  66501. /**
  66502. * Creates a new InstancesBlock
  66503. * @param name defines the block name
  66504. */
  66505. constructor(name: string);
  66506. /**
  66507. * Gets the current class name
  66508. * @returns the class name
  66509. */
  66510. getClassName(): string;
  66511. /**
  66512. * Gets the first world row input component
  66513. */
  66514. get world0(): NodeMaterialConnectionPoint;
  66515. /**
  66516. * Gets the second world row input component
  66517. */
  66518. get world1(): NodeMaterialConnectionPoint;
  66519. /**
  66520. * Gets the third world row input component
  66521. */
  66522. get world2(): NodeMaterialConnectionPoint;
  66523. /**
  66524. * Gets the forth world row input component
  66525. */
  66526. get world3(): NodeMaterialConnectionPoint;
  66527. /**
  66528. * Gets the world input component
  66529. */
  66530. get world(): NodeMaterialConnectionPoint;
  66531. /**
  66532. * Gets the output component
  66533. */
  66534. get output(): NodeMaterialConnectionPoint;
  66535. /**
  66536. * Gets the isntanceID component
  66537. */
  66538. get instanceID(): NodeMaterialConnectionPoint;
  66539. autoConfigure(material: NodeMaterial): void;
  66540. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66541. protected _buildBlock(state: NodeMaterialBuildState): this;
  66542. }
  66543. }
  66544. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  66545. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66546. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66547. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66549. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66550. import { Effect } from "babylonjs/Materials/effect";
  66551. import { Mesh } from "babylonjs/Meshes/mesh";
  66552. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66553. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66554. /**
  66555. * Block used to add morph targets support to vertex shader
  66556. */
  66557. export class MorphTargetsBlock extends NodeMaterialBlock {
  66558. private _repeatableContentAnchor;
  66559. /**
  66560. * Create a new MorphTargetsBlock
  66561. * @param name defines the block name
  66562. */
  66563. constructor(name: string);
  66564. /**
  66565. * Gets the current class name
  66566. * @returns the class name
  66567. */
  66568. getClassName(): string;
  66569. /**
  66570. * Gets the position input component
  66571. */
  66572. get position(): NodeMaterialConnectionPoint;
  66573. /**
  66574. * Gets the normal input component
  66575. */
  66576. get normal(): NodeMaterialConnectionPoint;
  66577. /**
  66578. * Gets the tangent input component
  66579. */
  66580. get tangent(): NodeMaterialConnectionPoint;
  66581. /**
  66582. * Gets the tangent input component
  66583. */
  66584. get uv(): NodeMaterialConnectionPoint;
  66585. /**
  66586. * Gets the position output component
  66587. */
  66588. get positionOutput(): NodeMaterialConnectionPoint;
  66589. /**
  66590. * Gets the normal output component
  66591. */
  66592. get normalOutput(): NodeMaterialConnectionPoint;
  66593. /**
  66594. * Gets the tangent output component
  66595. */
  66596. get tangentOutput(): NodeMaterialConnectionPoint;
  66597. /**
  66598. * Gets the tangent output component
  66599. */
  66600. get uvOutput(): NodeMaterialConnectionPoint;
  66601. initialize(state: NodeMaterialBuildState): void;
  66602. autoConfigure(material: NodeMaterial): void;
  66603. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66604. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66605. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66606. protected _buildBlock(state: NodeMaterialBuildState): this;
  66607. }
  66608. }
  66609. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  66610. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66611. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66612. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66613. import { Nullable } from "babylonjs/types";
  66614. import { Scene } from "babylonjs/scene";
  66615. import { Effect } from "babylonjs/Materials/effect";
  66616. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66617. import { Mesh } from "babylonjs/Meshes/mesh";
  66618. import { Light } from "babylonjs/Lights/light";
  66619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66620. /**
  66621. * Block used to get data information from a light
  66622. */
  66623. export class LightInformationBlock extends NodeMaterialBlock {
  66624. private _lightDataUniformName;
  66625. private _lightColorUniformName;
  66626. private _lightTypeDefineName;
  66627. /**
  66628. * Gets or sets the light associated with this block
  66629. */
  66630. light: Nullable<Light>;
  66631. /**
  66632. * Creates a new LightInformationBlock
  66633. * @param name defines the block name
  66634. */
  66635. constructor(name: string);
  66636. /**
  66637. * Gets the current class name
  66638. * @returns the class name
  66639. */
  66640. getClassName(): string;
  66641. /**
  66642. * Gets the world position input component
  66643. */
  66644. get worldPosition(): NodeMaterialConnectionPoint;
  66645. /**
  66646. * Gets the direction output component
  66647. */
  66648. get direction(): NodeMaterialConnectionPoint;
  66649. /**
  66650. * Gets the direction output component
  66651. */
  66652. get color(): NodeMaterialConnectionPoint;
  66653. /**
  66654. * Gets the direction output component
  66655. */
  66656. get intensity(): NodeMaterialConnectionPoint;
  66657. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66658. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66659. protected _buildBlock(state: NodeMaterialBuildState): this;
  66660. serialize(): any;
  66661. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66662. }
  66663. }
  66664. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  66665. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  66666. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  66667. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  66668. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  66669. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  66670. }
  66671. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  66672. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66673. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66674. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66676. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66677. import { Effect } from "babylonjs/Materials/effect";
  66678. import { Mesh } from "babylonjs/Meshes/mesh";
  66679. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66680. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66681. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66682. /**
  66683. * Block used to add image processing support to fragment shader
  66684. */
  66685. export class ImageProcessingBlock extends NodeMaterialBlock {
  66686. /**
  66687. * Create a new ImageProcessingBlock
  66688. * @param name defines the block name
  66689. */
  66690. constructor(name: string);
  66691. /**
  66692. * Gets the current class name
  66693. * @returns the class name
  66694. */
  66695. getClassName(): string;
  66696. /**
  66697. * Gets the color input component
  66698. */
  66699. get color(): NodeMaterialConnectionPoint;
  66700. /**
  66701. * Gets the output component
  66702. */
  66703. get output(): NodeMaterialConnectionPoint;
  66704. /**
  66705. * Initialize the block and prepare the context for build
  66706. * @param state defines the state that will be used for the build
  66707. */
  66708. initialize(state: NodeMaterialBuildState): void;
  66709. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66710. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66711. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66712. protected _buildBlock(state: NodeMaterialBuildState): this;
  66713. }
  66714. }
  66715. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  66716. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66717. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66718. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66719. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66721. import { Effect } from "babylonjs/Materials/effect";
  66722. import { Mesh } from "babylonjs/Meshes/mesh";
  66723. import { Scene } from "babylonjs/scene";
  66724. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  66725. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  66726. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  66727. /**
  66728. * Block used to pertub normals based on a normal map
  66729. */
  66730. export class PerturbNormalBlock extends NodeMaterialBlock {
  66731. private _tangentSpaceParameterName;
  66732. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66733. invertX: boolean;
  66734. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66735. invertY: boolean;
  66736. /**
  66737. * Create a new PerturbNormalBlock
  66738. * @param name defines the block name
  66739. */
  66740. constructor(name: string);
  66741. /**
  66742. * Gets the current class name
  66743. * @returns the class name
  66744. */
  66745. getClassName(): string;
  66746. /**
  66747. * Gets the world position input component
  66748. */
  66749. get worldPosition(): NodeMaterialConnectionPoint;
  66750. /**
  66751. * Gets the world normal input component
  66752. */
  66753. get worldNormal(): NodeMaterialConnectionPoint;
  66754. /**
  66755. * Gets the world tangent input component
  66756. */
  66757. get worldTangent(): NodeMaterialConnectionPoint;
  66758. /**
  66759. * Gets the uv input component
  66760. */
  66761. get uv(): NodeMaterialConnectionPoint;
  66762. /**
  66763. * Gets the normal map color input component
  66764. */
  66765. get normalMapColor(): NodeMaterialConnectionPoint;
  66766. /**
  66767. * Gets the strength input component
  66768. */
  66769. get strength(): NodeMaterialConnectionPoint;
  66770. /**
  66771. * Gets the output component
  66772. */
  66773. get output(): NodeMaterialConnectionPoint;
  66774. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66775. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66776. autoConfigure(material: NodeMaterial): void;
  66777. protected _buildBlock(state: NodeMaterialBuildState): this;
  66778. protected _dumpPropertiesCode(): string;
  66779. serialize(): any;
  66780. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66781. }
  66782. }
  66783. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  66784. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66785. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66786. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66787. /**
  66788. * Block used to discard a pixel if a value is smaller than a cutoff
  66789. */
  66790. export class DiscardBlock extends NodeMaterialBlock {
  66791. /**
  66792. * Create a new DiscardBlock
  66793. * @param name defines the block name
  66794. */
  66795. constructor(name: string);
  66796. /**
  66797. * Gets the current class name
  66798. * @returns the class name
  66799. */
  66800. getClassName(): string;
  66801. /**
  66802. * Gets the color input component
  66803. */
  66804. get value(): NodeMaterialConnectionPoint;
  66805. /**
  66806. * Gets the cutoff input component
  66807. */
  66808. get cutoff(): NodeMaterialConnectionPoint;
  66809. protected _buildBlock(state: NodeMaterialBuildState): this;
  66810. }
  66811. }
  66812. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  66813. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66814. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66815. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66816. /**
  66817. * Block used to test if the fragment shader is front facing
  66818. */
  66819. export class FrontFacingBlock extends NodeMaterialBlock {
  66820. /**
  66821. * Creates a new FrontFacingBlock
  66822. * @param name defines the block name
  66823. */
  66824. constructor(name: string);
  66825. /**
  66826. * Gets the current class name
  66827. * @returns the class name
  66828. */
  66829. getClassName(): string;
  66830. /**
  66831. * Gets the output component
  66832. */
  66833. get output(): NodeMaterialConnectionPoint;
  66834. protected _buildBlock(state: NodeMaterialBuildState): this;
  66835. }
  66836. }
  66837. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  66838. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66839. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66840. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66841. /**
  66842. * Block used to get the derivative value on x and y of a given input
  66843. */
  66844. export class DerivativeBlock extends NodeMaterialBlock {
  66845. /**
  66846. * Create a new DerivativeBlock
  66847. * @param name defines the block name
  66848. */
  66849. constructor(name: string);
  66850. /**
  66851. * Gets the current class name
  66852. * @returns the class name
  66853. */
  66854. getClassName(): string;
  66855. /**
  66856. * Gets the input component
  66857. */
  66858. get input(): NodeMaterialConnectionPoint;
  66859. /**
  66860. * Gets the derivative output on x
  66861. */
  66862. get dx(): NodeMaterialConnectionPoint;
  66863. /**
  66864. * Gets the derivative output on y
  66865. */
  66866. get dy(): NodeMaterialConnectionPoint;
  66867. protected _buildBlock(state: NodeMaterialBuildState): this;
  66868. }
  66869. }
  66870. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  66871. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66872. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66873. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66874. /**
  66875. * Block used to make gl_FragCoord available
  66876. */
  66877. export class FragCoordBlock extends NodeMaterialBlock {
  66878. /**
  66879. * Creates a new FragCoordBlock
  66880. * @param name defines the block name
  66881. */
  66882. constructor(name: string);
  66883. /**
  66884. * Gets the current class name
  66885. * @returns the class name
  66886. */
  66887. getClassName(): string;
  66888. /**
  66889. * Gets the xy component
  66890. */
  66891. get xy(): NodeMaterialConnectionPoint;
  66892. /**
  66893. * Gets the xyz component
  66894. */
  66895. get xyz(): NodeMaterialConnectionPoint;
  66896. /**
  66897. * Gets the xyzw component
  66898. */
  66899. get xyzw(): NodeMaterialConnectionPoint;
  66900. /**
  66901. * Gets the x component
  66902. */
  66903. get x(): NodeMaterialConnectionPoint;
  66904. /**
  66905. * Gets the y component
  66906. */
  66907. get y(): NodeMaterialConnectionPoint;
  66908. /**
  66909. * Gets the z component
  66910. */
  66911. get z(): NodeMaterialConnectionPoint;
  66912. /**
  66913. * Gets the w component
  66914. */
  66915. get output(): NodeMaterialConnectionPoint;
  66916. protected writeOutputs(state: NodeMaterialBuildState): string;
  66917. protected _buildBlock(state: NodeMaterialBuildState): this;
  66918. }
  66919. }
  66920. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66924. import { Effect } from "babylonjs/Materials/effect";
  66925. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66926. import { Mesh } from "babylonjs/Meshes/mesh";
  66927. /**
  66928. * Block used to get the screen sizes
  66929. */
  66930. export class ScreenSizeBlock extends NodeMaterialBlock {
  66931. private _varName;
  66932. private _scene;
  66933. /**
  66934. * Creates a new ScreenSizeBlock
  66935. * @param name defines the block name
  66936. */
  66937. constructor(name: string);
  66938. /**
  66939. * Gets the current class name
  66940. * @returns the class name
  66941. */
  66942. getClassName(): string;
  66943. /**
  66944. * Gets the xy component
  66945. */
  66946. get xy(): NodeMaterialConnectionPoint;
  66947. /**
  66948. * Gets the x component
  66949. */
  66950. get x(): NodeMaterialConnectionPoint;
  66951. /**
  66952. * Gets the y component
  66953. */
  66954. get y(): NodeMaterialConnectionPoint;
  66955. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66956. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66957. protected _buildBlock(state: NodeMaterialBuildState): this;
  66958. }
  66959. }
  66960. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66961. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66962. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66963. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66964. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66965. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66966. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66967. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66968. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66969. }
  66970. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66971. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66972. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66973. import { Mesh } from "babylonjs/Meshes/mesh";
  66974. import { Effect } from "babylonjs/Materials/effect";
  66975. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66977. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66978. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66979. /**
  66980. * Block used to add support for scene fog
  66981. */
  66982. export class FogBlock extends NodeMaterialBlock {
  66983. private _fogDistanceName;
  66984. private _fogParameters;
  66985. /**
  66986. * Create a new FogBlock
  66987. * @param name defines the block name
  66988. */
  66989. constructor(name: string);
  66990. /**
  66991. * Gets the current class name
  66992. * @returns the class name
  66993. */
  66994. getClassName(): string;
  66995. /**
  66996. * Gets the world position input component
  66997. */
  66998. get worldPosition(): NodeMaterialConnectionPoint;
  66999. /**
  67000. * Gets the view input component
  67001. */
  67002. get view(): NodeMaterialConnectionPoint;
  67003. /**
  67004. * Gets the color input component
  67005. */
  67006. get input(): NodeMaterialConnectionPoint;
  67007. /**
  67008. * Gets the fog color input component
  67009. */
  67010. get fogColor(): NodeMaterialConnectionPoint;
  67011. /**
  67012. * Gets the output component
  67013. */
  67014. get output(): NodeMaterialConnectionPoint;
  67015. autoConfigure(material: NodeMaterial): void;
  67016. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67017. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67018. protected _buildBlock(state: NodeMaterialBuildState): this;
  67019. }
  67020. }
  67021. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  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 { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67026. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67027. import { Effect } from "babylonjs/Materials/effect";
  67028. import { Mesh } from "babylonjs/Meshes/mesh";
  67029. import { Light } from "babylonjs/Lights/light";
  67030. import { Nullable } from "babylonjs/types";
  67031. import { Scene } from "babylonjs/scene";
  67032. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  67033. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  67034. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  67035. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67036. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  67037. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  67038. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  67039. /**
  67040. * Block used to add light in the fragment shader
  67041. */
  67042. export class LightBlock extends NodeMaterialBlock {
  67043. private _lightId;
  67044. /**
  67045. * Gets or sets the light associated with this block
  67046. */
  67047. light: Nullable<Light>;
  67048. /**
  67049. * Create a new LightBlock
  67050. * @param name defines the block name
  67051. */
  67052. constructor(name: string);
  67053. /**
  67054. * Gets the current class name
  67055. * @returns the class name
  67056. */
  67057. getClassName(): string;
  67058. /**
  67059. * Gets the world position input component
  67060. */
  67061. get worldPosition(): NodeMaterialConnectionPoint;
  67062. /**
  67063. * Gets the world normal input component
  67064. */
  67065. get worldNormal(): NodeMaterialConnectionPoint;
  67066. /**
  67067. * Gets the camera (or eye) position component
  67068. */
  67069. get cameraPosition(): NodeMaterialConnectionPoint;
  67070. /**
  67071. * Gets the glossiness component
  67072. */
  67073. get glossiness(): NodeMaterialConnectionPoint;
  67074. /**
  67075. * Gets the glossinness power component
  67076. */
  67077. get glossPower(): NodeMaterialConnectionPoint;
  67078. /**
  67079. * Gets the diffuse color component
  67080. */
  67081. get diffuseColor(): NodeMaterialConnectionPoint;
  67082. /**
  67083. * Gets the specular color component
  67084. */
  67085. get specularColor(): NodeMaterialConnectionPoint;
  67086. /**
  67087. * Gets the view matrix component
  67088. */
  67089. get view(): NodeMaterialConnectionPoint;
  67090. /**
  67091. * Gets the diffuse output component
  67092. */
  67093. get diffuseOutput(): NodeMaterialConnectionPoint;
  67094. /**
  67095. * Gets the specular output component
  67096. */
  67097. get specularOutput(): NodeMaterialConnectionPoint;
  67098. /**
  67099. * Gets the shadow output component
  67100. */
  67101. get shadow(): NodeMaterialConnectionPoint;
  67102. autoConfigure(material: NodeMaterial): void;
  67103. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67104. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67105. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67106. private _injectVertexCode;
  67107. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67108. serialize(): any;
  67109. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67110. }
  67111. }
  67112. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  67113. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67114. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67115. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67116. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67117. /**
  67118. * Block used to read a reflection texture from a sampler
  67119. */
  67120. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67121. /**
  67122. * Create a new ReflectionTextureBlock
  67123. * @param name defines the block name
  67124. */
  67125. constructor(name: string);
  67126. /**
  67127. * Gets the current class name
  67128. * @returns the class name
  67129. */
  67130. getClassName(): string;
  67131. /**
  67132. * Gets the world position input component
  67133. */
  67134. get position(): NodeMaterialConnectionPoint;
  67135. /**
  67136. * Gets the world position input component
  67137. */
  67138. get worldPosition(): NodeMaterialConnectionPoint;
  67139. /**
  67140. * Gets the world normal input component
  67141. */
  67142. get worldNormal(): NodeMaterialConnectionPoint;
  67143. /**
  67144. * Gets the world input component
  67145. */
  67146. get world(): NodeMaterialConnectionPoint;
  67147. /**
  67148. * Gets the camera (or eye) position component
  67149. */
  67150. get cameraPosition(): NodeMaterialConnectionPoint;
  67151. /**
  67152. * Gets the view input component
  67153. */
  67154. get view(): NodeMaterialConnectionPoint;
  67155. /**
  67156. * Gets the rgb output component
  67157. */
  67158. get rgb(): NodeMaterialConnectionPoint;
  67159. /**
  67160. * Gets the rgba output component
  67161. */
  67162. get rgba(): NodeMaterialConnectionPoint;
  67163. /**
  67164. * Gets the r output component
  67165. */
  67166. get r(): NodeMaterialConnectionPoint;
  67167. /**
  67168. * Gets the g output component
  67169. */
  67170. get g(): NodeMaterialConnectionPoint;
  67171. /**
  67172. * Gets the b output component
  67173. */
  67174. get b(): NodeMaterialConnectionPoint;
  67175. /**
  67176. * Gets the a output component
  67177. */
  67178. get a(): NodeMaterialConnectionPoint;
  67179. autoConfigure(material: NodeMaterial): void;
  67180. protected _buildBlock(state: NodeMaterialBuildState): this;
  67181. }
  67182. }
  67183. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  67184. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  67185. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  67186. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  67187. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  67188. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  67189. }
  67190. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  67191. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  67192. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  67193. }
  67194. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  67195. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67196. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67197. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67198. /**
  67199. * Block used to add 2 vectors
  67200. */
  67201. export class AddBlock extends NodeMaterialBlock {
  67202. /**
  67203. * Creates a new AddBlock
  67204. * @param name defines the block name
  67205. */
  67206. constructor(name: string);
  67207. /**
  67208. * Gets the current class name
  67209. * @returns the class name
  67210. */
  67211. getClassName(): string;
  67212. /**
  67213. * Gets the left operand input component
  67214. */
  67215. get left(): NodeMaterialConnectionPoint;
  67216. /**
  67217. * Gets the right operand input component
  67218. */
  67219. get right(): NodeMaterialConnectionPoint;
  67220. /**
  67221. * Gets the output component
  67222. */
  67223. get output(): NodeMaterialConnectionPoint;
  67224. protected _buildBlock(state: NodeMaterialBuildState): this;
  67225. }
  67226. }
  67227. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  67228. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67229. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67230. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67231. /**
  67232. * Block used to scale a vector by a float
  67233. */
  67234. export class ScaleBlock extends NodeMaterialBlock {
  67235. /**
  67236. * Creates a new ScaleBlock
  67237. * @param name defines the block name
  67238. */
  67239. constructor(name: string);
  67240. /**
  67241. * Gets the current class name
  67242. * @returns the class name
  67243. */
  67244. getClassName(): string;
  67245. /**
  67246. * Gets the input component
  67247. */
  67248. get input(): NodeMaterialConnectionPoint;
  67249. /**
  67250. * Gets the factor input component
  67251. */
  67252. get factor(): NodeMaterialConnectionPoint;
  67253. /**
  67254. * Gets the output component
  67255. */
  67256. get output(): NodeMaterialConnectionPoint;
  67257. protected _buildBlock(state: NodeMaterialBuildState): this;
  67258. }
  67259. }
  67260. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  67261. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67262. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67264. import { Scene } from "babylonjs/scene";
  67265. /**
  67266. * Block used to clamp a float
  67267. */
  67268. export class ClampBlock extends NodeMaterialBlock {
  67269. /** Gets or sets the minimum range */
  67270. minimum: number;
  67271. /** Gets or sets the maximum range */
  67272. maximum: number;
  67273. /**
  67274. * Creates a new ClampBlock
  67275. * @param name defines the block name
  67276. */
  67277. constructor(name: string);
  67278. /**
  67279. * Gets the current class name
  67280. * @returns the class name
  67281. */
  67282. getClassName(): string;
  67283. /**
  67284. * Gets the value input component
  67285. */
  67286. get value(): NodeMaterialConnectionPoint;
  67287. /**
  67288. * Gets the output component
  67289. */
  67290. get output(): NodeMaterialConnectionPoint;
  67291. protected _buildBlock(state: NodeMaterialBuildState): this;
  67292. protected _dumpPropertiesCode(): string;
  67293. serialize(): any;
  67294. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67295. }
  67296. }
  67297. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  67298. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67299. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67300. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67301. /**
  67302. * Block used to apply a cross product between 2 vectors
  67303. */
  67304. export class CrossBlock extends NodeMaterialBlock {
  67305. /**
  67306. * Creates a new CrossBlock
  67307. * @param name defines the block name
  67308. */
  67309. constructor(name: string);
  67310. /**
  67311. * Gets the current class name
  67312. * @returns the class name
  67313. */
  67314. getClassName(): string;
  67315. /**
  67316. * Gets the left operand input component
  67317. */
  67318. get left(): NodeMaterialConnectionPoint;
  67319. /**
  67320. * Gets the right operand input component
  67321. */
  67322. get right(): NodeMaterialConnectionPoint;
  67323. /**
  67324. * Gets the output component
  67325. */
  67326. get output(): NodeMaterialConnectionPoint;
  67327. protected _buildBlock(state: NodeMaterialBuildState): this;
  67328. }
  67329. }
  67330. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  67331. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67332. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67333. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67334. /**
  67335. * Block used to apply a dot product between 2 vectors
  67336. */
  67337. export class DotBlock extends NodeMaterialBlock {
  67338. /**
  67339. * Creates a new DotBlock
  67340. * @param name defines the block name
  67341. */
  67342. constructor(name: string);
  67343. /**
  67344. * Gets the current class name
  67345. * @returns the class name
  67346. */
  67347. getClassName(): string;
  67348. /**
  67349. * Gets the left operand input component
  67350. */
  67351. get left(): NodeMaterialConnectionPoint;
  67352. /**
  67353. * Gets the right operand input component
  67354. */
  67355. get right(): NodeMaterialConnectionPoint;
  67356. /**
  67357. * Gets the output component
  67358. */
  67359. get output(): NodeMaterialConnectionPoint;
  67360. protected _buildBlock(state: NodeMaterialBuildState): this;
  67361. }
  67362. }
  67363. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  67364. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67365. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67366. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67367. /**
  67368. * Block used to normalize a vector
  67369. */
  67370. export class NormalizeBlock extends NodeMaterialBlock {
  67371. /**
  67372. * Creates a new NormalizeBlock
  67373. * @param name defines the block name
  67374. */
  67375. constructor(name: string);
  67376. /**
  67377. * Gets the current class name
  67378. * @returns the class name
  67379. */
  67380. getClassName(): string;
  67381. /**
  67382. * Gets the input component
  67383. */
  67384. get input(): NodeMaterialConnectionPoint;
  67385. /**
  67386. * Gets the output component
  67387. */
  67388. get output(): NodeMaterialConnectionPoint;
  67389. protected _buildBlock(state: NodeMaterialBuildState): this;
  67390. }
  67391. }
  67392. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  67393. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67394. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67395. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67396. /**
  67397. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67398. */
  67399. export class ColorMergerBlock extends NodeMaterialBlock {
  67400. /**
  67401. * Create a new ColorMergerBlock
  67402. * @param name defines the block name
  67403. */
  67404. constructor(name: string);
  67405. /**
  67406. * Gets the current class name
  67407. * @returns the class name
  67408. */
  67409. getClassName(): string;
  67410. /**
  67411. * Gets the rgb component (input)
  67412. */
  67413. get rgbIn(): NodeMaterialConnectionPoint;
  67414. /**
  67415. * Gets the r component (input)
  67416. */
  67417. get r(): NodeMaterialConnectionPoint;
  67418. /**
  67419. * Gets the g component (input)
  67420. */
  67421. get g(): NodeMaterialConnectionPoint;
  67422. /**
  67423. * Gets the b component (input)
  67424. */
  67425. get b(): NodeMaterialConnectionPoint;
  67426. /**
  67427. * Gets the a component (input)
  67428. */
  67429. get a(): NodeMaterialConnectionPoint;
  67430. /**
  67431. * Gets the rgba component (output)
  67432. */
  67433. get rgba(): NodeMaterialConnectionPoint;
  67434. /**
  67435. * Gets the rgb component (output)
  67436. */
  67437. get rgbOut(): NodeMaterialConnectionPoint;
  67438. /**
  67439. * Gets the rgb component (output)
  67440. * @deprecated Please use rgbOut instead.
  67441. */
  67442. get rgb(): NodeMaterialConnectionPoint;
  67443. protected _buildBlock(state: NodeMaterialBuildState): this;
  67444. }
  67445. }
  67446. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  67447. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67448. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67449. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67450. /**
  67451. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67452. */
  67453. export class VectorSplitterBlock extends NodeMaterialBlock {
  67454. /**
  67455. * Create a new VectorSplitterBlock
  67456. * @param name defines the block name
  67457. */
  67458. constructor(name: string);
  67459. /**
  67460. * Gets the current class name
  67461. * @returns the class name
  67462. */
  67463. getClassName(): string;
  67464. /**
  67465. * Gets the xyzw component (input)
  67466. */
  67467. get xyzw(): NodeMaterialConnectionPoint;
  67468. /**
  67469. * Gets the xyz component (input)
  67470. */
  67471. get xyzIn(): NodeMaterialConnectionPoint;
  67472. /**
  67473. * Gets the xy component (input)
  67474. */
  67475. get xyIn(): NodeMaterialConnectionPoint;
  67476. /**
  67477. * Gets the xyz component (output)
  67478. */
  67479. get xyzOut(): NodeMaterialConnectionPoint;
  67480. /**
  67481. * Gets the xy component (output)
  67482. */
  67483. get xyOut(): NodeMaterialConnectionPoint;
  67484. /**
  67485. * Gets the x component (output)
  67486. */
  67487. get x(): NodeMaterialConnectionPoint;
  67488. /**
  67489. * Gets the y component (output)
  67490. */
  67491. get y(): NodeMaterialConnectionPoint;
  67492. /**
  67493. * Gets the z component (output)
  67494. */
  67495. get z(): NodeMaterialConnectionPoint;
  67496. /**
  67497. * Gets the w component (output)
  67498. */
  67499. get w(): NodeMaterialConnectionPoint;
  67500. protected _inputRename(name: string): string;
  67501. protected _outputRename(name: string): string;
  67502. protected _buildBlock(state: NodeMaterialBuildState): this;
  67503. }
  67504. }
  67505. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  67506. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67507. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67508. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67509. /**
  67510. * Block used to lerp between 2 values
  67511. */
  67512. export class LerpBlock extends NodeMaterialBlock {
  67513. /**
  67514. * Creates a new LerpBlock
  67515. * @param name defines the block name
  67516. */
  67517. constructor(name: string);
  67518. /**
  67519. * Gets the current class name
  67520. * @returns the class name
  67521. */
  67522. getClassName(): string;
  67523. /**
  67524. * Gets the left operand input component
  67525. */
  67526. get left(): NodeMaterialConnectionPoint;
  67527. /**
  67528. * Gets the right operand input component
  67529. */
  67530. get right(): NodeMaterialConnectionPoint;
  67531. /**
  67532. * Gets the gradient operand input component
  67533. */
  67534. get gradient(): NodeMaterialConnectionPoint;
  67535. /**
  67536. * Gets the output component
  67537. */
  67538. get output(): NodeMaterialConnectionPoint;
  67539. protected _buildBlock(state: NodeMaterialBuildState): this;
  67540. }
  67541. }
  67542. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  67543. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67544. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67545. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67546. /**
  67547. * Block used to divide 2 vectors
  67548. */
  67549. export class DivideBlock extends NodeMaterialBlock {
  67550. /**
  67551. * Creates a new DivideBlock
  67552. * @param name defines the block name
  67553. */
  67554. constructor(name: string);
  67555. /**
  67556. * Gets the current class name
  67557. * @returns the class name
  67558. */
  67559. getClassName(): string;
  67560. /**
  67561. * Gets the left operand input component
  67562. */
  67563. get left(): NodeMaterialConnectionPoint;
  67564. /**
  67565. * Gets the right operand input component
  67566. */
  67567. get right(): NodeMaterialConnectionPoint;
  67568. /**
  67569. * Gets the output component
  67570. */
  67571. get output(): NodeMaterialConnectionPoint;
  67572. protected _buildBlock(state: NodeMaterialBuildState): this;
  67573. }
  67574. }
  67575. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  67576. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67577. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67578. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67579. /**
  67580. * Block used to subtract 2 vectors
  67581. */
  67582. export class SubtractBlock extends NodeMaterialBlock {
  67583. /**
  67584. * Creates a new SubtractBlock
  67585. * @param name defines the block name
  67586. */
  67587. constructor(name: string);
  67588. /**
  67589. * Gets the current class name
  67590. * @returns the class name
  67591. */
  67592. getClassName(): string;
  67593. /**
  67594. * Gets the left operand input component
  67595. */
  67596. get left(): NodeMaterialConnectionPoint;
  67597. /**
  67598. * Gets the right operand input component
  67599. */
  67600. get right(): NodeMaterialConnectionPoint;
  67601. /**
  67602. * Gets the output component
  67603. */
  67604. get output(): NodeMaterialConnectionPoint;
  67605. protected _buildBlock(state: NodeMaterialBuildState): this;
  67606. }
  67607. }
  67608. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  67609. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67610. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67611. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67612. /**
  67613. * Block used to step a value
  67614. */
  67615. export class StepBlock extends NodeMaterialBlock {
  67616. /**
  67617. * Creates a new StepBlock
  67618. * @param name defines the block name
  67619. */
  67620. constructor(name: string);
  67621. /**
  67622. * Gets the current class name
  67623. * @returns the class name
  67624. */
  67625. getClassName(): string;
  67626. /**
  67627. * Gets the value operand input component
  67628. */
  67629. get value(): NodeMaterialConnectionPoint;
  67630. /**
  67631. * Gets the edge operand input component
  67632. */
  67633. get edge(): NodeMaterialConnectionPoint;
  67634. /**
  67635. * Gets the output component
  67636. */
  67637. get output(): NodeMaterialConnectionPoint;
  67638. protected _buildBlock(state: NodeMaterialBuildState): this;
  67639. }
  67640. }
  67641. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  67642. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67643. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67644. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67645. /**
  67646. * Block used to get the opposite (1 - x) of a value
  67647. */
  67648. export class OneMinusBlock extends NodeMaterialBlock {
  67649. /**
  67650. * Creates a new OneMinusBlock
  67651. * @param name defines the block name
  67652. */
  67653. constructor(name: string);
  67654. /**
  67655. * Gets the current class name
  67656. * @returns the class name
  67657. */
  67658. getClassName(): string;
  67659. /**
  67660. * Gets the input component
  67661. */
  67662. get input(): NodeMaterialConnectionPoint;
  67663. /**
  67664. * Gets the output component
  67665. */
  67666. get output(): NodeMaterialConnectionPoint;
  67667. protected _buildBlock(state: NodeMaterialBuildState): this;
  67668. }
  67669. }
  67670. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  67671. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67672. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67673. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67674. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67675. /**
  67676. * Block used to get the view direction
  67677. */
  67678. export class ViewDirectionBlock extends NodeMaterialBlock {
  67679. /**
  67680. * Creates a new ViewDirectionBlock
  67681. * @param name defines the block name
  67682. */
  67683. constructor(name: string);
  67684. /**
  67685. * Gets the current class name
  67686. * @returns the class name
  67687. */
  67688. getClassName(): string;
  67689. /**
  67690. * Gets the world position component
  67691. */
  67692. get worldPosition(): NodeMaterialConnectionPoint;
  67693. /**
  67694. * Gets the camera position component
  67695. */
  67696. get cameraPosition(): NodeMaterialConnectionPoint;
  67697. /**
  67698. * Gets the output component
  67699. */
  67700. get output(): NodeMaterialConnectionPoint;
  67701. autoConfigure(material: NodeMaterial): void;
  67702. protected _buildBlock(state: NodeMaterialBuildState): this;
  67703. }
  67704. }
  67705. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  67706. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67707. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67708. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67709. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67710. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  67711. /**
  67712. * Block used to compute fresnel value
  67713. */
  67714. export class FresnelBlock extends NodeMaterialBlock {
  67715. /**
  67716. * Create a new FresnelBlock
  67717. * @param name defines the block name
  67718. */
  67719. constructor(name: string);
  67720. /**
  67721. * Gets the current class name
  67722. * @returns the class name
  67723. */
  67724. getClassName(): string;
  67725. /**
  67726. * Gets the world normal input component
  67727. */
  67728. get worldNormal(): NodeMaterialConnectionPoint;
  67729. /**
  67730. * Gets the view direction input component
  67731. */
  67732. get viewDirection(): NodeMaterialConnectionPoint;
  67733. /**
  67734. * Gets the bias input component
  67735. */
  67736. get bias(): NodeMaterialConnectionPoint;
  67737. /**
  67738. * Gets the camera (or eye) position component
  67739. */
  67740. get power(): NodeMaterialConnectionPoint;
  67741. /**
  67742. * Gets the fresnel output component
  67743. */
  67744. get fresnel(): NodeMaterialConnectionPoint;
  67745. autoConfigure(material: NodeMaterial): void;
  67746. protected _buildBlock(state: NodeMaterialBuildState): this;
  67747. }
  67748. }
  67749. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  67750. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67751. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67752. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67753. /**
  67754. * Block used to get the max of 2 values
  67755. */
  67756. export class MaxBlock extends NodeMaterialBlock {
  67757. /**
  67758. * Creates a new MaxBlock
  67759. * @param name defines the block name
  67760. */
  67761. constructor(name: string);
  67762. /**
  67763. * Gets the current class name
  67764. * @returns the class name
  67765. */
  67766. getClassName(): string;
  67767. /**
  67768. * Gets the left operand input component
  67769. */
  67770. get left(): NodeMaterialConnectionPoint;
  67771. /**
  67772. * Gets the right operand input component
  67773. */
  67774. get right(): NodeMaterialConnectionPoint;
  67775. /**
  67776. * Gets the output component
  67777. */
  67778. get output(): NodeMaterialConnectionPoint;
  67779. protected _buildBlock(state: NodeMaterialBuildState): this;
  67780. }
  67781. }
  67782. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  67783. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67784. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67785. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67786. /**
  67787. * Block used to get the min of 2 values
  67788. */
  67789. export class MinBlock extends NodeMaterialBlock {
  67790. /**
  67791. * Creates a new MinBlock
  67792. * @param name defines the block name
  67793. */
  67794. constructor(name: string);
  67795. /**
  67796. * Gets the current class name
  67797. * @returns the class name
  67798. */
  67799. getClassName(): string;
  67800. /**
  67801. * Gets the left operand input component
  67802. */
  67803. get left(): NodeMaterialConnectionPoint;
  67804. /**
  67805. * Gets the right operand input component
  67806. */
  67807. get right(): NodeMaterialConnectionPoint;
  67808. /**
  67809. * Gets the output component
  67810. */
  67811. get output(): NodeMaterialConnectionPoint;
  67812. protected _buildBlock(state: NodeMaterialBuildState): this;
  67813. }
  67814. }
  67815. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  67816. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67817. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67818. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67819. /**
  67820. * Block used to get the distance between 2 values
  67821. */
  67822. export class DistanceBlock extends NodeMaterialBlock {
  67823. /**
  67824. * Creates a new DistanceBlock
  67825. * @param name defines the block name
  67826. */
  67827. constructor(name: string);
  67828. /**
  67829. * Gets the current class name
  67830. * @returns the class name
  67831. */
  67832. getClassName(): string;
  67833. /**
  67834. * Gets the left operand input component
  67835. */
  67836. get left(): NodeMaterialConnectionPoint;
  67837. /**
  67838. * Gets the right operand input component
  67839. */
  67840. get right(): NodeMaterialConnectionPoint;
  67841. /**
  67842. * Gets the output component
  67843. */
  67844. get output(): NodeMaterialConnectionPoint;
  67845. protected _buildBlock(state: NodeMaterialBuildState): this;
  67846. }
  67847. }
  67848. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  67849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67850. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67851. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67852. /**
  67853. * Block used to get the length of a vector
  67854. */
  67855. export class LengthBlock extends NodeMaterialBlock {
  67856. /**
  67857. * Creates a new LengthBlock
  67858. * @param name defines the block name
  67859. */
  67860. constructor(name: string);
  67861. /**
  67862. * Gets the current class name
  67863. * @returns the class name
  67864. */
  67865. getClassName(): string;
  67866. /**
  67867. * Gets the value input component
  67868. */
  67869. get value(): NodeMaterialConnectionPoint;
  67870. /**
  67871. * Gets the output component
  67872. */
  67873. get output(): NodeMaterialConnectionPoint;
  67874. protected _buildBlock(state: NodeMaterialBuildState): this;
  67875. }
  67876. }
  67877. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  67878. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67879. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67880. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67881. /**
  67882. * Block used to get negative version of a value (i.e. x * -1)
  67883. */
  67884. export class NegateBlock extends NodeMaterialBlock {
  67885. /**
  67886. * Creates a new NegateBlock
  67887. * @param name defines the block name
  67888. */
  67889. constructor(name: string);
  67890. /**
  67891. * Gets the current class name
  67892. * @returns the class name
  67893. */
  67894. getClassName(): string;
  67895. /**
  67896. * Gets the value input component
  67897. */
  67898. get value(): NodeMaterialConnectionPoint;
  67899. /**
  67900. * Gets the output component
  67901. */
  67902. get output(): NodeMaterialConnectionPoint;
  67903. protected _buildBlock(state: NodeMaterialBuildState): this;
  67904. }
  67905. }
  67906. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67907. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67908. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67909. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67910. /**
  67911. * Block used to get the value of the first parameter raised to the power of the second
  67912. */
  67913. export class PowBlock extends NodeMaterialBlock {
  67914. /**
  67915. * Creates a new PowBlock
  67916. * @param name defines the block name
  67917. */
  67918. constructor(name: string);
  67919. /**
  67920. * Gets the current class name
  67921. * @returns the class name
  67922. */
  67923. getClassName(): string;
  67924. /**
  67925. * Gets the value operand input component
  67926. */
  67927. get value(): NodeMaterialConnectionPoint;
  67928. /**
  67929. * Gets the power operand input component
  67930. */
  67931. get power(): NodeMaterialConnectionPoint;
  67932. /**
  67933. * Gets the output component
  67934. */
  67935. get output(): NodeMaterialConnectionPoint;
  67936. protected _buildBlock(state: NodeMaterialBuildState): this;
  67937. }
  67938. }
  67939. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  67940. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67941. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67942. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67943. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67944. /**
  67945. * Block used to get a random number
  67946. */
  67947. export class RandomNumberBlock extends NodeMaterialBlock {
  67948. /**
  67949. * Creates a new RandomNumberBlock
  67950. * @param name defines the block name
  67951. */
  67952. constructor(name: string);
  67953. /**
  67954. * Gets the current class name
  67955. * @returns the class name
  67956. */
  67957. getClassName(): string;
  67958. /**
  67959. * Gets the seed input component
  67960. */
  67961. get seed(): NodeMaterialConnectionPoint;
  67962. /**
  67963. * Gets the output component
  67964. */
  67965. get output(): NodeMaterialConnectionPoint;
  67966. protected _buildBlock(state: NodeMaterialBuildState): this;
  67967. }
  67968. }
  67969. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67970. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67971. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67972. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67973. /**
  67974. * Block used to compute arc tangent of 2 values
  67975. */
  67976. export class ArcTan2Block extends NodeMaterialBlock {
  67977. /**
  67978. * Creates a new ArcTan2Block
  67979. * @param name defines the block name
  67980. */
  67981. constructor(name: string);
  67982. /**
  67983. * Gets the current class name
  67984. * @returns the class name
  67985. */
  67986. getClassName(): string;
  67987. /**
  67988. * Gets the x operand input component
  67989. */
  67990. get x(): NodeMaterialConnectionPoint;
  67991. /**
  67992. * Gets the y operand input component
  67993. */
  67994. get y(): NodeMaterialConnectionPoint;
  67995. /**
  67996. * Gets the output component
  67997. */
  67998. get output(): NodeMaterialConnectionPoint;
  67999. protected _buildBlock(state: NodeMaterialBuildState): this;
  68000. }
  68001. }
  68002. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  68003. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68004. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68005. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68006. /**
  68007. * Block used to smooth step a value
  68008. */
  68009. export class SmoothStepBlock extends NodeMaterialBlock {
  68010. /**
  68011. * Creates a new SmoothStepBlock
  68012. * @param name defines the block name
  68013. */
  68014. constructor(name: string);
  68015. /**
  68016. * Gets the current class name
  68017. * @returns the class name
  68018. */
  68019. getClassName(): string;
  68020. /**
  68021. * Gets the value operand input component
  68022. */
  68023. get value(): NodeMaterialConnectionPoint;
  68024. /**
  68025. * Gets the first edge operand input component
  68026. */
  68027. get edge0(): NodeMaterialConnectionPoint;
  68028. /**
  68029. * Gets the second edge operand input component
  68030. */
  68031. get edge1(): NodeMaterialConnectionPoint;
  68032. /**
  68033. * Gets the output component
  68034. */
  68035. get output(): NodeMaterialConnectionPoint;
  68036. protected _buildBlock(state: NodeMaterialBuildState): this;
  68037. }
  68038. }
  68039. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  68040. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68041. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68042. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68043. /**
  68044. * Block used to get the reciprocal (1 / x) of a value
  68045. */
  68046. export class ReciprocalBlock extends NodeMaterialBlock {
  68047. /**
  68048. * Creates a new ReciprocalBlock
  68049. * @param name defines the block name
  68050. */
  68051. constructor(name: string);
  68052. /**
  68053. * Gets the current class name
  68054. * @returns the class name
  68055. */
  68056. getClassName(): string;
  68057. /**
  68058. * Gets the input component
  68059. */
  68060. get input(): NodeMaterialConnectionPoint;
  68061. /**
  68062. * Gets the output component
  68063. */
  68064. get output(): NodeMaterialConnectionPoint;
  68065. protected _buildBlock(state: NodeMaterialBuildState): this;
  68066. }
  68067. }
  68068. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  68069. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68070. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68071. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68072. /**
  68073. * Block used to replace a color by another one
  68074. */
  68075. export class ReplaceColorBlock extends NodeMaterialBlock {
  68076. /**
  68077. * Creates a new ReplaceColorBlock
  68078. * @param name defines the block name
  68079. */
  68080. constructor(name: string);
  68081. /**
  68082. * Gets the current class name
  68083. * @returns the class name
  68084. */
  68085. getClassName(): string;
  68086. /**
  68087. * Gets the value input component
  68088. */
  68089. get value(): NodeMaterialConnectionPoint;
  68090. /**
  68091. * Gets the reference input component
  68092. */
  68093. get reference(): NodeMaterialConnectionPoint;
  68094. /**
  68095. * Gets the distance input component
  68096. */
  68097. get distance(): NodeMaterialConnectionPoint;
  68098. /**
  68099. * Gets the replacement input component
  68100. */
  68101. get replacement(): NodeMaterialConnectionPoint;
  68102. /**
  68103. * Gets the output component
  68104. */
  68105. get output(): NodeMaterialConnectionPoint;
  68106. protected _buildBlock(state: NodeMaterialBuildState): this;
  68107. }
  68108. }
  68109. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  68110. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68111. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68112. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68113. /**
  68114. * Block used to posterize a value
  68115. * @see https://en.wikipedia.org/wiki/Posterization
  68116. */
  68117. export class PosterizeBlock extends NodeMaterialBlock {
  68118. /**
  68119. * Creates a new PosterizeBlock
  68120. * @param name defines the block name
  68121. */
  68122. constructor(name: string);
  68123. /**
  68124. * Gets the current class name
  68125. * @returns the class name
  68126. */
  68127. getClassName(): string;
  68128. /**
  68129. * Gets the value input component
  68130. */
  68131. get value(): NodeMaterialConnectionPoint;
  68132. /**
  68133. * Gets the steps input component
  68134. */
  68135. get steps(): NodeMaterialConnectionPoint;
  68136. /**
  68137. * Gets the output component
  68138. */
  68139. get output(): NodeMaterialConnectionPoint;
  68140. protected _buildBlock(state: NodeMaterialBuildState): this;
  68141. }
  68142. }
  68143. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  68144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68147. import { Scene } from "babylonjs/scene";
  68148. /**
  68149. * Operations supported by the Wave block
  68150. */
  68151. export enum WaveBlockKind {
  68152. /** SawTooth */
  68153. SawTooth = 0,
  68154. /** Square */
  68155. Square = 1,
  68156. /** Triangle */
  68157. Triangle = 2
  68158. }
  68159. /**
  68160. * Block used to apply wave operation to floats
  68161. */
  68162. export class WaveBlock extends NodeMaterialBlock {
  68163. /**
  68164. * Gets or sets the kibnd of wave to be applied by the block
  68165. */
  68166. kind: WaveBlockKind;
  68167. /**
  68168. * Creates a new WaveBlock
  68169. * @param name defines the block name
  68170. */
  68171. constructor(name: string);
  68172. /**
  68173. * Gets the current class name
  68174. * @returns the class name
  68175. */
  68176. getClassName(): string;
  68177. /**
  68178. * Gets the input component
  68179. */
  68180. get input(): NodeMaterialConnectionPoint;
  68181. /**
  68182. * Gets the output component
  68183. */
  68184. get output(): NodeMaterialConnectionPoint;
  68185. protected _buildBlock(state: NodeMaterialBuildState): this;
  68186. serialize(): any;
  68187. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68188. }
  68189. }
  68190. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  68191. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68192. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68193. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68194. import { Color3 } from "babylonjs/Maths/math.color";
  68195. import { Scene } from "babylonjs/scene";
  68196. import { Observable } from "babylonjs/Misc/observable";
  68197. /**
  68198. * Class used to store a color step for the GradientBlock
  68199. */
  68200. export class GradientBlockColorStep {
  68201. private _step;
  68202. /**
  68203. * Gets value indicating which step this color is associated with (between 0 and 1)
  68204. */
  68205. get step(): number;
  68206. /**
  68207. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68208. */
  68209. set step(val: number);
  68210. private _color;
  68211. /**
  68212. * Gets the color associated with this step
  68213. */
  68214. get color(): Color3;
  68215. /**
  68216. * Sets the color associated with this step
  68217. */
  68218. set color(val: Color3);
  68219. /**
  68220. * Creates a new GradientBlockColorStep
  68221. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68222. * @param color defines the color associated with this step
  68223. */
  68224. constructor(step: number, color: Color3);
  68225. }
  68226. /**
  68227. * Block used to return a color from a gradient based on an input value between 0 and 1
  68228. */
  68229. export class GradientBlock extends NodeMaterialBlock {
  68230. /**
  68231. * Gets or sets the list of color steps
  68232. */
  68233. colorSteps: GradientBlockColorStep[];
  68234. /** Gets an observable raised when the value is changed */
  68235. onValueChangedObservable: Observable<GradientBlock>;
  68236. /** calls observable when the value is changed*/
  68237. colorStepsUpdated(): void;
  68238. /**
  68239. * Creates a new GradientBlock
  68240. * @param name defines the block name
  68241. */
  68242. constructor(name: string);
  68243. /**
  68244. * Gets the current class name
  68245. * @returns the class name
  68246. */
  68247. getClassName(): string;
  68248. /**
  68249. * Gets the gradient input component
  68250. */
  68251. get gradient(): NodeMaterialConnectionPoint;
  68252. /**
  68253. * Gets the output component
  68254. */
  68255. get output(): NodeMaterialConnectionPoint;
  68256. private _writeColorConstant;
  68257. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68258. serialize(): any;
  68259. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68260. protected _dumpPropertiesCode(): string;
  68261. }
  68262. }
  68263. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  68264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68266. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68267. /**
  68268. * Block used to normalize lerp between 2 values
  68269. */
  68270. export class NLerpBlock extends NodeMaterialBlock {
  68271. /**
  68272. * Creates a new NLerpBlock
  68273. * @param name defines the block name
  68274. */
  68275. constructor(name: string);
  68276. /**
  68277. * Gets the current class name
  68278. * @returns the class name
  68279. */
  68280. getClassName(): string;
  68281. /**
  68282. * Gets the left operand input component
  68283. */
  68284. get left(): NodeMaterialConnectionPoint;
  68285. /**
  68286. * Gets the right operand input component
  68287. */
  68288. get right(): NodeMaterialConnectionPoint;
  68289. /**
  68290. * Gets the gradient operand input component
  68291. */
  68292. get gradient(): NodeMaterialConnectionPoint;
  68293. /**
  68294. * Gets the output component
  68295. */
  68296. get output(): NodeMaterialConnectionPoint;
  68297. protected _buildBlock(state: NodeMaterialBuildState): this;
  68298. }
  68299. }
  68300. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  68301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68304. import { Scene } from "babylonjs/scene";
  68305. /**
  68306. * block used to Generate a Worley Noise 3D Noise Pattern
  68307. */
  68308. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68309. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68310. manhattanDistance: boolean;
  68311. /**
  68312. * Creates a new WorleyNoise3DBlock
  68313. * @param name defines the block name
  68314. */
  68315. constructor(name: string);
  68316. /**
  68317. * Gets the current class name
  68318. * @returns the class name
  68319. */
  68320. getClassName(): string;
  68321. /**
  68322. * Gets the seed input component
  68323. */
  68324. get seed(): NodeMaterialConnectionPoint;
  68325. /**
  68326. * Gets the jitter input component
  68327. */
  68328. get jitter(): NodeMaterialConnectionPoint;
  68329. /**
  68330. * Gets the output component
  68331. */
  68332. get output(): NodeMaterialConnectionPoint;
  68333. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68334. /**
  68335. * Exposes the properties to the UI?
  68336. */
  68337. protected _dumpPropertiesCode(): string;
  68338. /**
  68339. * Exposes the properties to the Seralize?
  68340. */
  68341. serialize(): any;
  68342. /**
  68343. * Exposes the properties to the deseralize?
  68344. */
  68345. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68346. }
  68347. }
  68348. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  68349. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68350. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68351. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68352. /**
  68353. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68354. */
  68355. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68356. /**
  68357. * Creates a new SimplexPerlin3DBlock
  68358. * @param name defines the block name
  68359. */
  68360. constructor(name: string);
  68361. /**
  68362. * Gets the current class name
  68363. * @returns the class name
  68364. */
  68365. getClassName(): string;
  68366. /**
  68367. * Gets the seed operand input component
  68368. */
  68369. get seed(): NodeMaterialConnectionPoint;
  68370. /**
  68371. * Gets the output component
  68372. */
  68373. get output(): NodeMaterialConnectionPoint;
  68374. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68375. }
  68376. }
  68377. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  68378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68379. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68380. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68381. /**
  68382. * Block used to blend normals
  68383. */
  68384. export class NormalBlendBlock extends NodeMaterialBlock {
  68385. /**
  68386. * Creates a new NormalBlendBlock
  68387. * @param name defines the block name
  68388. */
  68389. constructor(name: string);
  68390. /**
  68391. * Gets the current class name
  68392. * @returns the class name
  68393. */
  68394. getClassName(): string;
  68395. /**
  68396. * Gets the first input component
  68397. */
  68398. get normalMap0(): NodeMaterialConnectionPoint;
  68399. /**
  68400. * Gets the second input component
  68401. */
  68402. get normalMap1(): NodeMaterialConnectionPoint;
  68403. /**
  68404. * Gets the output component
  68405. */
  68406. get output(): NodeMaterialConnectionPoint;
  68407. protected _buildBlock(state: NodeMaterialBuildState): this;
  68408. }
  68409. }
  68410. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  68411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68414. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68415. /**
  68416. * Block used to rotate a 2d vector by a given angle
  68417. */
  68418. export class Rotate2dBlock extends NodeMaterialBlock {
  68419. /**
  68420. * Creates a new Rotate2dBlock
  68421. * @param name defines the block name
  68422. */
  68423. constructor(name: string);
  68424. /**
  68425. * Gets the current class name
  68426. * @returns the class name
  68427. */
  68428. getClassName(): string;
  68429. /**
  68430. * Gets the input vector
  68431. */
  68432. get input(): NodeMaterialConnectionPoint;
  68433. /**
  68434. * Gets the input angle
  68435. */
  68436. get angle(): NodeMaterialConnectionPoint;
  68437. /**
  68438. * Gets the output component
  68439. */
  68440. get output(): NodeMaterialConnectionPoint;
  68441. autoConfigure(material: NodeMaterial): void;
  68442. protected _buildBlock(state: NodeMaterialBuildState): this;
  68443. }
  68444. }
  68445. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  68446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68449. /**
  68450. * Block used to get the reflected vector from a direction and a normal
  68451. */
  68452. export class ReflectBlock extends NodeMaterialBlock {
  68453. /**
  68454. * Creates a new ReflectBlock
  68455. * @param name defines the block name
  68456. */
  68457. constructor(name: string);
  68458. /**
  68459. * Gets the current class name
  68460. * @returns the class name
  68461. */
  68462. getClassName(): string;
  68463. /**
  68464. * Gets the incident component
  68465. */
  68466. get incident(): NodeMaterialConnectionPoint;
  68467. /**
  68468. * Gets the normal component
  68469. */
  68470. get normal(): NodeMaterialConnectionPoint;
  68471. /**
  68472. * Gets the output component
  68473. */
  68474. get output(): NodeMaterialConnectionPoint;
  68475. protected _buildBlock(state: NodeMaterialBuildState): this;
  68476. }
  68477. }
  68478. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  68479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68480. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68481. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68482. /**
  68483. * Block used to get the refracted vector from a direction and a normal
  68484. */
  68485. export class RefractBlock extends NodeMaterialBlock {
  68486. /**
  68487. * Creates a new RefractBlock
  68488. * @param name defines the block name
  68489. */
  68490. constructor(name: string);
  68491. /**
  68492. * Gets the current class name
  68493. * @returns the class name
  68494. */
  68495. getClassName(): string;
  68496. /**
  68497. * Gets the incident component
  68498. */
  68499. get incident(): NodeMaterialConnectionPoint;
  68500. /**
  68501. * Gets the normal component
  68502. */
  68503. get normal(): NodeMaterialConnectionPoint;
  68504. /**
  68505. * Gets the index of refraction component
  68506. */
  68507. get ior(): NodeMaterialConnectionPoint;
  68508. /**
  68509. * Gets the output component
  68510. */
  68511. get output(): NodeMaterialConnectionPoint;
  68512. protected _buildBlock(state: NodeMaterialBuildState): this;
  68513. }
  68514. }
  68515. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  68516. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68517. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68519. /**
  68520. * Block used to desaturate a color
  68521. */
  68522. export class DesaturateBlock extends NodeMaterialBlock {
  68523. /**
  68524. * Creates a new DesaturateBlock
  68525. * @param name defines the block name
  68526. */
  68527. constructor(name: string);
  68528. /**
  68529. * Gets the current class name
  68530. * @returns the class name
  68531. */
  68532. getClassName(): string;
  68533. /**
  68534. * Gets the color operand input component
  68535. */
  68536. get color(): NodeMaterialConnectionPoint;
  68537. /**
  68538. * Gets the level operand input component
  68539. */
  68540. get level(): NodeMaterialConnectionPoint;
  68541. /**
  68542. * Gets the output component
  68543. */
  68544. get output(): NodeMaterialConnectionPoint;
  68545. protected _buildBlock(state: NodeMaterialBuildState): this;
  68546. }
  68547. }
  68548. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  68549. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68550. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68551. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68552. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68553. import { Nullable } from "babylonjs/types";
  68554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68555. import { Scene } from "babylonjs/scene";
  68556. /**
  68557. * Block used to implement the ambient occlusion module of the PBR material
  68558. */
  68559. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  68560. /**
  68561. * Create a new AmbientOcclusionBlock
  68562. * @param name defines the block name
  68563. */
  68564. constructor(name: string);
  68565. /**
  68566. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  68567. */
  68568. useAmbientInGrayScale: boolean;
  68569. /**
  68570. * Initialize the block and prepare the context for build
  68571. * @param state defines the state that will be used for the build
  68572. */
  68573. initialize(state: NodeMaterialBuildState): void;
  68574. /**
  68575. * Gets the current class name
  68576. * @returns the class name
  68577. */
  68578. getClassName(): string;
  68579. /**
  68580. * Gets the texture input component
  68581. */
  68582. get texture(): NodeMaterialConnectionPoint;
  68583. /**
  68584. * Gets the texture intensity component
  68585. */
  68586. get intensity(): NodeMaterialConnectionPoint;
  68587. /**
  68588. * Gets the direct light intensity input component
  68589. */
  68590. get directLightIntensity(): NodeMaterialConnectionPoint;
  68591. /**
  68592. * Gets the ambient occlusion object output component
  68593. */
  68594. get ambientOcc(): NodeMaterialConnectionPoint;
  68595. /**
  68596. * Gets the main code of the block (fragment side)
  68597. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  68598. * @returns the shader code
  68599. */
  68600. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  68601. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68602. protected _buildBlock(state: NodeMaterialBuildState): this;
  68603. protected _dumpPropertiesCode(): string;
  68604. serialize(): any;
  68605. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68606. }
  68607. }
  68608. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  68609. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68610. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68611. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68612. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  68613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68614. import { Nullable } from "babylonjs/types";
  68615. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68616. import { Mesh } from "babylonjs/Meshes/mesh";
  68617. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68618. import { Effect } from "babylonjs/Materials/effect";
  68619. import { Scene } from "babylonjs/scene";
  68620. /**
  68621. * Block used to implement the reflection module of the PBR material
  68622. */
  68623. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68624. /** @hidden */
  68625. _defineLODReflectionAlpha: string;
  68626. /** @hidden */
  68627. _defineLinearSpecularReflection: string;
  68628. private _vEnvironmentIrradianceName;
  68629. /** @hidden */
  68630. _vReflectionMicrosurfaceInfosName: string;
  68631. /** @hidden */
  68632. _vReflectionInfosName: string;
  68633. /** @hidden */
  68634. _vReflectionFilteringInfoName: string;
  68635. private _scene;
  68636. /**
  68637. * The three properties below are set by the main PBR block prior to calling methods of this class.
  68638. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68639. * It's less burden on the user side in the editor part.
  68640. */
  68641. /** @hidden */
  68642. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68643. /** @hidden */
  68644. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68645. /** @hidden */
  68646. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68647. /**
  68648. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68649. * diffuse part of the IBL.
  68650. */
  68651. useSphericalHarmonics: boolean;
  68652. /**
  68653. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68654. */
  68655. forceIrradianceInFragment: boolean;
  68656. /**
  68657. * Create a new ReflectionBlock
  68658. * @param name defines the block name
  68659. */
  68660. constructor(name: string);
  68661. /**
  68662. * Gets the current class name
  68663. * @returns the class name
  68664. */
  68665. getClassName(): string;
  68666. /**
  68667. * Gets the position input component
  68668. */
  68669. get position(): NodeMaterialConnectionPoint;
  68670. /**
  68671. * Gets the world position input component
  68672. */
  68673. get worldPosition(): NodeMaterialConnectionPoint;
  68674. /**
  68675. * Gets the world normal input component
  68676. */
  68677. get worldNormal(): NodeMaterialConnectionPoint;
  68678. /**
  68679. * Gets the world input component
  68680. */
  68681. get world(): NodeMaterialConnectionPoint;
  68682. /**
  68683. * Gets the camera (or eye) position component
  68684. */
  68685. get cameraPosition(): NodeMaterialConnectionPoint;
  68686. /**
  68687. * Gets the view input component
  68688. */
  68689. get view(): NodeMaterialConnectionPoint;
  68690. /**
  68691. * Gets the color input component
  68692. */
  68693. get color(): NodeMaterialConnectionPoint;
  68694. /**
  68695. * Gets the reflection object output component
  68696. */
  68697. get reflection(): NodeMaterialConnectionPoint;
  68698. /**
  68699. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68700. */
  68701. get hasTexture(): boolean;
  68702. /**
  68703. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68704. */
  68705. get reflectionColor(): string;
  68706. protected _getTexture(): Nullable<BaseTexture>;
  68707. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68708. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68709. /**
  68710. * Gets the code to inject in the vertex shader
  68711. * @param state current state of the node material building
  68712. * @returns the shader code
  68713. */
  68714. handleVertexSide(state: NodeMaterialBuildState): string;
  68715. /**
  68716. * Gets the main code of the block (fragment side)
  68717. * @param state current state of the node material building
  68718. * @param normalVarName name of the existing variable corresponding to the normal
  68719. * @returns the shader code
  68720. */
  68721. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68722. protected _buildBlock(state: NodeMaterialBuildState): this;
  68723. protected _dumpPropertiesCode(): string;
  68724. serialize(): any;
  68725. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68726. }
  68727. }
  68728. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  68729. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68730. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68731. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68732. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68734. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68735. import { Scene } from "babylonjs/scene";
  68736. import { Nullable } from "babylonjs/types";
  68737. /**
  68738. * Block used to implement the sheen module of the PBR material
  68739. */
  68740. export class SheenBlock extends NodeMaterialBlock {
  68741. /**
  68742. * Create a new SheenBlock
  68743. * @param name defines the block name
  68744. */
  68745. constructor(name: string);
  68746. /**
  68747. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68748. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68749. * making it easier to setup and tweak the effect
  68750. */
  68751. albedoScaling: boolean;
  68752. /**
  68753. * Defines if the sheen is linked to the sheen color.
  68754. */
  68755. linkSheenWithAlbedo: boolean;
  68756. /**
  68757. * Initialize the block and prepare the context for build
  68758. * @param state defines the state that will be used for the build
  68759. */
  68760. initialize(state: NodeMaterialBuildState): void;
  68761. /**
  68762. * Gets the current class name
  68763. * @returns the class name
  68764. */
  68765. getClassName(): string;
  68766. /**
  68767. * Gets the intensity input component
  68768. */
  68769. get intensity(): NodeMaterialConnectionPoint;
  68770. /**
  68771. * Gets the color input component
  68772. */
  68773. get color(): NodeMaterialConnectionPoint;
  68774. /**
  68775. * Gets the roughness input component
  68776. */
  68777. get roughness(): NodeMaterialConnectionPoint;
  68778. /**
  68779. * Gets the sheen object output component
  68780. */
  68781. get sheen(): NodeMaterialConnectionPoint;
  68782. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68783. /**
  68784. * Gets the main code of the block (fragment side)
  68785. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68786. * @returns the shader code
  68787. */
  68788. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68789. protected _buildBlock(state: NodeMaterialBuildState): this;
  68790. protected _dumpPropertiesCode(): string;
  68791. serialize(): any;
  68792. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68793. }
  68794. }
  68795. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  68796. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68797. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68800. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68801. import { Scene } from "babylonjs/scene";
  68802. import { Nullable } from "babylonjs/types";
  68803. import { Mesh } from "babylonjs/Meshes/mesh";
  68804. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68805. import { Effect } from "babylonjs/Materials/effect";
  68806. /**
  68807. * Block used to implement the reflectivity module of the PBR material
  68808. */
  68809. export class ReflectivityBlock extends NodeMaterialBlock {
  68810. private _metallicReflectanceColor;
  68811. private _metallicF0Factor;
  68812. /** @hidden */
  68813. _vMetallicReflectanceFactorsName: string;
  68814. /**
  68815. * The property below is set by the main PBR block prior to calling methods of this class.
  68816. */
  68817. /** @hidden */
  68818. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  68819. /**
  68820. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  68821. */
  68822. useAmbientOcclusionFromMetallicTextureRed: boolean;
  68823. /**
  68824. * Specifies if the metallic texture contains the metallness information in its blue channel.
  68825. */
  68826. useMetallnessFromMetallicTextureBlue: boolean;
  68827. /**
  68828. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  68829. */
  68830. useRoughnessFromMetallicTextureAlpha: boolean;
  68831. /**
  68832. * Specifies if the metallic texture contains the roughness information in its green channel.
  68833. */
  68834. useRoughnessFromMetallicTextureGreen: boolean;
  68835. /**
  68836. * Create a new ReflectivityBlock
  68837. * @param name defines the block name
  68838. */
  68839. constructor(name: string);
  68840. /**
  68841. * Initialize the block and prepare the context for build
  68842. * @param state defines the state that will be used for the build
  68843. */
  68844. initialize(state: NodeMaterialBuildState): void;
  68845. /**
  68846. * Gets the current class name
  68847. * @returns the class name
  68848. */
  68849. getClassName(): string;
  68850. /**
  68851. * Gets the metallic input component
  68852. */
  68853. get metallic(): NodeMaterialConnectionPoint;
  68854. /**
  68855. * Gets the roughness input component
  68856. */
  68857. get roughness(): NodeMaterialConnectionPoint;
  68858. /**
  68859. * Gets the texture input component
  68860. */
  68861. get texture(): NodeMaterialConnectionPoint;
  68862. /**
  68863. * Gets the reflectivity object output component
  68864. */
  68865. get reflectivity(): NodeMaterialConnectionPoint;
  68866. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68867. /**
  68868. * Gets the main code of the block (fragment side)
  68869. * @param state current state of the node material building
  68870. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  68871. * @returns the shader code
  68872. */
  68873. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  68874. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68875. protected _buildBlock(state: NodeMaterialBuildState): this;
  68876. protected _dumpPropertiesCode(): string;
  68877. serialize(): any;
  68878. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68879. }
  68880. }
  68881. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  68882. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68883. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68884. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68885. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68887. /**
  68888. * Block used to implement the anisotropy module of the PBR material
  68889. */
  68890. export class AnisotropyBlock extends NodeMaterialBlock {
  68891. /**
  68892. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68893. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68894. * It's less burden on the user side in the editor part.
  68895. */
  68896. /** @hidden */
  68897. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68898. /** @hidden */
  68899. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68900. /**
  68901. * Create a new AnisotropyBlock
  68902. * @param name defines the block name
  68903. */
  68904. constructor(name: string);
  68905. /**
  68906. * Initialize the block and prepare the context for build
  68907. * @param state defines the state that will be used for the build
  68908. */
  68909. initialize(state: NodeMaterialBuildState): void;
  68910. /**
  68911. * Gets the current class name
  68912. * @returns the class name
  68913. */
  68914. getClassName(): string;
  68915. /**
  68916. * Gets the intensity input component
  68917. */
  68918. get intensity(): NodeMaterialConnectionPoint;
  68919. /**
  68920. * Gets the direction input component
  68921. */
  68922. get direction(): NodeMaterialConnectionPoint;
  68923. /**
  68924. * Gets the texture input component
  68925. */
  68926. get texture(): NodeMaterialConnectionPoint;
  68927. /**
  68928. * Gets the uv input component
  68929. */
  68930. get uv(): NodeMaterialConnectionPoint;
  68931. /**
  68932. * Gets the worldTangent input component
  68933. */
  68934. get worldTangent(): NodeMaterialConnectionPoint;
  68935. /**
  68936. * Gets the anisotropy object output component
  68937. */
  68938. get anisotropy(): NodeMaterialConnectionPoint;
  68939. private _generateTBNSpace;
  68940. /**
  68941. * Gets the main code of the block (fragment side)
  68942. * @param state current state of the node material building
  68943. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68944. * @returns the shader code
  68945. */
  68946. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68947. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68948. protected _buildBlock(state: NodeMaterialBuildState): this;
  68949. }
  68950. }
  68951. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68952. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68953. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68954. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68955. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68957. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68958. import { Nullable } from "babylonjs/types";
  68959. import { Mesh } from "babylonjs/Meshes/mesh";
  68960. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68961. import { Effect } from "babylonjs/Materials/effect";
  68962. /**
  68963. * Block used to implement the clear coat module of the PBR material
  68964. */
  68965. export class ClearCoatBlock extends NodeMaterialBlock {
  68966. private _scene;
  68967. /**
  68968. * Create a new ClearCoatBlock
  68969. * @param name defines the block name
  68970. */
  68971. constructor(name: string);
  68972. /**
  68973. * Initialize the block and prepare the context for build
  68974. * @param state defines the state that will be used for the build
  68975. */
  68976. initialize(state: NodeMaterialBuildState): void;
  68977. /**
  68978. * Gets the current class name
  68979. * @returns the class name
  68980. */
  68981. getClassName(): string;
  68982. /**
  68983. * Gets the intensity input component
  68984. */
  68985. get intensity(): NodeMaterialConnectionPoint;
  68986. /**
  68987. * Gets the roughness input component
  68988. */
  68989. get roughness(): NodeMaterialConnectionPoint;
  68990. /**
  68991. * Gets the ior input component
  68992. */
  68993. get ior(): NodeMaterialConnectionPoint;
  68994. /**
  68995. * Gets the texture input component
  68996. */
  68997. get texture(): NodeMaterialConnectionPoint;
  68998. /**
  68999. * Gets the bump texture input component
  69000. */
  69001. get bumpTexture(): NodeMaterialConnectionPoint;
  69002. /**
  69003. * Gets the uv input component
  69004. */
  69005. get uv(): NodeMaterialConnectionPoint;
  69006. /**
  69007. * Gets the tint color input component
  69008. */
  69009. get tintColor(): NodeMaterialConnectionPoint;
  69010. /**
  69011. * Gets the tint "at distance" input component
  69012. */
  69013. get tintAtDistance(): NodeMaterialConnectionPoint;
  69014. /**
  69015. * Gets the tint thickness input component
  69016. */
  69017. get tintThickness(): NodeMaterialConnectionPoint;
  69018. /**
  69019. * Gets the world tangent input component
  69020. */
  69021. get worldTangent(): NodeMaterialConnectionPoint;
  69022. /**
  69023. * Gets the clear coat object output component
  69024. */
  69025. get clearcoat(): NodeMaterialConnectionPoint;
  69026. autoConfigure(material: NodeMaterial): void;
  69027. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69028. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69029. private _generateTBNSpace;
  69030. /**
  69031. * Gets the main code of the block (fragment side)
  69032. * @param state current state of the node material building
  69033. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69034. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69035. * @param worldPosVarName name of the variable holding the world position
  69036. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69037. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69038. * @param worldNormalVarName name of the variable holding the world normal
  69039. * @returns the shader code
  69040. */
  69041. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69042. protected _buildBlock(state: NodeMaterialBuildState): this;
  69043. }
  69044. }
  69045. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  69046. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69047. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69048. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69049. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69051. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69052. import { Nullable } from "babylonjs/types";
  69053. /**
  69054. * Block used to implement the sub surface module of the PBR material
  69055. */
  69056. export class SubSurfaceBlock extends NodeMaterialBlock {
  69057. /**
  69058. * Create a new SubSurfaceBlock
  69059. * @param name defines the block name
  69060. */
  69061. constructor(name: string);
  69062. /**
  69063. * Stores the intensity of the different subsurface effects in the thickness texture.
  69064. * * the green channel is the translucency intensity.
  69065. * * the blue channel is the scattering intensity.
  69066. * * the alpha channel is the refraction intensity.
  69067. */
  69068. useMaskFromThicknessTexture: boolean;
  69069. /**
  69070. * Initialize the block and prepare the context for build
  69071. * @param state defines the state that will be used for the build
  69072. */
  69073. initialize(state: NodeMaterialBuildState): void;
  69074. /**
  69075. * Gets the current class name
  69076. * @returns the class name
  69077. */
  69078. getClassName(): string;
  69079. /**
  69080. * Gets the min thickness input component
  69081. */
  69082. get minThickness(): NodeMaterialConnectionPoint;
  69083. /**
  69084. * Gets the max thickness input component
  69085. */
  69086. get maxThickness(): NodeMaterialConnectionPoint;
  69087. /**
  69088. * Gets the thickness texture component
  69089. */
  69090. get thicknessTexture(): NodeMaterialConnectionPoint;
  69091. /**
  69092. * Gets the tint color input component
  69093. */
  69094. get tintColor(): NodeMaterialConnectionPoint;
  69095. /**
  69096. * Gets the translucency intensity input component
  69097. */
  69098. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69099. /**
  69100. * Gets the translucency diffusion distance input component
  69101. */
  69102. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  69103. /**
  69104. * Gets the refraction object parameters
  69105. */
  69106. get refraction(): NodeMaterialConnectionPoint;
  69107. /**
  69108. * Gets the sub surface object output component
  69109. */
  69110. get subsurface(): NodeMaterialConnectionPoint;
  69111. autoConfigure(material: NodeMaterial): void;
  69112. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69113. /**
  69114. * Gets the main code of the block (fragment side)
  69115. * @param state current state of the node material building
  69116. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69117. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69118. * @param worldPosVarName name of the variable holding the world position
  69119. * @returns the shader code
  69120. */
  69121. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69122. protected _buildBlock(state: NodeMaterialBuildState): this;
  69123. }
  69124. }
  69125. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  69126. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69127. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69128. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69129. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69130. import { Light } from "babylonjs/Lights/light";
  69131. import { Nullable } from "babylonjs/types";
  69132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69133. import { Effect } from "babylonjs/Materials/effect";
  69134. import { Mesh } from "babylonjs/Meshes/mesh";
  69135. import { Scene } from "babylonjs/scene";
  69136. /**
  69137. * Block used to implement the PBR metallic/roughness model
  69138. */
  69139. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69140. /**
  69141. * Gets or sets the light associated with this block
  69142. */
  69143. light: Nullable<Light>;
  69144. private _lightId;
  69145. private _scene;
  69146. private _environmentBRDFTexture;
  69147. private _environmentBrdfSamplerName;
  69148. private _vNormalWName;
  69149. private _invertNormalName;
  69150. /**
  69151. * Create a new ReflectionBlock
  69152. * @param name defines the block name
  69153. */
  69154. constructor(name: string);
  69155. /**
  69156. * Intensity of the direct lights e.g. the four lights available in your scene.
  69157. * This impacts both the direct diffuse and specular highlights.
  69158. */
  69159. directIntensity: number;
  69160. /**
  69161. * Intensity of the environment e.g. how much the environment will light the object
  69162. * either through harmonics for rough material or through the refelction for shiny ones.
  69163. */
  69164. environmentIntensity: number;
  69165. /**
  69166. * This is a special control allowing the reduction of the specular highlights coming from the
  69167. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69168. */
  69169. specularIntensity: number;
  69170. /**
  69171. * Defines the falloff type used in this material.
  69172. * It by default is Physical.
  69173. */
  69174. lightFalloff: number;
  69175. /**
  69176. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  69177. */
  69178. useAlphaFromAlbedoTexture: boolean;
  69179. /**
  69180. * Specifies that alpha test should be used
  69181. */
  69182. useAlphaTest: boolean;
  69183. /**
  69184. * Defines the alpha limits in alpha test mode.
  69185. */
  69186. alphaTestCutoff: number;
  69187. /**
  69188. * Specifies that alpha blending should be used
  69189. */
  69190. useAlphaBlending: boolean;
  69191. /**
  69192. * Defines if the alpha value should be determined via the rgb values.
  69193. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  69194. */
  69195. opacityRGB: boolean;
  69196. /**
  69197. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69198. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  69199. */
  69200. useRadianceOverAlpha: boolean;
  69201. /**
  69202. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69203. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  69204. */
  69205. useSpecularOverAlpha: boolean;
  69206. /**
  69207. * Enables specular anti aliasing in the PBR shader.
  69208. * It will both interacts on the Geometry for analytical and IBL lighting.
  69209. * It also prefilter the roughness map based on the bump values.
  69210. */
  69211. enableSpecularAntiAliasing: boolean;
  69212. /**
  69213. * Enables realtime filtering on the texture.
  69214. */
  69215. realTimeFiltering: boolean;
  69216. /**
  69217. * Quality switch for realtime filtering
  69218. */
  69219. realTimeFilteringQuality: number;
  69220. /**
  69221. * Defines if the material uses energy conservation.
  69222. */
  69223. useEnergyConservation: boolean;
  69224. /**
  69225. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69226. * too much the area relying on ambient texture to define their ambient occlusion.
  69227. */
  69228. useRadianceOcclusion: boolean;
  69229. /**
  69230. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69231. * makes the reflect vector face the model (under horizon).
  69232. */
  69233. useHorizonOcclusion: boolean;
  69234. /**
  69235. * If set to true, no lighting calculations will be applied.
  69236. */
  69237. unlit: boolean;
  69238. /**
  69239. * Force normal to face away from face.
  69240. */
  69241. forceNormalForward: boolean;
  69242. /**
  69243. * Defines the material debug mode.
  69244. * It helps seeing only some components of the material while troubleshooting.
  69245. */
  69246. debugMode: number;
  69247. /**
  69248. * Specify from where on screen the debug mode should start.
  69249. * The value goes from -1 (full screen) to 1 (not visible)
  69250. * It helps with side by side comparison against the final render
  69251. * This defaults to 0
  69252. */
  69253. debugLimit: number;
  69254. /**
  69255. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69256. * You can use the factor to better multiply the final value.
  69257. */
  69258. debugFactor: number;
  69259. /**
  69260. * Initialize the block and prepare the context for build
  69261. * @param state defines the state that will be used for the build
  69262. */
  69263. initialize(state: NodeMaterialBuildState): void;
  69264. /**
  69265. * Gets the current class name
  69266. * @returns the class name
  69267. */
  69268. getClassName(): string;
  69269. /**
  69270. * Gets the world position input component
  69271. */
  69272. get worldPosition(): NodeMaterialConnectionPoint;
  69273. /**
  69274. * Gets the world normal input component
  69275. */
  69276. get worldNormal(): NodeMaterialConnectionPoint;
  69277. /**
  69278. * Gets the perturbed normal input component
  69279. */
  69280. get perturbedNormal(): NodeMaterialConnectionPoint;
  69281. /**
  69282. * Gets the camera position input component
  69283. */
  69284. get cameraPosition(): NodeMaterialConnectionPoint;
  69285. /**
  69286. * Gets the base color input component
  69287. */
  69288. get baseColor(): NodeMaterialConnectionPoint;
  69289. /**
  69290. * Gets the opacity texture input component
  69291. */
  69292. get opacityTexture(): NodeMaterialConnectionPoint;
  69293. /**
  69294. * Gets the ambient color input component
  69295. */
  69296. get ambientColor(): NodeMaterialConnectionPoint;
  69297. /**
  69298. * Gets the reflectivity object parameters
  69299. */
  69300. get reflectivity(): NodeMaterialConnectionPoint;
  69301. /**
  69302. * Gets the ambient occlusion object parameters
  69303. */
  69304. get ambientOcc(): NodeMaterialConnectionPoint;
  69305. /**
  69306. * Gets the reflection object parameters
  69307. */
  69308. get reflection(): NodeMaterialConnectionPoint;
  69309. /**
  69310. * Gets the sheen object parameters
  69311. */
  69312. get sheen(): NodeMaterialConnectionPoint;
  69313. /**
  69314. * Gets the clear coat object parameters
  69315. */
  69316. get clearcoat(): NodeMaterialConnectionPoint;
  69317. /**
  69318. * Gets the sub surface object parameters
  69319. */
  69320. get subsurface(): NodeMaterialConnectionPoint;
  69321. /**
  69322. * Gets the anisotropy object parameters
  69323. */
  69324. get anisotropy(): NodeMaterialConnectionPoint;
  69325. /**
  69326. * Gets the view matrix parameter
  69327. */
  69328. get view(): NodeMaterialConnectionPoint;
  69329. /**
  69330. * Gets the ambient output component
  69331. */
  69332. get ambient(): NodeMaterialConnectionPoint;
  69333. /**
  69334. * Gets the diffuse output component
  69335. */
  69336. get diffuse(): NodeMaterialConnectionPoint;
  69337. /**
  69338. * Gets the specular output component
  69339. */
  69340. get specular(): NodeMaterialConnectionPoint;
  69341. /**
  69342. * Gets the sheen output component
  69343. */
  69344. get sheenDir(): NodeMaterialConnectionPoint;
  69345. /**
  69346. * Gets the clear coat output component
  69347. */
  69348. get clearcoatDir(): NodeMaterialConnectionPoint;
  69349. /**
  69350. * Gets the indirect diffuse output component
  69351. */
  69352. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69353. /**
  69354. * Gets the indirect specular output component
  69355. */
  69356. get specularIndirect(): NodeMaterialConnectionPoint;
  69357. /**
  69358. * Gets the indirect sheen output component
  69359. */
  69360. get sheenIndirect(): NodeMaterialConnectionPoint;
  69361. /**
  69362. * Gets the indirect clear coat output component
  69363. */
  69364. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69365. /**
  69366. * Gets the refraction output component
  69367. */
  69368. get refraction(): NodeMaterialConnectionPoint;
  69369. /**
  69370. * Gets the global lighting output component
  69371. */
  69372. get lighting(): NodeMaterialConnectionPoint;
  69373. /**
  69374. * Gets the shadow output component
  69375. */
  69376. get shadow(): NodeMaterialConnectionPoint;
  69377. /**
  69378. * Gets the alpha output component
  69379. */
  69380. get alpha(): NodeMaterialConnectionPoint;
  69381. autoConfigure(material: NodeMaterial): void;
  69382. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69383. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69384. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69385. private _injectVertexCode;
  69386. /**
  69387. * Gets the code corresponding to the albedo/opacity module
  69388. * @returns the shader code
  69389. */
  69390. getAlbedoOpacityCode(): string;
  69391. protected _buildBlock(state: NodeMaterialBuildState): this;
  69392. protected _dumpPropertiesCode(): string;
  69393. serialize(): any;
  69394. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69395. }
  69396. }
  69397. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  69398. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  69399. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  69400. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  69401. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  69402. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  69403. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69404. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  69405. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  69406. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  69407. }
  69408. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  69409. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  69410. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  69411. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  69412. }
  69413. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  69414. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69415. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69416. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69417. /**
  69418. * Block used to compute value of one parameter modulo another
  69419. */
  69420. export class ModBlock extends NodeMaterialBlock {
  69421. /**
  69422. * Creates a new ModBlock
  69423. * @param name defines the block name
  69424. */
  69425. constructor(name: string);
  69426. /**
  69427. * Gets the current class name
  69428. * @returns the class name
  69429. */
  69430. getClassName(): string;
  69431. /**
  69432. * Gets the left operand input component
  69433. */
  69434. get left(): NodeMaterialConnectionPoint;
  69435. /**
  69436. * Gets the right operand input component
  69437. */
  69438. get right(): NodeMaterialConnectionPoint;
  69439. /**
  69440. * Gets the output component
  69441. */
  69442. get output(): NodeMaterialConnectionPoint;
  69443. protected _buildBlock(state: NodeMaterialBuildState): this;
  69444. }
  69445. }
  69446. declare module "babylonjs/Materials/Node/Blocks/index" {
  69447. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  69448. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  69449. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69450. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69451. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69452. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69453. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69454. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69455. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69456. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69457. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69458. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69459. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69460. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69461. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69462. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69463. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69464. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69465. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69466. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69467. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69468. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69469. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69470. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69471. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69472. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69473. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69474. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69475. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69476. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69477. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69478. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69479. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69480. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69481. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69482. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69483. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69484. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69485. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69486. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69487. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69488. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69489. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69490. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69491. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69492. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69493. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69494. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69495. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69496. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69497. }
  69498. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69499. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69500. }
  69501. declare module "babylonjs/Materials/Node/index" {
  69502. export * from "babylonjs/Materials/Node/Enums/index";
  69503. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69504. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69505. export * from "babylonjs/Materials/Node/nodeMaterial";
  69506. export * from "babylonjs/Materials/Node/Blocks/index";
  69507. export * from "babylonjs/Materials/Node/Optimizers/index";
  69508. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69509. }
  69510. declare module "babylonjs/Materials/index" {
  69511. export * from "babylonjs/Materials/Background/index";
  69512. export * from "babylonjs/Materials/colorCurves";
  69513. export * from "babylonjs/Materials/iEffectFallbacks";
  69514. export * from "babylonjs/Materials/effectFallbacks";
  69515. export * from "babylonjs/Materials/effect";
  69516. export * from "babylonjs/Materials/fresnelParameters";
  69517. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69518. export * from "babylonjs/Materials/material";
  69519. export * from "babylonjs/Materials/materialDefines";
  69520. export * from "babylonjs/Materials/thinMaterialHelper";
  69521. export * from "babylonjs/Materials/materialHelper";
  69522. export * from "babylonjs/Materials/multiMaterial";
  69523. export * from "babylonjs/Materials/PBR/index";
  69524. export * from "babylonjs/Materials/pushMaterial";
  69525. export * from "babylonjs/Materials/shaderMaterial";
  69526. export * from "babylonjs/Materials/standardMaterial";
  69527. export * from "babylonjs/Materials/Textures/index";
  69528. export * from "babylonjs/Materials/uniformBuffer";
  69529. export * from "babylonjs/Materials/materialFlags";
  69530. export * from "babylonjs/Materials/Node/index";
  69531. export * from "babylonjs/Materials/effectRenderer";
  69532. export * from "babylonjs/Materials/shadowDepthWrapper";
  69533. }
  69534. declare module "babylonjs/Maths/index" {
  69535. export * from "babylonjs/Maths/math.scalar";
  69536. export * from "babylonjs/Maths/math";
  69537. export * from "babylonjs/Maths/sphericalPolynomial";
  69538. }
  69539. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69540. import { IDisposable } from "babylonjs/scene";
  69541. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69542. /**
  69543. * Configuration for Draco compression
  69544. */
  69545. export interface IDracoCompressionConfiguration {
  69546. /**
  69547. * Configuration for the decoder.
  69548. */
  69549. decoder: {
  69550. /**
  69551. * The url to the WebAssembly module.
  69552. */
  69553. wasmUrl?: string;
  69554. /**
  69555. * The url to the WebAssembly binary.
  69556. */
  69557. wasmBinaryUrl?: string;
  69558. /**
  69559. * The url to the fallback JavaScript module.
  69560. */
  69561. fallbackUrl?: string;
  69562. };
  69563. }
  69564. /**
  69565. * Draco compression (https://google.github.io/draco/)
  69566. *
  69567. * This class wraps the Draco module.
  69568. *
  69569. * **Encoder**
  69570. *
  69571. * The encoder is not currently implemented.
  69572. *
  69573. * **Decoder**
  69574. *
  69575. * 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.
  69576. *
  69577. * To update the configuration, use the following code:
  69578. * ```javascript
  69579. * DracoCompression.Configuration = {
  69580. * decoder: {
  69581. * wasmUrl: "<url to the WebAssembly library>",
  69582. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69583. * fallbackUrl: "<url to the fallback JavaScript library>",
  69584. * }
  69585. * };
  69586. * ```
  69587. *
  69588. * 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.
  69589. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69590. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69591. *
  69592. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69593. * ```javascript
  69594. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69595. * ```
  69596. *
  69597. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69598. */
  69599. export class DracoCompression implements IDisposable {
  69600. private _workerPoolPromise?;
  69601. private _decoderModulePromise?;
  69602. /**
  69603. * The configuration. Defaults to the following urls:
  69604. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69605. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69606. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69607. */
  69608. static Configuration: IDracoCompressionConfiguration;
  69609. /**
  69610. * Returns true if the decoder configuration is available.
  69611. */
  69612. static get DecoderAvailable(): boolean;
  69613. /**
  69614. * Default number of workers to create when creating the draco compression object.
  69615. */
  69616. static DefaultNumWorkers: number;
  69617. private static GetDefaultNumWorkers;
  69618. private static _Default;
  69619. /**
  69620. * Default instance for the draco compression object.
  69621. */
  69622. static get Default(): DracoCompression;
  69623. /**
  69624. * Constructor
  69625. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69626. */
  69627. constructor(numWorkers?: number);
  69628. /**
  69629. * Stop all async operations and release resources.
  69630. */
  69631. dispose(): void;
  69632. /**
  69633. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69634. * @returns a promise that resolves when ready
  69635. */
  69636. whenReadyAsync(): Promise<void>;
  69637. /**
  69638. * Decode Draco compressed mesh data to vertex data.
  69639. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69640. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69641. * @returns A promise that resolves with the decoded vertex data
  69642. */
  69643. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69644. [kind: string]: number;
  69645. }): Promise<VertexData>;
  69646. }
  69647. }
  69648. declare module "babylonjs/Meshes/Compression/index" {
  69649. export * from "babylonjs/Meshes/Compression/dracoCompression";
  69650. }
  69651. declare module "babylonjs/Meshes/csg" {
  69652. import { Nullable } from "babylonjs/types";
  69653. import { Scene } from "babylonjs/scene";
  69654. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  69655. import { Mesh } from "babylonjs/Meshes/mesh";
  69656. import { Material } from "babylonjs/Materials/material";
  69657. /**
  69658. * Class for building Constructive Solid Geometry
  69659. */
  69660. export class CSG {
  69661. private polygons;
  69662. /**
  69663. * The world matrix
  69664. */
  69665. matrix: Matrix;
  69666. /**
  69667. * Stores the position
  69668. */
  69669. position: Vector3;
  69670. /**
  69671. * Stores the rotation
  69672. */
  69673. rotation: Vector3;
  69674. /**
  69675. * Stores the rotation quaternion
  69676. */
  69677. rotationQuaternion: Nullable<Quaternion>;
  69678. /**
  69679. * Stores the scaling vector
  69680. */
  69681. scaling: Vector3;
  69682. /**
  69683. * Convert the Mesh to CSG
  69684. * @param mesh The Mesh to convert to CSG
  69685. * @returns A new CSG from the Mesh
  69686. */
  69687. static FromMesh(mesh: Mesh): CSG;
  69688. /**
  69689. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69690. * @param polygons Polygons used to construct a CSG solid
  69691. */
  69692. private static FromPolygons;
  69693. /**
  69694. * Clones, or makes a deep copy, of the CSG
  69695. * @returns A new CSG
  69696. */
  69697. clone(): CSG;
  69698. /**
  69699. * Unions this CSG with another CSG
  69700. * @param csg The CSG to union against this CSG
  69701. * @returns The unioned CSG
  69702. */
  69703. union(csg: CSG): CSG;
  69704. /**
  69705. * Unions this CSG with another CSG in place
  69706. * @param csg The CSG to union against this CSG
  69707. */
  69708. unionInPlace(csg: CSG): void;
  69709. /**
  69710. * Subtracts this CSG with another CSG
  69711. * @param csg The CSG to subtract against this CSG
  69712. * @returns A new CSG
  69713. */
  69714. subtract(csg: CSG): CSG;
  69715. /**
  69716. * Subtracts this CSG with another CSG in place
  69717. * @param csg The CSG to subtact against this CSG
  69718. */
  69719. subtractInPlace(csg: CSG): void;
  69720. /**
  69721. * Intersect this CSG with another CSG
  69722. * @param csg The CSG to intersect against this CSG
  69723. * @returns A new CSG
  69724. */
  69725. intersect(csg: CSG): CSG;
  69726. /**
  69727. * Intersects this CSG with another CSG in place
  69728. * @param csg The CSG to intersect against this CSG
  69729. */
  69730. intersectInPlace(csg: CSG): void;
  69731. /**
  69732. * Return a new CSG solid with solid and empty space switched. This solid is
  69733. * not modified.
  69734. * @returns A new CSG solid with solid and empty space switched
  69735. */
  69736. inverse(): CSG;
  69737. /**
  69738. * Inverses the CSG in place
  69739. */
  69740. inverseInPlace(): void;
  69741. /**
  69742. * This is used to keep meshes transformations so they can be restored
  69743. * when we build back a Babylon Mesh
  69744. * NB : All CSG operations are performed in world coordinates
  69745. * @param csg The CSG to copy the transform attributes from
  69746. * @returns This CSG
  69747. */
  69748. copyTransformAttributes(csg: CSG): CSG;
  69749. /**
  69750. * Build Raw mesh from CSG
  69751. * Coordinates here are in world space
  69752. * @param name The name of the mesh geometry
  69753. * @param scene The Scene
  69754. * @param keepSubMeshes Specifies if the submeshes should be kept
  69755. * @returns A new Mesh
  69756. */
  69757. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69758. /**
  69759. * Build Mesh from CSG taking material and transforms into account
  69760. * @param name The name of the Mesh
  69761. * @param material The material of the Mesh
  69762. * @param scene The Scene
  69763. * @param keepSubMeshes Specifies if submeshes should be kept
  69764. * @returns The new Mesh
  69765. */
  69766. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69767. }
  69768. }
  69769. declare module "babylonjs/Meshes/trailMesh" {
  69770. import { Mesh } from "babylonjs/Meshes/mesh";
  69771. import { Scene } from "babylonjs/scene";
  69772. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69773. /**
  69774. * Class used to create a trail following a mesh
  69775. */
  69776. export class TrailMesh extends Mesh {
  69777. private _generator;
  69778. private _autoStart;
  69779. private _running;
  69780. private _diameter;
  69781. private _length;
  69782. private _sectionPolygonPointsCount;
  69783. private _sectionVectors;
  69784. private _sectionNormalVectors;
  69785. private _beforeRenderObserver;
  69786. /**
  69787. * @constructor
  69788. * @param name The value used by scene.getMeshByName() to do a lookup.
  69789. * @param generator The mesh or transform node to generate a trail.
  69790. * @param scene The scene to add this mesh to.
  69791. * @param diameter Diameter of trailing mesh. Default is 1.
  69792. * @param length Length of trailing mesh. Default is 60.
  69793. * @param autoStart Automatically start trailing mesh. Default true.
  69794. */
  69795. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69796. /**
  69797. * "TrailMesh"
  69798. * @returns "TrailMesh"
  69799. */
  69800. getClassName(): string;
  69801. private _createMesh;
  69802. /**
  69803. * Start trailing mesh.
  69804. */
  69805. start(): void;
  69806. /**
  69807. * Stop trailing mesh.
  69808. */
  69809. stop(): void;
  69810. /**
  69811. * Update trailing mesh geometry.
  69812. */
  69813. update(): void;
  69814. /**
  69815. * Returns a new TrailMesh object.
  69816. * @param name is a string, the name given to the new mesh
  69817. * @param newGenerator use new generator object for cloned trail mesh
  69818. * @returns a new mesh
  69819. */
  69820. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69821. /**
  69822. * Serializes this trail mesh
  69823. * @param serializationObject object to write serialization to
  69824. */
  69825. serialize(serializationObject: any): void;
  69826. /**
  69827. * Parses a serialized trail mesh
  69828. * @param parsedMesh the serialized mesh
  69829. * @param scene the scene to create the trail mesh in
  69830. * @returns the created trail mesh
  69831. */
  69832. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69833. }
  69834. }
  69835. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  69836. import { Nullable } from "babylonjs/types";
  69837. import { Scene } from "babylonjs/scene";
  69838. import { Vector4 } from "babylonjs/Maths/math.vector";
  69839. import { Color4 } from "babylonjs/Maths/math.color";
  69840. import { Mesh } from "babylonjs/Meshes/mesh";
  69841. /**
  69842. * Class containing static functions to help procedurally build meshes
  69843. */
  69844. export class TiledBoxBuilder {
  69845. /**
  69846. * Creates a box mesh
  69847. * 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)
  69848. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69852. * @param name defines the name of the mesh
  69853. * @param options defines the options used to create the mesh
  69854. * @param scene defines the hosting scene
  69855. * @returns the box mesh
  69856. */
  69857. static CreateTiledBox(name: string, options: {
  69858. pattern?: number;
  69859. width?: number;
  69860. height?: number;
  69861. depth?: number;
  69862. tileSize?: number;
  69863. tileWidth?: number;
  69864. tileHeight?: number;
  69865. alignHorizontal?: number;
  69866. alignVertical?: number;
  69867. faceUV?: Vector4[];
  69868. faceColors?: Color4[];
  69869. sideOrientation?: number;
  69870. updatable?: boolean;
  69871. }, scene?: Nullable<Scene>): Mesh;
  69872. }
  69873. }
  69874. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  69875. import { Vector4 } from "babylonjs/Maths/math.vector";
  69876. import { Mesh } from "babylonjs/Meshes/mesh";
  69877. /**
  69878. * Class containing static functions to help procedurally build meshes
  69879. */
  69880. export class TorusKnotBuilder {
  69881. /**
  69882. * Creates a torus knot mesh
  69883. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69884. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69885. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69886. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69890. * @param name defines the name of the mesh
  69891. * @param options defines the options used to create the mesh
  69892. * @param scene defines the hosting scene
  69893. * @returns the torus knot mesh
  69894. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69895. */
  69896. static CreateTorusKnot(name: string, options: {
  69897. radius?: number;
  69898. tube?: number;
  69899. radialSegments?: number;
  69900. tubularSegments?: number;
  69901. p?: number;
  69902. q?: number;
  69903. updatable?: boolean;
  69904. sideOrientation?: number;
  69905. frontUVs?: Vector4;
  69906. backUVs?: Vector4;
  69907. }, scene: any): Mesh;
  69908. }
  69909. }
  69910. declare module "babylonjs/Meshes/polygonMesh" {
  69911. import { Scene } from "babylonjs/scene";
  69912. import { Vector2 } from "babylonjs/Maths/math.vector";
  69913. import { Mesh } from "babylonjs/Meshes/mesh";
  69914. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69915. import { Path2 } from "babylonjs/Maths/math.path";
  69916. /**
  69917. * Polygon
  69918. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69919. */
  69920. export class Polygon {
  69921. /**
  69922. * Creates a rectangle
  69923. * @param xmin bottom X coord
  69924. * @param ymin bottom Y coord
  69925. * @param xmax top X coord
  69926. * @param ymax top Y coord
  69927. * @returns points that make the resulting rectation
  69928. */
  69929. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69930. /**
  69931. * Creates a circle
  69932. * @param radius radius of circle
  69933. * @param cx scale in x
  69934. * @param cy scale in y
  69935. * @param numberOfSides number of sides that make up the circle
  69936. * @returns points that make the resulting circle
  69937. */
  69938. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69939. /**
  69940. * Creates a polygon from input string
  69941. * @param input Input polygon data
  69942. * @returns the parsed points
  69943. */
  69944. static Parse(input: string): Vector2[];
  69945. /**
  69946. * Starts building a polygon from x and y coordinates
  69947. * @param x x coordinate
  69948. * @param y y coordinate
  69949. * @returns the started path2
  69950. */
  69951. static StartingAt(x: number, y: number): Path2;
  69952. }
  69953. /**
  69954. * Builds a polygon
  69955. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69956. */
  69957. export class PolygonMeshBuilder {
  69958. private _points;
  69959. private _outlinepoints;
  69960. private _holes;
  69961. private _name;
  69962. private _scene;
  69963. private _epoints;
  69964. private _eholes;
  69965. private _addToepoint;
  69966. /**
  69967. * Babylon reference to the earcut plugin.
  69968. */
  69969. bjsEarcut: any;
  69970. /**
  69971. * Creates a PolygonMeshBuilder
  69972. * @param name name of the builder
  69973. * @param contours Path of the polygon
  69974. * @param scene scene to add to when creating the mesh
  69975. * @param earcutInjection can be used to inject your own earcut reference
  69976. */
  69977. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69978. /**
  69979. * Adds a whole within the polygon
  69980. * @param hole Array of points defining the hole
  69981. * @returns this
  69982. */
  69983. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69984. /**
  69985. * Creates the polygon
  69986. * @param updatable If the mesh should be updatable
  69987. * @param depth The depth of the mesh created
  69988. * @returns the created mesh
  69989. */
  69990. build(updatable?: boolean, depth?: number): Mesh;
  69991. /**
  69992. * Creates the polygon
  69993. * @param depth The depth of the mesh created
  69994. * @returns the created VertexData
  69995. */
  69996. buildVertexData(depth?: number): VertexData;
  69997. /**
  69998. * Adds a side to the polygon
  69999. * @param positions points that make the polygon
  70000. * @param normals normals of the polygon
  70001. * @param uvs uvs of the polygon
  70002. * @param indices indices of the polygon
  70003. * @param bounds bounds of the polygon
  70004. * @param points points of the polygon
  70005. * @param depth depth of the polygon
  70006. * @param flip flip of the polygon
  70007. */
  70008. private addSide;
  70009. }
  70010. }
  70011. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  70012. import { Scene } from "babylonjs/scene";
  70013. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70014. import { Color4 } from "babylonjs/Maths/math.color";
  70015. import { Mesh } from "babylonjs/Meshes/mesh";
  70016. import { Nullable } from "babylonjs/types";
  70017. /**
  70018. * Class containing static functions to help procedurally build meshes
  70019. */
  70020. export class PolygonBuilder {
  70021. /**
  70022. * Creates a polygon mesh
  70023. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70024. * * 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
  70025. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70027. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70028. * * Remember you can only change the shape positions, not their number when updating a polygon
  70029. * @param name defines the name of the mesh
  70030. * @param options defines the options used to create the mesh
  70031. * @param scene defines the hosting scene
  70032. * @param earcutInjection can be used to inject your own earcut reference
  70033. * @returns the polygon mesh
  70034. */
  70035. static CreatePolygon(name: string, options: {
  70036. shape: Vector3[];
  70037. holes?: Vector3[][];
  70038. depth?: number;
  70039. faceUV?: Vector4[];
  70040. faceColors?: Color4[];
  70041. updatable?: boolean;
  70042. sideOrientation?: number;
  70043. frontUVs?: Vector4;
  70044. backUVs?: Vector4;
  70045. wrap?: boolean;
  70046. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70047. /**
  70048. * Creates an extruded polygon mesh, with depth in the Y direction.
  70049. * * 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)
  70050. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70051. * @param name defines the name of the mesh
  70052. * @param options defines the options used to create the mesh
  70053. * @param scene defines the hosting scene
  70054. * @param earcutInjection can be used to inject your own earcut reference
  70055. * @returns the polygon mesh
  70056. */
  70057. static ExtrudePolygon(name: string, options: {
  70058. shape: Vector3[];
  70059. holes?: Vector3[][];
  70060. depth?: number;
  70061. faceUV?: Vector4[];
  70062. faceColors?: Color4[];
  70063. updatable?: boolean;
  70064. sideOrientation?: number;
  70065. frontUVs?: Vector4;
  70066. backUVs?: Vector4;
  70067. wrap?: boolean;
  70068. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70069. }
  70070. }
  70071. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  70072. import { Scene } from "babylonjs/scene";
  70073. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70074. import { Mesh } from "babylonjs/Meshes/mesh";
  70075. import { Nullable } from "babylonjs/types";
  70076. /**
  70077. * Class containing static functions to help procedurally build meshes
  70078. */
  70079. export class LatheBuilder {
  70080. /**
  70081. * Creates lathe mesh.
  70082. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70083. * * 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
  70084. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70085. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70086. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70087. * * 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
  70088. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70089. * * 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
  70090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70091. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70092. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70094. * @param name defines the name of the mesh
  70095. * @param options defines the options used to create the mesh
  70096. * @param scene defines the hosting scene
  70097. * @returns the lathe mesh
  70098. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70099. */
  70100. static CreateLathe(name: string, options: {
  70101. shape: Vector3[];
  70102. radius?: number;
  70103. tessellation?: number;
  70104. clip?: number;
  70105. arc?: number;
  70106. closed?: boolean;
  70107. updatable?: boolean;
  70108. sideOrientation?: number;
  70109. frontUVs?: Vector4;
  70110. backUVs?: Vector4;
  70111. cap?: number;
  70112. invertUV?: boolean;
  70113. }, scene?: Nullable<Scene>): Mesh;
  70114. }
  70115. }
  70116. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  70117. import { Nullable } from "babylonjs/types";
  70118. import { Scene } from "babylonjs/scene";
  70119. import { Vector4 } from "babylonjs/Maths/math.vector";
  70120. import { Mesh } from "babylonjs/Meshes/mesh";
  70121. /**
  70122. * Class containing static functions to help procedurally build meshes
  70123. */
  70124. export class TiledPlaneBuilder {
  70125. /**
  70126. * Creates a tiled plane mesh
  70127. * * The parameter `pattern` will, depending on value, do nothing or
  70128. * * * flip (reflect about central vertical) alternate tiles across and up
  70129. * * * flip every tile on alternate rows
  70130. * * * rotate (180 degs) alternate tiles across and up
  70131. * * * rotate every tile on alternate rows
  70132. * * * flip and rotate alternate tiles across and up
  70133. * * * flip and rotate every tile on alternate rows
  70134. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70135. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70136. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70137. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70138. * * 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)
  70139. * * 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)
  70140. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  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 box mesh
  70145. */
  70146. static CreateTiledPlane(name: string, options: {
  70147. pattern?: number;
  70148. tileSize?: number;
  70149. tileWidth?: number;
  70150. tileHeight?: number;
  70151. size?: number;
  70152. width?: number;
  70153. height?: number;
  70154. alignHorizontal?: number;
  70155. alignVertical?: number;
  70156. sideOrientation?: number;
  70157. frontUVs?: Vector4;
  70158. backUVs?: Vector4;
  70159. updatable?: boolean;
  70160. }, scene?: Nullable<Scene>): Mesh;
  70161. }
  70162. }
  70163. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  70164. import { Nullable } from "babylonjs/types";
  70165. import { Scene } from "babylonjs/scene";
  70166. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70167. import { Mesh } from "babylonjs/Meshes/mesh";
  70168. /**
  70169. * Class containing static functions to help procedurally build meshes
  70170. */
  70171. export class TubeBuilder {
  70172. /**
  70173. * Creates a tube mesh.
  70174. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70175. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70176. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70177. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70178. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70179. * * 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)
  70180. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70181. * * 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
  70182. * * 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
  70183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70184. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70185. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70187. * @param name defines the name of the mesh
  70188. * @param options defines the options used to create the mesh
  70189. * @param scene defines the hosting scene
  70190. * @returns the tube mesh
  70191. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70192. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70193. */
  70194. static CreateTube(name: string, options: {
  70195. path: Vector3[];
  70196. radius?: number;
  70197. tessellation?: number;
  70198. radiusFunction?: {
  70199. (i: number, distance: number): number;
  70200. };
  70201. cap?: number;
  70202. arc?: number;
  70203. updatable?: boolean;
  70204. sideOrientation?: number;
  70205. frontUVs?: Vector4;
  70206. backUVs?: Vector4;
  70207. instance?: Mesh;
  70208. invertUV?: boolean;
  70209. }, scene?: Nullable<Scene>): Mesh;
  70210. }
  70211. }
  70212. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  70213. import { Scene } from "babylonjs/scene";
  70214. import { Vector4 } from "babylonjs/Maths/math.vector";
  70215. import { Mesh } from "babylonjs/Meshes/mesh";
  70216. import { Nullable } from "babylonjs/types";
  70217. /**
  70218. * Class containing static functions to help procedurally build meshes
  70219. */
  70220. export class IcoSphereBuilder {
  70221. /**
  70222. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70223. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70224. * * 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`)
  70225. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70226. * * 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
  70227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70228. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70230. * @param name defines the name of the mesh
  70231. * @param options defines the options used to create the mesh
  70232. * @param scene defines the hosting scene
  70233. * @returns the icosahedron mesh
  70234. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70235. */
  70236. static CreateIcoSphere(name: string, options: {
  70237. radius?: number;
  70238. radiusX?: number;
  70239. radiusY?: number;
  70240. radiusZ?: number;
  70241. flat?: boolean;
  70242. subdivisions?: number;
  70243. sideOrientation?: number;
  70244. frontUVs?: Vector4;
  70245. backUVs?: Vector4;
  70246. updatable?: boolean;
  70247. }, scene?: Nullable<Scene>): Mesh;
  70248. }
  70249. }
  70250. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  70251. import { Vector3 } from "babylonjs/Maths/math.vector";
  70252. import { Mesh } from "babylonjs/Meshes/mesh";
  70253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70254. /**
  70255. * Class containing static functions to help procedurally build meshes
  70256. */
  70257. export class DecalBuilder {
  70258. /**
  70259. * Creates a decal mesh.
  70260. * 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
  70261. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70262. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70263. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70264. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70265. * @param name defines the name of the mesh
  70266. * @param sourceMesh defines the mesh where the decal must be applied
  70267. * @param options defines the options used to create the mesh
  70268. * @param scene defines the hosting scene
  70269. * @returns the decal mesh
  70270. * @see https://doc.babylonjs.com/how_to/decals
  70271. */
  70272. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70273. position?: Vector3;
  70274. normal?: Vector3;
  70275. size?: Vector3;
  70276. angle?: number;
  70277. }): Mesh;
  70278. }
  70279. }
  70280. declare module "babylonjs/Meshes/meshBuilder" {
  70281. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  70282. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  70283. import { Nullable } from "babylonjs/types";
  70284. import { Scene } from "babylonjs/scene";
  70285. import { Mesh } from "babylonjs/Meshes/mesh";
  70286. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  70287. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  70288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70289. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70290. import { Plane } from "babylonjs/Maths/math.plane";
  70291. /**
  70292. * Class containing static functions to help procedurally build meshes
  70293. */
  70294. export class MeshBuilder {
  70295. /**
  70296. * Creates a box mesh
  70297. * * The parameter `size` sets the size (float) of each box side (default 1)
  70298. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70299. * * 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)
  70300. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70302. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70304. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70305. * @param name defines the name of the mesh
  70306. * @param options defines the options used to create the mesh
  70307. * @param scene defines the hosting scene
  70308. * @returns the box mesh
  70309. */
  70310. static CreateBox(name: string, options: {
  70311. size?: number;
  70312. width?: number;
  70313. height?: number;
  70314. depth?: number;
  70315. faceUV?: Vector4[];
  70316. faceColors?: Color4[];
  70317. sideOrientation?: number;
  70318. frontUVs?: Vector4;
  70319. backUVs?: Vector4;
  70320. wrap?: boolean;
  70321. topBaseAt?: number;
  70322. bottomBaseAt?: number;
  70323. updatable?: boolean;
  70324. }, scene?: Nullable<Scene>): Mesh;
  70325. /**
  70326. * Creates a tiled box mesh
  70327. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70329. * @param name defines the name of the mesh
  70330. * @param options defines the options used to create the mesh
  70331. * @param scene defines the hosting scene
  70332. * @returns the tiled box mesh
  70333. */
  70334. static CreateTiledBox(name: string, options: {
  70335. pattern?: number;
  70336. size?: number;
  70337. width?: number;
  70338. height?: number;
  70339. depth: number;
  70340. tileSize?: number;
  70341. tileWidth?: number;
  70342. tileHeight?: number;
  70343. faceUV?: Vector4[];
  70344. faceColors?: Color4[];
  70345. alignHorizontal?: number;
  70346. alignVertical?: number;
  70347. sideOrientation?: number;
  70348. updatable?: boolean;
  70349. }, scene?: Nullable<Scene>): Mesh;
  70350. /**
  70351. * Creates a sphere mesh
  70352. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70353. * * 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`)
  70354. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70355. * * 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
  70356. * * 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)
  70357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70360. * @param name defines the name of the mesh
  70361. * @param options defines the options used to create the mesh
  70362. * @param scene defines the hosting scene
  70363. * @returns the sphere mesh
  70364. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70365. */
  70366. static CreateSphere(name: string, options: {
  70367. segments?: number;
  70368. diameter?: number;
  70369. diameterX?: number;
  70370. diameterY?: number;
  70371. diameterZ?: number;
  70372. arc?: number;
  70373. slice?: number;
  70374. sideOrientation?: number;
  70375. frontUVs?: Vector4;
  70376. backUVs?: Vector4;
  70377. updatable?: boolean;
  70378. }, scene?: Nullable<Scene>): Mesh;
  70379. /**
  70380. * Creates a plane polygonal mesh. By default, this is a disc
  70381. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70382. * * 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
  70383. * * 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
  70384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70387. * @param name defines the name of the mesh
  70388. * @param options defines the options used to create the mesh
  70389. * @param scene defines the hosting scene
  70390. * @returns the plane polygonal mesh
  70391. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70392. */
  70393. static CreateDisc(name: string, options: {
  70394. radius?: number;
  70395. tessellation?: number;
  70396. arc?: number;
  70397. updatable?: boolean;
  70398. sideOrientation?: number;
  70399. frontUVs?: Vector4;
  70400. backUVs?: Vector4;
  70401. }, scene?: Nullable<Scene>): Mesh;
  70402. /**
  70403. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70404. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70405. * * 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`)
  70406. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70407. * * 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
  70408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70411. * @param name defines the name of the mesh
  70412. * @param options defines the options used to create the mesh
  70413. * @param scene defines the hosting scene
  70414. * @returns the icosahedron mesh
  70415. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70416. */
  70417. static CreateIcoSphere(name: string, options: {
  70418. radius?: number;
  70419. radiusX?: number;
  70420. radiusY?: number;
  70421. radiusZ?: number;
  70422. flat?: boolean;
  70423. subdivisions?: number;
  70424. sideOrientation?: number;
  70425. frontUVs?: Vector4;
  70426. backUVs?: Vector4;
  70427. updatable?: boolean;
  70428. }, scene?: Nullable<Scene>): Mesh;
  70429. /**
  70430. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70431. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70432. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70433. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70434. * * 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
  70435. * * 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
  70436. * * 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
  70437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70439. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70440. * * 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
  70441. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70442. * * 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
  70443. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70445. * @param name defines the name of the mesh
  70446. * @param options defines the options used to create the mesh
  70447. * @param scene defines the hosting scene
  70448. * @returns the ribbon mesh
  70449. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70450. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70451. */
  70452. static CreateRibbon(name: string, options: {
  70453. pathArray: Vector3[][];
  70454. closeArray?: boolean;
  70455. closePath?: boolean;
  70456. offset?: number;
  70457. updatable?: boolean;
  70458. sideOrientation?: number;
  70459. frontUVs?: Vector4;
  70460. backUVs?: Vector4;
  70461. instance?: Mesh;
  70462. invertUV?: boolean;
  70463. uvs?: Vector2[];
  70464. colors?: Color4[];
  70465. }, scene?: Nullable<Scene>): Mesh;
  70466. /**
  70467. * Creates a cylinder or a cone mesh
  70468. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70469. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70470. * * 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.
  70471. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70472. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70473. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70474. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70475. * * 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).
  70476. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70477. * * 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).
  70478. * * 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
  70479. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70480. * * 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
  70481. * * 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.
  70482. * * If `enclose` is false, a ring surface is one element.
  70483. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70484. * * 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
  70485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70488. * @param name defines the name of the mesh
  70489. * @param options defines the options used to create the mesh
  70490. * @param scene defines the hosting scene
  70491. * @returns the cylinder mesh
  70492. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70493. */
  70494. static CreateCylinder(name: string, options: {
  70495. height?: number;
  70496. diameterTop?: number;
  70497. diameterBottom?: number;
  70498. diameter?: number;
  70499. tessellation?: number;
  70500. subdivisions?: number;
  70501. arc?: number;
  70502. faceColors?: Color4[];
  70503. faceUV?: Vector4[];
  70504. updatable?: boolean;
  70505. hasRings?: boolean;
  70506. enclose?: boolean;
  70507. cap?: number;
  70508. sideOrientation?: number;
  70509. frontUVs?: Vector4;
  70510. backUVs?: Vector4;
  70511. }, scene?: Nullable<Scene>): Mesh;
  70512. /**
  70513. * Creates a torus mesh
  70514. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70515. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70516. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70520. * @param name defines the name of the mesh
  70521. * @param options defines the options used to create the mesh
  70522. * @param scene defines the hosting scene
  70523. * @returns the torus mesh
  70524. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70525. */
  70526. static CreateTorus(name: string, options: {
  70527. diameter?: number;
  70528. thickness?: number;
  70529. tessellation?: number;
  70530. updatable?: boolean;
  70531. sideOrientation?: number;
  70532. frontUVs?: Vector4;
  70533. backUVs?: Vector4;
  70534. }, scene?: Nullable<Scene>): Mesh;
  70535. /**
  70536. * Creates a torus knot mesh
  70537. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70538. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70539. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70540. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70544. * @param name defines the name of the mesh
  70545. * @param options defines the options used to create the mesh
  70546. * @param scene defines the hosting scene
  70547. * @returns the torus knot mesh
  70548. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70549. */
  70550. static CreateTorusKnot(name: string, options: {
  70551. radius?: number;
  70552. tube?: number;
  70553. radialSegments?: number;
  70554. tubularSegments?: number;
  70555. p?: number;
  70556. q?: number;
  70557. updatable?: boolean;
  70558. sideOrientation?: number;
  70559. frontUVs?: Vector4;
  70560. backUVs?: Vector4;
  70561. }, scene?: Nullable<Scene>): Mesh;
  70562. /**
  70563. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70564. * * 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
  70565. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70566. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70567. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70568. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70569. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70570. * * 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
  70571. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70573. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70574. * @param name defines the name of the new line system
  70575. * @param options defines the options used to create the line system
  70576. * @param scene defines the hosting scene
  70577. * @returns a new line system mesh
  70578. */
  70579. static CreateLineSystem(name: string, options: {
  70580. lines: Vector3[][];
  70581. updatable?: boolean;
  70582. instance?: Nullable<LinesMesh>;
  70583. colors?: Nullable<Color4[][]>;
  70584. useVertexAlpha?: boolean;
  70585. }, scene: Nullable<Scene>): LinesMesh;
  70586. /**
  70587. * Creates a line mesh
  70588. * 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
  70589. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70590. * * The parameter `points` is an array successive Vector3
  70591. * * 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
  70592. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70593. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70594. * * When updating an instance, remember that only point positions can change, not the number of points
  70595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70596. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70597. * @param name defines the name of the new line system
  70598. * @param options defines the options used to create the line system
  70599. * @param scene defines the hosting scene
  70600. * @returns a new line mesh
  70601. */
  70602. static CreateLines(name: string, options: {
  70603. points: Vector3[];
  70604. updatable?: boolean;
  70605. instance?: Nullable<LinesMesh>;
  70606. colors?: Color4[];
  70607. useVertexAlpha?: boolean;
  70608. }, scene?: Nullable<Scene>): LinesMesh;
  70609. /**
  70610. * Creates a dashed line mesh
  70611. * * 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
  70612. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70613. * * The parameter `points` is an array successive Vector3
  70614. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70615. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70616. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70617. * * 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
  70618. * * When updating an instance, remember that only point positions can change, not the number of points
  70619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70620. * @param name defines the name of the mesh
  70621. * @param options defines the options used to create the mesh
  70622. * @param scene defines the hosting scene
  70623. * @returns the dashed line mesh
  70624. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70625. */
  70626. static CreateDashedLines(name: string, options: {
  70627. points: Vector3[];
  70628. dashSize?: number;
  70629. gapSize?: number;
  70630. dashNb?: number;
  70631. updatable?: boolean;
  70632. instance?: LinesMesh;
  70633. }, scene?: Nullable<Scene>): LinesMesh;
  70634. /**
  70635. * 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.
  70636. * * 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.
  70637. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70638. * * 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.
  70639. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70640. * * 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
  70641. * * 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
  70642. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70645. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70647. * @param name defines the name of the mesh
  70648. * @param options defines the options used to create the mesh
  70649. * @param scene defines the hosting scene
  70650. * @returns the extruded shape mesh
  70651. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70652. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70653. */
  70654. static ExtrudeShape(name: string, options: {
  70655. shape: Vector3[];
  70656. path: Vector3[];
  70657. scale?: number;
  70658. rotation?: number;
  70659. cap?: number;
  70660. updatable?: boolean;
  70661. sideOrientation?: number;
  70662. frontUVs?: Vector4;
  70663. backUVs?: Vector4;
  70664. instance?: Mesh;
  70665. invertUV?: boolean;
  70666. }, scene?: Nullable<Scene>): Mesh;
  70667. /**
  70668. * Creates an custom extruded shape mesh.
  70669. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70670. * * 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.
  70671. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70672. * * 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
  70673. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70674. * * 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
  70675. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70676. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70677. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70678. * * 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
  70679. * * 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
  70680. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70683. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70685. * @param name defines the name of the mesh
  70686. * @param options defines the options used to create the mesh
  70687. * @param scene defines the hosting scene
  70688. * @returns the custom extruded shape mesh
  70689. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70690. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70691. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70692. */
  70693. static ExtrudeShapeCustom(name: string, options: {
  70694. shape: Vector3[];
  70695. path: Vector3[];
  70696. scaleFunction?: any;
  70697. rotationFunction?: any;
  70698. ribbonCloseArray?: boolean;
  70699. ribbonClosePath?: boolean;
  70700. cap?: number;
  70701. updatable?: boolean;
  70702. sideOrientation?: number;
  70703. frontUVs?: Vector4;
  70704. backUVs?: Vector4;
  70705. instance?: Mesh;
  70706. invertUV?: boolean;
  70707. }, scene?: Nullable<Scene>): Mesh;
  70708. /**
  70709. * Creates lathe mesh.
  70710. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70711. * * 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
  70712. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70713. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70714. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70715. * * 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
  70716. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70717. * * 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
  70718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70719. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70720. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70722. * @param name defines the name of the mesh
  70723. * @param options defines the options used to create the mesh
  70724. * @param scene defines the hosting scene
  70725. * @returns the lathe mesh
  70726. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70727. */
  70728. static CreateLathe(name: string, options: {
  70729. shape: Vector3[];
  70730. radius?: number;
  70731. tessellation?: number;
  70732. clip?: number;
  70733. arc?: number;
  70734. closed?: boolean;
  70735. updatable?: boolean;
  70736. sideOrientation?: number;
  70737. frontUVs?: Vector4;
  70738. backUVs?: Vector4;
  70739. cap?: number;
  70740. invertUV?: boolean;
  70741. }, scene?: Nullable<Scene>): Mesh;
  70742. /**
  70743. * Creates a tiled plane mesh
  70744. * * You can set a limited pattern arrangement with the tiles
  70745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70748. * @param name defines the name of the mesh
  70749. * @param options defines the options used to create the mesh
  70750. * @param scene defines the hosting scene
  70751. * @returns the plane mesh
  70752. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70753. */
  70754. static CreateTiledPlane(name: string, options: {
  70755. pattern?: number;
  70756. tileSize?: number;
  70757. tileWidth?: number;
  70758. tileHeight?: number;
  70759. size?: number;
  70760. width?: number;
  70761. height?: number;
  70762. alignHorizontal?: number;
  70763. alignVertical?: number;
  70764. sideOrientation?: number;
  70765. frontUVs?: Vector4;
  70766. backUVs?: Vector4;
  70767. updatable?: boolean;
  70768. }, scene?: Nullable<Scene>): Mesh;
  70769. /**
  70770. * Creates a plane mesh
  70771. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70772. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70773. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70775. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70777. * @param name defines the name of the mesh
  70778. * @param options defines the options used to create the mesh
  70779. * @param scene defines the hosting scene
  70780. * @returns the plane mesh
  70781. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70782. */
  70783. static CreatePlane(name: string, options: {
  70784. size?: number;
  70785. width?: number;
  70786. height?: number;
  70787. sideOrientation?: number;
  70788. frontUVs?: Vector4;
  70789. backUVs?: Vector4;
  70790. updatable?: boolean;
  70791. sourcePlane?: Plane;
  70792. }, scene?: Nullable<Scene>): Mesh;
  70793. /**
  70794. * Creates a ground mesh
  70795. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70796. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70798. * @param name defines the name of the mesh
  70799. * @param options defines the options used to create the mesh
  70800. * @param scene defines the hosting scene
  70801. * @returns the ground mesh
  70802. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70803. */
  70804. static CreateGround(name: string, options: {
  70805. width?: number;
  70806. height?: number;
  70807. subdivisions?: number;
  70808. subdivisionsX?: number;
  70809. subdivisionsY?: number;
  70810. updatable?: boolean;
  70811. }, scene?: Nullable<Scene>): Mesh;
  70812. /**
  70813. * Creates a tiled ground mesh
  70814. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70815. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70816. * * 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
  70817. * * 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
  70818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70819. * @param name defines the name of the mesh
  70820. * @param options defines the options used to create the mesh
  70821. * @param scene defines the hosting scene
  70822. * @returns the tiled ground mesh
  70823. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70824. */
  70825. static CreateTiledGround(name: string, options: {
  70826. xmin: number;
  70827. zmin: number;
  70828. xmax: number;
  70829. zmax: number;
  70830. subdivisions?: {
  70831. w: number;
  70832. h: number;
  70833. };
  70834. precision?: {
  70835. w: number;
  70836. h: number;
  70837. };
  70838. updatable?: boolean;
  70839. }, scene?: Nullable<Scene>): Mesh;
  70840. /**
  70841. * Creates a ground mesh from a height map
  70842. * * The parameter `url` sets the URL of the height map image resource.
  70843. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70844. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70845. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70846. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70847. * * 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.
  70848. * * 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).
  70849. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70851. * @param name defines the name of the mesh
  70852. * @param url defines the url to the height map
  70853. * @param options defines the options used to create the mesh
  70854. * @param scene defines the hosting scene
  70855. * @returns the ground mesh
  70856. * @see https://doc.babylonjs.com/babylon101/height_map
  70857. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70858. */
  70859. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70860. width?: number;
  70861. height?: number;
  70862. subdivisions?: number;
  70863. minHeight?: number;
  70864. maxHeight?: number;
  70865. colorFilter?: Color3;
  70866. alphaFilter?: number;
  70867. updatable?: boolean;
  70868. onReady?: (mesh: GroundMesh) => void;
  70869. }, scene?: Nullable<Scene>): GroundMesh;
  70870. /**
  70871. * Creates a polygon mesh
  70872. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70873. * * 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
  70874. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70877. * * Remember you can only change the shape positions, not their number when updating a polygon
  70878. * @param name defines the name of the mesh
  70879. * @param options defines the options used to create the mesh
  70880. * @param scene defines the hosting scene
  70881. * @param earcutInjection can be used to inject your own earcut reference
  70882. * @returns the polygon mesh
  70883. */
  70884. static CreatePolygon(name: string, options: {
  70885. shape: Vector3[];
  70886. holes?: Vector3[][];
  70887. depth?: number;
  70888. faceUV?: Vector4[];
  70889. faceColors?: Color4[];
  70890. updatable?: boolean;
  70891. sideOrientation?: number;
  70892. frontUVs?: Vector4;
  70893. backUVs?: Vector4;
  70894. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70895. /**
  70896. * Creates an extruded polygon mesh, with depth in the Y direction.
  70897. * * 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)
  70898. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70899. * @param name defines the name of the mesh
  70900. * @param options defines the options used to create the mesh
  70901. * @param scene defines the hosting scene
  70902. * @param earcutInjection can be used to inject your own earcut reference
  70903. * @returns the polygon mesh
  70904. */
  70905. static ExtrudePolygon(name: string, options: {
  70906. shape: Vector3[];
  70907. holes?: Vector3[][];
  70908. depth?: number;
  70909. faceUV?: Vector4[];
  70910. faceColors?: Color4[];
  70911. updatable?: boolean;
  70912. sideOrientation?: number;
  70913. frontUVs?: Vector4;
  70914. backUVs?: Vector4;
  70915. wrap?: boolean;
  70916. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70917. /**
  70918. * Creates a tube mesh.
  70919. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70920. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70921. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70922. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70923. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70924. * * 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)
  70925. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70926. * * 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
  70927. * * 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
  70928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70930. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70932. * @param name defines the name of the mesh
  70933. * @param options defines the options used to create the mesh
  70934. * @param scene defines the hosting scene
  70935. * @returns the tube mesh
  70936. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70937. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70938. */
  70939. static CreateTube(name: string, options: {
  70940. path: Vector3[];
  70941. radius?: number;
  70942. tessellation?: number;
  70943. radiusFunction?: {
  70944. (i: number, distance: number): number;
  70945. };
  70946. cap?: number;
  70947. arc?: number;
  70948. updatable?: boolean;
  70949. sideOrientation?: number;
  70950. frontUVs?: Vector4;
  70951. backUVs?: Vector4;
  70952. instance?: Mesh;
  70953. invertUV?: boolean;
  70954. }, scene?: Nullable<Scene>): Mesh;
  70955. /**
  70956. * Creates a polyhedron mesh
  70957. * * 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
  70958. * * The parameter `size` (positive float, default 1) sets the polygon size
  70959. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70960. * * 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`
  70961. * * 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
  70962. * * 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)`)
  70963. * * 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
  70964. * * 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
  70965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70968. * @param name defines the name of the mesh
  70969. * @param options defines the options used to create the mesh
  70970. * @param scene defines the hosting scene
  70971. * @returns the polyhedron mesh
  70972. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70973. */
  70974. static CreatePolyhedron(name: string, options: {
  70975. type?: number;
  70976. size?: number;
  70977. sizeX?: number;
  70978. sizeY?: number;
  70979. sizeZ?: number;
  70980. custom?: any;
  70981. faceUV?: Vector4[];
  70982. faceColors?: Color4[];
  70983. flat?: boolean;
  70984. updatable?: boolean;
  70985. sideOrientation?: number;
  70986. frontUVs?: Vector4;
  70987. backUVs?: Vector4;
  70988. }, scene?: Nullable<Scene>): Mesh;
  70989. /**
  70990. * Creates a decal mesh.
  70991. * 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
  70992. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70993. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70994. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70995. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70996. * @param name defines the name of the mesh
  70997. * @param sourceMesh defines the mesh where the decal must be applied
  70998. * @param options defines the options used to create the mesh
  70999. * @param scene defines the hosting scene
  71000. * @returns the decal mesh
  71001. * @see https://doc.babylonjs.com/how_to/decals
  71002. */
  71003. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71004. position?: Vector3;
  71005. normal?: Vector3;
  71006. size?: Vector3;
  71007. angle?: number;
  71008. }): Mesh;
  71009. /**
  71010. * Creates a Capsule Mesh
  71011. * @param name defines the name of the mesh.
  71012. * @param options the constructors options used to shape the mesh.
  71013. * @param scene defines the scene the mesh is scoped to.
  71014. * @returns the capsule mesh
  71015. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71016. */
  71017. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71018. }
  71019. }
  71020. declare module "babylonjs/Meshes/meshSimplification" {
  71021. import { Mesh } from "babylonjs/Meshes/mesh";
  71022. /**
  71023. * A simplifier interface for future simplification implementations
  71024. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71025. */
  71026. export interface ISimplifier {
  71027. /**
  71028. * Simplification of a given mesh according to the given settings.
  71029. * Since this requires computation, it is assumed that the function runs async.
  71030. * @param settings The settings of the simplification, including quality and distance
  71031. * @param successCallback A callback that will be called after the mesh was simplified.
  71032. * @param errorCallback in case of an error, this callback will be called. optional.
  71033. */
  71034. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71035. }
  71036. /**
  71037. * Expected simplification settings.
  71038. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71039. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71040. */
  71041. export interface ISimplificationSettings {
  71042. /**
  71043. * Gets or sets the expected quality
  71044. */
  71045. quality: number;
  71046. /**
  71047. * Gets or sets the distance when this optimized version should be used
  71048. */
  71049. distance: number;
  71050. /**
  71051. * Gets an already optimized mesh
  71052. */
  71053. optimizeMesh?: boolean;
  71054. }
  71055. /**
  71056. * Class used to specify simplification options
  71057. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71058. */
  71059. export class SimplificationSettings implements ISimplificationSettings {
  71060. /** expected quality */
  71061. quality: number;
  71062. /** distance when this optimized version should be used */
  71063. distance: number;
  71064. /** already optimized mesh */
  71065. optimizeMesh?: boolean | undefined;
  71066. /**
  71067. * Creates a SimplificationSettings
  71068. * @param quality expected quality
  71069. * @param distance distance when this optimized version should be used
  71070. * @param optimizeMesh already optimized mesh
  71071. */
  71072. constructor(
  71073. /** expected quality */
  71074. quality: number,
  71075. /** distance when this optimized version should be used */
  71076. distance: number,
  71077. /** already optimized mesh */
  71078. optimizeMesh?: boolean | undefined);
  71079. }
  71080. /**
  71081. * Interface used to define a simplification task
  71082. */
  71083. export interface ISimplificationTask {
  71084. /**
  71085. * Array of settings
  71086. */
  71087. settings: Array<ISimplificationSettings>;
  71088. /**
  71089. * Simplification type
  71090. */
  71091. simplificationType: SimplificationType;
  71092. /**
  71093. * Mesh to simplify
  71094. */
  71095. mesh: Mesh;
  71096. /**
  71097. * Callback called on success
  71098. */
  71099. successCallback?: () => void;
  71100. /**
  71101. * Defines if parallel processing can be used
  71102. */
  71103. parallelProcessing: boolean;
  71104. }
  71105. /**
  71106. * Queue used to order the simplification tasks
  71107. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71108. */
  71109. export class SimplificationQueue {
  71110. private _simplificationArray;
  71111. /**
  71112. * Gets a boolean indicating that the process is still running
  71113. */
  71114. running: boolean;
  71115. /**
  71116. * Creates a new queue
  71117. */
  71118. constructor();
  71119. /**
  71120. * Adds a new simplification task
  71121. * @param task defines a task to add
  71122. */
  71123. addTask(task: ISimplificationTask): void;
  71124. /**
  71125. * Execute next task
  71126. */
  71127. executeNext(): void;
  71128. /**
  71129. * Execute a simplification task
  71130. * @param task defines the task to run
  71131. */
  71132. runSimplification(task: ISimplificationTask): void;
  71133. private getSimplifier;
  71134. }
  71135. /**
  71136. * The implemented types of simplification
  71137. * At the moment only Quadratic Error Decimation is implemented
  71138. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71139. */
  71140. export enum SimplificationType {
  71141. /** Quadratic error decimation */
  71142. QUADRATIC = 0
  71143. }
  71144. /**
  71145. * An implementation of the Quadratic Error simplification algorithm.
  71146. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71147. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71148. * @author RaananW
  71149. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71150. */
  71151. export class QuadraticErrorSimplification implements ISimplifier {
  71152. private _mesh;
  71153. private triangles;
  71154. private vertices;
  71155. private references;
  71156. private _reconstructedMesh;
  71157. /** Gets or sets the number pf sync interations */
  71158. syncIterations: number;
  71159. /** Gets or sets the aggressiveness of the simplifier */
  71160. aggressiveness: number;
  71161. /** Gets or sets the number of allowed iterations for decimation */
  71162. decimationIterations: number;
  71163. /** Gets or sets the espilon to use for bounding box computation */
  71164. boundingBoxEpsilon: number;
  71165. /**
  71166. * Creates a new QuadraticErrorSimplification
  71167. * @param _mesh defines the target mesh
  71168. */
  71169. constructor(_mesh: Mesh);
  71170. /**
  71171. * Simplification of a given mesh according to the given settings.
  71172. * Since this requires computation, it is assumed that the function runs async.
  71173. * @param settings The settings of the simplification, including quality and distance
  71174. * @param successCallback A callback that will be called after the mesh was simplified.
  71175. */
  71176. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71177. private runDecimation;
  71178. private initWithMesh;
  71179. private init;
  71180. private reconstructMesh;
  71181. private initDecimatedMesh;
  71182. private isFlipped;
  71183. private updateTriangles;
  71184. private identifyBorder;
  71185. private updateMesh;
  71186. private vertexError;
  71187. private calculateError;
  71188. }
  71189. }
  71190. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  71191. import { Scene } from "babylonjs/scene";
  71192. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  71193. import { ISceneComponent } from "babylonjs/sceneComponent";
  71194. module "babylonjs/scene" {
  71195. interface Scene {
  71196. /** @hidden (Backing field) */
  71197. _simplificationQueue: SimplificationQueue;
  71198. /**
  71199. * Gets or sets the simplification queue attached to the scene
  71200. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71201. */
  71202. simplificationQueue: SimplificationQueue;
  71203. }
  71204. }
  71205. module "babylonjs/Meshes/mesh" {
  71206. interface Mesh {
  71207. /**
  71208. * Simplify the mesh according to the given array of settings.
  71209. * Function will return immediately and will simplify async
  71210. * @param settings a collection of simplification settings
  71211. * @param parallelProcessing should all levels calculate parallel or one after the other
  71212. * @param simplificationType the type of simplification to run
  71213. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71214. * @returns the current mesh
  71215. */
  71216. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71217. }
  71218. }
  71219. /**
  71220. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71221. * created in a scene
  71222. */
  71223. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71224. /**
  71225. * The component name helpfull to identify the component in the list of scene components.
  71226. */
  71227. readonly name: string;
  71228. /**
  71229. * The scene the component belongs to.
  71230. */
  71231. scene: Scene;
  71232. /**
  71233. * Creates a new instance of the component for the given scene
  71234. * @param scene Defines the scene to register the component in
  71235. */
  71236. constructor(scene: Scene);
  71237. /**
  71238. * Registers the component in a given scene
  71239. */
  71240. register(): void;
  71241. /**
  71242. * Rebuilds the elements related to this component in case of
  71243. * context lost for instance.
  71244. */
  71245. rebuild(): void;
  71246. /**
  71247. * Disposes the component and the associated ressources
  71248. */
  71249. dispose(): void;
  71250. private _beforeCameraUpdate;
  71251. }
  71252. }
  71253. declare module "babylonjs/Meshes/Builders/index" {
  71254. export * from "babylonjs/Meshes/Builders/boxBuilder";
  71255. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  71256. export * from "babylonjs/Meshes/Builders/discBuilder";
  71257. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  71258. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  71259. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  71260. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  71261. export * from "babylonjs/Meshes/Builders/torusBuilder";
  71262. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  71263. export * from "babylonjs/Meshes/Builders/linesBuilder";
  71264. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  71265. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  71266. export * from "babylonjs/Meshes/Builders/latheBuilder";
  71267. export * from "babylonjs/Meshes/Builders/planeBuilder";
  71268. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  71269. export * from "babylonjs/Meshes/Builders/groundBuilder";
  71270. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  71271. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  71272. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71273. export * from "babylonjs/Meshes/Builders/decalBuilder";
  71274. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71275. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  71276. }
  71277. declare module "babylonjs/Meshes/thinInstanceMesh" {
  71278. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  71279. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  71280. import { Matrix } from "babylonjs/Maths/math.vector";
  71281. module "babylonjs/Meshes/mesh" {
  71282. interface Mesh {
  71283. /**
  71284. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71285. */
  71286. thinInstanceEnablePicking: boolean;
  71287. /**
  71288. * Creates a new thin instance
  71289. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71290. * @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
  71291. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71292. */
  71293. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71294. /**
  71295. * Adds the transformation (matrix) of the current mesh as a thin instance
  71296. * @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
  71297. * @returns the thin instance index number
  71298. */
  71299. thinInstanceAddSelf(refresh: boolean): number;
  71300. /**
  71301. * Registers a custom attribute to be used with thin instances
  71302. * @param kind name of the attribute
  71303. * @param stride size in floats of the attribute
  71304. */
  71305. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71306. /**
  71307. * Sets the matrix of a thin instance
  71308. * @param index index of the thin instance
  71309. * @param matrix matrix to set
  71310. * @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
  71311. */
  71312. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71313. /**
  71314. * Sets the value of a custom attribute for a thin instance
  71315. * @param kind name of the attribute
  71316. * @param index index of the thin instance
  71317. * @param value value to set
  71318. * @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
  71319. */
  71320. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71321. /**
  71322. * 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.
  71323. */
  71324. thinInstanceCount: number;
  71325. /**
  71326. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71327. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71328. * @param buffer buffer to set
  71329. * @param stride size in floats of each value of the buffer
  71330. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71331. */
  71332. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71333. /**
  71334. * Gets the list of world matrices
  71335. * @return an array containing all the world matrices from the thin instances
  71336. */
  71337. thinInstanceGetWorldMatrices(): Matrix[];
  71338. /**
  71339. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71340. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71341. */
  71342. thinInstanceBufferUpdated(kind: string): void;
  71343. /**
  71344. * Applies a partial update to a buffer directly on the GPU
  71345. * 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
  71346. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71347. * @param data the data to set in the GPU buffer
  71348. * @param offset the offset in the GPU buffer where to update the data
  71349. */
  71350. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71351. /**
  71352. * Refreshes the bounding info, taking into account all the thin instances defined
  71353. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71354. */
  71355. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71356. /** @hidden */
  71357. _thinInstanceInitializeUserStorage(): void;
  71358. /** @hidden */
  71359. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71360. /** @hidden */
  71361. _userThinInstanceBuffersStorage: {
  71362. data: {
  71363. [key: string]: Float32Array;
  71364. };
  71365. sizes: {
  71366. [key: string]: number;
  71367. };
  71368. vertexBuffers: {
  71369. [key: string]: Nullable<VertexBuffer>;
  71370. };
  71371. strides: {
  71372. [key: string]: number;
  71373. };
  71374. };
  71375. }
  71376. }
  71377. }
  71378. declare module "babylonjs/Meshes/index" {
  71379. export * from "babylonjs/Meshes/abstractMesh";
  71380. export * from "babylonjs/Meshes/buffer";
  71381. export * from "babylonjs/Meshes/Compression/index";
  71382. export * from "babylonjs/Meshes/csg";
  71383. export * from "babylonjs/Meshes/geometry";
  71384. export * from "babylonjs/Meshes/groundMesh";
  71385. export * from "babylonjs/Meshes/trailMesh";
  71386. export * from "babylonjs/Meshes/instancedMesh";
  71387. export * from "babylonjs/Meshes/linesMesh";
  71388. export * from "babylonjs/Meshes/mesh";
  71389. export * from "babylonjs/Meshes/mesh.vertexData";
  71390. export * from "babylonjs/Meshes/meshBuilder";
  71391. export * from "babylonjs/Meshes/meshSimplification";
  71392. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  71393. export * from "babylonjs/Meshes/polygonMesh";
  71394. export * from "babylonjs/Meshes/subMesh";
  71395. export * from "babylonjs/Meshes/meshLODLevel";
  71396. export * from "babylonjs/Meshes/transformNode";
  71397. export * from "babylonjs/Meshes/Builders/index";
  71398. export * from "babylonjs/Meshes/dataBuffer";
  71399. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  71400. import "babylonjs/Meshes/thinInstanceMesh";
  71401. export * from "babylonjs/Meshes/thinInstanceMesh";
  71402. }
  71403. declare module "babylonjs/Morph/index" {
  71404. export * from "babylonjs/Morph/morphTarget";
  71405. export * from "babylonjs/Morph/morphTargetManager";
  71406. }
  71407. declare module "babylonjs/Navigation/INavigationEngine" {
  71408. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71409. import { Vector3 } from "babylonjs/Maths/math";
  71410. import { Mesh } from "babylonjs/Meshes/mesh";
  71411. import { Scene } from "babylonjs/scene";
  71412. /**
  71413. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71414. */
  71415. export interface INavigationEnginePlugin {
  71416. /**
  71417. * plugin name
  71418. */
  71419. name: string;
  71420. /**
  71421. * Creates a navigation mesh
  71422. * @param meshes array of all the geometry used to compute the navigatio mesh
  71423. * @param parameters bunch of parameters used to filter geometry
  71424. */
  71425. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71426. /**
  71427. * Create a navigation mesh debug mesh
  71428. * @param scene is where the mesh will be added
  71429. * @returns debug display mesh
  71430. */
  71431. createDebugNavMesh(scene: Scene): Mesh;
  71432. /**
  71433. * Get a navigation mesh constrained position, closest to the parameter position
  71434. * @param position world position
  71435. * @returns the closest point to position constrained by the navigation mesh
  71436. */
  71437. getClosestPoint(position: Vector3): Vector3;
  71438. /**
  71439. * Get a navigation mesh constrained position, closest to the parameter position
  71440. * @param position world position
  71441. * @param result output the closest point to position constrained by the navigation mesh
  71442. */
  71443. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71444. /**
  71445. * Get a navigation mesh constrained position, within a particular radius
  71446. * @param position world position
  71447. * @param maxRadius the maximum distance to the constrained world position
  71448. * @returns the closest point to position constrained by the navigation mesh
  71449. */
  71450. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71451. /**
  71452. * Get a navigation mesh constrained position, within a particular radius
  71453. * @param position world position
  71454. * @param maxRadius the maximum distance to the constrained world position
  71455. * @param result output the closest point to position constrained by the navigation mesh
  71456. */
  71457. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71458. /**
  71459. * Compute the final position from a segment made of destination-position
  71460. * @param position world position
  71461. * @param destination world position
  71462. * @returns the resulting point along the navmesh
  71463. */
  71464. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71465. /**
  71466. * Compute the final position from a segment made of destination-position
  71467. * @param position world position
  71468. * @param destination world position
  71469. * @param result output the resulting point along the navmesh
  71470. */
  71471. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71472. /**
  71473. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71474. * @param start world position
  71475. * @param end world position
  71476. * @returns array containing world position composing the path
  71477. */
  71478. computePath(start: Vector3, end: Vector3): Vector3[];
  71479. /**
  71480. * If this plugin is supported
  71481. * @returns true if plugin is supported
  71482. */
  71483. isSupported(): boolean;
  71484. /**
  71485. * Create a new Crowd so you can add agents
  71486. * @param maxAgents the maximum agent count in the crowd
  71487. * @param maxAgentRadius the maximum radius an agent can have
  71488. * @param scene to attach the crowd to
  71489. * @returns the crowd you can add agents to
  71490. */
  71491. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71492. /**
  71493. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71494. * The queries will try to find a solution within those bounds
  71495. * default is (1,1,1)
  71496. * @param extent x,y,z value that define the extent around the queries point of reference
  71497. */
  71498. setDefaultQueryExtent(extent: Vector3): void;
  71499. /**
  71500. * Get the Bounding box extent specified by setDefaultQueryExtent
  71501. * @returns the box extent values
  71502. */
  71503. getDefaultQueryExtent(): Vector3;
  71504. /**
  71505. * build the navmesh from a previously saved state using getNavmeshData
  71506. * @param data the Uint8Array returned by getNavmeshData
  71507. */
  71508. buildFromNavmeshData(data: Uint8Array): void;
  71509. /**
  71510. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71511. * @returns data the Uint8Array that can be saved and reused
  71512. */
  71513. getNavmeshData(): Uint8Array;
  71514. /**
  71515. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71516. * @param result output the box extent values
  71517. */
  71518. getDefaultQueryExtentToRef(result: Vector3): void;
  71519. /**
  71520. * Release all resources
  71521. */
  71522. dispose(): void;
  71523. }
  71524. /**
  71525. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71526. */
  71527. export interface ICrowd {
  71528. /**
  71529. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71530. * You can attach anything to that node. The node position is updated in the scene update tick.
  71531. * @param pos world position that will be constrained by the navigation mesh
  71532. * @param parameters agent parameters
  71533. * @param transform hooked to the agent that will be update by the scene
  71534. * @returns agent index
  71535. */
  71536. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71537. /**
  71538. * Returns the agent position in world space
  71539. * @param index agent index returned by addAgent
  71540. * @returns world space position
  71541. */
  71542. getAgentPosition(index: number): Vector3;
  71543. /**
  71544. * Gets the agent position result in world space
  71545. * @param index agent index returned by addAgent
  71546. * @param result output world space position
  71547. */
  71548. getAgentPositionToRef(index: number, result: Vector3): void;
  71549. /**
  71550. * Gets the agent velocity in world space
  71551. * @param index agent index returned by addAgent
  71552. * @returns world space velocity
  71553. */
  71554. getAgentVelocity(index: number): Vector3;
  71555. /**
  71556. * Gets the agent velocity result in world space
  71557. * @param index agent index returned by addAgent
  71558. * @param result output world space velocity
  71559. */
  71560. getAgentVelocityToRef(index: number, result: Vector3): void;
  71561. /**
  71562. * Gets the agent next target point on the path
  71563. * @param index agent index returned by addAgent
  71564. * @returns world space position
  71565. */
  71566. getAgentNextTargetPath(index: number): Vector3;
  71567. /**
  71568. * Gets the agent state
  71569. * @param index agent index returned by addAgent
  71570. * @returns agent state
  71571. */
  71572. getAgentState(index: number): number;
  71573. /**
  71574. * returns true if the agent in over an off mesh link connection
  71575. * @param index agent index returned by addAgent
  71576. * @returns true if over an off mesh link connection
  71577. */
  71578. overOffmeshConnection(index: number): boolean;
  71579. /**
  71580. * Gets the agent next target point on the path
  71581. * @param index agent index returned by addAgent
  71582. * @param result output world space position
  71583. */
  71584. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71585. /**
  71586. * remove a particular agent previously created
  71587. * @param index agent index returned by addAgent
  71588. */
  71589. removeAgent(index: number): void;
  71590. /**
  71591. * get the list of all agents attached to this crowd
  71592. * @returns list of agent indices
  71593. */
  71594. getAgents(): number[];
  71595. /**
  71596. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71597. * @param deltaTime in seconds
  71598. */
  71599. update(deltaTime: number): void;
  71600. /**
  71601. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71602. * @param index agent index returned by addAgent
  71603. * @param destination targeted world position
  71604. */
  71605. agentGoto(index: number, destination: Vector3): void;
  71606. /**
  71607. * Teleport the agent to a new position
  71608. * @param index agent index returned by addAgent
  71609. * @param destination targeted world position
  71610. */
  71611. agentTeleport(index: number, destination: Vector3): void;
  71612. /**
  71613. * Update agent parameters
  71614. * @param index agent index returned by addAgent
  71615. * @param parameters agent parameters
  71616. */
  71617. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71618. /**
  71619. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71620. * The queries will try to find a solution within those bounds
  71621. * default is (1,1,1)
  71622. * @param extent x,y,z value that define the extent around the queries point of reference
  71623. */
  71624. setDefaultQueryExtent(extent: Vector3): void;
  71625. /**
  71626. * Get the Bounding box extent specified by setDefaultQueryExtent
  71627. * @returns the box extent values
  71628. */
  71629. getDefaultQueryExtent(): Vector3;
  71630. /**
  71631. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71632. * @param result output the box extent values
  71633. */
  71634. getDefaultQueryExtentToRef(result: Vector3): void;
  71635. /**
  71636. * Release all resources
  71637. */
  71638. dispose(): void;
  71639. }
  71640. /**
  71641. * Configures an agent
  71642. */
  71643. export interface IAgentParameters {
  71644. /**
  71645. * Agent radius. [Limit: >= 0]
  71646. */
  71647. radius: number;
  71648. /**
  71649. * Agent height. [Limit: > 0]
  71650. */
  71651. height: number;
  71652. /**
  71653. * Maximum allowed acceleration. [Limit: >= 0]
  71654. */
  71655. maxAcceleration: number;
  71656. /**
  71657. * Maximum allowed speed. [Limit: >= 0]
  71658. */
  71659. maxSpeed: number;
  71660. /**
  71661. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71662. */
  71663. collisionQueryRange: number;
  71664. /**
  71665. * The path visibility optimization range. [Limit: > 0]
  71666. */
  71667. pathOptimizationRange: number;
  71668. /**
  71669. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71670. */
  71671. separationWeight: number;
  71672. }
  71673. /**
  71674. * Configures the navigation mesh creation
  71675. */
  71676. export interface INavMeshParameters {
  71677. /**
  71678. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71679. */
  71680. cs: number;
  71681. /**
  71682. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71683. */
  71684. ch: number;
  71685. /**
  71686. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71687. */
  71688. walkableSlopeAngle: number;
  71689. /**
  71690. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71691. * be considered walkable. [Limit: >= 3] [Units: vx]
  71692. */
  71693. walkableHeight: number;
  71694. /**
  71695. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71696. */
  71697. walkableClimb: number;
  71698. /**
  71699. * The distance to erode/shrink the walkable area of the heightfield away from
  71700. * obstructions. [Limit: >=0] [Units: vx]
  71701. */
  71702. walkableRadius: number;
  71703. /**
  71704. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71705. */
  71706. maxEdgeLen: number;
  71707. /**
  71708. * The maximum distance a simplfied contour's border edges should deviate
  71709. * the original raw contour. [Limit: >=0] [Units: vx]
  71710. */
  71711. maxSimplificationError: number;
  71712. /**
  71713. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71714. */
  71715. minRegionArea: number;
  71716. /**
  71717. * Any regions with a span count smaller than this value will, if possible,
  71718. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71719. */
  71720. mergeRegionArea: number;
  71721. /**
  71722. * The maximum number of vertices allowed for polygons generated during the
  71723. * contour to polygon conversion process. [Limit: >= 3]
  71724. */
  71725. maxVertsPerPoly: number;
  71726. /**
  71727. * Sets the sampling distance to use when generating the detail mesh.
  71728. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71729. */
  71730. detailSampleDist: number;
  71731. /**
  71732. * The maximum distance the detail mesh surface should deviate from heightfield
  71733. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71734. */
  71735. detailSampleMaxError: number;
  71736. }
  71737. }
  71738. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  71739. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  71740. import { Mesh } from "babylonjs/Meshes/mesh";
  71741. import { Scene } from "babylonjs/scene";
  71742. import { Vector3 } from "babylonjs/Maths/math";
  71743. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71744. /**
  71745. * RecastJS navigation plugin
  71746. */
  71747. export class RecastJSPlugin implements INavigationEnginePlugin {
  71748. /**
  71749. * Reference to the Recast library
  71750. */
  71751. bjsRECAST: any;
  71752. /**
  71753. * plugin name
  71754. */
  71755. name: string;
  71756. /**
  71757. * the first navmesh created. We might extend this to support multiple navmeshes
  71758. */
  71759. navMesh: any;
  71760. /**
  71761. * Initializes the recastJS plugin
  71762. * @param recastInjection can be used to inject your own recast reference
  71763. */
  71764. constructor(recastInjection?: any);
  71765. /**
  71766. * Creates a navigation mesh
  71767. * @param meshes array of all the geometry used to compute the navigatio mesh
  71768. * @param parameters bunch of parameters used to filter geometry
  71769. */
  71770. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71771. /**
  71772. * Create a navigation mesh debug mesh
  71773. * @param scene is where the mesh will be added
  71774. * @returns debug display mesh
  71775. */
  71776. createDebugNavMesh(scene: Scene): Mesh;
  71777. /**
  71778. * Get a navigation mesh constrained position, closest to the parameter position
  71779. * @param position world position
  71780. * @returns the closest point to position constrained by the navigation mesh
  71781. */
  71782. getClosestPoint(position: Vector3): Vector3;
  71783. /**
  71784. * Get a navigation mesh constrained position, closest to the parameter position
  71785. * @param position world position
  71786. * @param result output the closest point to position constrained by the navigation mesh
  71787. */
  71788. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71789. /**
  71790. * Get a navigation mesh constrained position, within a particular radius
  71791. * @param position world position
  71792. * @param maxRadius the maximum distance to the constrained world position
  71793. * @returns the closest point to position constrained by the navigation mesh
  71794. */
  71795. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71796. /**
  71797. * Get a navigation mesh constrained position, within a particular radius
  71798. * @param position world position
  71799. * @param maxRadius the maximum distance to the constrained world position
  71800. * @param result output the closest point to position constrained by the navigation mesh
  71801. */
  71802. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71803. /**
  71804. * Compute the final position from a segment made of destination-position
  71805. * @param position world position
  71806. * @param destination world position
  71807. * @returns the resulting point along the navmesh
  71808. */
  71809. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71810. /**
  71811. * Compute the final position from a segment made of destination-position
  71812. * @param position world position
  71813. * @param destination world position
  71814. * @param result output the resulting point along the navmesh
  71815. */
  71816. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71817. /**
  71818. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71819. * @param start world position
  71820. * @param end world position
  71821. * @returns array containing world position composing the path
  71822. */
  71823. computePath(start: Vector3, end: Vector3): Vector3[];
  71824. /**
  71825. * Create a new Crowd so you can add agents
  71826. * @param maxAgents the maximum agent count in the crowd
  71827. * @param maxAgentRadius the maximum radius an agent can have
  71828. * @param scene to attach the crowd to
  71829. * @returns the crowd you can add agents to
  71830. */
  71831. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71832. /**
  71833. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71834. * The queries will try to find a solution within those bounds
  71835. * default is (1,1,1)
  71836. * @param extent x,y,z value that define the extent around the queries point of reference
  71837. */
  71838. setDefaultQueryExtent(extent: Vector3): void;
  71839. /**
  71840. * Get the Bounding box extent specified by setDefaultQueryExtent
  71841. * @returns the box extent values
  71842. */
  71843. getDefaultQueryExtent(): Vector3;
  71844. /**
  71845. * build the navmesh from a previously saved state using getNavmeshData
  71846. * @param data the Uint8Array returned by getNavmeshData
  71847. */
  71848. buildFromNavmeshData(data: Uint8Array): void;
  71849. /**
  71850. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71851. * @returns data the Uint8Array that can be saved and reused
  71852. */
  71853. getNavmeshData(): Uint8Array;
  71854. /**
  71855. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71856. * @param result output the box extent values
  71857. */
  71858. getDefaultQueryExtentToRef(result: Vector3): void;
  71859. /**
  71860. * Disposes
  71861. */
  71862. dispose(): void;
  71863. /**
  71864. * If this plugin is supported
  71865. * @returns true if plugin is supported
  71866. */
  71867. isSupported(): boolean;
  71868. }
  71869. /**
  71870. * Recast detour crowd implementation
  71871. */
  71872. export class RecastJSCrowd implements ICrowd {
  71873. /**
  71874. * Recast/detour plugin
  71875. */
  71876. bjsRECASTPlugin: RecastJSPlugin;
  71877. /**
  71878. * Link to the detour crowd
  71879. */
  71880. recastCrowd: any;
  71881. /**
  71882. * One transform per agent
  71883. */
  71884. transforms: TransformNode[];
  71885. /**
  71886. * All agents created
  71887. */
  71888. agents: number[];
  71889. /**
  71890. * Link to the scene is kept to unregister the crowd from the scene
  71891. */
  71892. private _scene;
  71893. /**
  71894. * Observer for crowd updates
  71895. */
  71896. private _onBeforeAnimationsObserver;
  71897. /**
  71898. * Constructor
  71899. * @param plugin recastJS plugin
  71900. * @param maxAgents the maximum agent count in the crowd
  71901. * @param maxAgentRadius the maximum radius an agent can have
  71902. * @param scene to attach the crowd to
  71903. * @returns the crowd you can add agents to
  71904. */
  71905. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71906. /**
  71907. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71908. * You can attach anything to that node. The node position is updated in the scene update tick.
  71909. * @param pos world position that will be constrained by the navigation mesh
  71910. * @param parameters agent parameters
  71911. * @param transform hooked to the agent that will be update by the scene
  71912. * @returns agent index
  71913. */
  71914. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71915. /**
  71916. * Returns the agent position in world space
  71917. * @param index agent index returned by addAgent
  71918. * @returns world space position
  71919. */
  71920. getAgentPosition(index: number): Vector3;
  71921. /**
  71922. * Returns the agent position result in world space
  71923. * @param index agent index returned by addAgent
  71924. * @param result output world space position
  71925. */
  71926. getAgentPositionToRef(index: number, result: Vector3): void;
  71927. /**
  71928. * Returns the agent velocity in world space
  71929. * @param index agent index returned by addAgent
  71930. * @returns world space velocity
  71931. */
  71932. getAgentVelocity(index: number): Vector3;
  71933. /**
  71934. * Returns the agent velocity result in world space
  71935. * @param index agent index returned by addAgent
  71936. * @param result output world space velocity
  71937. */
  71938. getAgentVelocityToRef(index: number, result: Vector3): void;
  71939. /**
  71940. * Returns the agent next target point on the path
  71941. * @param index agent index returned by addAgent
  71942. * @returns world space position
  71943. */
  71944. getAgentNextTargetPath(index: number): Vector3;
  71945. /**
  71946. * Returns the agent next target point on the path
  71947. * @param index agent index returned by addAgent
  71948. * @param result output world space position
  71949. */
  71950. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71951. /**
  71952. * Gets the agent state
  71953. * @param index agent index returned by addAgent
  71954. * @returns agent state
  71955. */
  71956. getAgentState(index: number): number;
  71957. /**
  71958. * returns true if the agent in over an off mesh link connection
  71959. * @param index agent index returned by addAgent
  71960. * @returns true if over an off mesh link connection
  71961. */
  71962. overOffmeshConnection(index: number): boolean;
  71963. /**
  71964. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71965. * @param index agent index returned by addAgent
  71966. * @param destination targeted world position
  71967. */
  71968. agentGoto(index: number, destination: Vector3): void;
  71969. /**
  71970. * Teleport the agent to a new position
  71971. * @param index agent index returned by addAgent
  71972. * @param destination targeted world position
  71973. */
  71974. agentTeleport(index: number, destination: Vector3): void;
  71975. /**
  71976. * Update agent parameters
  71977. * @param index agent index returned by addAgent
  71978. * @param parameters agent parameters
  71979. */
  71980. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71981. /**
  71982. * remove a particular agent previously created
  71983. * @param index agent index returned by addAgent
  71984. */
  71985. removeAgent(index: number): void;
  71986. /**
  71987. * get the list of all agents attached to this crowd
  71988. * @returns list of agent indices
  71989. */
  71990. getAgents(): number[];
  71991. /**
  71992. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71993. * @param deltaTime in seconds
  71994. */
  71995. update(deltaTime: number): void;
  71996. /**
  71997. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71998. * The queries will try to find a solution within those bounds
  71999. * default is (1,1,1)
  72000. * @param extent x,y,z value that define the extent around the queries point of reference
  72001. */
  72002. setDefaultQueryExtent(extent: Vector3): void;
  72003. /**
  72004. * Get the Bounding box extent specified by setDefaultQueryExtent
  72005. * @returns the box extent values
  72006. */
  72007. getDefaultQueryExtent(): Vector3;
  72008. /**
  72009. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72010. * @param result output the box extent values
  72011. */
  72012. getDefaultQueryExtentToRef(result: Vector3): void;
  72013. /**
  72014. * Release all resources
  72015. */
  72016. dispose(): void;
  72017. }
  72018. }
  72019. declare module "babylonjs/Navigation/Plugins/index" {
  72020. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  72021. }
  72022. declare module "babylonjs/Navigation/index" {
  72023. export * from "babylonjs/Navigation/INavigationEngine";
  72024. export * from "babylonjs/Navigation/Plugins/index";
  72025. }
  72026. declare module "babylonjs/Offline/database" {
  72027. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  72028. /**
  72029. * Class used to enable access to IndexedDB
  72030. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72031. */
  72032. export class Database implements IOfflineProvider {
  72033. private _callbackManifestChecked;
  72034. private _currentSceneUrl;
  72035. private _db;
  72036. private _enableSceneOffline;
  72037. private _enableTexturesOffline;
  72038. private _manifestVersionFound;
  72039. private _mustUpdateRessources;
  72040. private _hasReachedQuota;
  72041. private _isSupported;
  72042. private _idbFactory;
  72043. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72044. private static IsUASupportingBlobStorage;
  72045. /**
  72046. * Gets a boolean indicating if Database storate is enabled (off by default)
  72047. */
  72048. static IDBStorageEnabled: boolean;
  72049. /**
  72050. * Gets a boolean indicating if scene must be saved in the database
  72051. */
  72052. get enableSceneOffline(): boolean;
  72053. /**
  72054. * Gets a boolean indicating if textures must be saved in the database
  72055. */
  72056. get enableTexturesOffline(): boolean;
  72057. /**
  72058. * Creates a new Database
  72059. * @param urlToScene defines the url to load the scene
  72060. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72061. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72062. */
  72063. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72064. private static _ParseURL;
  72065. private static _ReturnFullUrlLocation;
  72066. private _checkManifestFile;
  72067. /**
  72068. * Open the database and make it available
  72069. * @param successCallback defines the callback to call on success
  72070. * @param errorCallback defines the callback to call on error
  72071. */
  72072. open(successCallback: () => void, errorCallback: () => void): void;
  72073. /**
  72074. * Loads an image from the database
  72075. * @param url defines the url to load from
  72076. * @param image defines the target DOM image
  72077. */
  72078. loadImage(url: string, image: HTMLImageElement): void;
  72079. private _loadImageFromDBAsync;
  72080. private _saveImageIntoDBAsync;
  72081. private _checkVersionFromDB;
  72082. private _loadVersionFromDBAsync;
  72083. private _saveVersionIntoDBAsync;
  72084. /**
  72085. * Loads a file from database
  72086. * @param url defines the URL to load from
  72087. * @param sceneLoaded defines a callback to call on success
  72088. * @param progressCallBack defines a callback to call when progress changed
  72089. * @param errorCallback defines a callback to call on error
  72090. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72091. */
  72092. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72093. private _loadFileAsync;
  72094. private _saveFileAsync;
  72095. /**
  72096. * Validates if xhr data is correct
  72097. * @param xhr defines the request to validate
  72098. * @param dataType defines the expected data type
  72099. * @returns true if data is correct
  72100. */
  72101. private static _ValidateXHRData;
  72102. }
  72103. }
  72104. declare module "babylonjs/Offline/index" {
  72105. export * from "babylonjs/Offline/database";
  72106. export * from "babylonjs/Offline/IOfflineProvider";
  72107. }
  72108. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  72109. /** @hidden */
  72110. export var gpuUpdateParticlesPixelShader: {
  72111. name: string;
  72112. shader: string;
  72113. };
  72114. }
  72115. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  72116. /** @hidden */
  72117. export var gpuUpdateParticlesVertexShader: {
  72118. name: string;
  72119. shader: string;
  72120. };
  72121. }
  72122. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  72123. /** @hidden */
  72124. export var clipPlaneFragmentDeclaration2: {
  72125. name: string;
  72126. shader: string;
  72127. };
  72128. }
  72129. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  72130. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  72131. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  72132. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72133. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  72134. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  72135. /** @hidden */
  72136. export var gpuRenderParticlesPixelShader: {
  72137. name: string;
  72138. shader: string;
  72139. };
  72140. }
  72141. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  72142. /** @hidden */
  72143. export var clipPlaneVertexDeclaration2: {
  72144. name: string;
  72145. shader: string;
  72146. };
  72147. }
  72148. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  72149. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  72150. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  72151. /** @hidden */
  72152. export var gpuRenderParticlesVertexShader: {
  72153. name: string;
  72154. shader: string;
  72155. };
  72156. }
  72157. declare module "babylonjs/Particles/gpuParticleSystem" {
  72158. import { Nullable } from "babylonjs/types";
  72159. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  72160. import { Observable } from "babylonjs/Misc/observable";
  72161. import { Matrix } from "babylonjs/Maths/math.vector";
  72162. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  72163. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72164. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  72165. import { IDisposable } from "babylonjs/scene";
  72166. import { Effect } from "babylonjs/Materials/effect";
  72167. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72168. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72169. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  72170. import { Scene } from "babylonjs/scene";
  72171. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  72172. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  72173. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  72174. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  72175. /**
  72176. * This represents a GPU particle system in Babylon
  72177. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72178. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72179. */
  72180. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72181. /**
  72182. * The layer mask we are rendering the particles through.
  72183. */
  72184. layerMask: number;
  72185. private _capacity;
  72186. private _activeCount;
  72187. private _currentActiveCount;
  72188. private _accumulatedCount;
  72189. private _renderEffect;
  72190. private _updateEffect;
  72191. private _buffer0;
  72192. private _buffer1;
  72193. private _spriteBuffer;
  72194. private _updateVAO;
  72195. private _renderVAO;
  72196. private _targetIndex;
  72197. private _sourceBuffer;
  72198. private _targetBuffer;
  72199. private _currentRenderId;
  72200. private _started;
  72201. private _stopped;
  72202. private _timeDelta;
  72203. private _randomTexture;
  72204. private _randomTexture2;
  72205. private _attributesStrideSize;
  72206. private _updateEffectOptions;
  72207. private _randomTextureSize;
  72208. private _actualFrame;
  72209. private _customEffect;
  72210. private readonly _rawTextureWidth;
  72211. /**
  72212. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72213. */
  72214. static get IsSupported(): boolean;
  72215. /**
  72216. * An event triggered when the system is disposed.
  72217. */
  72218. onDisposeObservable: Observable<IParticleSystem>;
  72219. /**
  72220. * An event triggered when the system is stopped
  72221. */
  72222. onStoppedObservable: Observable<IParticleSystem>;
  72223. /**
  72224. * Gets the maximum number of particles active at the same time.
  72225. * @returns The max number of active particles.
  72226. */
  72227. getCapacity(): number;
  72228. /**
  72229. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72230. * to override the particles.
  72231. */
  72232. forceDepthWrite: boolean;
  72233. /**
  72234. * Gets or set the number of active particles
  72235. */
  72236. get activeParticleCount(): number;
  72237. set activeParticleCount(value: number);
  72238. private _preWarmDone;
  72239. /**
  72240. * Specifies if the particles are updated in emitter local space or world space.
  72241. */
  72242. isLocal: boolean;
  72243. /** Gets or sets a matrix to use to compute projection */
  72244. defaultProjectionMatrix: Matrix;
  72245. /**
  72246. * Is this system ready to be used/rendered
  72247. * @return true if the system is ready
  72248. */
  72249. isReady(): boolean;
  72250. /**
  72251. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72252. * @returns True if it has been started, otherwise false.
  72253. */
  72254. isStarted(): boolean;
  72255. /**
  72256. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72257. * @returns True if it has been stopped, otherwise false.
  72258. */
  72259. isStopped(): boolean;
  72260. /**
  72261. * Gets a boolean indicating that the system is stopping
  72262. * @returns true if the system is currently stopping
  72263. */
  72264. isStopping(): boolean;
  72265. /**
  72266. * Gets the number of particles active at the same time.
  72267. * @returns The number of active particles.
  72268. */
  72269. getActiveCount(): number;
  72270. /**
  72271. * Starts the particle system and begins to emit
  72272. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72273. */
  72274. start(delay?: number): void;
  72275. /**
  72276. * Stops the particle system.
  72277. */
  72278. stop(): void;
  72279. /**
  72280. * Remove all active particles
  72281. */
  72282. reset(): void;
  72283. /**
  72284. * Returns the string "GPUParticleSystem"
  72285. * @returns a string containing the class name
  72286. */
  72287. getClassName(): string;
  72288. /**
  72289. * Gets the custom effect used to render the particles
  72290. * @param blendMode Blend mode for which the effect should be retrieved
  72291. * @returns The effect
  72292. */
  72293. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72294. /**
  72295. * Sets the custom effect used to render the particles
  72296. * @param effect The effect to set
  72297. * @param blendMode Blend mode for which the effect should be set
  72298. */
  72299. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72300. /** @hidden */
  72301. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72302. /**
  72303. * Observable that will be called just before the particles are drawn
  72304. */
  72305. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72306. /**
  72307. * Gets the name of the particle vertex shader
  72308. */
  72309. get vertexShaderName(): string;
  72310. private _colorGradientsTexture;
  72311. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72312. /**
  72313. * Adds a new color gradient
  72314. * @param gradient defines the gradient to use (between 0 and 1)
  72315. * @param color1 defines the color to affect to the specified gradient
  72316. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72317. * @returns the current particle system
  72318. */
  72319. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72320. private _refreshColorGradient;
  72321. /** Force the system to rebuild all gradients that need to be resync */
  72322. forceRefreshGradients(): void;
  72323. /**
  72324. * Remove a specific color gradient
  72325. * @param gradient defines the gradient to remove
  72326. * @returns the current particle system
  72327. */
  72328. removeColorGradient(gradient: number): GPUParticleSystem;
  72329. private _angularSpeedGradientsTexture;
  72330. private _sizeGradientsTexture;
  72331. private _velocityGradientsTexture;
  72332. private _limitVelocityGradientsTexture;
  72333. private _dragGradientsTexture;
  72334. private _addFactorGradient;
  72335. /**
  72336. * Adds a new size gradient
  72337. * @param gradient defines the gradient to use (between 0 and 1)
  72338. * @param factor defines the size factor to affect to the specified gradient
  72339. * @returns the current particle system
  72340. */
  72341. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72342. /**
  72343. * Remove a specific size gradient
  72344. * @param gradient defines the gradient to remove
  72345. * @returns the current particle system
  72346. */
  72347. removeSizeGradient(gradient: number): GPUParticleSystem;
  72348. private _refreshFactorGradient;
  72349. /**
  72350. * Adds a new angular speed gradient
  72351. * @param gradient defines the gradient to use (between 0 and 1)
  72352. * @param factor defines the angular speed to affect to the specified gradient
  72353. * @returns the current particle system
  72354. */
  72355. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72356. /**
  72357. * Remove a specific angular speed gradient
  72358. * @param gradient defines the gradient to remove
  72359. * @returns the current particle system
  72360. */
  72361. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72362. /**
  72363. * Adds a new velocity gradient
  72364. * @param gradient defines the gradient to use (between 0 and 1)
  72365. * @param factor defines the velocity to affect to the specified gradient
  72366. * @returns the current particle system
  72367. */
  72368. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72369. /**
  72370. * Remove a specific velocity gradient
  72371. * @param gradient defines the gradient to remove
  72372. * @returns the current particle system
  72373. */
  72374. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72375. /**
  72376. * Adds a new limit velocity gradient
  72377. * @param gradient defines the gradient to use (between 0 and 1)
  72378. * @param factor defines the limit velocity value to affect to the specified gradient
  72379. * @returns the current particle system
  72380. */
  72381. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72382. /**
  72383. * Remove a specific limit velocity gradient
  72384. * @param gradient defines the gradient to remove
  72385. * @returns the current particle system
  72386. */
  72387. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72388. /**
  72389. * Adds a new drag gradient
  72390. * @param gradient defines the gradient to use (between 0 and 1)
  72391. * @param factor defines the drag value to affect to the specified gradient
  72392. * @returns the current particle system
  72393. */
  72394. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72395. /**
  72396. * Remove a specific drag gradient
  72397. * @param gradient defines the gradient to remove
  72398. * @returns the current particle system
  72399. */
  72400. removeDragGradient(gradient: number): GPUParticleSystem;
  72401. /**
  72402. * Not supported by GPUParticleSystem
  72403. * @param gradient defines the gradient to use (between 0 and 1)
  72404. * @param factor defines the emit rate value to affect to the specified gradient
  72405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72406. * @returns the current particle system
  72407. */
  72408. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72409. /**
  72410. * Not supported by GPUParticleSystem
  72411. * @param gradient defines the gradient to remove
  72412. * @returns the current particle system
  72413. */
  72414. removeEmitRateGradient(gradient: number): IParticleSystem;
  72415. /**
  72416. * Not supported by GPUParticleSystem
  72417. * @param gradient defines the gradient to use (between 0 and 1)
  72418. * @param factor defines the start size value to affect to the specified gradient
  72419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72420. * @returns the current particle system
  72421. */
  72422. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72423. /**
  72424. * Not supported by GPUParticleSystem
  72425. * @param gradient defines the gradient to remove
  72426. * @returns the current particle system
  72427. */
  72428. removeStartSizeGradient(gradient: number): IParticleSystem;
  72429. /**
  72430. * Not supported by GPUParticleSystem
  72431. * @param gradient defines the gradient to use (between 0 and 1)
  72432. * @param min defines the color remap minimal range
  72433. * @param max defines the color remap maximal range
  72434. * @returns the current particle system
  72435. */
  72436. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72437. /**
  72438. * Not supported by GPUParticleSystem
  72439. * @param gradient defines the gradient to remove
  72440. * @returns the current particle system
  72441. */
  72442. removeColorRemapGradient(): IParticleSystem;
  72443. /**
  72444. * Not supported by GPUParticleSystem
  72445. * @param gradient defines the gradient to use (between 0 and 1)
  72446. * @param min defines the alpha remap minimal range
  72447. * @param max defines the alpha remap maximal range
  72448. * @returns the current particle system
  72449. */
  72450. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72451. /**
  72452. * Not supported by GPUParticleSystem
  72453. * @param gradient defines the gradient to remove
  72454. * @returns the current particle system
  72455. */
  72456. removeAlphaRemapGradient(): IParticleSystem;
  72457. /**
  72458. * Not supported by GPUParticleSystem
  72459. * @param gradient defines the gradient to use (between 0 and 1)
  72460. * @param color defines the color to affect to the specified gradient
  72461. * @returns the current particle system
  72462. */
  72463. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72464. /**
  72465. * Not supported by GPUParticleSystem
  72466. * @param gradient defines the gradient to remove
  72467. * @returns the current particle system
  72468. */
  72469. removeRampGradient(): IParticleSystem;
  72470. /**
  72471. * Not supported by GPUParticleSystem
  72472. * @returns the list of ramp gradients
  72473. */
  72474. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72475. /**
  72476. * Not supported by GPUParticleSystem
  72477. * Gets or sets a boolean indicating that ramp gradients must be used
  72478. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72479. */
  72480. get useRampGradients(): boolean;
  72481. set useRampGradients(value: boolean);
  72482. /**
  72483. * Not supported by GPUParticleSystem
  72484. * @param gradient defines the gradient to use (between 0 and 1)
  72485. * @param factor defines the life time factor to affect to the specified gradient
  72486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72487. * @returns the current particle system
  72488. */
  72489. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72490. /**
  72491. * Not supported by GPUParticleSystem
  72492. * @param gradient defines the gradient to remove
  72493. * @returns the current particle system
  72494. */
  72495. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72496. /**
  72497. * Instantiates a GPU particle system.
  72498. * 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.
  72499. * @param name The name of the particle system
  72500. * @param options The options used to create the system
  72501. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72502. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72503. * @param customEffect a custom effect used to change the way particles are rendered by default
  72504. */
  72505. constructor(name: string, options: Partial<{
  72506. capacity: number;
  72507. randomTextureSize: number;
  72508. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72509. protected _reset(): void;
  72510. private _createUpdateVAO;
  72511. private _createRenderVAO;
  72512. private _initialize;
  72513. /** @hidden */
  72514. _recreateUpdateEffect(): void;
  72515. private _getEffect;
  72516. /**
  72517. * Fill the defines array according to the current settings of the particle system
  72518. * @param defines Array to be updated
  72519. * @param blendMode blend mode to take into account when updating the array
  72520. */
  72521. fillDefines(defines: Array<string>, blendMode?: number): void;
  72522. /**
  72523. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72524. * @param uniforms Uniforms array to fill
  72525. * @param attributes Attributes array to fill
  72526. * @param samplers Samplers array to fill
  72527. */
  72528. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72529. /** @hidden */
  72530. _recreateRenderEffect(): Effect;
  72531. /**
  72532. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72533. * @param preWarm defines if we are in the pre-warmimg phase
  72534. */
  72535. animate(preWarm?: boolean): void;
  72536. private _createFactorGradientTexture;
  72537. private _createSizeGradientTexture;
  72538. private _createAngularSpeedGradientTexture;
  72539. private _createVelocityGradientTexture;
  72540. private _createLimitVelocityGradientTexture;
  72541. private _createDragGradientTexture;
  72542. private _createColorGradientTexture;
  72543. /**
  72544. * Renders the particle system in its current state
  72545. * @param preWarm defines if the system should only update the particles but not render them
  72546. * @returns the current number of particles
  72547. */
  72548. render(preWarm?: boolean): number;
  72549. /**
  72550. * Rebuilds the particle system
  72551. */
  72552. rebuild(): void;
  72553. private _releaseBuffers;
  72554. private _releaseVAOs;
  72555. /**
  72556. * Disposes the particle system and free the associated resources
  72557. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72558. */
  72559. dispose(disposeTexture?: boolean): void;
  72560. /**
  72561. * Clones the particle system.
  72562. * @param name The name of the cloned object
  72563. * @param newEmitter The new emitter to use
  72564. * @returns the cloned particle system
  72565. */
  72566. clone(name: string, newEmitter: any): GPUParticleSystem;
  72567. /**
  72568. * Serializes the particle system to a JSON object
  72569. * @param serializeTexture defines if the texture must be serialized as well
  72570. * @returns the JSON object
  72571. */
  72572. serialize(serializeTexture?: boolean): any;
  72573. /**
  72574. * Parses a JSON object to create a GPU particle system.
  72575. * @param parsedParticleSystem The JSON object to parse
  72576. * @param sceneOrEngine The scene or the engine to create the particle system in
  72577. * @param rootUrl The root url to use to load external dependencies like texture
  72578. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72579. * @returns the parsed GPU particle system
  72580. */
  72581. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72582. }
  72583. }
  72584. declare module "babylonjs/Particles/particleSystemSet" {
  72585. import { Nullable } from "babylonjs/types";
  72586. import { Color3 } from "babylonjs/Maths/math.color";
  72587. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72589. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72590. import { Scene, IDisposable } from "babylonjs/scene";
  72591. /**
  72592. * Represents a set of particle systems working together to create a specific effect
  72593. */
  72594. export class ParticleSystemSet implements IDisposable {
  72595. /**
  72596. * Gets or sets base Assets URL
  72597. */
  72598. static BaseAssetsUrl: string;
  72599. private _emitterCreationOptions;
  72600. private _emitterNode;
  72601. /**
  72602. * Gets the particle system list
  72603. */
  72604. systems: IParticleSystem[];
  72605. /**
  72606. * Gets the emitter node used with this set
  72607. */
  72608. get emitterNode(): Nullable<TransformNode>;
  72609. /**
  72610. * Creates a new emitter mesh as a sphere
  72611. * @param options defines the options used to create the sphere
  72612. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72613. * @param scene defines the hosting scene
  72614. */
  72615. setEmitterAsSphere(options: {
  72616. diameter: number;
  72617. segments: number;
  72618. color: Color3;
  72619. }, renderingGroupId: number, scene: Scene): void;
  72620. /**
  72621. * Starts all particle systems of the set
  72622. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72623. */
  72624. start(emitter?: AbstractMesh): void;
  72625. /**
  72626. * Release all associated resources
  72627. */
  72628. dispose(): void;
  72629. /**
  72630. * Serialize the set into a JSON compatible object
  72631. * @param serializeTexture defines if the texture must be serialized as well
  72632. * @returns a JSON compatible representation of the set
  72633. */
  72634. serialize(serializeTexture?: boolean): any;
  72635. /**
  72636. * Parse a new ParticleSystemSet from a serialized source
  72637. * @param data defines a JSON compatible representation of the set
  72638. * @param scene defines the hosting scene
  72639. * @param gpu defines if we want GPU particles or CPU particles
  72640. * @returns a new ParticleSystemSet
  72641. */
  72642. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72643. }
  72644. }
  72645. declare module "babylonjs/Particles/particleHelper" {
  72646. import { Nullable } from "babylonjs/types";
  72647. import { Scene } from "babylonjs/scene";
  72648. import { Vector3 } from "babylonjs/Maths/math.vector";
  72649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72650. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72651. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  72652. /**
  72653. * This class is made for on one-liner static method to help creating particle system set.
  72654. */
  72655. export class ParticleHelper {
  72656. /**
  72657. * Gets or sets base Assets URL
  72658. */
  72659. static BaseAssetsUrl: string;
  72660. /** Define the Url to load snippets */
  72661. static SnippetUrl: string;
  72662. /**
  72663. * Create a default particle system that you can tweak
  72664. * @param emitter defines the emitter to use
  72665. * @param capacity defines the system capacity (default is 500 particles)
  72666. * @param scene defines the hosting scene
  72667. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72668. * @returns the new Particle system
  72669. */
  72670. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72671. /**
  72672. * This is the main static method (one-liner) of this helper to create different particle systems
  72673. * @param type This string represents the type to the particle system to create
  72674. * @param scene The scene where the particle system should live
  72675. * @param gpu If the system will use gpu
  72676. * @returns the ParticleSystemSet created
  72677. */
  72678. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72679. /**
  72680. * Static function used to export a particle system to a ParticleSystemSet variable.
  72681. * Please note that the emitter shape is not exported
  72682. * @param systems defines the particle systems to export
  72683. * @returns the created particle system set
  72684. */
  72685. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72686. /**
  72687. * Creates a particle system from a snippet saved in a remote file
  72688. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72689. * @param url defines the url to load from
  72690. * @param scene defines the hosting scene
  72691. * @param gpu If the system will use gpu
  72692. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72693. * @returns a promise that will resolve to the new particle system
  72694. */
  72695. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72696. /**
  72697. * Creates a particle system from a snippet saved by the particle system editor
  72698. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72699. * @param scene defines the hosting scene
  72700. * @param gpu If the system will use gpu
  72701. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72702. * @returns a promise that will resolve to the new particle system
  72703. */
  72704. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72705. }
  72706. }
  72707. declare module "babylonjs/Particles/particleSystemComponent" {
  72708. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72709. import { Effect } from "babylonjs/Materials/effect";
  72710. import "babylonjs/Shaders/particles.vertex";
  72711. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  72712. module "babylonjs/Engines/engine" {
  72713. interface Engine {
  72714. /**
  72715. * Create an effect to use with particle systems.
  72716. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72717. * the particle system for which you want to create a custom effect in the last parameter
  72718. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72719. * @param uniformsNames defines a list of attribute names
  72720. * @param samplers defines an array of string used to represent textures
  72721. * @param defines defines the string containing the defines to use to compile the shaders
  72722. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72723. * @param onCompiled defines a function to call when the effect creation is successful
  72724. * @param onError defines a function to call when the effect creation has failed
  72725. * @param particleSystem the particle system you want to create the effect for
  72726. * @returns the new Effect
  72727. */
  72728. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72729. }
  72730. }
  72731. module "babylonjs/Meshes/mesh" {
  72732. interface Mesh {
  72733. /**
  72734. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72735. * @returns an array of IParticleSystem
  72736. */
  72737. getEmittedParticleSystems(): IParticleSystem[];
  72738. /**
  72739. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72740. * @returns an array of IParticleSystem
  72741. */
  72742. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72743. }
  72744. }
  72745. }
  72746. declare module "babylonjs/Particles/pointsCloudSystem" {
  72747. import { Color4 } from "babylonjs/Maths/math";
  72748. import { Mesh } from "babylonjs/Meshes/mesh";
  72749. import { Scene, IDisposable } from "babylonjs/scene";
  72750. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  72751. /** Defines the 4 color options */
  72752. export enum PointColor {
  72753. /** color value */
  72754. Color = 2,
  72755. /** uv value */
  72756. UV = 1,
  72757. /** random value */
  72758. Random = 0,
  72759. /** stated value */
  72760. Stated = 3
  72761. }
  72762. /**
  72763. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72764. * 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.
  72765. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72766. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72767. *
  72768. * Full documentation here : TO BE ENTERED
  72769. */
  72770. export class PointsCloudSystem implements IDisposable {
  72771. /**
  72772. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72773. * Example : var p = SPS.particles[i];
  72774. */
  72775. particles: CloudPoint[];
  72776. /**
  72777. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72778. */
  72779. nbParticles: number;
  72780. /**
  72781. * This a counter for your own usage. It's not set by any SPS functions.
  72782. */
  72783. counter: number;
  72784. /**
  72785. * The PCS name. This name is also given to the underlying mesh.
  72786. */
  72787. name: string;
  72788. /**
  72789. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72790. */
  72791. mesh: Mesh;
  72792. /**
  72793. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72794. * Please read :
  72795. */
  72796. vars: any;
  72797. /**
  72798. * @hidden
  72799. */
  72800. _size: number;
  72801. private _scene;
  72802. private _promises;
  72803. private _positions;
  72804. private _indices;
  72805. private _normals;
  72806. private _colors;
  72807. private _uvs;
  72808. private _indices32;
  72809. private _positions32;
  72810. private _colors32;
  72811. private _uvs32;
  72812. private _updatable;
  72813. private _isVisibilityBoxLocked;
  72814. private _alwaysVisible;
  72815. private _groups;
  72816. private _groupCounter;
  72817. private _computeParticleColor;
  72818. private _computeParticleTexture;
  72819. private _computeParticleRotation;
  72820. private _computeBoundingBox;
  72821. private _isReady;
  72822. /**
  72823. * Creates a PCS (Points Cloud System) object
  72824. * @param name (String) is the PCS name, this will be the underlying mesh name
  72825. * @param pointSize (number) is the size for each point
  72826. * @param scene (Scene) is the scene in which the PCS is added
  72827. * @param options defines the options of the PCS e.g.
  72828. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72829. */
  72830. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72831. updatable?: boolean;
  72832. });
  72833. /**
  72834. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72835. * If no points were added to the PCS, the returned mesh is just a single point.
  72836. * @returns a promise for the created mesh
  72837. */
  72838. buildMeshAsync(): Promise<Mesh>;
  72839. /**
  72840. * @hidden
  72841. */
  72842. private _buildMesh;
  72843. private _addParticle;
  72844. private _randomUnitVector;
  72845. private _getColorIndicesForCoord;
  72846. private _setPointsColorOrUV;
  72847. private _colorFromTexture;
  72848. private _calculateDensity;
  72849. /**
  72850. * Adds points to the PCS in random positions within a unit sphere
  72851. * @param nb (positive integer) the number of particles to be created from this model
  72852. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72853. * @returns the number of groups in the system
  72854. */
  72855. addPoints(nb: number, pointFunction?: any): number;
  72856. /**
  72857. * Adds points to the PCS from the surface of the model shape
  72858. * @param mesh is any Mesh object that will be used as a surface model for the points
  72859. * @param nb (positive integer) the number of particles to be created from this model
  72860. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72861. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72862. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72863. * @returns the number of groups in the system
  72864. */
  72865. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72866. /**
  72867. * Adds points to the PCS inside the model shape
  72868. * @param mesh is any Mesh object that will be used as a surface model for the points
  72869. * @param nb (positive integer) the number of particles to be created from this model
  72870. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72871. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72872. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72873. * @returns the number of groups in the system
  72874. */
  72875. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72876. /**
  72877. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72878. * This method calls `updateParticle()` for each particle of the SPS.
  72879. * For an animated SPS, it is usually called within the render loop.
  72880. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72881. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72882. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72883. * @returns the PCS.
  72884. */
  72885. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72886. /**
  72887. * Disposes the PCS.
  72888. */
  72889. dispose(): void;
  72890. /**
  72891. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72892. * doc :
  72893. * @returns the PCS.
  72894. */
  72895. refreshVisibleSize(): PointsCloudSystem;
  72896. /**
  72897. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72898. * @param size the size (float) of the visibility box
  72899. * note : this doesn't lock the PCS mesh bounding box.
  72900. * doc :
  72901. */
  72902. setVisibilityBox(size: number): void;
  72903. /**
  72904. * Gets whether the PCS is always visible or not
  72905. * doc :
  72906. */
  72907. get isAlwaysVisible(): boolean;
  72908. /**
  72909. * Sets the PCS as always visible or not
  72910. * doc :
  72911. */
  72912. set isAlwaysVisible(val: boolean);
  72913. /**
  72914. * Tells to `setParticles()` to compute the particle rotations or not
  72915. * Default value : false. The PCS is faster when it's set to false
  72916. * Note : particle rotations are only applied to parent particles
  72917. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72918. */
  72919. set computeParticleRotation(val: boolean);
  72920. /**
  72921. * Tells to `setParticles()` to compute the particle colors or not.
  72922. * Default value : true. The PCS is faster when it's set to false.
  72923. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72924. */
  72925. set computeParticleColor(val: boolean);
  72926. set computeParticleTexture(val: boolean);
  72927. /**
  72928. * Gets if `setParticles()` computes the particle colors or not.
  72929. * Default value : false. The PCS is faster when it's set to false.
  72930. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72931. */
  72932. get computeParticleColor(): boolean;
  72933. /**
  72934. * Gets if `setParticles()` computes the particle textures or not.
  72935. * Default value : false. The PCS is faster when it's set to false.
  72936. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72937. */
  72938. get computeParticleTexture(): boolean;
  72939. /**
  72940. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72941. */
  72942. set computeBoundingBox(val: boolean);
  72943. /**
  72944. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72945. */
  72946. get computeBoundingBox(): boolean;
  72947. /**
  72948. * This function does nothing. It may be overwritten to set all the particle first values.
  72949. * The PCS doesn't call this function, you may have to call it by your own.
  72950. * doc :
  72951. */
  72952. initParticles(): void;
  72953. /**
  72954. * This function does nothing. It may be overwritten to recycle a particle
  72955. * The PCS doesn't call this function, you can to call it
  72956. * doc :
  72957. * @param particle The particle to recycle
  72958. * @returns the recycled particle
  72959. */
  72960. recycleParticle(particle: CloudPoint): CloudPoint;
  72961. /**
  72962. * Updates a particle : this function should be overwritten by the user.
  72963. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72964. * doc :
  72965. * @example : just set a particle position or velocity and recycle conditions
  72966. * @param particle The particle to update
  72967. * @returns the updated particle
  72968. */
  72969. updateParticle(particle: CloudPoint): CloudPoint;
  72970. /**
  72971. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72972. * This does nothing and may be overwritten by the user.
  72973. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72974. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72975. * @param update the boolean update value actually passed to setParticles()
  72976. */
  72977. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72978. /**
  72979. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72980. * This will be passed three parameters.
  72981. * This does nothing and may be overwritten by the user.
  72982. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72983. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72984. * @param update the boolean update value actually passed to setParticles()
  72985. */
  72986. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72987. }
  72988. }
  72989. declare module "babylonjs/Particles/cloudPoint" {
  72990. import { Nullable } from "babylonjs/types";
  72991. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  72992. import { Mesh } from "babylonjs/Meshes/mesh";
  72993. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  72994. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  72995. /**
  72996. * Represents one particle of a points cloud system.
  72997. */
  72998. export class CloudPoint {
  72999. /**
  73000. * particle global index
  73001. */
  73002. idx: number;
  73003. /**
  73004. * The color of the particle
  73005. */
  73006. color: Nullable<Color4>;
  73007. /**
  73008. * The world space position of the particle.
  73009. */
  73010. position: Vector3;
  73011. /**
  73012. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73013. */
  73014. rotation: Vector3;
  73015. /**
  73016. * The world space rotation quaternion of the particle.
  73017. */
  73018. rotationQuaternion: Nullable<Quaternion>;
  73019. /**
  73020. * The uv of the particle.
  73021. */
  73022. uv: Nullable<Vector2>;
  73023. /**
  73024. * The current speed of the particle.
  73025. */
  73026. velocity: Vector3;
  73027. /**
  73028. * The pivot point in the particle local space.
  73029. */
  73030. pivot: Vector3;
  73031. /**
  73032. * Must the particle be translated from its pivot point in its local space ?
  73033. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73034. * Default : false
  73035. */
  73036. translateFromPivot: boolean;
  73037. /**
  73038. * Index of this particle in the global "positions" array (Internal use)
  73039. * @hidden
  73040. */
  73041. _pos: number;
  73042. /**
  73043. * @hidden Index of this particle in the global "indices" array (Internal use)
  73044. */
  73045. _ind: number;
  73046. /**
  73047. * Group this particle belongs to
  73048. */
  73049. _group: PointsGroup;
  73050. /**
  73051. * Group id of this particle
  73052. */
  73053. groupId: number;
  73054. /**
  73055. * Index of the particle in its group id (Internal use)
  73056. */
  73057. idxInGroup: number;
  73058. /**
  73059. * @hidden Particle BoundingInfo object (Internal use)
  73060. */
  73061. _boundingInfo: BoundingInfo;
  73062. /**
  73063. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73064. */
  73065. _pcs: PointsCloudSystem;
  73066. /**
  73067. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73068. */
  73069. _stillInvisible: boolean;
  73070. /**
  73071. * @hidden Last computed particle rotation matrix
  73072. */
  73073. _rotationMatrix: number[];
  73074. /**
  73075. * Parent particle Id, if any.
  73076. * Default null.
  73077. */
  73078. parentId: Nullable<number>;
  73079. /**
  73080. * @hidden Internal global position in the PCS.
  73081. */
  73082. _globalPosition: Vector3;
  73083. /**
  73084. * Creates a Point Cloud object.
  73085. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73086. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73087. * @param group (PointsGroup) is the group the particle belongs to
  73088. * @param groupId (integer) is the group identifier in the PCS.
  73089. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73090. * @param pcs defines the PCS it is associated to
  73091. */
  73092. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73093. /**
  73094. * get point size
  73095. */
  73096. get size(): Vector3;
  73097. /**
  73098. * Set point size
  73099. */
  73100. set size(scale: Vector3);
  73101. /**
  73102. * Legacy support, changed quaternion to rotationQuaternion
  73103. */
  73104. get quaternion(): Nullable<Quaternion>;
  73105. /**
  73106. * Legacy support, changed quaternion to rotationQuaternion
  73107. */
  73108. set quaternion(q: Nullable<Quaternion>);
  73109. /**
  73110. * Returns a boolean. True if the particle intersects a mesh, else false
  73111. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73112. * @param target is the object (point or mesh) what the intersection is computed against
  73113. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  73114. * @returns true if it intersects
  73115. */
  73116. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73117. /**
  73118. * get the rotation matrix of the particle
  73119. * @hidden
  73120. */
  73121. getRotationMatrix(m: Matrix): void;
  73122. }
  73123. /**
  73124. * Represents a group of points in a points cloud system
  73125. * * PCS internal tool, don't use it manually.
  73126. */
  73127. export class PointsGroup {
  73128. /**
  73129. * The group id
  73130. * @hidden
  73131. */
  73132. groupID: number;
  73133. /**
  73134. * image data for group (internal use)
  73135. * @hidden
  73136. */
  73137. _groupImageData: Nullable<ArrayBufferView>;
  73138. /**
  73139. * Image Width (internal use)
  73140. * @hidden
  73141. */
  73142. _groupImgWidth: number;
  73143. /**
  73144. * Image Height (internal use)
  73145. * @hidden
  73146. */
  73147. _groupImgHeight: number;
  73148. /**
  73149. * Custom position function (internal use)
  73150. * @hidden
  73151. */
  73152. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73153. /**
  73154. * density per facet for surface points
  73155. * @hidden
  73156. */
  73157. _groupDensity: number[];
  73158. /**
  73159. * Only when points are colored by texture carries pointer to texture list array
  73160. * @hidden
  73161. */
  73162. _textureNb: number;
  73163. /**
  73164. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73165. * PCS internal tool, don't use it manually.
  73166. * @hidden
  73167. */
  73168. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73169. }
  73170. }
  73171. declare module "babylonjs/Particles/index" {
  73172. export * from "babylonjs/Particles/baseParticleSystem";
  73173. export * from "babylonjs/Particles/EmitterTypes/index";
  73174. export * from "babylonjs/Particles/gpuParticleSystem";
  73175. export * from "babylonjs/Particles/IParticleSystem";
  73176. export * from "babylonjs/Particles/particle";
  73177. export * from "babylonjs/Particles/particleHelper";
  73178. export * from "babylonjs/Particles/particleSystem";
  73179. import "babylonjs/Particles/particleSystemComponent";
  73180. export * from "babylonjs/Particles/particleSystemComponent";
  73181. export * from "babylonjs/Particles/particleSystemSet";
  73182. export * from "babylonjs/Particles/solidParticle";
  73183. export * from "babylonjs/Particles/solidParticleSystem";
  73184. export * from "babylonjs/Particles/cloudPoint";
  73185. export * from "babylonjs/Particles/pointsCloudSystem";
  73186. export * from "babylonjs/Particles/subEmitter";
  73187. }
  73188. declare module "babylonjs/Physics/physicsEngineComponent" {
  73189. import { Nullable } from "babylonjs/types";
  73190. import { Observable, Observer } from "babylonjs/Misc/observable";
  73191. import { Vector3 } from "babylonjs/Maths/math.vector";
  73192. import { Mesh } from "babylonjs/Meshes/mesh";
  73193. import { ISceneComponent } from "babylonjs/sceneComponent";
  73194. import { Scene } from "babylonjs/scene";
  73195. import { Node } from "babylonjs/node";
  73196. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  73197. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73198. module "babylonjs/scene" {
  73199. interface Scene {
  73200. /** @hidden (Backing field) */
  73201. _physicsEngine: Nullable<IPhysicsEngine>;
  73202. /** @hidden */
  73203. _physicsTimeAccumulator: number;
  73204. /**
  73205. * Gets the current physics engine
  73206. * @returns a IPhysicsEngine or null if none attached
  73207. */
  73208. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73209. /**
  73210. * Enables physics to the current scene
  73211. * @param gravity defines the scene's gravity for the physics engine
  73212. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73213. * @return a boolean indicating if the physics engine was initialized
  73214. */
  73215. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73216. /**
  73217. * Disables and disposes the physics engine associated with the scene
  73218. */
  73219. disablePhysicsEngine(): void;
  73220. /**
  73221. * Gets a boolean indicating if there is an active physics engine
  73222. * @returns a boolean indicating if there is an active physics engine
  73223. */
  73224. isPhysicsEnabled(): boolean;
  73225. /**
  73226. * Deletes a physics compound impostor
  73227. * @param compound defines the compound to delete
  73228. */
  73229. deleteCompoundImpostor(compound: any): void;
  73230. /**
  73231. * An event triggered when physic simulation is about to be run
  73232. */
  73233. onBeforePhysicsObservable: Observable<Scene>;
  73234. /**
  73235. * An event triggered when physic simulation has been done
  73236. */
  73237. onAfterPhysicsObservable: Observable<Scene>;
  73238. }
  73239. }
  73240. module "babylonjs/Meshes/abstractMesh" {
  73241. interface AbstractMesh {
  73242. /** @hidden */
  73243. _physicsImpostor: Nullable<PhysicsImpostor>;
  73244. /**
  73245. * Gets or sets impostor used for physic simulation
  73246. * @see https://doc.babylonjs.com/features/physics_engine
  73247. */
  73248. physicsImpostor: Nullable<PhysicsImpostor>;
  73249. /**
  73250. * Gets the current physics impostor
  73251. * @see https://doc.babylonjs.com/features/physics_engine
  73252. * @returns a physics impostor or null
  73253. */
  73254. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73255. /** Apply a physic impulse to the mesh
  73256. * @param force defines the force to apply
  73257. * @param contactPoint defines where to apply the force
  73258. * @returns the current mesh
  73259. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73260. */
  73261. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73262. /**
  73263. * Creates a physic joint between two meshes
  73264. * @param otherMesh defines the other mesh to use
  73265. * @param pivot1 defines the pivot to use on this mesh
  73266. * @param pivot2 defines the pivot to use on the other mesh
  73267. * @param options defines additional options (can be plugin dependent)
  73268. * @returns the current mesh
  73269. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73270. */
  73271. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73272. /** @hidden */
  73273. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73274. }
  73275. }
  73276. /**
  73277. * Defines the physics engine scene component responsible to manage a physics engine
  73278. */
  73279. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73280. /**
  73281. * The component name helpful to identify the component in the list of scene components.
  73282. */
  73283. readonly name: string;
  73284. /**
  73285. * The scene the component belongs to.
  73286. */
  73287. scene: Scene;
  73288. /**
  73289. * Creates a new instance of the component for the given scene
  73290. * @param scene Defines the scene to register the component in
  73291. */
  73292. constructor(scene: Scene);
  73293. /**
  73294. * Registers the component in a given scene
  73295. */
  73296. register(): void;
  73297. /**
  73298. * Rebuilds the elements related to this component in case of
  73299. * context lost for instance.
  73300. */
  73301. rebuild(): void;
  73302. /**
  73303. * Disposes the component and the associated ressources
  73304. */
  73305. dispose(): void;
  73306. }
  73307. }
  73308. declare module "babylonjs/Physics/physicsHelper" {
  73309. import { Nullable } from "babylonjs/types";
  73310. import { Vector3 } from "babylonjs/Maths/math.vector";
  73311. import { Mesh } from "babylonjs/Meshes/mesh";
  73312. import { Scene } from "babylonjs/scene";
  73313. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73314. /**
  73315. * A helper for physics simulations
  73316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73317. */
  73318. export class PhysicsHelper {
  73319. private _scene;
  73320. private _physicsEngine;
  73321. /**
  73322. * Initializes the Physics helper
  73323. * @param scene Babylon.js scene
  73324. */
  73325. constructor(scene: Scene);
  73326. /**
  73327. * Applies a radial explosion impulse
  73328. * @param origin the origin of the explosion
  73329. * @param radiusOrEventOptions the radius or the options of radial explosion
  73330. * @param strength the explosion strength
  73331. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73332. * @returns A physics radial explosion event, or null
  73333. */
  73334. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73335. /**
  73336. * Applies a radial explosion force
  73337. * @param origin the origin of the explosion
  73338. * @param radiusOrEventOptions the radius or the options of radial explosion
  73339. * @param strength the explosion strength
  73340. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73341. * @returns A physics radial explosion event, or null
  73342. */
  73343. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73344. /**
  73345. * Creates a gravitational field
  73346. * @param origin the origin of the explosion
  73347. * @param radiusOrEventOptions the radius or the options of radial explosion
  73348. * @param strength the explosion strength
  73349. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73350. * @returns A physics gravitational field event, or null
  73351. */
  73352. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73353. /**
  73354. * Creates a physics updraft event
  73355. * @param origin the origin of the updraft
  73356. * @param radiusOrEventOptions the radius or the options of the updraft
  73357. * @param strength the strength of the updraft
  73358. * @param height the height of the updraft
  73359. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73360. * @returns A physics updraft event, or null
  73361. */
  73362. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73363. /**
  73364. * Creates a physics vortex event
  73365. * @param origin the of the vortex
  73366. * @param radiusOrEventOptions the radius or the options of the vortex
  73367. * @param strength the strength of the vortex
  73368. * @param height the height of the vortex
  73369. * @returns a Physics vortex event, or null
  73370. * A physics vortex event or null
  73371. */
  73372. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73373. }
  73374. /**
  73375. * Represents a physics radial explosion event
  73376. */
  73377. class PhysicsRadialExplosionEvent {
  73378. private _scene;
  73379. private _options;
  73380. private _sphere;
  73381. private _dataFetched;
  73382. /**
  73383. * Initializes a radial explosioin event
  73384. * @param _scene BabylonJS scene
  73385. * @param _options The options for the vortex event
  73386. */
  73387. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73388. /**
  73389. * Returns the data related to the radial explosion event (sphere).
  73390. * @returns The radial explosion event data
  73391. */
  73392. getData(): PhysicsRadialExplosionEventData;
  73393. /**
  73394. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73395. * @param impostor A physics imposter
  73396. * @param origin the origin of the explosion
  73397. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73398. */
  73399. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73400. /**
  73401. * Triggers affecterd impostors callbacks
  73402. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73403. */
  73404. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73405. /**
  73406. * Disposes the sphere.
  73407. * @param force Specifies if the sphere should be disposed by force
  73408. */
  73409. dispose(force?: boolean): void;
  73410. /*** Helpers ***/
  73411. private _prepareSphere;
  73412. private _intersectsWithSphere;
  73413. }
  73414. /**
  73415. * Represents a gravitational field event
  73416. */
  73417. class PhysicsGravitationalFieldEvent {
  73418. private _physicsHelper;
  73419. private _scene;
  73420. private _origin;
  73421. private _options;
  73422. private _tickCallback;
  73423. private _sphere;
  73424. private _dataFetched;
  73425. /**
  73426. * Initializes the physics gravitational field event
  73427. * @param _physicsHelper A physics helper
  73428. * @param _scene BabylonJS scene
  73429. * @param _origin The origin position of the gravitational field event
  73430. * @param _options The options for the vortex event
  73431. */
  73432. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73433. /**
  73434. * Returns the data related to the gravitational field event (sphere).
  73435. * @returns A gravitational field event
  73436. */
  73437. getData(): PhysicsGravitationalFieldEventData;
  73438. /**
  73439. * Enables the gravitational field.
  73440. */
  73441. enable(): void;
  73442. /**
  73443. * Disables the gravitational field.
  73444. */
  73445. disable(): void;
  73446. /**
  73447. * Disposes the sphere.
  73448. * @param force The force to dispose from the gravitational field event
  73449. */
  73450. dispose(force?: boolean): void;
  73451. private _tick;
  73452. }
  73453. /**
  73454. * Represents a physics updraft event
  73455. */
  73456. class PhysicsUpdraftEvent {
  73457. private _scene;
  73458. private _origin;
  73459. private _options;
  73460. private _physicsEngine;
  73461. private _originTop;
  73462. private _originDirection;
  73463. private _tickCallback;
  73464. private _cylinder;
  73465. private _cylinderPosition;
  73466. private _dataFetched;
  73467. /**
  73468. * Initializes the physics updraft event
  73469. * @param _scene BabylonJS scene
  73470. * @param _origin The origin position of the updraft
  73471. * @param _options The options for the updraft event
  73472. */
  73473. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73474. /**
  73475. * Returns the data related to the updraft event (cylinder).
  73476. * @returns A physics updraft event
  73477. */
  73478. getData(): PhysicsUpdraftEventData;
  73479. /**
  73480. * Enables the updraft.
  73481. */
  73482. enable(): void;
  73483. /**
  73484. * Disables the updraft.
  73485. */
  73486. disable(): void;
  73487. /**
  73488. * Disposes the cylinder.
  73489. * @param force Specifies if the updraft should be disposed by force
  73490. */
  73491. dispose(force?: boolean): void;
  73492. private getImpostorHitData;
  73493. private _tick;
  73494. /*** Helpers ***/
  73495. private _prepareCylinder;
  73496. private _intersectsWithCylinder;
  73497. }
  73498. /**
  73499. * Represents a physics vortex event
  73500. */
  73501. class PhysicsVortexEvent {
  73502. private _scene;
  73503. private _origin;
  73504. private _options;
  73505. private _physicsEngine;
  73506. private _originTop;
  73507. private _tickCallback;
  73508. private _cylinder;
  73509. private _cylinderPosition;
  73510. private _dataFetched;
  73511. /**
  73512. * Initializes the physics vortex event
  73513. * @param _scene The BabylonJS scene
  73514. * @param _origin The origin position of the vortex
  73515. * @param _options The options for the vortex event
  73516. */
  73517. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73518. /**
  73519. * Returns the data related to the vortex event (cylinder).
  73520. * @returns The physics vortex event data
  73521. */
  73522. getData(): PhysicsVortexEventData;
  73523. /**
  73524. * Enables the vortex.
  73525. */
  73526. enable(): void;
  73527. /**
  73528. * Disables the cortex.
  73529. */
  73530. disable(): void;
  73531. /**
  73532. * Disposes the sphere.
  73533. * @param force
  73534. */
  73535. dispose(force?: boolean): void;
  73536. private getImpostorHitData;
  73537. private _tick;
  73538. /*** Helpers ***/
  73539. private _prepareCylinder;
  73540. private _intersectsWithCylinder;
  73541. }
  73542. /**
  73543. * Options fot the radial explosion event
  73544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73545. */
  73546. export class PhysicsRadialExplosionEventOptions {
  73547. /**
  73548. * The radius of the sphere for the radial explosion.
  73549. */
  73550. radius: number;
  73551. /**
  73552. * The strenth of the explosion.
  73553. */
  73554. strength: number;
  73555. /**
  73556. * The strenght of the force in correspondence to the distance of the affected object
  73557. */
  73558. falloff: PhysicsRadialImpulseFalloff;
  73559. /**
  73560. * Sphere options for the radial explosion.
  73561. */
  73562. sphere: {
  73563. segments: number;
  73564. diameter: number;
  73565. };
  73566. /**
  73567. * Sphere options for the radial explosion.
  73568. */
  73569. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73570. }
  73571. /**
  73572. * Options fot the updraft event
  73573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73574. */
  73575. export class PhysicsUpdraftEventOptions {
  73576. /**
  73577. * The radius of the cylinder for the vortex
  73578. */
  73579. radius: number;
  73580. /**
  73581. * The strenth of the updraft.
  73582. */
  73583. strength: number;
  73584. /**
  73585. * The height of the cylinder for the updraft.
  73586. */
  73587. height: number;
  73588. /**
  73589. * The mode for the the updraft.
  73590. */
  73591. updraftMode: PhysicsUpdraftMode;
  73592. }
  73593. /**
  73594. * Options fot the vortex event
  73595. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73596. */
  73597. export class PhysicsVortexEventOptions {
  73598. /**
  73599. * The radius of the cylinder for the vortex
  73600. */
  73601. radius: number;
  73602. /**
  73603. * The strenth of the vortex.
  73604. */
  73605. strength: number;
  73606. /**
  73607. * The height of the cylinder for the vortex.
  73608. */
  73609. height: number;
  73610. /**
  73611. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73612. */
  73613. centripetalForceThreshold: number;
  73614. /**
  73615. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73616. */
  73617. centripetalForceMultiplier: number;
  73618. /**
  73619. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73620. */
  73621. centrifugalForceMultiplier: number;
  73622. /**
  73623. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73624. */
  73625. updraftForceMultiplier: number;
  73626. }
  73627. /**
  73628. * The strenght of the force in correspondence to the distance of the affected object
  73629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73630. */
  73631. export enum PhysicsRadialImpulseFalloff {
  73632. /** Defines that impulse is constant in strength across it's whole radius */
  73633. Constant = 0,
  73634. /** Defines that impulse gets weaker if it's further from the origin */
  73635. Linear = 1
  73636. }
  73637. /**
  73638. * The strength of the force in correspondence to the distance of the affected object
  73639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73640. */
  73641. export enum PhysicsUpdraftMode {
  73642. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73643. Center = 0,
  73644. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73645. Perpendicular = 1
  73646. }
  73647. /**
  73648. * Interface for a physics hit data
  73649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73650. */
  73651. export interface PhysicsHitData {
  73652. /**
  73653. * The force applied at the contact point
  73654. */
  73655. force: Vector3;
  73656. /**
  73657. * The contact point
  73658. */
  73659. contactPoint: Vector3;
  73660. /**
  73661. * The distance from the origin to the contact point
  73662. */
  73663. distanceFromOrigin: number;
  73664. }
  73665. /**
  73666. * Interface for radial explosion event data
  73667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73668. */
  73669. export interface PhysicsRadialExplosionEventData {
  73670. /**
  73671. * A sphere used for the radial explosion event
  73672. */
  73673. sphere: Mesh;
  73674. }
  73675. /**
  73676. * Interface for gravitational field event data
  73677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73678. */
  73679. export interface PhysicsGravitationalFieldEventData {
  73680. /**
  73681. * A sphere mesh used for the gravitational field event
  73682. */
  73683. sphere: Mesh;
  73684. }
  73685. /**
  73686. * Interface for updraft event data
  73687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73688. */
  73689. export interface PhysicsUpdraftEventData {
  73690. /**
  73691. * A cylinder used for the updraft event
  73692. */
  73693. cylinder: Mesh;
  73694. }
  73695. /**
  73696. * Interface for vortex event data
  73697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73698. */
  73699. export interface PhysicsVortexEventData {
  73700. /**
  73701. * A cylinder used for the vortex event
  73702. */
  73703. cylinder: Mesh;
  73704. }
  73705. /**
  73706. * Interface for an affected physics impostor
  73707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73708. */
  73709. export interface PhysicsAffectedImpostorWithData {
  73710. /**
  73711. * The impostor affected by the effect
  73712. */
  73713. impostor: PhysicsImpostor;
  73714. /**
  73715. * The data about the hit/horce from the explosion
  73716. */
  73717. hitData: PhysicsHitData;
  73718. }
  73719. }
  73720. declare module "babylonjs/Physics/Plugins/index" {
  73721. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  73722. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  73723. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  73724. }
  73725. declare module "babylonjs/Physics/index" {
  73726. export * from "babylonjs/Physics/IPhysicsEngine";
  73727. export * from "babylonjs/Physics/physicsEngine";
  73728. export * from "babylonjs/Physics/physicsEngineComponent";
  73729. export * from "babylonjs/Physics/physicsHelper";
  73730. export * from "babylonjs/Physics/physicsImpostor";
  73731. export * from "babylonjs/Physics/physicsJoint";
  73732. export * from "babylonjs/Physics/Plugins/index";
  73733. }
  73734. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  73735. /** @hidden */
  73736. export var blackAndWhitePixelShader: {
  73737. name: string;
  73738. shader: string;
  73739. };
  73740. }
  73741. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  73742. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73743. import { Camera } from "babylonjs/Cameras/camera";
  73744. import { Engine } from "babylonjs/Engines/engine";
  73745. import "babylonjs/Shaders/blackAndWhite.fragment";
  73746. import { Nullable } from "babylonjs/types";
  73747. import { Scene } from "babylonjs/scene";
  73748. /**
  73749. * Post process used to render in black and white
  73750. */
  73751. export class BlackAndWhitePostProcess extends PostProcess {
  73752. /**
  73753. * Linear about to convert he result to black and white (default: 1)
  73754. */
  73755. degree: number;
  73756. /**
  73757. * Gets a string identifying the name of the class
  73758. * @returns "BlackAndWhitePostProcess" string
  73759. */
  73760. getClassName(): string;
  73761. /**
  73762. * Creates a black and white post process
  73763. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73764. * @param name The name of the effect.
  73765. * @param options The required width/height ratio to downsize to before computing the render pass.
  73766. * @param camera The camera to apply the render pass to.
  73767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73768. * @param engine The engine which the post process will be applied. (default: current engine)
  73769. * @param reusable If the post process can be reused on the same frame. (default: false)
  73770. */
  73771. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73772. /** @hidden */
  73773. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73774. }
  73775. }
  73776. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  73777. import { Nullable } from "babylonjs/types";
  73778. import { Camera } from "babylonjs/Cameras/camera";
  73779. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73780. import { Engine } from "babylonjs/Engines/engine";
  73781. /**
  73782. * This represents a set of one or more post processes in Babylon.
  73783. * A post process can be used to apply a shader to a texture after it is rendered.
  73784. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73785. */
  73786. export class PostProcessRenderEffect {
  73787. private _postProcesses;
  73788. private _getPostProcesses;
  73789. private _singleInstance;
  73790. private _cameras;
  73791. private _indicesForCamera;
  73792. /**
  73793. * Name of the effect
  73794. * @hidden
  73795. */
  73796. _name: string;
  73797. /**
  73798. * Instantiates a post process render effect.
  73799. * A post process can be used to apply a shader to a texture after it is rendered.
  73800. * @param engine The engine the effect is tied to
  73801. * @param name The name of the effect
  73802. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73803. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73804. */
  73805. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73806. /**
  73807. * Checks if all the post processes in the effect are supported.
  73808. */
  73809. get isSupported(): boolean;
  73810. /**
  73811. * Updates the current state of the effect
  73812. * @hidden
  73813. */
  73814. _update(): void;
  73815. /**
  73816. * Attaches the effect on cameras
  73817. * @param cameras The camera to attach to.
  73818. * @hidden
  73819. */
  73820. _attachCameras(cameras: Camera): void;
  73821. /**
  73822. * Attaches the effect on cameras
  73823. * @param cameras The camera to attach to.
  73824. * @hidden
  73825. */
  73826. _attachCameras(cameras: Camera[]): void;
  73827. /**
  73828. * Detaches the effect on cameras
  73829. * @param cameras The camera to detatch from.
  73830. * @hidden
  73831. */
  73832. _detachCameras(cameras: Camera): void;
  73833. /**
  73834. * Detatches the effect on cameras
  73835. * @param cameras The camera to detatch from.
  73836. * @hidden
  73837. */
  73838. _detachCameras(cameras: Camera[]): void;
  73839. /**
  73840. * Enables the effect on given cameras
  73841. * @param cameras The camera to enable.
  73842. * @hidden
  73843. */
  73844. _enable(cameras: Camera): void;
  73845. /**
  73846. * Enables the effect on given cameras
  73847. * @param cameras The camera to enable.
  73848. * @hidden
  73849. */
  73850. _enable(cameras: Nullable<Camera[]>): void;
  73851. /**
  73852. * Disables the effect on the given cameras
  73853. * @param cameras The camera to disable.
  73854. * @hidden
  73855. */
  73856. _disable(cameras: Camera): void;
  73857. /**
  73858. * Disables the effect on the given cameras
  73859. * @param cameras The camera to disable.
  73860. * @hidden
  73861. */
  73862. _disable(cameras: Nullable<Camera[]>): void;
  73863. /**
  73864. * Gets a list of the post processes contained in the effect.
  73865. * @param camera The camera to get the post processes on.
  73866. * @returns The list of the post processes in the effect.
  73867. */
  73868. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73869. }
  73870. }
  73871. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  73872. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73873. /** @hidden */
  73874. export var extractHighlightsPixelShader: {
  73875. name: string;
  73876. shader: string;
  73877. };
  73878. }
  73879. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  73880. import { Nullable } from "babylonjs/types";
  73881. import { Camera } from "babylonjs/Cameras/camera";
  73882. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73883. import { Engine } from "babylonjs/Engines/engine";
  73884. import "babylonjs/Shaders/extractHighlights.fragment";
  73885. /**
  73886. * 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.
  73887. */
  73888. export class ExtractHighlightsPostProcess extends PostProcess {
  73889. /**
  73890. * The luminance threshold, pixels below this value will be set to black.
  73891. */
  73892. threshold: number;
  73893. /** @hidden */
  73894. _exposure: number;
  73895. /**
  73896. * Post process which has the input texture to be used when performing highlight extraction
  73897. * @hidden
  73898. */
  73899. _inputPostProcess: Nullable<PostProcess>;
  73900. /**
  73901. * Gets a string identifying the name of the class
  73902. * @returns "ExtractHighlightsPostProcess" string
  73903. */
  73904. getClassName(): string;
  73905. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73906. }
  73907. }
  73908. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  73909. /** @hidden */
  73910. export var bloomMergePixelShader: {
  73911. name: string;
  73912. shader: string;
  73913. };
  73914. }
  73915. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  73916. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73917. import { Nullable } from "babylonjs/types";
  73918. import { Engine } from "babylonjs/Engines/engine";
  73919. import { Camera } from "babylonjs/Cameras/camera";
  73920. import "babylonjs/Shaders/bloomMerge.fragment";
  73921. /**
  73922. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73923. */
  73924. export class BloomMergePostProcess extends PostProcess {
  73925. /** Weight of the bloom to be added to the original input. */
  73926. weight: number;
  73927. /**
  73928. * Gets a string identifying the name of the class
  73929. * @returns "BloomMergePostProcess" string
  73930. */
  73931. getClassName(): string;
  73932. /**
  73933. * Creates a new instance of @see BloomMergePostProcess
  73934. * @param name The name of the effect.
  73935. * @param originalFromInput Post process which's input will be used for the merge.
  73936. * @param blurred Blurred highlights post process which's output will be used.
  73937. * @param weight Weight of the bloom to be added to the original input.
  73938. * @param options The required width/height ratio to downsize to before computing the render pass.
  73939. * @param camera The camera to apply the render pass to.
  73940. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73941. * @param engine The engine which the post process will be applied. (default: current engine)
  73942. * @param reusable If the post process can be reused on the same frame. (default: false)
  73943. * @param textureType Type of textures used when performing the post process. (default: 0)
  73944. * @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)
  73945. */
  73946. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73947. /** Weight of the bloom to be added to the original input. */
  73948. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73949. }
  73950. }
  73951. declare module "babylonjs/PostProcesses/bloomEffect" {
  73952. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73953. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73954. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73955. import { Camera } from "babylonjs/Cameras/camera";
  73956. import { Scene } from "babylonjs/scene";
  73957. /**
  73958. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73959. */
  73960. export class BloomEffect extends PostProcessRenderEffect {
  73961. private bloomScale;
  73962. /**
  73963. * @hidden Internal
  73964. */
  73965. _effects: Array<PostProcess>;
  73966. /**
  73967. * @hidden Internal
  73968. */
  73969. _downscale: ExtractHighlightsPostProcess;
  73970. private _blurX;
  73971. private _blurY;
  73972. private _merge;
  73973. /**
  73974. * The luminance threshold to find bright areas of the image to bloom.
  73975. */
  73976. get threshold(): number;
  73977. set threshold(value: number);
  73978. /**
  73979. * The strength of the bloom.
  73980. */
  73981. get weight(): number;
  73982. set weight(value: number);
  73983. /**
  73984. * Specifies the size of the bloom blur kernel, relative to the final output size
  73985. */
  73986. get kernel(): number;
  73987. set kernel(value: number);
  73988. /**
  73989. * Creates a new instance of @see BloomEffect
  73990. * @param scene The scene the effect belongs to.
  73991. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73992. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73993. * @param bloomWeight The the strength of bloom.
  73994. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73995. * @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)
  73996. */
  73997. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73998. /**
  73999. * Disposes each of the internal effects for a given camera.
  74000. * @param camera The camera to dispose the effect on.
  74001. */
  74002. disposeEffects(camera: Camera): void;
  74003. /**
  74004. * @hidden Internal
  74005. */
  74006. _updateEffects(): void;
  74007. /**
  74008. * Internal
  74009. * @returns if all the contained post processes are ready.
  74010. * @hidden
  74011. */
  74012. _isReady(): boolean;
  74013. }
  74014. }
  74015. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  74016. /** @hidden */
  74017. export var chromaticAberrationPixelShader: {
  74018. name: string;
  74019. shader: string;
  74020. };
  74021. }
  74022. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  74023. import { Vector2 } from "babylonjs/Maths/math.vector";
  74024. import { Nullable } from "babylonjs/types";
  74025. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74026. import { Camera } from "babylonjs/Cameras/camera";
  74027. import { Engine } from "babylonjs/Engines/engine";
  74028. import "babylonjs/Shaders/chromaticAberration.fragment";
  74029. import { Scene } from "babylonjs/scene";
  74030. /**
  74031. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74032. */
  74033. export class ChromaticAberrationPostProcess extends PostProcess {
  74034. /**
  74035. * The amount of seperation of rgb channels (default: 30)
  74036. */
  74037. aberrationAmount: number;
  74038. /**
  74039. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74040. */
  74041. radialIntensity: number;
  74042. /**
  74043. * 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))
  74044. */
  74045. direction: Vector2;
  74046. /**
  74047. * 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))
  74048. */
  74049. centerPosition: Vector2;
  74050. /** The width of the screen to apply the effect on */
  74051. screenWidth: number;
  74052. /** The height of the screen to apply the effect on */
  74053. screenHeight: number;
  74054. /**
  74055. * Gets a string identifying the name of the class
  74056. * @returns "ChromaticAberrationPostProcess" string
  74057. */
  74058. getClassName(): string;
  74059. /**
  74060. * Creates a new instance ChromaticAberrationPostProcess
  74061. * @param name The name of the effect.
  74062. * @param screenWidth The width of the screen to apply the effect on.
  74063. * @param screenHeight The height of the screen to apply the effect on.
  74064. * @param options The required width/height ratio to downsize to before computing the render pass.
  74065. * @param camera The camera to apply the render pass to.
  74066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74067. * @param engine The engine which the post process will be applied. (default: current engine)
  74068. * @param reusable If the post process can be reused on the same frame. (default: false)
  74069. * @param textureType Type of textures used when performing the post process. (default: 0)
  74070. * @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)
  74071. */
  74072. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74073. /** @hidden */
  74074. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74075. }
  74076. }
  74077. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  74078. /** @hidden */
  74079. export var circleOfConfusionPixelShader: {
  74080. name: string;
  74081. shader: string;
  74082. };
  74083. }
  74084. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  74085. import { Nullable } from "babylonjs/types";
  74086. import { Engine } from "babylonjs/Engines/engine";
  74087. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74088. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74089. import { Camera } from "babylonjs/Cameras/camera";
  74090. import "babylonjs/Shaders/circleOfConfusion.fragment";
  74091. /**
  74092. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74093. */
  74094. export class CircleOfConfusionPostProcess extends PostProcess {
  74095. /**
  74096. * 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.
  74097. */
  74098. lensSize: number;
  74099. /**
  74100. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74101. */
  74102. fStop: number;
  74103. /**
  74104. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74105. */
  74106. focusDistance: number;
  74107. /**
  74108. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74109. */
  74110. focalLength: number;
  74111. /**
  74112. * Gets a string identifying the name of the class
  74113. * @returns "CircleOfConfusionPostProcess" string
  74114. */
  74115. getClassName(): string;
  74116. private _depthTexture;
  74117. /**
  74118. * Creates a new instance CircleOfConfusionPostProcess
  74119. * @param name The name of the effect.
  74120. * @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.
  74121. * @param options The required width/height ratio to downsize to before computing the render pass.
  74122. * @param camera The camera to apply the render pass to.
  74123. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74124. * @param engine The engine which the post process will be applied. (default: current engine)
  74125. * @param reusable If the post process can be reused on the same frame. (default: false)
  74126. * @param textureType Type of textures used when performing the post process. (default: 0)
  74127. * @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)
  74128. */
  74129. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74130. /**
  74131. * 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.
  74132. */
  74133. set depthTexture(value: RenderTargetTexture);
  74134. }
  74135. }
  74136. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  74137. /** @hidden */
  74138. export var colorCorrectionPixelShader: {
  74139. name: string;
  74140. shader: string;
  74141. };
  74142. }
  74143. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  74144. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74145. import { Engine } from "babylonjs/Engines/engine";
  74146. import { Camera } from "babylonjs/Cameras/camera";
  74147. import "babylonjs/Shaders/colorCorrection.fragment";
  74148. import { Nullable } from "babylonjs/types";
  74149. import { Scene } from "babylonjs/scene";
  74150. /**
  74151. *
  74152. * This post-process allows the modification of rendered colors by using
  74153. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74154. *
  74155. * The object needs to be provided an url to a texture containing the color
  74156. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74157. * Use an image editing software to tweak the LUT to match your needs.
  74158. *
  74159. * For an example of a color LUT, see here:
  74160. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74161. * For explanations on color grading, see here:
  74162. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74163. *
  74164. */
  74165. export class ColorCorrectionPostProcess extends PostProcess {
  74166. private _colorTableTexture;
  74167. /**
  74168. * Gets the color table url used to create the LUT texture
  74169. */
  74170. colorTableUrl: string;
  74171. /**
  74172. * Gets a string identifying the name of the class
  74173. * @returns "ColorCorrectionPostProcess" string
  74174. */
  74175. getClassName(): string;
  74176. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74177. /** @hidden */
  74178. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74179. }
  74180. }
  74181. declare module "babylonjs/Shaders/convolution.fragment" {
  74182. /** @hidden */
  74183. export var convolutionPixelShader: {
  74184. name: string;
  74185. shader: string;
  74186. };
  74187. }
  74188. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  74189. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74190. import { Nullable } from "babylonjs/types";
  74191. import { Camera } from "babylonjs/Cameras/camera";
  74192. import { Engine } from "babylonjs/Engines/engine";
  74193. import "babylonjs/Shaders/convolution.fragment";
  74194. import { Scene } from "babylonjs/scene";
  74195. /**
  74196. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74197. * input texture to perform effects such as edge detection or sharpening
  74198. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74199. */
  74200. export class ConvolutionPostProcess extends PostProcess {
  74201. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74202. kernel: number[];
  74203. /**
  74204. * Gets a string identifying the name of the class
  74205. * @returns "ConvolutionPostProcess" string
  74206. */
  74207. getClassName(): string;
  74208. /**
  74209. * Creates a new instance ConvolutionPostProcess
  74210. * @param name The name of the effect.
  74211. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74212. * @param options The required width/height ratio to downsize to before computing the render pass.
  74213. * @param camera The camera to apply the render pass to.
  74214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74215. * @param engine The engine which the post process will be applied. (default: current engine)
  74216. * @param reusable If the post process can be reused on the same frame. (default: false)
  74217. * @param textureType Type of textures used when performing the post process. (default: 0)
  74218. */
  74219. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74220. /** @hidden */
  74221. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74222. /**
  74223. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74224. */
  74225. static EdgeDetect0Kernel: number[];
  74226. /**
  74227. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74228. */
  74229. static EdgeDetect1Kernel: number[];
  74230. /**
  74231. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74232. */
  74233. static EdgeDetect2Kernel: number[];
  74234. /**
  74235. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74236. */
  74237. static SharpenKernel: number[];
  74238. /**
  74239. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74240. */
  74241. static EmbossKernel: number[];
  74242. /**
  74243. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74244. */
  74245. static GaussianKernel: number[];
  74246. }
  74247. }
  74248. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  74249. import { Nullable } from "babylonjs/types";
  74250. import { Vector2 } from "babylonjs/Maths/math.vector";
  74251. import { Camera } from "babylonjs/Cameras/camera";
  74252. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74253. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74254. import { Engine } from "babylonjs/Engines/engine";
  74255. import { Scene } from "babylonjs/scene";
  74256. /**
  74257. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74258. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74259. * based on samples that have a large difference in distance than the center pixel.
  74260. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74261. */
  74262. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74263. /**
  74264. * The direction the blur should be applied
  74265. */
  74266. direction: Vector2;
  74267. /**
  74268. * Gets a string identifying the name of the class
  74269. * @returns "DepthOfFieldBlurPostProcess" string
  74270. */
  74271. getClassName(): string;
  74272. /**
  74273. * Creates a new instance CircleOfConfusionPostProcess
  74274. * @param name The name of the effect.
  74275. * @param scene The scene the effect belongs to.
  74276. * @param direction The direction the blur should be applied.
  74277. * @param kernel The size of the kernel used to blur.
  74278. * @param options The required width/height ratio to downsize to before computing the render pass.
  74279. * @param camera The camera to apply the render pass to.
  74280. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  74281. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74283. * @param engine The engine which the post process will be applied. (default: current engine)
  74284. * @param reusable If the post process can be reused on the same frame. (default: false)
  74285. * @param textureType Type of textures used when performing the post process. (default: 0)
  74286. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  74287. */
  74288. 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);
  74289. }
  74290. }
  74291. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  74292. /** @hidden */
  74293. export var depthOfFieldMergePixelShader: {
  74294. name: string;
  74295. shader: string;
  74296. };
  74297. }
  74298. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  74299. import { Nullable } from "babylonjs/types";
  74300. import { Camera } from "babylonjs/Cameras/camera";
  74301. import { Effect } from "babylonjs/Materials/effect";
  74302. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74303. import { Engine } from "babylonjs/Engines/engine";
  74304. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  74305. /**
  74306. * Options to be set when merging outputs from the default pipeline.
  74307. */
  74308. export class DepthOfFieldMergePostProcessOptions {
  74309. /**
  74310. * The original image to merge on top of
  74311. */
  74312. originalFromInput: PostProcess;
  74313. /**
  74314. * Parameters to perform the merge of the depth of field effect
  74315. */
  74316. depthOfField?: {
  74317. circleOfConfusion: PostProcess;
  74318. blurSteps: Array<PostProcess>;
  74319. };
  74320. /**
  74321. * Parameters to perform the merge of bloom effect
  74322. */
  74323. bloom?: {
  74324. blurred: PostProcess;
  74325. weight: number;
  74326. };
  74327. }
  74328. /**
  74329. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74330. */
  74331. export class DepthOfFieldMergePostProcess extends PostProcess {
  74332. private blurSteps;
  74333. /**
  74334. * Gets a string identifying the name of the class
  74335. * @returns "DepthOfFieldMergePostProcess" string
  74336. */
  74337. getClassName(): string;
  74338. /**
  74339. * Creates a new instance of DepthOfFieldMergePostProcess
  74340. * @param name The name of the effect.
  74341. * @param originalFromInput Post process which's input will be used for the merge.
  74342. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74343. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74344. * @param options The required width/height ratio to downsize to before computing the render pass.
  74345. * @param camera The camera to apply the render pass to.
  74346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74347. * @param engine The engine which the post process will be applied. (default: current engine)
  74348. * @param reusable If the post process can be reused on the same frame. (default: false)
  74349. * @param textureType Type of textures used when performing the post process. (default: 0)
  74350. * @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)
  74351. */
  74352. 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);
  74353. /**
  74354. * Updates the effect with the current post process compile time values and recompiles the shader.
  74355. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74356. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74357. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74358. * @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
  74359. * @param onCompiled Called when the shader has been compiled.
  74360. * @param onError Called if there is an error when compiling a shader.
  74361. */
  74362. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74363. }
  74364. }
  74365. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  74366. import { Nullable } from "babylonjs/types";
  74367. import { Camera } from "babylonjs/Cameras/camera";
  74368. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74369. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74370. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74371. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74372. import { Scene } from "babylonjs/scene";
  74373. /**
  74374. * Specifies the level of max blur that should be applied when using the depth of field effect
  74375. */
  74376. export enum DepthOfFieldEffectBlurLevel {
  74377. /**
  74378. * Subtle blur
  74379. */
  74380. Low = 0,
  74381. /**
  74382. * Medium blur
  74383. */
  74384. Medium = 1,
  74385. /**
  74386. * Large blur
  74387. */
  74388. High = 2
  74389. }
  74390. /**
  74391. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74392. */
  74393. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74394. private _circleOfConfusion;
  74395. /**
  74396. * @hidden Internal, blurs from high to low
  74397. */
  74398. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74399. private _depthOfFieldBlurY;
  74400. private _dofMerge;
  74401. /**
  74402. * @hidden Internal post processes in depth of field effect
  74403. */
  74404. _effects: Array<PostProcess>;
  74405. /**
  74406. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74407. */
  74408. set focalLength(value: number);
  74409. get focalLength(): number;
  74410. /**
  74411. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74412. */
  74413. set fStop(value: number);
  74414. get fStop(): number;
  74415. /**
  74416. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74417. */
  74418. set focusDistance(value: number);
  74419. get focusDistance(): number;
  74420. /**
  74421. * 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.
  74422. */
  74423. set lensSize(value: number);
  74424. get lensSize(): number;
  74425. /**
  74426. * Creates a new instance DepthOfFieldEffect
  74427. * @param scene The scene the effect belongs to.
  74428. * @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.
  74429. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74430. * @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)
  74431. */
  74432. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74433. /**
  74434. * Get the current class name of the current effet
  74435. * @returns "DepthOfFieldEffect"
  74436. */
  74437. getClassName(): string;
  74438. /**
  74439. * 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.
  74440. */
  74441. set depthTexture(value: RenderTargetTexture);
  74442. /**
  74443. * Disposes each of the internal effects for a given camera.
  74444. * @param camera The camera to dispose the effect on.
  74445. */
  74446. disposeEffects(camera: Camera): void;
  74447. /**
  74448. * @hidden Internal
  74449. */
  74450. _updateEffects(): void;
  74451. /**
  74452. * Internal
  74453. * @returns if all the contained post processes are ready.
  74454. * @hidden
  74455. */
  74456. _isReady(): boolean;
  74457. }
  74458. }
  74459. declare module "babylonjs/Shaders/displayPass.fragment" {
  74460. /** @hidden */
  74461. export var displayPassPixelShader: {
  74462. name: string;
  74463. shader: string;
  74464. };
  74465. }
  74466. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  74467. import { Nullable } from "babylonjs/types";
  74468. import { Camera } from "babylonjs/Cameras/camera";
  74469. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74470. import { Engine } from "babylonjs/Engines/engine";
  74471. import "babylonjs/Shaders/displayPass.fragment";
  74472. import { Scene } from "babylonjs/scene";
  74473. /**
  74474. * DisplayPassPostProcess which produces an output the same as it's input
  74475. */
  74476. export class DisplayPassPostProcess extends PostProcess {
  74477. /**
  74478. * Gets a string identifying the name of the class
  74479. * @returns "DisplayPassPostProcess" string
  74480. */
  74481. getClassName(): string;
  74482. /**
  74483. * Creates the DisplayPassPostProcess
  74484. * @param name The name of the effect.
  74485. * @param options The required width/height ratio to downsize to before computing the render pass.
  74486. * @param camera The camera to apply the render pass to.
  74487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74488. * @param engine The engine which the post process will be applied. (default: current engine)
  74489. * @param reusable If the post process can be reused on the same frame. (default: false)
  74490. */
  74491. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74492. /** @hidden */
  74493. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74494. }
  74495. }
  74496. declare module "babylonjs/Shaders/filter.fragment" {
  74497. /** @hidden */
  74498. export var filterPixelShader: {
  74499. name: string;
  74500. shader: string;
  74501. };
  74502. }
  74503. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74504. import { Nullable } from "babylonjs/types";
  74505. import { Matrix } from "babylonjs/Maths/math.vector";
  74506. import { Camera } from "babylonjs/Cameras/camera";
  74507. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74508. import { Engine } from "babylonjs/Engines/engine";
  74509. import "babylonjs/Shaders/filter.fragment";
  74510. import { Scene } from "babylonjs/scene";
  74511. /**
  74512. * Applies a kernel filter to the image
  74513. */
  74514. export class FilterPostProcess extends PostProcess {
  74515. /** The matrix to be applied to the image */
  74516. kernelMatrix: Matrix;
  74517. /**
  74518. * Gets a string identifying the name of the class
  74519. * @returns "FilterPostProcess" string
  74520. */
  74521. getClassName(): string;
  74522. /**
  74523. *
  74524. * @param name The name of the effect.
  74525. * @param kernelMatrix The matrix to be applied to the image
  74526. * @param options The required width/height ratio to downsize to before computing the render pass.
  74527. * @param camera The camera to apply the render pass to.
  74528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74529. * @param engine The engine which the post process will be applied. (default: current engine)
  74530. * @param reusable If the post process can be reused on the same frame. (default: false)
  74531. */
  74532. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74533. /** @hidden */
  74534. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74535. }
  74536. }
  74537. declare module "babylonjs/Shaders/fxaa.fragment" {
  74538. /** @hidden */
  74539. export var fxaaPixelShader: {
  74540. name: string;
  74541. shader: string;
  74542. };
  74543. }
  74544. declare module "babylonjs/Shaders/fxaa.vertex" {
  74545. /** @hidden */
  74546. export var fxaaVertexShader: {
  74547. name: string;
  74548. shader: string;
  74549. };
  74550. }
  74551. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74552. import { Nullable } from "babylonjs/types";
  74553. import { Camera } from "babylonjs/Cameras/camera";
  74554. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74555. import { Engine } from "babylonjs/Engines/engine";
  74556. import "babylonjs/Shaders/fxaa.fragment";
  74557. import "babylonjs/Shaders/fxaa.vertex";
  74558. import { Scene } from "babylonjs/scene";
  74559. /**
  74560. * Fxaa post process
  74561. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74562. */
  74563. export class FxaaPostProcess extends PostProcess {
  74564. /**
  74565. * Gets a string identifying the name of the class
  74566. * @returns "FxaaPostProcess" string
  74567. */
  74568. getClassName(): string;
  74569. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74570. private _getDefines;
  74571. /** @hidden */
  74572. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74573. }
  74574. }
  74575. declare module "babylonjs/Shaders/grain.fragment" {
  74576. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74577. /** @hidden */
  74578. export var grainPixelShader: {
  74579. name: string;
  74580. shader: string;
  74581. };
  74582. }
  74583. declare module "babylonjs/PostProcesses/grainPostProcess" {
  74584. import { Nullable } from "babylonjs/types";
  74585. import { Camera } from "babylonjs/Cameras/camera";
  74586. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74587. import { Engine } from "babylonjs/Engines/engine";
  74588. import "babylonjs/Shaders/grain.fragment";
  74589. import { Scene } from "babylonjs/scene";
  74590. /**
  74591. * The GrainPostProcess adds noise to the image at mid luminance levels
  74592. */
  74593. export class GrainPostProcess extends PostProcess {
  74594. /**
  74595. * The intensity of the grain added (default: 30)
  74596. */
  74597. intensity: number;
  74598. /**
  74599. * If the grain should be randomized on every frame
  74600. */
  74601. animated: boolean;
  74602. /**
  74603. * Gets a string identifying the name of the class
  74604. * @returns "GrainPostProcess" string
  74605. */
  74606. getClassName(): string;
  74607. /**
  74608. * Creates a new instance of @see GrainPostProcess
  74609. * @param name The name of the effect.
  74610. * @param options The required width/height ratio to downsize to before computing the render pass.
  74611. * @param camera The camera to apply the render pass to.
  74612. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74613. * @param engine The engine which the post process will be applied. (default: current engine)
  74614. * @param reusable If the post process can be reused on the same frame. (default: false)
  74615. * @param textureType Type of textures used when performing the post process. (default: 0)
  74616. * @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)
  74617. */
  74618. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74619. /** @hidden */
  74620. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74621. }
  74622. }
  74623. declare module "babylonjs/Shaders/highlights.fragment" {
  74624. /** @hidden */
  74625. export var highlightsPixelShader: {
  74626. name: string;
  74627. shader: string;
  74628. };
  74629. }
  74630. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  74631. import { Nullable } from "babylonjs/types";
  74632. import { Camera } from "babylonjs/Cameras/camera";
  74633. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74634. import { Engine } from "babylonjs/Engines/engine";
  74635. import "babylonjs/Shaders/highlights.fragment";
  74636. /**
  74637. * Extracts highlights from the image
  74638. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74639. */
  74640. export class HighlightsPostProcess extends PostProcess {
  74641. /**
  74642. * Gets a string identifying the name of the class
  74643. * @returns "HighlightsPostProcess" string
  74644. */
  74645. getClassName(): string;
  74646. /**
  74647. * Extracts highlights from the image
  74648. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74649. * @param name The name of the effect.
  74650. * @param options The required width/height ratio to downsize to before computing the render pass.
  74651. * @param camera The camera to apply the render pass to.
  74652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74653. * @param engine The engine which the post process will be applied. (default: current engine)
  74654. * @param reusable If the post process can be reused on the same frame. (default: false)
  74655. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74656. */
  74657. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74658. }
  74659. }
  74660. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74661. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74662. /**
  74663. * Contains all parameters needed for the prepass to perform
  74664. * motion blur
  74665. */
  74666. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74667. /**
  74668. * Is motion blur enabled
  74669. */
  74670. enabled: boolean;
  74671. /**
  74672. * Name of the configuration
  74673. */
  74674. name: string;
  74675. /**
  74676. * Textures that should be present in the MRT for this effect to work
  74677. */
  74678. readonly texturesRequired: number[];
  74679. }
  74680. }
  74681. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74682. import { Nullable } from "babylonjs/types";
  74683. import { Scene } from "babylonjs/scene";
  74684. import { ISceneComponent } from "babylonjs/sceneComponent";
  74685. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74686. module "babylonjs/scene" {
  74687. interface Scene {
  74688. /** @hidden (Backing field) */
  74689. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74690. /**
  74691. * Gets or Sets the current geometry buffer associated to the scene.
  74692. */
  74693. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74694. /**
  74695. * Enables a GeometryBufferRender and associates it with the scene
  74696. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74697. * @returns the GeometryBufferRenderer
  74698. */
  74699. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74700. /**
  74701. * Disables the GeometryBufferRender associated with the scene
  74702. */
  74703. disableGeometryBufferRenderer(): void;
  74704. }
  74705. }
  74706. /**
  74707. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74708. * in several rendering techniques.
  74709. */
  74710. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74711. /**
  74712. * The component name helpful to identify the component in the list of scene components.
  74713. */
  74714. readonly name: string;
  74715. /**
  74716. * The scene the component belongs to.
  74717. */
  74718. scene: Scene;
  74719. /**
  74720. * Creates a new instance of the component for the given scene
  74721. * @param scene Defines the scene to register the component in
  74722. */
  74723. constructor(scene: Scene);
  74724. /**
  74725. * Registers the component in a given scene
  74726. */
  74727. register(): void;
  74728. /**
  74729. * Rebuilds the elements related to this component in case of
  74730. * context lost for instance.
  74731. */
  74732. rebuild(): void;
  74733. /**
  74734. * Disposes the component and the associated ressources
  74735. */
  74736. dispose(): void;
  74737. private _gatherRenderTargets;
  74738. }
  74739. }
  74740. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74741. /** @hidden */
  74742. export var motionBlurPixelShader: {
  74743. name: string;
  74744. shader: string;
  74745. };
  74746. }
  74747. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74748. import { Nullable } from "babylonjs/types";
  74749. import { Camera } from "babylonjs/Cameras/camera";
  74750. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74752. import "babylonjs/Animations/animatable";
  74753. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74754. import "babylonjs/Shaders/motionBlur.fragment";
  74755. import { Engine } from "babylonjs/Engines/engine";
  74756. import { Scene } from "babylonjs/scene";
  74757. /**
  74758. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74759. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74760. * As an example, all you have to do is to create the post-process:
  74761. * var mb = new BABYLON.MotionBlurPostProcess(
  74762. * 'mb', // The name of the effect.
  74763. * scene, // The scene containing the objects to blur according to their velocity.
  74764. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74765. * camera // The camera to apply the render pass to.
  74766. * );
  74767. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74768. */
  74769. export class MotionBlurPostProcess extends PostProcess {
  74770. /**
  74771. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74772. */
  74773. motionStrength: number;
  74774. /**
  74775. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74776. */
  74777. get motionBlurSamples(): number;
  74778. /**
  74779. * Sets the number of iterations to be used for motion blur quality
  74780. */
  74781. set motionBlurSamples(samples: number);
  74782. private _motionBlurSamples;
  74783. private _forceGeometryBuffer;
  74784. private _geometryBufferRenderer;
  74785. private _prePassRenderer;
  74786. /**
  74787. * Gets a string identifying the name of the class
  74788. * @returns "MotionBlurPostProcess" string
  74789. */
  74790. getClassName(): string;
  74791. /**
  74792. * Creates a new instance MotionBlurPostProcess
  74793. * @param name The name of the effect.
  74794. * @param scene The scene containing the objects to blur according to their velocity.
  74795. * @param options The required width/height ratio to downsize to before computing the render pass.
  74796. * @param camera The camera to apply the render pass to.
  74797. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74798. * @param engine The engine which the post process will be applied. (default: current engine)
  74799. * @param reusable If the post process can be reused on the same frame. (default: false)
  74800. * @param textureType Type of textures used when performing the post process. (default: 0)
  74801. * @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)
  74802. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74803. */
  74804. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74805. /**
  74806. * Excludes the given skinned mesh from computing bones velocities.
  74807. * 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.
  74808. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74809. */
  74810. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74811. /**
  74812. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74813. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74814. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74815. */
  74816. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74817. /**
  74818. * Disposes the post process.
  74819. * @param camera The camera to dispose the post process on.
  74820. */
  74821. dispose(camera?: Camera): void;
  74822. /** @hidden */
  74823. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74824. }
  74825. }
  74826. declare module "babylonjs/Shaders/refraction.fragment" {
  74827. /** @hidden */
  74828. export var refractionPixelShader: {
  74829. name: string;
  74830. shader: string;
  74831. };
  74832. }
  74833. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74834. import { Color3 } from "babylonjs/Maths/math.color";
  74835. import { Camera } from "babylonjs/Cameras/camera";
  74836. import { Texture } from "babylonjs/Materials/Textures/texture";
  74837. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74838. import { Engine } from "babylonjs/Engines/engine";
  74839. import "babylonjs/Shaders/refraction.fragment";
  74840. import { Scene } from "babylonjs/scene";
  74841. /**
  74842. * Post process which applies a refractin texture
  74843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74844. */
  74845. export class RefractionPostProcess extends PostProcess {
  74846. private _refTexture;
  74847. private _ownRefractionTexture;
  74848. /** the base color of the refraction (used to taint the rendering) */
  74849. color: Color3;
  74850. /** simulated refraction depth */
  74851. depth: number;
  74852. /** the coefficient of the base color (0 to remove base color tainting) */
  74853. colorLevel: number;
  74854. /** Gets the url used to load the refraction texture */
  74855. refractionTextureUrl: string;
  74856. /**
  74857. * Gets or sets the refraction texture
  74858. * Please note that you are responsible for disposing the texture if you set it manually
  74859. */
  74860. get refractionTexture(): Texture;
  74861. set refractionTexture(value: Texture);
  74862. /**
  74863. * Gets a string identifying the name of the class
  74864. * @returns "RefractionPostProcess" string
  74865. */
  74866. getClassName(): string;
  74867. /**
  74868. * Initializes the RefractionPostProcess
  74869. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74870. * @param name The name of the effect.
  74871. * @param refractionTextureUrl Url of the refraction texture to use
  74872. * @param color the base color of the refraction (used to taint the rendering)
  74873. * @param depth simulated refraction depth
  74874. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74875. * @param camera The camera to apply the render pass to.
  74876. * @param options The required width/height ratio to downsize to before computing the render pass.
  74877. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74878. * @param engine The engine which the post process will be applied. (default: current engine)
  74879. * @param reusable If the post process can be reused on the same frame. (default: false)
  74880. */
  74881. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74882. /**
  74883. * Disposes of the post process
  74884. * @param camera Camera to dispose post process on
  74885. */
  74886. dispose(camera: Camera): void;
  74887. /** @hidden */
  74888. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74889. }
  74890. }
  74891. declare module "babylonjs/Shaders/sharpen.fragment" {
  74892. /** @hidden */
  74893. export var sharpenPixelShader: {
  74894. name: string;
  74895. shader: string;
  74896. };
  74897. }
  74898. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74899. import { Nullable } from "babylonjs/types";
  74900. import { Camera } from "babylonjs/Cameras/camera";
  74901. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74902. import "babylonjs/Shaders/sharpen.fragment";
  74903. import { Engine } from "babylonjs/Engines/engine";
  74904. import { Scene } from "babylonjs/scene";
  74905. /**
  74906. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74907. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74908. */
  74909. export class SharpenPostProcess extends PostProcess {
  74910. /**
  74911. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74912. */
  74913. colorAmount: number;
  74914. /**
  74915. * How much sharpness should be applied (default: 0.3)
  74916. */
  74917. edgeAmount: number;
  74918. /**
  74919. * Gets a string identifying the name of the class
  74920. * @returns "SharpenPostProcess" string
  74921. */
  74922. getClassName(): string;
  74923. /**
  74924. * Creates a new instance ConvolutionPostProcess
  74925. * @param name The name of the effect.
  74926. * @param options The required width/height ratio to downsize to before computing the render pass.
  74927. * @param camera The camera to apply the render pass to.
  74928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74929. * @param engine The engine which the post process will be applied. (default: current engine)
  74930. * @param reusable If the post process can be reused on the same frame. (default: false)
  74931. * @param textureType Type of textures used when performing the post process. (default: 0)
  74932. * @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)
  74933. */
  74934. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74935. /** @hidden */
  74936. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74937. }
  74938. }
  74939. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74940. import { Nullable } from "babylonjs/types";
  74941. import { Camera } from "babylonjs/Cameras/camera";
  74942. import { Engine } from "babylonjs/Engines/engine";
  74943. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74944. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74945. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74946. /**
  74947. * PostProcessRenderPipeline
  74948. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74949. */
  74950. export class PostProcessRenderPipeline {
  74951. private engine;
  74952. private _renderEffects;
  74953. private _renderEffectsForIsolatedPass;
  74954. /**
  74955. * List of inspectable custom properties (used by the Inspector)
  74956. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74957. */
  74958. inspectableCustomProperties: IInspectable[];
  74959. /**
  74960. * @hidden
  74961. */
  74962. protected _cameras: Camera[];
  74963. /** @hidden */
  74964. _name: string;
  74965. /**
  74966. * Gets pipeline name
  74967. */
  74968. get name(): string;
  74969. /** Gets the list of attached cameras */
  74970. get cameras(): Camera[];
  74971. /**
  74972. * Initializes a PostProcessRenderPipeline
  74973. * @param engine engine to add the pipeline to
  74974. * @param name name of the pipeline
  74975. */
  74976. constructor(engine: Engine, name: string);
  74977. /**
  74978. * Gets the class name
  74979. * @returns "PostProcessRenderPipeline"
  74980. */
  74981. getClassName(): string;
  74982. /**
  74983. * If all the render effects in the pipeline are supported
  74984. */
  74985. get isSupported(): boolean;
  74986. /**
  74987. * Adds an effect to the pipeline
  74988. * @param renderEffect the effect to add
  74989. */
  74990. addEffect(renderEffect: PostProcessRenderEffect): void;
  74991. /** @hidden */
  74992. _rebuild(): void;
  74993. /** @hidden */
  74994. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74995. /** @hidden */
  74996. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74997. /** @hidden */
  74998. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74999. /** @hidden */
  75000. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75001. /** @hidden */
  75002. _attachCameras(cameras: Camera, unique: boolean): void;
  75003. /** @hidden */
  75004. _attachCameras(cameras: Camera[], unique: boolean): void;
  75005. /** @hidden */
  75006. _detachCameras(cameras: Camera): void;
  75007. /** @hidden */
  75008. _detachCameras(cameras: Nullable<Camera[]>): void;
  75009. /** @hidden */
  75010. _update(): void;
  75011. /** @hidden */
  75012. _reset(): void;
  75013. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  75014. /**
  75015. * Sets the required values to the prepass renderer.
  75016. * @param prePassRenderer defines the prepass renderer to setup.
  75017. * @returns true if the pre pass is needed.
  75018. */
  75019. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75020. /**
  75021. * Disposes of the pipeline
  75022. */
  75023. dispose(): void;
  75024. }
  75025. }
  75026. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  75027. import { Camera } from "babylonjs/Cameras/camera";
  75028. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75029. /**
  75030. * PostProcessRenderPipelineManager class
  75031. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75032. */
  75033. export class PostProcessRenderPipelineManager {
  75034. private _renderPipelines;
  75035. /**
  75036. * Initializes a PostProcessRenderPipelineManager
  75037. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75038. */
  75039. constructor();
  75040. /**
  75041. * Gets the list of supported render pipelines
  75042. */
  75043. get supportedPipelines(): PostProcessRenderPipeline[];
  75044. /**
  75045. * Adds a pipeline to the manager
  75046. * @param renderPipeline The pipeline to add
  75047. */
  75048. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  75049. /**
  75050. * Attaches a camera to the pipeline
  75051. * @param renderPipelineName The name of the pipeline to attach to
  75052. * @param cameras the camera to attach
  75053. * @param unique if the camera can be attached multiple times to the pipeline
  75054. */
  75055. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  75056. /**
  75057. * Detaches a camera from the pipeline
  75058. * @param renderPipelineName The name of the pipeline to detach from
  75059. * @param cameras the camera to detach
  75060. */
  75061. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  75062. /**
  75063. * Enables an effect by name on a pipeline
  75064. * @param renderPipelineName the name of the pipeline to enable the effect in
  75065. * @param renderEffectName the name of the effect to enable
  75066. * @param cameras the cameras that the effect should be enabled on
  75067. */
  75068. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75069. /**
  75070. * Disables an effect by name on a pipeline
  75071. * @param renderPipelineName the name of the pipeline to disable the effect in
  75072. * @param renderEffectName the name of the effect to disable
  75073. * @param cameras the cameras that the effect should be disabled on
  75074. */
  75075. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75076. /**
  75077. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  75078. */
  75079. update(): void;
  75080. /** @hidden */
  75081. _rebuild(): void;
  75082. /**
  75083. * Disposes of the manager and pipelines
  75084. */
  75085. dispose(): void;
  75086. }
  75087. }
  75088. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  75089. import { ISceneComponent } from "babylonjs/sceneComponent";
  75090. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75091. import { Scene } from "babylonjs/scene";
  75092. module "babylonjs/scene" {
  75093. interface Scene {
  75094. /** @hidden (Backing field) */
  75095. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75096. /**
  75097. * Gets the postprocess render pipeline manager
  75098. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75099. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75100. */
  75101. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75102. }
  75103. }
  75104. /**
  75105. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75106. */
  75107. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75108. /**
  75109. * The component name helpfull to identify the component in the list of scene components.
  75110. */
  75111. readonly name: string;
  75112. /**
  75113. * The scene the component belongs to.
  75114. */
  75115. scene: Scene;
  75116. /**
  75117. * Creates a new instance of the component for the given scene
  75118. * @param scene Defines the scene to register the component in
  75119. */
  75120. constructor(scene: Scene);
  75121. /**
  75122. * Registers the component in a given scene
  75123. */
  75124. register(): void;
  75125. /**
  75126. * Rebuilds the elements related to this component in case of
  75127. * context lost for instance.
  75128. */
  75129. rebuild(): void;
  75130. /**
  75131. * Disposes the component and the associated ressources
  75132. */
  75133. dispose(): void;
  75134. private _gatherRenderTargets;
  75135. }
  75136. }
  75137. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  75138. import { Nullable } from "babylonjs/types";
  75139. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75140. import { Camera } from "babylonjs/Cameras/camera";
  75141. import { IDisposable } from "babylonjs/scene";
  75142. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  75143. import { Scene } from "babylonjs/scene";
  75144. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  75145. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75146. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75147. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  75148. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75149. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75150. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  75151. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75152. import { Animation } from "babylonjs/Animations/animation";
  75153. /**
  75154. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75155. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75156. */
  75157. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75158. private _scene;
  75159. private _camerasToBeAttached;
  75160. /**
  75161. * ID of the sharpen post process,
  75162. */
  75163. private readonly SharpenPostProcessId;
  75164. /**
  75165. * @ignore
  75166. * ID of the image processing post process;
  75167. */
  75168. readonly ImageProcessingPostProcessId: string;
  75169. /**
  75170. * @ignore
  75171. * ID of the Fast Approximate Anti-Aliasing post process;
  75172. */
  75173. readonly FxaaPostProcessId: string;
  75174. /**
  75175. * ID of the chromatic aberration post process,
  75176. */
  75177. private readonly ChromaticAberrationPostProcessId;
  75178. /**
  75179. * ID of the grain post process
  75180. */
  75181. private readonly GrainPostProcessId;
  75182. /**
  75183. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75184. */
  75185. sharpen: SharpenPostProcess;
  75186. private _sharpenEffect;
  75187. private bloom;
  75188. /**
  75189. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75190. */
  75191. depthOfField: DepthOfFieldEffect;
  75192. /**
  75193. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75194. */
  75195. fxaa: FxaaPostProcess;
  75196. /**
  75197. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75198. */
  75199. imageProcessing: ImageProcessingPostProcess;
  75200. /**
  75201. * Chromatic aberration post process which will shift rgb colors in the image
  75202. */
  75203. chromaticAberration: ChromaticAberrationPostProcess;
  75204. private _chromaticAberrationEffect;
  75205. /**
  75206. * Grain post process which add noise to the image
  75207. */
  75208. grain: GrainPostProcess;
  75209. private _grainEffect;
  75210. /**
  75211. * Glow post process which adds a glow to emissive areas of the image
  75212. */
  75213. private _glowLayer;
  75214. /**
  75215. * Animations which can be used to tweak settings over a period of time
  75216. */
  75217. animations: Animation[];
  75218. private _imageProcessingConfigurationObserver;
  75219. private _sharpenEnabled;
  75220. private _bloomEnabled;
  75221. private _depthOfFieldEnabled;
  75222. private _depthOfFieldBlurLevel;
  75223. private _fxaaEnabled;
  75224. private _imageProcessingEnabled;
  75225. private _defaultPipelineTextureType;
  75226. private _bloomScale;
  75227. private _chromaticAberrationEnabled;
  75228. private _grainEnabled;
  75229. private _buildAllowed;
  75230. /**
  75231. * Gets active scene
  75232. */
  75233. get scene(): Scene;
  75234. /**
  75235. * Enable or disable the sharpen process from the pipeline
  75236. */
  75237. set sharpenEnabled(enabled: boolean);
  75238. get sharpenEnabled(): boolean;
  75239. private _resizeObserver;
  75240. private _hardwareScaleLevel;
  75241. private _bloomKernel;
  75242. /**
  75243. * Specifies the size of the bloom blur kernel, relative to the final output size
  75244. */
  75245. get bloomKernel(): number;
  75246. set bloomKernel(value: number);
  75247. /**
  75248. * Specifies the weight of the bloom in the final rendering
  75249. */
  75250. private _bloomWeight;
  75251. /**
  75252. * Specifies the luma threshold for the area that will be blurred by the bloom
  75253. */
  75254. private _bloomThreshold;
  75255. private _hdr;
  75256. /**
  75257. * The strength of the bloom.
  75258. */
  75259. set bloomWeight(value: number);
  75260. get bloomWeight(): number;
  75261. /**
  75262. * The strength of the bloom.
  75263. */
  75264. set bloomThreshold(value: number);
  75265. get bloomThreshold(): number;
  75266. /**
  75267. * The scale of the bloom, lower value will provide better performance.
  75268. */
  75269. set bloomScale(value: number);
  75270. get bloomScale(): number;
  75271. /**
  75272. * Enable or disable the bloom from the pipeline
  75273. */
  75274. set bloomEnabled(enabled: boolean);
  75275. get bloomEnabled(): boolean;
  75276. private _rebuildBloom;
  75277. /**
  75278. * If the depth of field is enabled.
  75279. */
  75280. get depthOfFieldEnabled(): boolean;
  75281. set depthOfFieldEnabled(enabled: boolean);
  75282. /**
  75283. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75284. */
  75285. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75286. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75287. /**
  75288. * If the anti aliasing is enabled.
  75289. */
  75290. set fxaaEnabled(enabled: boolean);
  75291. get fxaaEnabled(): boolean;
  75292. private _samples;
  75293. /**
  75294. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75295. */
  75296. set samples(sampleCount: number);
  75297. get samples(): number;
  75298. /**
  75299. * If image processing is enabled.
  75300. */
  75301. set imageProcessingEnabled(enabled: boolean);
  75302. get imageProcessingEnabled(): boolean;
  75303. /**
  75304. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75305. */
  75306. set glowLayerEnabled(enabled: boolean);
  75307. get glowLayerEnabled(): boolean;
  75308. /**
  75309. * Gets the glow layer (or null if not defined)
  75310. */
  75311. get glowLayer(): Nullable<GlowLayer>;
  75312. /**
  75313. * Enable or disable the chromaticAberration process from the pipeline
  75314. */
  75315. set chromaticAberrationEnabled(enabled: boolean);
  75316. get chromaticAberrationEnabled(): boolean;
  75317. /**
  75318. * Enable or disable the grain process from the pipeline
  75319. */
  75320. set grainEnabled(enabled: boolean);
  75321. get grainEnabled(): boolean;
  75322. /**
  75323. * @constructor
  75324. * @param name - The rendering pipeline name (default: "")
  75325. * @param hdr - If high dynamic range textures should be used (default: true)
  75326. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75327. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75328. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75329. */
  75330. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75331. /**
  75332. * Get the class name
  75333. * @returns "DefaultRenderingPipeline"
  75334. */
  75335. getClassName(): string;
  75336. /**
  75337. * Force the compilation of the entire pipeline.
  75338. */
  75339. prepare(): void;
  75340. private _hasCleared;
  75341. private _prevPostProcess;
  75342. private _prevPrevPostProcess;
  75343. private _setAutoClearAndTextureSharing;
  75344. private _depthOfFieldSceneObserver;
  75345. private _buildPipeline;
  75346. private _disposePostProcesses;
  75347. /**
  75348. * Adds a camera to the pipeline
  75349. * @param camera the camera to be added
  75350. */
  75351. addCamera(camera: Camera): void;
  75352. /**
  75353. * Removes a camera from the pipeline
  75354. * @param camera the camera to remove
  75355. */
  75356. removeCamera(camera: Camera): void;
  75357. /**
  75358. * Dispose of the pipeline and stop all post processes
  75359. */
  75360. dispose(): void;
  75361. /**
  75362. * Serialize the rendering pipeline (Used when exporting)
  75363. * @returns the serialized object
  75364. */
  75365. serialize(): any;
  75366. /**
  75367. * Parse the serialized pipeline
  75368. * @param source Source pipeline.
  75369. * @param scene The scene to load the pipeline to.
  75370. * @param rootUrl The URL of the serialized pipeline.
  75371. * @returns An instantiated pipeline from the serialized object.
  75372. */
  75373. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75374. }
  75375. }
  75376. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  75377. /** @hidden */
  75378. export var lensHighlightsPixelShader: {
  75379. name: string;
  75380. shader: string;
  75381. };
  75382. }
  75383. declare module "babylonjs/Shaders/depthOfField.fragment" {
  75384. /** @hidden */
  75385. export var depthOfFieldPixelShader: {
  75386. name: string;
  75387. shader: string;
  75388. };
  75389. }
  75390. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  75391. import { Camera } from "babylonjs/Cameras/camera";
  75392. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75393. import { Scene } from "babylonjs/scene";
  75394. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75395. import "babylonjs/Shaders/chromaticAberration.fragment";
  75396. import "babylonjs/Shaders/lensHighlights.fragment";
  75397. import "babylonjs/Shaders/depthOfField.fragment";
  75398. /**
  75399. * BABYLON.JS Chromatic Aberration GLSL Shader
  75400. * Author: Olivier Guyot
  75401. * Separates very slightly R, G and B colors on the edges of the screen
  75402. * Inspired by Francois Tarlier & Martins Upitis
  75403. */
  75404. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75405. /**
  75406. * @ignore
  75407. * The chromatic aberration PostProcess id in the pipeline
  75408. */
  75409. LensChromaticAberrationEffect: string;
  75410. /**
  75411. * @ignore
  75412. * The highlights enhancing PostProcess id in the pipeline
  75413. */
  75414. HighlightsEnhancingEffect: string;
  75415. /**
  75416. * @ignore
  75417. * The depth-of-field PostProcess id in the pipeline
  75418. */
  75419. LensDepthOfFieldEffect: string;
  75420. private _scene;
  75421. private _depthTexture;
  75422. private _grainTexture;
  75423. private _chromaticAberrationPostProcess;
  75424. private _highlightsPostProcess;
  75425. private _depthOfFieldPostProcess;
  75426. private _edgeBlur;
  75427. private _grainAmount;
  75428. private _chromaticAberration;
  75429. private _distortion;
  75430. private _highlightsGain;
  75431. private _highlightsThreshold;
  75432. private _dofDistance;
  75433. private _dofAperture;
  75434. private _dofDarken;
  75435. private _dofPentagon;
  75436. private _blurNoise;
  75437. /**
  75438. * @constructor
  75439. *
  75440. * Effect parameters are as follow:
  75441. * {
  75442. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75443. * edge_blur: number; // from 0 to x (1 for realism)
  75444. * distortion: number; // from 0 to x (1 for realism)
  75445. * grain_amount: number; // from 0 to 1
  75446. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75447. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75448. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75449. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75450. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75451. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75452. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75453. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75454. * }
  75455. * Note: if an effect parameter is unset, effect is disabled
  75456. *
  75457. * @param name The rendering pipeline name
  75458. * @param parameters - An object containing all parameters (see above)
  75459. * @param scene The scene linked to this pipeline
  75460. * @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)
  75461. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75462. */
  75463. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75464. /**
  75465. * Get the class name
  75466. * @returns "LensRenderingPipeline"
  75467. */
  75468. getClassName(): string;
  75469. /**
  75470. * Gets associated scene
  75471. */
  75472. get scene(): Scene;
  75473. /**
  75474. * Gets or sets the edge blur
  75475. */
  75476. get edgeBlur(): number;
  75477. set edgeBlur(value: number);
  75478. /**
  75479. * Gets or sets the grain amount
  75480. */
  75481. get grainAmount(): number;
  75482. set grainAmount(value: number);
  75483. /**
  75484. * Gets or sets the chromatic aberration amount
  75485. */
  75486. get chromaticAberration(): number;
  75487. set chromaticAberration(value: number);
  75488. /**
  75489. * Gets or sets the depth of field aperture
  75490. */
  75491. get dofAperture(): number;
  75492. set dofAperture(value: number);
  75493. /**
  75494. * Gets or sets the edge distortion
  75495. */
  75496. get edgeDistortion(): number;
  75497. set edgeDistortion(value: number);
  75498. /**
  75499. * Gets or sets the depth of field distortion
  75500. */
  75501. get dofDistortion(): number;
  75502. set dofDistortion(value: number);
  75503. /**
  75504. * Gets or sets the darken out of focus amount
  75505. */
  75506. get darkenOutOfFocus(): number;
  75507. set darkenOutOfFocus(value: number);
  75508. /**
  75509. * Gets or sets a boolean indicating if blur noise is enabled
  75510. */
  75511. get blurNoise(): boolean;
  75512. set blurNoise(value: boolean);
  75513. /**
  75514. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75515. */
  75516. get pentagonBokeh(): boolean;
  75517. set pentagonBokeh(value: boolean);
  75518. /**
  75519. * Gets or sets the highlight grain amount
  75520. */
  75521. get highlightsGain(): number;
  75522. set highlightsGain(value: number);
  75523. /**
  75524. * Gets or sets the highlight threshold
  75525. */
  75526. get highlightsThreshold(): number;
  75527. set highlightsThreshold(value: number);
  75528. /**
  75529. * Sets the amount of blur at the edges
  75530. * @param amount blur amount
  75531. */
  75532. setEdgeBlur(amount: number): void;
  75533. /**
  75534. * Sets edge blur to 0
  75535. */
  75536. disableEdgeBlur(): void;
  75537. /**
  75538. * Sets the amout of grain
  75539. * @param amount Amount of grain
  75540. */
  75541. setGrainAmount(amount: number): void;
  75542. /**
  75543. * Set grain amount to 0
  75544. */
  75545. disableGrain(): void;
  75546. /**
  75547. * Sets the chromatic aberration amount
  75548. * @param amount amount of chromatic aberration
  75549. */
  75550. setChromaticAberration(amount: number): void;
  75551. /**
  75552. * Sets chromatic aberration amount to 0
  75553. */
  75554. disableChromaticAberration(): void;
  75555. /**
  75556. * Sets the EdgeDistortion amount
  75557. * @param amount amount of EdgeDistortion
  75558. */
  75559. setEdgeDistortion(amount: number): void;
  75560. /**
  75561. * Sets edge distortion to 0
  75562. */
  75563. disableEdgeDistortion(): void;
  75564. /**
  75565. * Sets the FocusDistance amount
  75566. * @param amount amount of FocusDistance
  75567. */
  75568. setFocusDistance(amount: number): void;
  75569. /**
  75570. * Disables depth of field
  75571. */
  75572. disableDepthOfField(): void;
  75573. /**
  75574. * Sets the Aperture amount
  75575. * @param amount amount of Aperture
  75576. */
  75577. setAperture(amount: number): void;
  75578. /**
  75579. * Sets the DarkenOutOfFocus amount
  75580. * @param amount amount of DarkenOutOfFocus
  75581. */
  75582. setDarkenOutOfFocus(amount: number): void;
  75583. private _pentagonBokehIsEnabled;
  75584. /**
  75585. * Creates a pentagon bokeh effect
  75586. */
  75587. enablePentagonBokeh(): void;
  75588. /**
  75589. * Disables the pentagon bokeh effect
  75590. */
  75591. disablePentagonBokeh(): void;
  75592. /**
  75593. * Enables noise blur
  75594. */
  75595. enableNoiseBlur(): void;
  75596. /**
  75597. * Disables noise blur
  75598. */
  75599. disableNoiseBlur(): void;
  75600. /**
  75601. * Sets the HighlightsGain amount
  75602. * @param amount amount of HighlightsGain
  75603. */
  75604. setHighlightsGain(amount: number): void;
  75605. /**
  75606. * Sets the HighlightsThreshold amount
  75607. * @param amount amount of HighlightsThreshold
  75608. */
  75609. setHighlightsThreshold(amount: number): void;
  75610. /**
  75611. * Disables highlights
  75612. */
  75613. disableHighlights(): void;
  75614. /**
  75615. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75616. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75617. */
  75618. dispose(disableDepthRender?: boolean): void;
  75619. private _createChromaticAberrationPostProcess;
  75620. private _createHighlightsPostProcess;
  75621. private _createDepthOfFieldPostProcess;
  75622. private _createGrainTexture;
  75623. }
  75624. }
  75625. declare module "babylonjs/Rendering/ssao2Configuration" {
  75626. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75627. /**
  75628. * Contains all parameters needed for the prepass to perform
  75629. * screen space subsurface scattering
  75630. */
  75631. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75632. /**
  75633. * Is subsurface enabled
  75634. */
  75635. enabled: boolean;
  75636. /**
  75637. * Name of the configuration
  75638. */
  75639. name: string;
  75640. /**
  75641. * Textures that should be present in the MRT for this effect to work
  75642. */
  75643. readonly texturesRequired: number[];
  75644. }
  75645. }
  75646. declare module "babylonjs/Shaders/ssao2.fragment" {
  75647. /** @hidden */
  75648. export var ssao2PixelShader: {
  75649. name: string;
  75650. shader: string;
  75651. };
  75652. }
  75653. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75654. /** @hidden */
  75655. export var ssaoCombinePixelShader: {
  75656. name: string;
  75657. shader: string;
  75658. };
  75659. }
  75660. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75661. import { Camera } from "babylonjs/Cameras/camera";
  75662. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75663. import { Scene } from "babylonjs/scene";
  75664. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75665. import "babylonjs/Shaders/ssao2.fragment";
  75666. import "babylonjs/Shaders/ssaoCombine.fragment";
  75667. /**
  75668. * Render pipeline to produce ssao effect
  75669. */
  75670. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75671. /**
  75672. * @ignore
  75673. * The PassPostProcess id in the pipeline that contains the original scene color
  75674. */
  75675. SSAOOriginalSceneColorEffect: string;
  75676. /**
  75677. * @ignore
  75678. * The SSAO PostProcess id in the pipeline
  75679. */
  75680. SSAORenderEffect: string;
  75681. /**
  75682. * @ignore
  75683. * The horizontal blur PostProcess id in the pipeline
  75684. */
  75685. SSAOBlurHRenderEffect: string;
  75686. /**
  75687. * @ignore
  75688. * The vertical blur PostProcess id in the pipeline
  75689. */
  75690. SSAOBlurVRenderEffect: string;
  75691. /**
  75692. * @ignore
  75693. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75694. */
  75695. SSAOCombineRenderEffect: string;
  75696. /**
  75697. * The output strength of the SSAO post-process. Default value is 1.0.
  75698. */
  75699. totalStrength: number;
  75700. /**
  75701. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75702. */
  75703. maxZ: number;
  75704. /**
  75705. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75706. */
  75707. minZAspect: number;
  75708. private _samples;
  75709. /**
  75710. * Number of samples used for the SSAO calculations. Default value is 8
  75711. */
  75712. set samples(n: number);
  75713. get samples(): number;
  75714. private _textureSamples;
  75715. /**
  75716. * Number of samples to use for antialiasing
  75717. */
  75718. set textureSamples(n: number);
  75719. get textureSamples(): number;
  75720. /**
  75721. * Force rendering the geometry through geometry buffer
  75722. */
  75723. private _forceGeometryBuffer;
  75724. /**
  75725. * Ratio object used for SSAO ratio and blur ratio
  75726. */
  75727. private _ratio;
  75728. /**
  75729. * Dynamically generated sphere sampler.
  75730. */
  75731. private _sampleSphere;
  75732. /**
  75733. * Blur filter offsets
  75734. */
  75735. private _samplerOffsets;
  75736. private _expensiveBlur;
  75737. /**
  75738. * If bilateral blur should be used
  75739. */
  75740. set expensiveBlur(b: boolean);
  75741. get expensiveBlur(): boolean;
  75742. /**
  75743. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75744. */
  75745. radius: number;
  75746. /**
  75747. * The base color of the SSAO post-process
  75748. * The final result is "base + ssao" between [0, 1]
  75749. */
  75750. base: number;
  75751. /**
  75752. * Support test.
  75753. */
  75754. static get IsSupported(): boolean;
  75755. private _scene;
  75756. private _randomTexture;
  75757. private _originalColorPostProcess;
  75758. private _ssaoPostProcess;
  75759. private _blurHPostProcess;
  75760. private _blurVPostProcess;
  75761. private _ssaoCombinePostProcess;
  75762. private _prePassRenderer;
  75763. /**
  75764. * Gets active scene
  75765. */
  75766. get scene(): Scene;
  75767. /**
  75768. * @constructor
  75769. * @param name The rendering pipeline name
  75770. * @param scene The scene linked to this pipeline
  75771. * @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 }
  75772. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75773. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75774. */
  75775. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75776. /**
  75777. * Get the class name
  75778. * @returns "SSAO2RenderingPipeline"
  75779. */
  75780. getClassName(): string;
  75781. /**
  75782. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75783. */
  75784. dispose(disableGeometryBufferRenderer?: boolean): void;
  75785. private _createBlurPostProcess;
  75786. /** @hidden */
  75787. _rebuild(): void;
  75788. private _bits;
  75789. private _radicalInverse_VdC;
  75790. private _hammersley;
  75791. private _hemisphereSample_uniform;
  75792. private _generateHemisphere;
  75793. private _getDefinesForSSAO;
  75794. private _createSSAOPostProcess;
  75795. private _createSSAOCombinePostProcess;
  75796. private _createRandomTexture;
  75797. /**
  75798. * Serialize the rendering pipeline (Used when exporting)
  75799. * @returns the serialized object
  75800. */
  75801. serialize(): any;
  75802. /**
  75803. * Parse the serialized pipeline
  75804. * @param source Source pipeline.
  75805. * @param scene The scene to load the pipeline to.
  75806. * @param rootUrl The URL of the serialized pipeline.
  75807. * @returns An instantiated pipeline from the serialized object.
  75808. */
  75809. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75810. }
  75811. }
  75812. declare module "babylonjs/Shaders/ssao.fragment" {
  75813. /** @hidden */
  75814. export var ssaoPixelShader: {
  75815. name: string;
  75816. shader: string;
  75817. };
  75818. }
  75819. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75820. import { Camera } from "babylonjs/Cameras/camera";
  75821. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75822. import { Scene } from "babylonjs/scene";
  75823. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75824. import "babylonjs/Shaders/ssao.fragment";
  75825. import "babylonjs/Shaders/ssaoCombine.fragment";
  75826. /**
  75827. * Render pipeline to produce ssao effect
  75828. */
  75829. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75830. /**
  75831. * @ignore
  75832. * The PassPostProcess id in the pipeline that contains the original scene color
  75833. */
  75834. SSAOOriginalSceneColorEffect: string;
  75835. /**
  75836. * @ignore
  75837. * The SSAO PostProcess id in the pipeline
  75838. */
  75839. SSAORenderEffect: string;
  75840. /**
  75841. * @ignore
  75842. * The horizontal blur PostProcess id in the pipeline
  75843. */
  75844. SSAOBlurHRenderEffect: string;
  75845. /**
  75846. * @ignore
  75847. * The vertical blur PostProcess id in the pipeline
  75848. */
  75849. SSAOBlurVRenderEffect: string;
  75850. /**
  75851. * @ignore
  75852. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75853. */
  75854. SSAOCombineRenderEffect: string;
  75855. /**
  75856. * The output strength of the SSAO post-process. Default value is 1.0.
  75857. */
  75858. totalStrength: number;
  75859. /**
  75860. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75861. */
  75862. radius: number;
  75863. /**
  75864. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75865. * Must not be equal to fallOff and superior to fallOff.
  75866. * Default value is 0.0075
  75867. */
  75868. area: number;
  75869. /**
  75870. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75871. * Must not be equal to area and inferior to area.
  75872. * Default value is 0.000001
  75873. */
  75874. fallOff: number;
  75875. /**
  75876. * The base color of the SSAO post-process
  75877. * The final result is "base + ssao" between [0, 1]
  75878. */
  75879. base: number;
  75880. private _scene;
  75881. private _depthTexture;
  75882. private _randomTexture;
  75883. private _originalColorPostProcess;
  75884. private _ssaoPostProcess;
  75885. private _blurHPostProcess;
  75886. private _blurVPostProcess;
  75887. private _ssaoCombinePostProcess;
  75888. private _firstUpdate;
  75889. /**
  75890. * Gets active scene
  75891. */
  75892. get scene(): Scene;
  75893. /**
  75894. * @constructor
  75895. * @param name - The rendering pipeline name
  75896. * @param scene - The scene linked to this pipeline
  75897. * @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 }
  75898. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75899. */
  75900. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75901. /**
  75902. * Get the class name
  75903. * @returns "SSAORenderingPipeline"
  75904. */
  75905. getClassName(): string;
  75906. /**
  75907. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75908. */
  75909. dispose(disableDepthRender?: boolean): void;
  75910. private _createBlurPostProcess;
  75911. /** @hidden */
  75912. _rebuild(): void;
  75913. private _createSSAOPostProcess;
  75914. private _createSSAOCombinePostProcess;
  75915. private _createRandomTexture;
  75916. }
  75917. }
  75918. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  75919. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75920. /**
  75921. * Contains all parameters needed for the prepass to perform
  75922. * screen space reflections
  75923. */
  75924. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75925. /**
  75926. * Is ssr enabled
  75927. */
  75928. enabled: boolean;
  75929. /**
  75930. * Name of the configuration
  75931. */
  75932. name: string;
  75933. /**
  75934. * Textures that should be present in the MRT for this effect to work
  75935. */
  75936. readonly texturesRequired: number[];
  75937. }
  75938. }
  75939. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75940. /** @hidden */
  75941. export var screenSpaceReflectionPixelShader: {
  75942. name: string;
  75943. shader: string;
  75944. };
  75945. }
  75946. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75947. import { Nullable } from "babylonjs/types";
  75948. import { Camera } from "babylonjs/Cameras/camera";
  75949. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75950. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75951. import { Engine } from "babylonjs/Engines/engine";
  75952. import { Scene } from "babylonjs/scene";
  75953. /**
  75954. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75955. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75956. */
  75957. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75958. /**
  75959. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75960. */
  75961. threshold: number;
  75962. /**
  75963. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75964. */
  75965. strength: number;
  75966. /**
  75967. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75968. */
  75969. reflectionSpecularFalloffExponent: number;
  75970. /**
  75971. * 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]
  75972. */
  75973. step: number;
  75974. /**
  75975. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75976. */
  75977. roughnessFactor: number;
  75978. private _forceGeometryBuffer;
  75979. private _geometryBufferRenderer;
  75980. private _prePassRenderer;
  75981. private _enableSmoothReflections;
  75982. private _reflectionSamples;
  75983. private _smoothSteps;
  75984. /**
  75985. * Gets a string identifying the name of the class
  75986. * @returns "ScreenSpaceReflectionPostProcess" string
  75987. */
  75988. getClassName(): string;
  75989. /**
  75990. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75991. * @param name The name of the effect.
  75992. * @param scene The scene containing the objects to calculate reflections.
  75993. * @param options The required width/height ratio to downsize to before computing the render pass.
  75994. * @param camera The camera to apply the render pass to.
  75995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75996. * @param engine The engine which the post process will be applied. (default: current engine)
  75997. * @param reusable If the post process can be reused on the same frame. (default: false)
  75998. * @param textureType Type of textures used when performing the post process. (default: 0)
  75999. * @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)
  76000. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  76001. */
  76002. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  76003. /**
  76004. * Gets wether or not smoothing reflections is enabled.
  76005. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76006. */
  76007. get enableSmoothReflections(): boolean;
  76008. /**
  76009. * Sets wether or not smoothing reflections is enabled.
  76010. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76011. */
  76012. set enableSmoothReflections(enabled: boolean);
  76013. /**
  76014. * Gets the number of samples taken while computing reflections. More samples count is high,
  76015. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76016. */
  76017. get reflectionSamples(): number;
  76018. /**
  76019. * Sets the number of samples taken while computing reflections. More samples count is high,
  76020. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76021. */
  76022. set reflectionSamples(samples: number);
  76023. /**
  76024. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  76025. * more the post-process will require GPU power and can generate a drop in FPS.
  76026. * Default value (5.0) work pretty well in all cases but can be adjusted.
  76027. */
  76028. get smoothSteps(): number;
  76029. set smoothSteps(steps: number);
  76030. private _updateEffectDefines;
  76031. /** @hidden */
  76032. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  76033. }
  76034. }
  76035. declare module "babylonjs/Shaders/standard.fragment" {
  76036. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  76037. /** @hidden */
  76038. export var standardPixelShader: {
  76039. name: string;
  76040. shader: string;
  76041. };
  76042. }
  76043. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  76044. import { Nullable } from "babylonjs/types";
  76045. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  76046. import { Camera } from "babylonjs/Cameras/camera";
  76047. import { Texture } from "babylonjs/Materials/Textures/texture";
  76048. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76049. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76050. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  76051. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  76052. import { IDisposable } from "babylonjs/scene";
  76053. import { SpotLight } from "babylonjs/Lights/spotLight";
  76054. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  76055. import { Scene } from "babylonjs/scene";
  76056. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76057. import { Animation } from "babylonjs/Animations/animation";
  76058. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76059. import "babylonjs/Shaders/standard.fragment";
  76060. /**
  76061. * Standard rendering pipeline
  76062. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76063. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  76064. */
  76065. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  76066. /**
  76067. * Public members
  76068. */
  76069. /**
  76070. * Post-process which contains the original scene color before the pipeline applies all the effects
  76071. */
  76072. originalPostProcess: Nullable<PostProcess>;
  76073. /**
  76074. * Post-process used to down scale an image x4
  76075. */
  76076. downSampleX4PostProcess: Nullable<PostProcess>;
  76077. /**
  76078. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  76079. */
  76080. brightPassPostProcess: Nullable<PostProcess>;
  76081. /**
  76082. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  76083. */
  76084. blurHPostProcesses: PostProcess[];
  76085. /**
  76086. * Post-process array storing all the vertical blur post-processes used by the pipeline
  76087. */
  76088. blurVPostProcesses: PostProcess[];
  76089. /**
  76090. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  76091. */
  76092. textureAdderPostProcess: Nullable<PostProcess>;
  76093. /**
  76094. * Post-process used to create volumetric lighting effect
  76095. */
  76096. volumetricLightPostProcess: Nullable<PostProcess>;
  76097. /**
  76098. * Post-process used to smooth the previous volumetric light post-process on the X axis
  76099. */
  76100. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  76101. /**
  76102. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  76103. */
  76104. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  76105. /**
  76106. * Post-process used to merge the volumetric light effect and the real scene color
  76107. */
  76108. volumetricLightMergePostProces: Nullable<PostProcess>;
  76109. /**
  76110. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  76111. */
  76112. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  76113. /**
  76114. * Base post-process used to calculate the average luminance of the final image for HDR
  76115. */
  76116. luminancePostProcess: Nullable<PostProcess>;
  76117. /**
  76118. * Post-processes used to create down sample post-processes in order to get
  76119. * the average luminance of the final image for HDR
  76120. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  76121. */
  76122. luminanceDownSamplePostProcesses: PostProcess[];
  76123. /**
  76124. * Post-process used to create a HDR effect (light adaptation)
  76125. */
  76126. hdrPostProcess: Nullable<PostProcess>;
  76127. /**
  76128. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  76129. */
  76130. textureAdderFinalPostProcess: Nullable<PostProcess>;
  76131. /**
  76132. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  76133. */
  76134. lensFlareFinalPostProcess: Nullable<PostProcess>;
  76135. /**
  76136. * Post-process used to merge the final HDR post-process and the real scene color
  76137. */
  76138. hdrFinalPostProcess: Nullable<PostProcess>;
  76139. /**
  76140. * Post-process used to create a lens flare effect
  76141. */
  76142. lensFlarePostProcess: Nullable<PostProcess>;
  76143. /**
  76144. * Post-process that merges the result of the lens flare post-process and the real scene color
  76145. */
  76146. lensFlareComposePostProcess: Nullable<PostProcess>;
  76147. /**
  76148. * Post-process used to create a motion blur effect
  76149. */
  76150. motionBlurPostProcess: Nullable<PostProcess>;
  76151. /**
  76152. * Post-process used to create a depth of field effect
  76153. */
  76154. depthOfFieldPostProcess: Nullable<PostProcess>;
  76155. /**
  76156. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  76157. */
  76158. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76159. /**
  76160. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76161. */
  76162. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76163. /**
  76164. * Represents the brightness threshold in order to configure the illuminated surfaces
  76165. */
  76166. brightThreshold: number;
  76167. /**
  76168. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76169. */
  76170. blurWidth: number;
  76171. /**
  76172. * Sets if the blur for highlighted surfaces must be only horizontal
  76173. */
  76174. horizontalBlur: boolean;
  76175. /**
  76176. * Gets the overall exposure used by the pipeline
  76177. */
  76178. get exposure(): number;
  76179. /**
  76180. * Sets the overall exposure used by the pipeline
  76181. */
  76182. set exposure(value: number);
  76183. /**
  76184. * Texture used typically to simulate "dirty" on camera lens
  76185. */
  76186. lensTexture: Nullable<Texture>;
  76187. /**
  76188. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76189. */
  76190. volumetricLightCoefficient: number;
  76191. /**
  76192. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76193. */
  76194. volumetricLightPower: number;
  76195. /**
  76196. * Used the set the blur intensity to smooth the volumetric lights
  76197. */
  76198. volumetricLightBlurScale: number;
  76199. /**
  76200. * Light (spot or directional) used to generate the volumetric lights rays
  76201. * The source light must have a shadow generate so the pipeline can get its
  76202. * depth map
  76203. */
  76204. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76205. /**
  76206. * For eye adaptation, represents the minimum luminance the eye can see
  76207. */
  76208. hdrMinimumLuminance: number;
  76209. /**
  76210. * For eye adaptation, represents the decrease luminance speed
  76211. */
  76212. hdrDecreaseRate: number;
  76213. /**
  76214. * For eye adaptation, represents the increase luminance speed
  76215. */
  76216. hdrIncreaseRate: number;
  76217. /**
  76218. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76219. */
  76220. get hdrAutoExposure(): boolean;
  76221. /**
  76222. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76223. */
  76224. set hdrAutoExposure(value: boolean);
  76225. /**
  76226. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76227. */
  76228. lensColorTexture: Nullable<Texture>;
  76229. /**
  76230. * The overall strengh for the lens flare effect
  76231. */
  76232. lensFlareStrength: number;
  76233. /**
  76234. * Dispersion coefficient for lens flare ghosts
  76235. */
  76236. lensFlareGhostDispersal: number;
  76237. /**
  76238. * Main lens flare halo width
  76239. */
  76240. lensFlareHaloWidth: number;
  76241. /**
  76242. * Based on the lens distortion effect, defines how much the lens flare result
  76243. * is distorted
  76244. */
  76245. lensFlareDistortionStrength: number;
  76246. /**
  76247. * Configures the blur intensity used for for lens flare (halo)
  76248. */
  76249. lensFlareBlurWidth: number;
  76250. /**
  76251. * Lens star texture must be used to simulate rays on the flares and is available
  76252. * in the documentation
  76253. */
  76254. lensStarTexture: Nullable<Texture>;
  76255. /**
  76256. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76257. * flare effect by taking account of the dirt texture
  76258. */
  76259. lensFlareDirtTexture: Nullable<Texture>;
  76260. /**
  76261. * Represents the focal length for the depth of field effect
  76262. */
  76263. depthOfFieldDistance: number;
  76264. /**
  76265. * Represents the blur intensity for the blurred part of the depth of field effect
  76266. */
  76267. depthOfFieldBlurWidth: number;
  76268. /**
  76269. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76270. */
  76271. get motionStrength(): number;
  76272. /**
  76273. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76274. */
  76275. set motionStrength(strength: number);
  76276. /**
  76277. * Gets wether or not the motion blur post-process is object based or screen based.
  76278. */
  76279. get objectBasedMotionBlur(): boolean;
  76280. /**
  76281. * Sets wether or not the motion blur post-process should be object based or screen based
  76282. */
  76283. set objectBasedMotionBlur(value: boolean);
  76284. /**
  76285. * List of animations for the pipeline (IAnimatable implementation)
  76286. */
  76287. animations: Animation[];
  76288. /**
  76289. * Private members
  76290. */
  76291. private _scene;
  76292. private _currentDepthOfFieldSource;
  76293. private _basePostProcess;
  76294. private _fixedExposure;
  76295. private _currentExposure;
  76296. private _hdrAutoExposure;
  76297. private _hdrCurrentLuminance;
  76298. private _motionStrength;
  76299. private _isObjectBasedMotionBlur;
  76300. private _floatTextureType;
  76301. private _camerasToBeAttached;
  76302. private _ratio;
  76303. private _bloomEnabled;
  76304. private _depthOfFieldEnabled;
  76305. private _vlsEnabled;
  76306. private _lensFlareEnabled;
  76307. private _hdrEnabled;
  76308. private _motionBlurEnabled;
  76309. private _fxaaEnabled;
  76310. private _screenSpaceReflectionsEnabled;
  76311. private _motionBlurSamples;
  76312. private _volumetricLightStepsCount;
  76313. private _samples;
  76314. /**
  76315. * @ignore
  76316. * Specifies if the bloom pipeline is enabled
  76317. */
  76318. get BloomEnabled(): boolean;
  76319. set BloomEnabled(enabled: boolean);
  76320. /**
  76321. * @ignore
  76322. * Specifies if the depth of field pipeline is enabed
  76323. */
  76324. get DepthOfFieldEnabled(): boolean;
  76325. set DepthOfFieldEnabled(enabled: boolean);
  76326. /**
  76327. * @ignore
  76328. * Specifies if the lens flare pipeline is enabed
  76329. */
  76330. get LensFlareEnabled(): boolean;
  76331. set LensFlareEnabled(enabled: boolean);
  76332. /**
  76333. * @ignore
  76334. * Specifies if the HDR pipeline is enabled
  76335. */
  76336. get HDREnabled(): boolean;
  76337. set HDREnabled(enabled: boolean);
  76338. /**
  76339. * @ignore
  76340. * Specifies if the volumetric lights scattering effect is enabled
  76341. */
  76342. get VLSEnabled(): boolean;
  76343. set VLSEnabled(enabled: boolean);
  76344. /**
  76345. * @ignore
  76346. * Specifies if the motion blur effect is enabled
  76347. */
  76348. get MotionBlurEnabled(): boolean;
  76349. set MotionBlurEnabled(enabled: boolean);
  76350. /**
  76351. * Specifies if anti-aliasing is enabled
  76352. */
  76353. get fxaaEnabled(): boolean;
  76354. set fxaaEnabled(enabled: boolean);
  76355. /**
  76356. * Specifies if screen space reflections are enabled.
  76357. */
  76358. get screenSpaceReflectionsEnabled(): boolean;
  76359. set screenSpaceReflectionsEnabled(enabled: boolean);
  76360. /**
  76361. * Specifies the number of steps used to calculate the volumetric lights
  76362. * Typically in interval [50, 200]
  76363. */
  76364. get volumetricLightStepsCount(): number;
  76365. set volumetricLightStepsCount(count: number);
  76366. /**
  76367. * Specifies the number of samples used for the motion blur effect
  76368. * Typically in interval [16, 64]
  76369. */
  76370. get motionBlurSamples(): number;
  76371. set motionBlurSamples(samples: number);
  76372. /**
  76373. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76374. */
  76375. get samples(): number;
  76376. set samples(sampleCount: number);
  76377. /**
  76378. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76379. * @constructor
  76380. * @param name The rendering pipeline name
  76381. * @param scene The scene linked to this pipeline
  76382. * @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)
  76383. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76384. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76385. */
  76386. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76387. private _buildPipeline;
  76388. private _createDownSampleX4PostProcess;
  76389. private _createBrightPassPostProcess;
  76390. private _createBlurPostProcesses;
  76391. private _createTextureAdderPostProcess;
  76392. private _createVolumetricLightPostProcess;
  76393. private _createLuminancePostProcesses;
  76394. private _createHdrPostProcess;
  76395. private _createLensFlarePostProcess;
  76396. private _createDepthOfFieldPostProcess;
  76397. private _createMotionBlurPostProcess;
  76398. private _getDepthTexture;
  76399. private _disposePostProcesses;
  76400. /**
  76401. * Dispose of the pipeline and stop all post processes
  76402. */
  76403. dispose(): void;
  76404. /**
  76405. * Serialize the rendering pipeline (Used when exporting)
  76406. * @returns the serialized object
  76407. */
  76408. serialize(): any;
  76409. /**
  76410. * Parse the serialized pipeline
  76411. * @param source Source pipeline.
  76412. * @param scene The scene to load the pipeline to.
  76413. * @param rootUrl The URL of the serialized pipeline.
  76414. * @returns An instantiated pipeline from the serialized object.
  76415. */
  76416. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76417. /**
  76418. * Luminance steps
  76419. */
  76420. static LuminanceSteps: number;
  76421. }
  76422. }
  76423. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  76424. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  76425. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  76426. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  76427. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  76428. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  76429. }
  76430. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  76431. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  76432. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  76433. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76434. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  76435. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76436. }
  76437. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  76438. /** @hidden */
  76439. export var stereoscopicInterlacePixelShader: {
  76440. name: string;
  76441. shader: string;
  76442. };
  76443. }
  76444. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  76445. import { Camera } from "babylonjs/Cameras/camera";
  76446. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76447. import { Engine } from "babylonjs/Engines/engine";
  76448. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  76449. /**
  76450. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  76451. */
  76452. export class StereoscopicInterlacePostProcessI extends PostProcess {
  76453. private _stepSize;
  76454. private _passedProcess;
  76455. /**
  76456. * Gets a string identifying the name of the class
  76457. * @returns "StereoscopicInterlacePostProcessI" string
  76458. */
  76459. getClassName(): string;
  76460. /**
  76461. * Initializes a StereoscopicInterlacePostProcessI
  76462. * @param name The name of the effect.
  76463. * @param rigCameras The rig cameras to be appled to the post process
  76464. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  76465. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  76466. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76467. * @param engine The engine which the post process will be applied. (default: current engine)
  76468. * @param reusable If the post process can be reused on the same frame. (default: false)
  76469. */
  76470. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76471. }
  76472. /**
  76473. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  76474. */
  76475. export class StereoscopicInterlacePostProcess extends PostProcess {
  76476. private _stepSize;
  76477. private _passedProcess;
  76478. /**
  76479. * Gets a string identifying the name of the class
  76480. * @returns "StereoscopicInterlacePostProcess" string
  76481. */
  76482. getClassName(): string;
  76483. /**
  76484. * Initializes a StereoscopicInterlacePostProcess
  76485. * @param name The name of the effect.
  76486. * @param rigCameras The rig cameras to be appled to the post process
  76487. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  76488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76489. * @param engine The engine which the post process will be applied. (default: current engine)
  76490. * @param reusable If the post process can be reused on the same frame. (default: false)
  76491. */
  76492. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76493. }
  76494. }
  76495. declare module "babylonjs/Shaders/tonemap.fragment" {
  76496. /** @hidden */
  76497. export var tonemapPixelShader: {
  76498. name: string;
  76499. shader: string;
  76500. };
  76501. }
  76502. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76503. import { Camera } from "babylonjs/Cameras/camera";
  76504. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76505. import "babylonjs/Shaders/tonemap.fragment";
  76506. import { Engine } from "babylonjs/Engines/engine";
  76507. /** Defines operator used for tonemapping */
  76508. export enum TonemappingOperator {
  76509. /** Hable */
  76510. Hable = 0,
  76511. /** Reinhard */
  76512. Reinhard = 1,
  76513. /** HejiDawson */
  76514. HejiDawson = 2,
  76515. /** Photographic */
  76516. Photographic = 3
  76517. }
  76518. /**
  76519. * Defines a post process to apply tone mapping
  76520. */
  76521. export class TonemapPostProcess extends PostProcess {
  76522. private _operator;
  76523. /** Defines the required exposure adjustement */
  76524. exposureAdjustment: number;
  76525. /**
  76526. * Gets a string identifying the name of the class
  76527. * @returns "TonemapPostProcess" string
  76528. */
  76529. getClassName(): string;
  76530. /**
  76531. * Creates a new TonemapPostProcess
  76532. * @param name defines the name of the postprocess
  76533. * @param _operator defines the operator to use
  76534. * @param exposureAdjustment defines the required exposure adjustement
  76535. * @param camera defines the camera to use (can be null)
  76536. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76537. * @param engine defines the hosting engine (can be ignore if camera is set)
  76538. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76539. */
  76540. constructor(name: string, _operator: TonemappingOperator,
  76541. /** Defines the required exposure adjustement */
  76542. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76543. }
  76544. }
  76545. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76546. /** @hidden */
  76547. export var volumetricLightScatteringPixelShader: {
  76548. name: string;
  76549. shader: string;
  76550. };
  76551. }
  76552. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  76553. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76554. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76555. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76556. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76557. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76558. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76559. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76560. /** @hidden */
  76561. export var volumetricLightScatteringPassVertexShader: {
  76562. name: string;
  76563. shader: string;
  76564. };
  76565. }
  76566. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  76567. /** @hidden */
  76568. export var volumetricLightScatteringPassPixelShader: {
  76569. name: string;
  76570. shader: string;
  76571. };
  76572. }
  76573. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  76574. import { Vector3 } from "babylonjs/Maths/math.vector";
  76575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76576. import { Mesh } from "babylonjs/Meshes/mesh";
  76577. import { Camera } from "babylonjs/Cameras/camera";
  76578. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  76579. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76580. import { Scene } from "babylonjs/scene";
  76581. import "babylonjs/Meshes/Builders/planeBuilder";
  76582. import "babylonjs/Shaders/depth.vertex";
  76583. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  76584. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  76585. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  76586. import { Engine } from "babylonjs/Engines/engine";
  76587. /**
  76588. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76589. */
  76590. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76591. private _volumetricLightScatteringPass;
  76592. private _volumetricLightScatteringRTT;
  76593. private _viewPort;
  76594. private _screenCoordinates;
  76595. private _cachedDefines;
  76596. /**
  76597. * If not undefined, the mesh position is computed from the attached node position
  76598. */
  76599. attachedNode: {
  76600. position: Vector3;
  76601. };
  76602. /**
  76603. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76604. */
  76605. customMeshPosition: Vector3;
  76606. /**
  76607. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76608. */
  76609. useCustomMeshPosition: boolean;
  76610. /**
  76611. * If the post-process should inverse the light scattering direction
  76612. */
  76613. invert: boolean;
  76614. /**
  76615. * The internal mesh used by the post-process
  76616. */
  76617. mesh: Mesh;
  76618. /**
  76619. * @hidden
  76620. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76621. */
  76622. get useDiffuseColor(): boolean;
  76623. set useDiffuseColor(useDiffuseColor: boolean);
  76624. /**
  76625. * Array containing the excluded meshes not rendered in the internal pass
  76626. */
  76627. excludedMeshes: AbstractMesh[];
  76628. /**
  76629. * Controls the overall intensity of the post-process
  76630. */
  76631. exposure: number;
  76632. /**
  76633. * Dissipates each sample's contribution in range [0, 1]
  76634. */
  76635. decay: number;
  76636. /**
  76637. * Controls the overall intensity of each sample
  76638. */
  76639. weight: number;
  76640. /**
  76641. * Controls the density of each sample
  76642. */
  76643. density: number;
  76644. /**
  76645. * @constructor
  76646. * @param name The post-process name
  76647. * @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)
  76648. * @param camera The camera that the post-process will be attached to
  76649. * @param mesh The mesh used to create the light scattering
  76650. * @param samples The post-process quality, default 100
  76651. * @param samplingModeThe post-process filtering mode
  76652. * @param engine The babylon engine
  76653. * @param reusable If the post-process is reusable
  76654. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76655. */
  76656. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76657. /**
  76658. * Returns the string "VolumetricLightScatteringPostProcess"
  76659. * @returns "VolumetricLightScatteringPostProcess"
  76660. */
  76661. getClassName(): string;
  76662. private _isReady;
  76663. /**
  76664. * Sets the new light position for light scattering effect
  76665. * @param position The new custom light position
  76666. */
  76667. setCustomMeshPosition(position: Vector3): void;
  76668. /**
  76669. * Returns the light position for light scattering effect
  76670. * @return Vector3 The custom light position
  76671. */
  76672. getCustomMeshPosition(): Vector3;
  76673. /**
  76674. * Disposes the internal assets and detaches the post-process from the camera
  76675. */
  76676. dispose(camera: Camera): void;
  76677. /**
  76678. * Returns the render target texture used by the post-process
  76679. * @return the render target texture used by the post-process
  76680. */
  76681. getPass(): RenderTargetTexture;
  76682. private _meshExcluded;
  76683. private _createPass;
  76684. private _updateMeshScreenCoordinates;
  76685. /**
  76686. * Creates a default mesh for the Volumeric Light Scattering post-process
  76687. * @param name The mesh name
  76688. * @param scene The scene where to create the mesh
  76689. * @return the default mesh
  76690. */
  76691. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76692. }
  76693. }
  76694. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76695. /** @hidden */
  76696. export var screenSpaceCurvaturePixelShader: {
  76697. name: string;
  76698. shader: string;
  76699. };
  76700. }
  76701. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76702. import { Nullable } from "babylonjs/types";
  76703. import { Camera } from "babylonjs/Cameras/camera";
  76704. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76705. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76706. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76707. import { Engine } from "babylonjs/Engines/engine";
  76708. import { Scene } from "babylonjs/scene";
  76709. /**
  76710. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76711. */
  76712. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76713. /**
  76714. * Defines how much ridge the curvature effect displays.
  76715. */
  76716. ridge: number;
  76717. /**
  76718. * Defines how much valley the curvature effect displays.
  76719. */
  76720. valley: number;
  76721. private _geometryBufferRenderer;
  76722. /**
  76723. * Gets a string identifying the name of the class
  76724. * @returns "ScreenSpaceCurvaturePostProcess" string
  76725. */
  76726. getClassName(): string;
  76727. /**
  76728. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76729. * @param name The name of the effect.
  76730. * @param scene The scene containing the objects to blur according to their velocity.
  76731. * @param options The required width/height ratio to downsize to before computing the render pass.
  76732. * @param camera The camera to apply the render pass to.
  76733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76734. * @param engine The engine which the post process will be applied. (default: current engine)
  76735. * @param reusable If the post process can be reused on the same frame. (default: false)
  76736. * @param textureType Type of textures used when performing the post process. (default: 0)
  76737. * @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)
  76738. */
  76739. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76740. /**
  76741. * Support test.
  76742. */
  76743. static get IsSupported(): boolean;
  76744. /** @hidden */
  76745. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76746. }
  76747. }
  76748. declare module "babylonjs/PostProcesses/index" {
  76749. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  76750. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  76751. export * from "babylonjs/PostProcesses/bloomEffect";
  76752. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  76753. export * from "babylonjs/PostProcesses/blurPostProcess";
  76754. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  76755. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  76756. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  76757. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  76758. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  76759. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  76760. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  76761. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  76762. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  76763. export * from "babylonjs/PostProcesses/filterPostProcess";
  76764. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  76765. export * from "babylonjs/PostProcesses/grainPostProcess";
  76766. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  76767. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  76768. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  76769. export * from "babylonjs/PostProcesses/passPostProcess";
  76770. export * from "babylonjs/PostProcesses/postProcess";
  76771. export * from "babylonjs/PostProcesses/postProcessManager";
  76772. export * from "babylonjs/PostProcesses/refractionPostProcess";
  76773. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  76774. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  76775. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  76776. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  76777. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  76778. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  76779. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  76780. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76781. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  76782. }
  76783. declare module "babylonjs/Probes/index" {
  76784. export * from "babylonjs/Probes/reflectionProbe";
  76785. }
  76786. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  76787. import { Scene } from "babylonjs/scene";
  76788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76789. import { SmartArray } from "babylonjs/Misc/smartArray";
  76790. import { ISceneComponent } from "babylonjs/sceneComponent";
  76791. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  76792. import "babylonjs/Meshes/Builders/boxBuilder";
  76793. import "babylonjs/Shaders/color.fragment";
  76794. import "babylonjs/Shaders/color.vertex";
  76795. import { Color3 } from "babylonjs/Maths/math.color";
  76796. import { Observable } from "babylonjs/Misc/observable";
  76797. module "babylonjs/scene" {
  76798. interface Scene {
  76799. /** @hidden (Backing field) */
  76800. _boundingBoxRenderer: BoundingBoxRenderer;
  76801. /** @hidden (Backing field) */
  76802. _forceShowBoundingBoxes: boolean;
  76803. /**
  76804. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76805. */
  76806. forceShowBoundingBoxes: boolean;
  76807. /**
  76808. * Gets the bounding box renderer associated with the scene
  76809. * @returns a BoundingBoxRenderer
  76810. */
  76811. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76812. }
  76813. }
  76814. module "babylonjs/Meshes/abstractMesh" {
  76815. interface AbstractMesh {
  76816. /** @hidden (Backing field) */
  76817. _showBoundingBox: boolean;
  76818. /**
  76819. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76820. */
  76821. showBoundingBox: boolean;
  76822. }
  76823. }
  76824. /**
  76825. * Component responsible of rendering the bounding box of the meshes in a scene.
  76826. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76827. */
  76828. export class BoundingBoxRenderer implements ISceneComponent {
  76829. /**
  76830. * The component name helpfull to identify the component in the list of scene components.
  76831. */
  76832. readonly name: string;
  76833. /**
  76834. * The scene the component belongs to.
  76835. */
  76836. scene: Scene;
  76837. /**
  76838. * Color of the bounding box lines placed in front of an object
  76839. */
  76840. frontColor: Color3;
  76841. /**
  76842. * Color of the bounding box lines placed behind an object
  76843. */
  76844. backColor: Color3;
  76845. /**
  76846. * Defines if the renderer should show the back lines or not
  76847. */
  76848. showBackLines: boolean;
  76849. /**
  76850. * Observable raised before rendering a bounding box
  76851. */
  76852. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76853. /**
  76854. * Observable raised after rendering a bounding box
  76855. */
  76856. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76857. /**
  76858. * Observable raised after resources are created
  76859. */
  76860. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  76861. /**
  76862. * When false, no bounding boxes will be rendered
  76863. */
  76864. enabled: boolean;
  76865. /**
  76866. * @hidden
  76867. */
  76868. renderList: SmartArray<BoundingBox>;
  76869. private _colorShader;
  76870. private _vertexBuffers;
  76871. private _indexBuffer;
  76872. private _fillIndexBuffer;
  76873. private _fillIndexData;
  76874. /**
  76875. * Instantiates a new bounding box renderer in a scene.
  76876. * @param scene the scene the renderer renders in
  76877. */
  76878. constructor(scene: Scene);
  76879. /**
  76880. * Registers the component in a given scene
  76881. */
  76882. register(): void;
  76883. private _evaluateSubMesh;
  76884. private _preActiveMesh;
  76885. private _prepareResources;
  76886. private _createIndexBuffer;
  76887. /**
  76888. * Rebuilds the elements related to this component in case of
  76889. * context lost for instance.
  76890. */
  76891. rebuild(): void;
  76892. /**
  76893. * @hidden
  76894. */
  76895. reset(): void;
  76896. /**
  76897. * Render the bounding boxes of a specific rendering group
  76898. * @param renderingGroupId defines the rendering group to render
  76899. */
  76900. render(renderingGroupId: number): void;
  76901. /**
  76902. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76903. * @param mesh Define the mesh to render the occlusion bounding box for
  76904. */
  76905. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76906. /**
  76907. * Dispose and release the resources attached to this renderer.
  76908. */
  76909. dispose(): void;
  76910. }
  76911. }
  76912. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76913. import { Nullable } from "babylonjs/types";
  76914. import { Scene } from "babylonjs/scene";
  76915. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76916. import { Camera } from "babylonjs/Cameras/camera";
  76917. import { ISceneComponent } from "babylonjs/sceneComponent";
  76918. module "babylonjs/scene" {
  76919. interface Scene {
  76920. /** @hidden (Backing field) */
  76921. _depthRenderer: {
  76922. [id: string]: DepthRenderer;
  76923. };
  76924. /**
  76925. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76926. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76927. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76928. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76929. * @returns the created depth renderer
  76930. */
  76931. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76932. /**
  76933. * Disables a depth renderer for a given camera
  76934. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76935. */
  76936. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76937. }
  76938. }
  76939. /**
  76940. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76941. * in several rendering techniques.
  76942. */
  76943. export class DepthRendererSceneComponent implements ISceneComponent {
  76944. /**
  76945. * The component name helpfull to identify the component in the list of scene components.
  76946. */
  76947. readonly name: string;
  76948. /**
  76949. * The scene the component belongs to.
  76950. */
  76951. scene: Scene;
  76952. /**
  76953. * Creates a new instance of the component for the given scene
  76954. * @param scene Defines the scene to register the component in
  76955. */
  76956. constructor(scene: Scene);
  76957. /**
  76958. * Registers the component in a given scene
  76959. */
  76960. register(): void;
  76961. /**
  76962. * Rebuilds the elements related to this component in case of
  76963. * context lost for instance.
  76964. */
  76965. rebuild(): void;
  76966. /**
  76967. * Disposes the component and the associated ressources
  76968. */
  76969. dispose(): void;
  76970. private _gatherRenderTargets;
  76971. private _gatherActiveCameraRenderTargets;
  76972. }
  76973. }
  76974. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76975. import { Nullable } from "babylonjs/types";
  76976. import { Scene } from "babylonjs/scene";
  76977. import { ISceneComponent } from "babylonjs/sceneComponent";
  76978. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76979. module "babylonjs/abstractScene" {
  76980. interface AbstractScene {
  76981. /** @hidden (Backing field) */
  76982. _prePassRenderer: Nullable<PrePassRenderer>;
  76983. /**
  76984. * Gets or Sets the current prepass renderer associated to the scene.
  76985. */
  76986. prePassRenderer: Nullable<PrePassRenderer>;
  76987. /**
  76988. * Enables the prepass and associates it with the scene
  76989. * @returns the PrePassRenderer
  76990. */
  76991. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76992. /**
  76993. * Disables the prepass associated with the scene
  76994. */
  76995. disablePrePassRenderer(): void;
  76996. }
  76997. }
  76998. /**
  76999. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77000. * in several rendering techniques.
  77001. */
  77002. export class PrePassRendererSceneComponent implements ISceneComponent {
  77003. /**
  77004. * The component name helpful to identify the component in the list of scene components.
  77005. */
  77006. readonly name: string;
  77007. /**
  77008. * The scene the component belongs to.
  77009. */
  77010. scene: Scene;
  77011. /**
  77012. * Creates a new instance of the component for the given scene
  77013. * @param scene Defines the scene to register the component in
  77014. */
  77015. constructor(scene: Scene);
  77016. /**
  77017. * Registers the component in a given scene
  77018. */
  77019. register(): void;
  77020. private _beforeCameraDraw;
  77021. private _afterCameraDraw;
  77022. private _beforeClearStage;
  77023. /**
  77024. * Rebuilds the elements related to this component in case of
  77025. * context lost for instance.
  77026. */
  77027. rebuild(): void;
  77028. /**
  77029. * Disposes the component and the associated ressources
  77030. */
  77031. dispose(): void;
  77032. }
  77033. }
  77034. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  77035. /** @hidden */
  77036. export var fibonacci: {
  77037. name: string;
  77038. shader: string;
  77039. };
  77040. }
  77041. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  77042. /** @hidden */
  77043. export var diffusionProfile: {
  77044. name: string;
  77045. shader: string;
  77046. };
  77047. }
  77048. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  77049. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  77050. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77051. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  77052. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  77053. /** @hidden */
  77054. export var subSurfaceScatteringPixelShader: {
  77055. name: string;
  77056. shader: string;
  77057. };
  77058. }
  77059. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  77060. import { Nullable } from "babylonjs/types";
  77061. import { Camera } from "babylonjs/Cameras/camera";
  77062. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77063. import { Engine } from "babylonjs/Engines/engine";
  77064. import { Scene } from "babylonjs/scene";
  77065. import "babylonjs/Shaders/imageProcessing.fragment";
  77066. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  77067. import "babylonjs/Shaders/postprocess.vertex";
  77068. /**
  77069. * Sub surface scattering post process
  77070. */
  77071. export class SubSurfaceScatteringPostProcess extends PostProcess {
  77072. /**
  77073. * Gets a string identifying the name of the class
  77074. * @returns "SubSurfaceScatteringPostProcess" string
  77075. */
  77076. getClassName(): string;
  77077. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77078. }
  77079. }
  77080. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  77081. import { Scene } from "babylonjs/scene";
  77082. import { Color3 } from "babylonjs/Maths/math.color";
  77083. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  77084. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  77085. /**
  77086. * Contains all parameters needed for the prepass to perform
  77087. * screen space subsurface scattering
  77088. */
  77089. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  77090. /** @hidden */
  77091. static _SceneComponentInitialization: (scene: Scene) => void;
  77092. private _ssDiffusionS;
  77093. private _ssFilterRadii;
  77094. private _ssDiffusionD;
  77095. /**
  77096. * Post process to attach for screen space subsurface scattering
  77097. */
  77098. postProcess: SubSurfaceScatteringPostProcess;
  77099. /**
  77100. * Diffusion profile color for subsurface scattering
  77101. */
  77102. get ssDiffusionS(): number[];
  77103. /**
  77104. * Diffusion profile max color channel value for subsurface scattering
  77105. */
  77106. get ssDiffusionD(): number[];
  77107. /**
  77108. * Diffusion profile filter radius for subsurface scattering
  77109. */
  77110. get ssFilterRadii(): number[];
  77111. /**
  77112. * Is subsurface enabled
  77113. */
  77114. enabled: boolean;
  77115. /**
  77116. * Name of the configuration
  77117. */
  77118. name: string;
  77119. /**
  77120. * Diffusion profile colors for subsurface scattering
  77121. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  77122. * See ...
  77123. * Note that you can only store up to 5 of them
  77124. */
  77125. ssDiffusionProfileColors: Color3[];
  77126. /**
  77127. * Defines the ratio real world => scene units.
  77128. * Used for subsurface scattering
  77129. */
  77130. metersPerUnit: number;
  77131. /**
  77132. * Textures that should be present in the MRT for this effect to work
  77133. */
  77134. readonly texturesRequired: number[];
  77135. private _scene;
  77136. /**
  77137. * Builds a subsurface configuration object
  77138. * @param scene The scene
  77139. */
  77140. constructor(scene: Scene);
  77141. /**
  77142. * Adds a new diffusion profile.
  77143. * Useful for more realistic subsurface scattering on diverse materials.
  77144. * @param color The color of the diffusion profile. Should be the average color of the material.
  77145. * @return The index of the diffusion profile for the material subsurface configuration
  77146. */
  77147. addDiffusionProfile(color: Color3): number;
  77148. /**
  77149. * Creates the sss post process
  77150. * @return The created post process
  77151. */
  77152. createPostProcess(): SubSurfaceScatteringPostProcess;
  77153. /**
  77154. * Deletes all diffusion profiles.
  77155. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  77156. */
  77157. clearAllDiffusionProfiles(): void;
  77158. /**
  77159. * Disposes this object
  77160. */
  77161. dispose(): void;
  77162. /**
  77163. * @hidden
  77164. * https://zero-radiance.github.io/post/sampling-diffusion/
  77165. *
  77166. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  77167. * ------------------------------------------------------------------------------------
  77168. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  77169. * PDF[r, phi, s] = r * R[r, phi, s]
  77170. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  77171. * ------------------------------------------------------------------------------------
  77172. * We importance sample the color channel with the widest scattering distance.
  77173. */
  77174. getDiffusionProfileParameters(color: Color3): number;
  77175. /**
  77176. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  77177. * 'u' is the random number (the value of the CDF): [0, 1).
  77178. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  77179. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  77180. */
  77181. private _sampleBurleyDiffusionProfile;
  77182. }
  77183. }
  77184. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  77185. import { Nullable } from "babylonjs/types";
  77186. import { Scene } from "babylonjs/scene";
  77187. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  77188. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  77189. import { AbstractScene } from "babylonjs/abstractScene";
  77190. module "babylonjs/abstractScene" {
  77191. interface AbstractScene {
  77192. /** @hidden (Backing field) */
  77193. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77194. /**
  77195. * Gets or Sets the current prepass renderer associated to the scene.
  77196. */
  77197. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77198. /**
  77199. * Enables the subsurface effect for prepass
  77200. * @returns the SubSurfaceConfiguration
  77201. */
  77202. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  77203. /**
  77204. * Disables the subsurface effect for prepass
  77205. */
  77206. disableSubSurfaceForPrePass(): void;
  77207. }
  77208. }
  77209. /**
  77210. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77211. * in several rendering techniques.
  77212. */
  77213. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  77214. /**
  77215. * The component name helpful to identify the component in the list of scene components.
  77216. */
  77217. readonly name: string;
  77218. /**
  77219. * The scene the component belongs to.
  77220. */
  77221. scene: Scene;
  77222. /**
  77223. * Creates a new instance of the component for the given scene
  77224. * @param scene Defines the scene to register the component in
  77225. */
  77226. constructor(scene: Scene);
  77227. /**
  77228. * Registers the component in a given scene
  77229. */
  77230. register(): void;
  77231. /**
  77232. * Serializes the component data to the specified json object
  77233. * @param serializationObject The object to serialize to
  77234. */
  77235. serialize(serializationObject: any): void;
  77236. /**
  77237. * Adds all the elements from the container to the scene
  77238. * @param container the container holding the elements
  77239. */
  77240. addFromContainer(container: AbstractScene): void;
  77241. /**
  77242. * Removes all the elements in the container from the scene
  77243. * @param container contains the elements to remove
  77244. * @param dispose if the removed element should be disposed (default: false)
  77245. */
  77246. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77247. /**
  77248. * Rebuilds the elements related to this component in case of
  77249. * context lost for instance.
  77250. */
  77251. rebuild(): void;
  77252. /**
  77253. * Disposes the component and the associated ressources
  77254. */
  77255. dispose(): void;
  77256. }
  77257. }
  77258. declare module "babylonjs/Shaders/outline.fragment" {
  77259. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77260. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  77261. /** @hidden */
  77262. export var outlinePixelShader: {
  77263. name: string;
  77264. shader: string;
  77265. };
  77266. }
  77267. declare module "babylonjs/Shaders/outline.vertex" {
  77268. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  77269. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  77270. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  77271. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  77272. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77273. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  77274. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  77275. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  77276. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  77277. /** @hidden */
  77278. export var outlineVertexShader: {
  77279. name: string;
  77280. shader: string;
  77281. };
  77282. }
  77283. declare module "babylonjs/Rendering/outlineRenderer" {
  77284. import { SubMesh } from "babylonjs/Meshes/subMesh";
  77285. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  77286. import { Scene } from "babylonjs/scene";
  77287. import { ISceneComponent } from "babylonjs/sceneComponent";
  77288. import "babylonjs/Shaders/outline.fragment";
  77289. import "babylonjs/Shaders/outline.vertex";
  77290. module "babylonjs/scene" {
  77291. interface Scene {
  77292. /** @hidden */
  77293. _outlineRenderer: OutlineRenderer;
  77294. /**
  77295. * Gets the outline renderer associated with the scene
  77296. * @returns a OutlineRenderer
  77297. */
  77298. getOutlineRenderer(): OutlineRenderer;
  77299. }
  77300. }
  77301. module "babylonjs/Meshes/abstractMesh" {
  77302. interface AbstractMesh {
  77303. /** @hidden (Backing field) */
  77304. _renderOutline: boolean;
  77305. /**
  77306. * Gets or sets a boolean indicating if the outline must be rendered as well
  77307. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  77308. */
  77309. renderOutline: boolean;
  77310. /** @hidden (Backing field) */
  77311. _renderOverlay: boolean;
  77312. /**
  77313. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77314. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77315. */
  77316. renderOverlay: boolean;
  77317. }
  77318. }
  77319. /**
  77320. * This class is responsible to draw bothe outline/overlay of meshes.
  77321. * It should not be used directly but through the available method on mesh.
  77322. */
  77323. export class OutlineRenderer implements ISceneComponent {
  77324. /**
  77325. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77326. */
  77327. private static _StencilReference;
  77328. /**
  77329. * The name of the component. Each component must have a unique name.
  77330. */
  77331. name: string;
  77332. /**
  77333. * The scene the component belongs to.
  77334. */
  77335. scene: Scene;
  77336. /**
  77337. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77338. */
  77339. zOffset: number;
  77340. private _engine;
  77341. private _effect;
  77342. private _cachedDefines;
  77343. private _savedDepthWrite;
  77344. /**
  77345. * Instantiates a new outline renderer. (There could be only one per scene).
  77346. * @param scene Defines the scene it belongs to
  77347. */
  77348. constructor(scene: Scene);
  77349. /**
  77350. * Register the component to one instance of a scene.
  77351. */
  77352. register(): void;
  77353. /**
  77354. * Rebuilds the elements related to this component in case of
  77355. * context lost for instance.
  77356. */
  77357. rebuild(): void;
  77358. /**
  77359. * Disposes the component and the associated ressources.
  77360. */
  77361. dispose(): void;
  77362. /**
  77363. * Renders the outline in the canvas.
  77364. * @param subMesh Defines the sumesh to render
  77365. * @param batch Defines the batch of meshes in case of instances
  77366. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77367. */
  77368. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77369. /**
  77370. * Returns whether or not the outline renderer is ready for a given submesh.
  77371. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77372. * @param subMesh Defines the submesh to check readyness for
  77373. * @param useInstances Defines wheter wee are trying to render instances or not
  77374. * @returns true if ready otherwise false
  77375. */
  77376. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77377. private _beforeRenderingMesh;
  77378. private _afterRenderingMesh;
  77379. }
  77380. }
  77381. declare module "babylonjs/Rendering/index" {
  77382. export * from "babylonjs/Rendering/boundingBoxRenderer";
  77383. export * from "babylonjs/Rendering/depthRenderer";
  77384. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  77385. export * from "babylonjs/Rendering/edgesRenderer";
  77386. export * from "babylonjs/Rendering/geometryBufferRenderer";
  77387. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77388. export * from "babylonjs/Rendering/prePassRenderer";
  77389. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  77390. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  77391. export * from "babylonjs/Rendering/outlineRenderer";
  77392. export * from "babylonjs/Rendering/renderingGroup";
  77393. export * from "babylonjs/Rendering/renderingManager";
  77394. export * from "babylonjs/Rendering/utilityLayerRenderer";
  77395. }
  77396. declare module "babylonjs/Sprites/ISprites" {
  77397. /**
  77398. * Defines the basic options interface of a Sprite Frame Source Size.
  77399. */
  77400. export interface ISpriteJSONSpriteSourceSize {
  77401. /**
  77402. * number of the original width of the Frame
  77403. */
  77404. w: number;
  77405. /**
  77406. * number of the original height of the Frame
  77407. */
  77408. h: number;
  77409. }
  77410. /**
  77411. * Defines the basic options interface of a Sprite Frame Data.
  77412. */
  77413. export interface ISpriteJSONSpriteFrameData {
  77414. /**
  77415. * number of the x offset of the Frame
  77416. */
  77417. x: number;
  77418. /**
  77419. * number of the y offset of the Frame
  77420. */
  77421. y: number;
  77422. /**
  77423. * number of the width of the Frame
  77424. */
  77425. w: number;
  77426. /**
  77427. * number of the height of the Frame
  77428. */
  77429. h: number;
  77430. }
  77431. /**
  77432. * Defines the basic options interface of a JSON Sprite.
  77433. */
  77434. export interface ISpriteJSONSprite {
  77435. /**
  77436. * string name of the Frame
  77437. */
  77438. filename: string;
  77439. /**
  77440. * ISpriteJSONSpriteFrame basic object of the frame data
  77441. */
  77442. frame: ISpriteJSONSpriteFrameData;
  77443. /**
  77444. * boolean to flag is the frame was rotated.
  77445. */
  77446. rotated: boolean;
  77447. /**
  77448. * boolean to flag is the frame was trimmed.
  77449. */
  77450. trimmed: boolean;
  77451. /**
  77452. * ISpriteJSONSpriteFrame basic object of the source data
  77453. */
  77454. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77455. /**
  77456. * ISpriteJSONSpriteFrame basic object of the source data
  77457. */
  77458. sourceSize: ISpriteJSONSpriteSourceSize;
  77459. }
  77460. /**
  77461. * Defines the basic options interface of a JSON atlas.
  77462. */
  77463. export interface ISpriteJSONAtlas {
  77464. /**
  77465. * Array of objects that contain the frame data.
  77466. */
  77467. frames: Array<ISpriteJSONSprite>;
  77468. /**
  77469. * object basic object containing the sprite meta data.
  77470. */
  77471. meta?: object;
  77472. }
  77473. }
  77474. declare module "babylonjs/Shaders/spriteMap.fragment" {
  77475. /** @hidden */
  77476. export var spriteMapPixelShader: {
  77477. name: string;
  77478. shader: string;
  77479. };
  77480. }
  77481. declare module "babylonjs/Shaders/spriteMap.vertex" {
  77482. /** @hidden */
  77483. export var spriteMapVertexShader: {
  77484. name: string;
  77485. shader: string;
  77486. };
  77487. }
  77488. declare module "babylonjs/Sprites/spriteMap" {
  77489. import { IDisposable, Scene } from "babylonjs/scene";
  77490. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  77491. import { Texture } from "babylonjs/Materials/Textures/texture";
  77492. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  77493. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  77494. import "babylonjs/Meshes/Builders/planeBuilder";
  77495. import "babylonjs/Shaders/spriteMap.fragment";
  77496. import "babylonjs/Shaders/spriteMap.vertex";
  77497. /**
  77498. * Defines the basic options interface of a SpriteMap
  77499. */
  77500. export interface ISpriteMapOptions {
  77501. /**
  77502. * Vector2 of the number of cells in the grid.
  77503. */
  77504. stageSize?: Vector2;
  77505. /**
  77506. * Vector2 of the size of the output plane in World Units.
  77507. */
  77508. outputSize?: Vector2;
  77509. /**
  77510. * Vector3 of the position of the output plane in World Units.
  77511. */
  77512. outputPosition?: Vector3;
  77513. /**
  77514. * Vector3 of the rotation of the output plane.
  77515. */
  77516. outputRotation?: Vector3;
  77517. /**
  77518. * number of layers that the system will reserve in resources.
  77519. */
  77520. layerCount?: number;
  77521. /**
  77522. * number of max animation frames a single cell will reserve in resources.
  77523. */
  77524. maxAnimationFrames?: number;
  77525. /**
  77526. * number cell index of the base tile when the system compiles.
  77527. */
  77528. baseTile?: number;
  77529. /**
  77530. * boolean flip the sprite after its been repositioned by the framing data.
  77531. */
  77532. flipU?: boolean;
  77533. /**
  77534. * Vector3 scalar of the global RGB values of the SpriteMap.
  77535. */
  77536. colorMultiply?: Vector3;
  77537. }
  77538. /**
  77539. * Defines the IDisposable interface in order to be cleanable from resources.
  77540. */
  77541. export interface ISpriteMap extends IDisposable {
  77542. /**
  77543. * String name of the SpriteMap.
  77544. */
  77545. name: string;
  77546. /**
  77547. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77548. */
  77549. atlasJSON: ISpriteJSONAtlas;
  77550. /**
  77551. * Texture of the SpriteMap.
  77552. */
  77553. spriteSheet: Texture;
  77554. /**
  77555. * The parameters to initialize the SpriteMap with.
  77556. */
  77557. options: ISpriteMapOptions;
  77558. }
  77559. /**
  77560. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77561. */
  77562. export class SpriteMap implements ISpriteMap {
  77563. /** The Name of the spriteMap */
  77564. name: string;
  77565. /** The JSON file with the frame and meta data */
  77566. atlasJSON: ISpriteJSONAtlas;
  77567. /** The systems Sprite Sheet Texture */
  77568. spriteSheet: Texture;
  77569. /** Arguments passed with the Constructor */
  77570. options: ISpriteMapOptions;
  77571. /** Public Sprite Storage array, parsed from atlasJSON */
  77572. sprites: Array<ISpriteJSONSprite>;
  77573. /** Returns the Number of Sprites in the System */
  77574. get spriteCount(): number;
  77575. /** Returns the Position of Output Plane*/
  77576. get position(): Vector3;
  77577. /** Returns the Position of Output Plane*/
  77578. set position(v: Vector3);
  77579. /** Returns the Rotation of Output Plane*/
  77580. get rotation(): Vector3;
  77581. /** Returns the Rotation of Output Plane*/
  77582. set rotation(v: Vector3);
  77583. /** Sets the AnimationMap*/
  77584. get animationMap(): RawTexture;
  77585. /** Sets the AnimationMap*/
  77586. set animationMap(v: RawTexture);
  77587. /** Scene that the SpriteMap was created in */
  77588. private _scene;
  77589. /** Texture Buffer of Float32 that holds tile frame data*/
  77590. private _frameMap;
  77591. /** Texture Buffers of Float32 that holds tileMap data*/
  77592. private _tileMaps;
  77593. /** Texture Buffer of Float32 that holds Animation Data*/
  77594. private _animationMap;
  77595. /** Custom ShaderMaterial Central to the System*/
  77596. private _material;
  77597. /** Custom ShaderMaterial Central to the System*/
  77598. private _output;
  77599. /** Systems Time Ticker*/
  77600. private _time;
  77601. /**
  77602. * Creates a new SpriteMap
  77603. * @param name defines the SpriteMaps Name
  77604. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77605. * @param spriteSheet is the Texture that the Sprites are on.
  77606. * @param options a basic deployment configuration
  77607. * @param scene The Scene that the map is deployed on
  77608. */
  77609. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77610. /**
  77611. * Returns tileID location
  77612. * @returns Vector2 the cell position ID
  77613. */
  77614. getTileID(): Vector2;
  77615. /**
  77616. * Gets the UV location of the mouse over the SpriteMap.
  77617. * @returns Vector2 the UV position of the mouse interaction
  77618. */
  77619. getMousePosition(): Vector2;
  77620. /**
  77621. * Creates the "frame" texture Buffer
  77622. * -------------------------------------
  77623. * Structure of frames
  77624. * "filename": "Falling-Water-2.png",
  77625. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77626. * "rotated": true,
  77627. * "trimmed": true,
  77628. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77629. * "sourceSize": {"w":32,"h":32}
  77630. * @returns RawTexture of the frameMap
  77631. */
  77632. private _createFrameBuffer;
  77633. /**
  77634. * Creates the tileMap texture Buffer
  77635. * @param buffer normally and array of numbers, or a false to generate from scratch
  77636. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77637. * @returns RawTexture of the tileMap
  77638. */
  77639. private _createTileBuffer;
  77640. /**
  77641. * Modifies the data of the tileMaps
  77642. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77643. * @param pos is the iVector2 Coordinates of the Tile
  77644. * @param tile The SpriteIndex of the new Tile
  77645. */
  77646. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77647. /**
  77648. * Creates the animationMap texture Buffer
  77649. * @param buffer normally and array of numbers, or a false to generate from scratch
  77650. * @returns RawTexture of the animationMap
  77651. */
  77652. private _createTileAnimationBuffer;
  77653. /**
  77654. * Modifies the data of the animationMap
  77655. * @param cellID is the Index of the Sprite
  77656. * @param _frame is the target Animation frame
  77657. * @param toCell is the Target Index of the next frame of the animation
  77658. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77659. * @param speed is a global scalar of the time variable on the map.
  77660. */
  77661. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77662. /**
  77663. * Exports the .tilemaps file
  77664. */
  77665. saveTileMaps(): void;
  77666. /**
  77667. * Imports the .tilemaps file
  77668. * @param url of the .tilemaps file
  77669. */
  77670. loadTileMaps(url: string): void;
  77671. /**
  77672. * Release associated resources
  77673. */
  77674. dispose(): void;
  77675. }
  77676. }
  77677. declare module "babylonjs/Sprites/spritePackedManager" {
  77678. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77679. import { Scene } from "babylonjs/scene";
  77680. /**
  77681. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77682. * @see https://doc.babylonjs.com/babylon101/sprites
  77683. */
  77684. export class SpritePackedManager extends SpriteManager {
  77685. /** defines the packed manager's name */
  77686. name: string;
  77687. /**
  77688. * Creates a new sprite manager from a packed sprite sheet
  77689. * @param name defines the manager's name
  77690. * @param imgUrl defines the sprite sheet url
  77691. * @param capacity defines the maximum allowed number of sprites
  77692. * @param scene defines the hosting scene
  77693. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77694. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77695. * @param samplingMode defines the smapling mode to use with spritesheet
  77696. * @param fromPacked set to true; do not alter
  77697. */
  77698. constructor(
  77699. /** defines the packed manager's name */
  77700. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77701. }
  77702. }
  77703. declare module "babylonjs/Sprites/index" {
  77704. export * from "babylonjs/Sprites/sprite";
  77705. export * from "babylonjs/Sprites/ISprites";
  77706. export * from "babylonjs/Sprites/spriteManager";
  77707. export * from "babylonjs/Sprites/spriteMap";
  77708. export * from "babylonjs/Sprites/spritePackedManager";
  77709. export * from "babylonjs/Sprites/spriteSceneComponent";
  77710. }
  77711. declare module "babylonjs/States/index" {
  77712. export * from "babylonjs/States/alphaCullingState";
  77713. export * from "babylonjs/States/depthCullingState";
  77714. export * from "babylonjs/States/stencilState";
  77715. }
  77716. declare module "babylonjs/Misc/assetsManager" {
  77717. import { Scene } from "babylonjs/scene";
  77718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77719. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77720. import { Skeleton } from "babylonjs/Bones/skeleton";
  77721. import { Observable } from "babylonjs/Misc/observable";
  77722. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77723. import { Texture } from "babylonjs/Materials/Textures/texture";
  77724. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77725. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77726. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77727. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77728. import { AssetContainer } from "babylonjs/assetContainer";
  77729. /**
  77730. * Defines the list of states available for a task inside a AssetsManager
  77731. */
  77732. export enum AssetTaskState {
  77733. /**
  77734. * Initialization
  77735. */
  77736. INIT = 0,
  77737. /**
  77738. * Running
  77739. */
  77740. RUNNING = 1,
  77741. /**
  77742. * Done
  77743. */
  77744. DONE = 2,
  77745. /**
  77746. * Error
  77747. */
  77748. ERROR = 3
  77749. }
  77750. /**
  77751. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77752. */
  77753. export abstract class AbstractAssetTask {
  77754. /**
  77755. * Task name
  77756. */ name: string;
  77757. /**
  77758. * Callback called when the task is successful
  77759. */
  77760. onSuccess: (task: any) => void;
  77761. /**
  77762. * Callback called when the task is not successful
  77763. */
  77764. onError: (task: any, message?: string, exception?: any) => void;
  77765. /**
  77766. * Creates a new AssetsManager
  77767. * @param name defines the name of the task
  77768. */
  77769. constructor(
  77770. /**
  77771. * Task name
  77772. */ name: string);
  77773. private _isCompleted;
  77774. private _taskState;
  77775. private _errorObject;
  77776. /**
  77777. * Get if the task is completed
  77778. */
  77779. get isCompleted(): boolean;
  77780. /**
  77781. * Gets the current state of the task
  77782. */
  77783. get taskState(): AssetTaskState;
  77784. /**
  77785. * Gets the current error object (if task is in error)
  77786. */
  77787. get errorObject(): {
  77788. message?: string;
  77789. exception?: any;
  77790. };
  77791. /**
  77792. * Internal only
  77793. * @hidden
  77794. */
  77795. _setErrorObject(message?: string, exception?: any): void;
  77796. /**
  77797. * Execute the current task
  77798. * @param scene defines the scene where you want your assets to be loaded
  77799. * @param onSuccess is a callback called when the task is successfully executed
  77800. * @param onError is a callback called if an error occurs
  77801. */
  77802. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77803. /**
  77804. * Execute the current task
  77805. * @param scene defines the scene where you want your assets to be loaded
  77806. * @param onSuccess is a callback called when the task is successfully executed
  77807. * @param onError is a callback called if an error occurs
  77808. */
  77809. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77810. /**
  77811. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77812. * This can be used with failed tasks that have the reason for failure fixed.
  77813. */
  77814. reset(): void;
  77815. private onErrorCallback;
  77816. private onDoneCallback;
  77817. }
  77818. /**
  77819. * Define the interface used by progress events raised during assets loading
  77820. */
  77821. export interface IAssetsProgressEvent {
  77822. /**
  77823. * Defines the number of remaining tasks to process
  77824. */
  77825. remainingCount: number;
  77826. /**
  77827. * Defines the total number of tasks
  77828. */
  77829. totalCount: number;
  77830. /**
  77831. * Defines the task that was just processed
  77832. */
  77833. task: AbstractAssetTask;
  77834. }
  77835. /**
  77836. * Class used to share progress information about assets loading
  77837. */
  77838. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77839. /**
  77840. * Defines the number of remaining tasks to process
  77841. */
  77842. remainingCount: number;
  77843. /**
  77844. * Defines the total number of tasks
  77845. */
  77846. totalCount: number;
  77847. /**
  77848. * Defines the task that was just processed
  77849. */
  77850. task: AbstractAssetTask;
  77851. /**
  77852. * Creates a AssetsProgressEvent
  77853. * @param remainingCount defines the number of remaining tasks to process
  77854. * @param totalCount defines the total number of tasks
  77855. * @param task defines the task that was just processed
  77856. */
  77857. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77858. }
  77859. /**
  77860. * Define a task used by AssetsManager to load assets into a container
  77861. */
  77862. export class ContainerAssetTask extends AbstractAssetTask {
  77863. /**
  77864. * Defines the name of the task
  77865. */
  77866. name: string;
  77867. /**
  77868. * Defines the list of mesh's names you want to load
  77869. */
  77870. meshesNames: any;
  77871. /**
  77872. * Defines the root url to use as a base to load your meshes and associated resources
  77873. */
  77874. rootUrl: string;
  77875. /**
  77876. * Defines the filename or File of the scene to load from
  77877. */
  77878. sceneFilename: string | File;
  77879. /**
  77880. * Get the loaded asset container
  77881. */
  77882. loadedContainer: AssetContainer;
  77883. /**
  77884. * Gets the list of loaded meshes
  77885. */
  77886. loadedMeshes: Array<AbstractMesh>;
  77887. /**
  77888. * Gets the list of loaded particle systems
  77889. */
  77890. loadedParticleSystems: Array<IParticleSystem>;
  77891. /**
  77892. * Gets the list of loaded skeletons
  77893. */
  77894. loadedSkeletons: Array<Skeleton>;
  77895. /**
  77896. * Gets the list of loaded animation groups
  77897. */
  77898. loadedAnimationGroups: Array<AnimationGroup>;
  77899. /**
  77900. * Callback called when the task is successful
  77901. */
  77902. onSuccess: (task: ContainerAssetTask) => void;
  77903. /**
  77904. * Callback called when the task is successful
  77905. */
  77906. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77907. /**
  77908. * Creates a new ContainerAssetTask
  77909. * @param name defines the name of the task
  77910. * @param meshesNames defines the list of mesh's names you want to load
  77911. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77912. * @param sceneFilename defines the filename or File of the scene to load from
  77913. */
  77914. constructor(
  77915. /**
  77916. * Defines the name of the task
  77917. */
  77918. name: string,
  77919. /**
  77920. * Defines the list of mesh's names you want to load
  77921. */
  77922. meshesNames: any,
  77923. /**
  77924. * Defines the root url to use as a base to load your meshes and associated resources
  77925. */
  77926. rootUrl: string,
  77927. /**
  77928. * Defines the filename or File of the scene to load from
  77929. */
  77930. sceneFilename: string | File);
  77931. /**
  77932. * Execute the current task
  77933. * @param scene defines the scene where you want your assets to be loaded
  77934. * @param onSuccess is a callback called when the task is successfully executed
  77935. * @param onError is a callback called if an error occurs
  77936. */
  77937. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77938. }
  77939. /**
  77940. * Define a task used by AssetsManager to load meshes
  77941. */
  77942. export class MeshAssetTask extends AbstractAssetTask {
  77943. /**
  77944. * Defines the name of the task
  77945. */
  77946. name: string;
  77947. /**
  77948. * Defines the list of mesh's names you want to load
  77949. */
  77950. meshesNames: any;
  77951. /**
  77952. * Defines the root url to use as a base to load your meshes and associated resources
  77953. */
  77954. rootUrl: string;
  77955. /**
  77956. * Defines the filename or File of the scene to load from
  77957. */
  77958. sceneFilename: string | File;
  77959. /**
  77960. * Gets the list of loaded meshes
  77961. */
  77962. loadedMeshes: Array<AbstractMesh>;
  77963. /**
  77964. * Gets the list of loaded particle systems
  77965. */
  77966. loadedParticleSystems: Array<IParticleSystem>;
  77967. /**
  77968. * Gets the list of loaded skeletons
  77969. */
  77970. loadedSkeletons: Array<Skeleton>;
  77971. /**
  77972. * Gets the list of loaded animation groups
  77973. */
  77974. loadedAnimationGroups: Array<AnimationGroup>;
  77975. /**
  77976. * Callback called when the task is successful
  77977. */
  77978. onSuccess: (task: MeshAssetTask) => void;
  77979. /**
  77980. * Callback called when the task is successful
  77981. */
  77982. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77983. /**
  77984. * Creates a new MeshAssetTask
  77985. * @param name defines the name of the task
  77986. * @param meshesNames defines the list of mesh's names you want to load
  77987. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77988. * @param sceneFilename defines the filename or File of the scene to load from
  77989. */
  77990. constructor(
  77991. /**
  77992. * Defines the name of the task
  77993. */
  77994. name: string,
  77995. /**
  77996. * Defines the list of mesh's names you want to load
  77997. */
  77998. meshesNames: any,
  77999. /**
  78000. * Defines the root url to use as a base to load your meshes and associated resources
  78001. */
  78002. rootUrl: string,
  78003. /**
  78004. * Defines the filename or File of the scene to load from
  78005. */
  78006. sceneFilename: string | File);
  78007. /**
  78008. * Execute the current task
  78009. * @param scene defines the scene where you want your assets to be loaded
  78010. * @param onSuccess is a callback called when the task is successfully executed
  78011. * @param onError is a callback called if an error occurs
  78012. */
  78013. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78014. }
  78015. /**
  78016. * Define a task used by AssetsManager to load text content
  78017. */
  78018. export class TextFileAssetTask extends AbstractAssetTask {
  78019. /**
  78020. * Defines the name of the task
  78021. */
  78022. name: string;
  78023. /**
  78024. * Defines the location of the file to load
  78025. */
  78026. url: string;
  78027. /**
  78028. * Gets the loaded text string
  78029. */
  78030. text: string;
  78031. /**
  78032. * Callback called when the task is successful
  78033. */
  78034. onSuccess: (task: TextFileAssetTask) => void;
  78035. /**
  78036. * Callback called when the task is successful
  78037. */
  78038. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  78039. /**
  78040. * Creates a new TextFileAssetTask object
  78041. * @param name defines the name of the task
  78042. * @param url defines the location of the file to load
  78043. */
  78044. constructor(
  78045. /**
  78046. * Defines the name of the task
  78047. */
  78048. name: string,
  78049. /**
  78050. * Defines the location of the file to load
  78051. */
  78052. url: string);
  78053. /**
  78054. * Execute the current task
  78055. * @param scene defines the scene where you want your assets to be loaded
  78056. * @param onSuccess is a callback called when the task is successfully executed
  78057. * @param onError is a callback called if an error occurs
  78058. */
  78059. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78060. }
  78061. /**
  78062. * Define a task used by AssetsManager to load binary data
  78063. */
  78064. export class BinaryFileAssetTask extends AbstractAssetTask {
  78065. /**
  78066. * Defines the name of the task
  78067. */
  78068. name: string;
  78069. /**
  78070. * Defines the location of the file to load
  78071. */
  78072. url: string;
  78073. /**
  78074. * Gets the lodaded data (as an array buffer)
  78075. */
  78076. data: ArrayBuffer;
  78077. /**
  78078. * Callback called when the task is successful
  78079. */
  78080. onSuccess: (task: BinaryFileAssetTask) => void;
  78081. /**
  78082. * Callback called when the task is successful
  78083. */
  78084. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  78085. /**
  78086. * Creates a new BinaryFileAssetTask object
  78087. * @param name defines the name of the new task
  78088. * @param url defines the location of the file to load
  78089. */
  78090. constructor(
  78091. /**
  78092. * Defines the name of the task
  78093. */
  78094. name: string,
  78095. /**
  78096. * Defines the location of the file to load
  78097. */
  78098. url: string);
  78099. /**
  78100. * Execute the current task
  78101. * @param scene defines the scene where you want your assets to be loaded
  78102. * @param onSuccess is a callback called when the task is successfully executed
  78103. * @param onError is a callback called if an error occurs
  78104. */
  78105. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78106. }
  78107. /**
  78108. * Define a task used by AssetsManager to load images
  78109. */
  78110. export class ImageAssetTask extends AbstractAssetTask {
  78111. /**
  78112. * Defines the name of the task
  78113. */
  78114. name: string;
  78115. /**
  78116. * Defines the location of the image to load
  78117. */
  78118. url: string;
  78119. /**
  78120. * Gets the loaded images
  78121. */
  78122. image: HTMLImageElement;
  78123. /**
  78124. * Callback called when the task is successful
  78125. */
  78126. onSuccess: (task: ImageAssetTask) => void;
  78127. /**
  78128. * Callback called when the task is successful
  78129. */
  78130. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  78131. /**
  78132. * Creates a new ImageAssetTask
  78133. * @param name defines the name of the task
  78134. * @param url defines the location of the image to load
  78135. */
  78136. constructor(
  78137. /**
  78138. * Defines the name of the task
  78139. */
  78140. name: string,
  78141. /**
  78142. * Defines the location of the image to load
  78143. */
  78144. url: string);
  78145. /**
  78146. * Execute the current task
  78147. * @param scene defines the scene where you want your assets to be loaded
  78148. * @param onSuccess is a callback called when the task is successfully executed
  78149. * @param onError is a callback called if an error occurs
  78150. */
  78151. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78152. }
  78153. /**
  78154. * Defines the interface used by texture loading tasks
  78155. */
  78156. export interface ITextureAssetTask<TEX extends BaseTexture> {
  78157. /**
  78158. * Gets the loaded texture
  78159. */
  78160. texture: TEX;
  78161. }
  78162. /**
  78163. * Define a task used by AssetsManager to load 2D textures
  78164. */
  78165. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  78166. /**
  78167. * Defines the name of the task
  78168. */
  78169. name: string;
  78170. /**
  78171. * Defines the location of the file to load
  78172. */
  78173. url: string;
  78174. /**
  78175. * Defines if mipmap should not be generated (default is false)
  78176. */
  78177. noMipmap?: boolean | undefined;
  78178. /**
  78179. * Defines if texture must be inverted on Y axis (default is true)
  78180. */
  78181. invertY: boolean;
  78182. /**
  78183. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78184. */
  78185. samplingMode: number;
  78186. /**
  78187. * Gets the loaded texture
  78188. */
  78189. texture: Texture;
  78190. /**
  78191. * Callback called when the task is successful
  78192. */
  78193. onSuccess: (task: TextureAssetTask) => void;
  78194. /**
  78195. * Callback called when the task is successful
  78196. */
  78197. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  78198. /**
  78199. * Creates a new TextureAssetTask object
  78200. * @param name defines the name of the task
  78201. * @param url defines the location of the file to load
  78202. * @param noMipmap defines if mipmap should not be generated (default is false)
  78203. * @param invertY defines if texture must be inverted on Y axis (default is true)
  78204. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78205. */
  78206. constructor(
  78207. /**
  78208. * Defines the name of the task
  78209. */
  78210. name: string,
  78211. /**
  78212. * Defines the location of the file to load
  78213. */
  78214. url: string,
  78215. /**
  78216. * Defines if mipmap should not be generated (default is false)
  78217. */
  78218. noMipmap?: boolean | undefined,
  78219. /**
  78220. * Defines if texture must be inverted on Y axis (default is true)
  78221. */
  78222. invertY?: boolean,
  78223. /**
  78224. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78225. */
  78226. samplingMode?: number);
  78227. /**
  78228. * Execute the current task
  78229. * @param scene defines the scene where you want your assets to be loaded
  78230. * @param onSuccess is a callback called when the task is successfully executed
  78231. * @param onError is a callback called if an error occurs
  78232. */
  78233. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78234. }
  78235. /**
  78236. * Define a task used by AssetsManager to load cube textures
  78237. */
  78238. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  78239. /**
  78240. * Defines the name of the task
  78241. */
  78242. name: string;
  78243. /**
  78244. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78245. */
  78246. url: string;
  78247. /**
  78248. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78249. */
  78250. extensions?: string[] | undefined;
  78251. /**
  78252. * Defines if mipmaps should not be generated (default is false)
  78253. */
  78254. noMipmap?: boolean | undefined;
  78255. /**
  78256. * Defines the explicit list of files (undefined by default)
  78257. */
  78258. files?: string[] | undefined;
  78259. /**
  78260. * Gets the loaded texture
  78261. */
  78262. texture: CubeTexture;
  78263. /**
  78264. * Callback called when the task is successful
  78265. */
  78266. onSuccess: (task: CubeTextureAssetTask) => void;
  78267. /**
  78268. * Callback called when the task is successful
  78269. */
  78270. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  78271. /**
  78272. * Creates a new CubeTextureAssetTask
  78273. * @param name defines the name of the task
  78274. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78275. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78276. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78277. * @param files defines the explicit list of files (undefined by default)
  78278. */
  78279. constructor(
  78280. /**
  78281. * Defines the name of the task
  78282. */
  78283. name: string,
  78284. /**
  78285. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78286. */
  78287. url: string,
  78288. /**
  78289. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78290. */
  78291. extensions?: string[] | undefined,
  78292. /**
  78293. * Defines if mipmaps should not be generated (default is false)
  78294. */
  78295. noMipmap?: boolean | undefined,
  78296. /**
  78297. * Defines the explicit list of files (undefined by default)
  78298. */
  78299. files?: string[] | undefined);
  78300. /**
  78301. * Execute the current task
  78302. * @param scene defines the scene where you want your assets to be loaded
  78303. * @param onSuccess is a callback called when the task is successfully executed
  78304. * @param onError is a callback called if an error occurs
  78305. */
  78306. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78307. }
  78308. /**
  78309. * Define a task used by AssetsManager to load HDR cube textures
  78310. */
  78311. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78312. /**
  78313. * Defines the name of the task
  78314. */
  78315. name: string;
  78316. /**
  78317. * Defines the location of the file to load
  78318. */
  78319. url: string;
  78320. /**
  78321. * Defines the desired size (the more it increases the longer the generation will be)
  78322. */
  78323. size: number;
  78324. /**
  78325. * Defines if mipmaps should not be generated (default is false)
  78326. */
  78327. noMipmap: boolean;
  78328. /**
  78329. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78330. */
  78331. generateHarmonics: boolean;
  78332. /**
  78333. * 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)
  78334. */
  78335. gammaSpace: boolean;
  78336. /**
  78337. * Internal Use Only
  78338. */
  78339. reserved: boolean;
  78340. /**
  78341. * Gets the loaded texture
  78342. */
  78343. texture: HDRCubeTexture;
  78344. /**
  78345. * Callback called when the task is successful
  78346. */
  78347. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78348. /**
  78349. * Callback called when the task is successful
  78350. */
  78351. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78352. /**
  78353. * Creates a new HDRCubeTextureAssetTask object
  78354. * @param name defines the name of the task
  78355. * @param url defines the location of the file to load
  78356. * @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.
  78357. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78358. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78359. * @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)
  78360. * @param reserved Internal use only
  78361. */
  78362. constructor(
  78363. /**
  78364. * Defines the name of the task
  78365. */
  78366. name: string,
  78367. /**
  78368. * Defines the location of the file to load
  78369. */
  78370. url: string,
  78371. /**
  78372. * Defines the desired size (the more it increases the longer the generation will be)
  78373. */
  78374. size: number,
  78375. /**
  78376. * Defines if mipmaps should not be generated (default is false)
  78377. */
  78378. noMipmap?: boolean,
  78379. /**
  78380. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78381. */
  78382. generateHarmonics?: boolean,
  78383. /**
  78384. * 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)
  78385. */
  78386. gammaSpace?: boolean,
  78387. /**
  78388. * Internal Use Only
  78389. */
  78390. reserved?: boolean);
  78391. /**
  78392. * Execute the current task
  78393. * @param scene defines the scene where you want your assets to be loaded
  78394. * @param onSuccess is a callback called when the task is successfully executed
  78395. * @param onError is a callback called if an error occurs
  78396. */
  78397. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78398. }
  78399. /**
  78400. * Define a task used by AssetsManager to load Equirectangular cube textures
  78401. */
  78402. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78403. /**
  78404. * Defines the name of the task
  78405. */
  78406. name: string;
  78407. /**
  78408. * Defines the location of the file to load
  78409. */
  78410. url: string;
  78411. /**
  78412. * Defines the desired size (the more it increases the longer the generation will be)
  78413. */
  78414. size: number;
  78415. /**
  78416. * Defines if mipmaps should not be generated (default is false)
  78417. */
  78418. noMipmap: boolean;
  78419. /**
  78420. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78421. * but the standard material would require them in Gamma space) (default is true)
  78422. */
  78423. gammaSpace: boolean;
  78424. /**
  78425. * Gets the loaded texture
  78426. */
  78427. texture: EquiRectangularCubeTexture;
  78428. /**
  78429. * Callback called when the task is successful
  78430. */
  78431. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78432. /**
  78433. * Callback called when the task is successful
  78434. */
  78435. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78436. /**
  78437. * Creates a new EquiRectangularCubeTextureAssetTask object
  78438. * @param name defines the name of the task
  78439. * @param url defines the location of the file to load
  78440. * @param size defines the desired size (the more it increases the longer the generation will be)
  78441. * If the size is omitted this implies you are using a preprocessed cubemap.
  78442. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78443. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78444. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78445. * (default is true)
  78446. */
  78447. constructor(
  78448. /**
  78449. * Defines the name of the task
  78450. */
  78451. name: string,
  78452. /**
  78453. * Defines the location of the file to load
  78454. */
  78455. url: string,
  78456. /**
  78457. * Defines the desired size (the more it increases the longer the generation will be)
  78458. */
  78459. size: number,
  78460. /**
  78461. * Defines if mipmaps should not be generated (default is false)
  78462. */
  78463. noMipmap?: boolean,
  78464. /**
  78465. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78466. * but the standard material would require them in Gamma space) (default is true)
  78467. */
  78468. gammaSpace?: boolean);
  78469. /**
  78470. * Execute the current task
  78471. * @param scene defines the scene where you want your assets to be loaded
  78472. * @param onSuccess is a callback called when the task is successfully executed
  78473. * @param onError is a callback called if an error occurs
  78474. */
  78475. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78476. }
  78477. /**
  78478. * This class can be used to easily import assets into a scene
  78479. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78480. */
  78481. export class AssetsManager {
  78482. private _scene;
  78483. private _isLoading;
  78484. protected _tasks: AbstractAssetTask[];
  78485. protected _waitingTasksCount: number;
  78486. protected _totalTasksCount: number;
  78487. /**
  78488. * Callback called when all tasks are processed
  78489. */
  78490. onFinish: (tasks: AbstractAssetTask[]) => void;
  78491. /**
  78492. * Callback called when a task is successful
  78493. */
  78494. onTaskSuccess: (task: AbstractAssetTask) => void;
  78495. /**
  78496. * Callback called when a task had an error
  78497. */
  78498. onTaskError: (task: AbstractAssetTask) => void;
  78499. /**
  78500. * Callback called when a task is done (whatever the result is)
  78501. */
  78502. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78503. /**
  78504. * Observable called when all tasks are processed
  78505. */
  78506. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78507. /**
  78508. * Observable called when a task had an error
  78509. */
  78510. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78511. /**
  78512. * Observable called when all tasks were executed
  78513. */
  78514. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78515. /**
  78516. * Observable called when a task is done (whatever the result is)
  78517. */
  78518. onProgressObservable: Observable<IAssetsProgressEvent>;
  78519. /**
  78520. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78521. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78522. */
  78523. useDefaultLoadingScreen: boolean;
  78524. /**
  78525. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78526. * when all assets have been downloaded.
  78527. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78528. */
  78529. autoHideLoadingUI: boolean;
  78530. /**
  78531. * Creates a new AssetsManager
  78532. * @param scene defines the scene to work on
  78533. */
  78534. constructor(scene: Scene);
  78535. /**
  78536. * Add a ContainerAssetTask to the list of active tasks
  78537. * @param taskName defines the name of the new task
  78538. * @param meshesNames defines the name of meshes to load
  78539. * @param rootUrl defines the root url to use to locate files
  78540. * @param sceneFilename defines the filename of the scene file
  78541. * @returns a new ContainerAssetTask object
  78542. */
  78543. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78544. /**
  78545. * Add a MeshAssetTask to the list of active tasks
  78546. * @param taskName defines the name of the new task
  78547. * @param meshesNames defines the name of meshes to load
  78548. * @param rootUrl defines the root url to use to locate files
  78549. * @param sceneFilename defines the filename of the scene file
  78550. * @returns a new MeshAssetTask object
  78551. */
  78552. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78553. /**
  78554. * Add a TextFileAssetTask to the list of active tasks
  78555. * @param taskName defines the name of the new task
  78556. * @param url defines the url of the file to load
  78557. * @returns a new TextFileAssetTask object
  78558. */
  78559. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78560. /**
  78561. * Add a BinaryFileAssetTask to the list of active tasks
  78562. * @param taskName defines the name of the new task
  78563. * @param url defines the url of the file to load
  78564. * @returns a new BinaryFileAssetTask object
  78565. */
  78566. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78567. /**
  78568. * Add a ImageAssetTask to the list of active tasks
  78569. * @param taskName defines the name of the new task
  78570. * @param url defines the url of the file to load
  78571. * @returns a new ImageAssetTask object
  78572. */
  78573. addImageTask(taskName: string, url: string): ImageAssetTask;
  78574. /**
  78575. * Add a TextureAssetTask to the list of active tasks
  78576. * @param taskName defines the name of the new task
  78577. * @param url defines the url of the file to load
  78578. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78579. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78580. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78581. * @returns a new TextureAssetTask object
  78582. */
  78583. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78584. /**
  78585. * Add a CubeTextureAssetTask to the list of active tasks
  78586. * @param taskName defines the name of the new task
  78587. * @param url defines the url of the file to load
  78588. * @param extensions defines the extension to use to load the cube map (can be null)
  78589. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78590. * @param files defines the list of files to load (can be null)
  78591. * @returns a new CubeTextureAssetTask object
  78592. */
  78593. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78594. /**
  78595. *
  78596. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78597. * @param taskName defines the name of the new task
  78598. * @param url defines the url of the file to load
  78599. * @param size defines the size you want for the cubemap (can be null)
  78600. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78601. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78602. * @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)
  78603. * @param reserved Internal use only
  78604. * @returns a new HDRCubeTextureAssetTask object
  78605. */
  78606. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78607. /**
  78608. *
  78609. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78610. * @param taskName defines the name of the new task
  78611. * @param url defines the url of the file to load
  78612. * @param size defines the size you want for the cubemap (can be null)
  78613. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78614. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78615. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78616. * @returns a new EquiRectangularCubeTextureAssetTask object
  78617. */
  78618. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78619. /**
  78620. * Remove a task from the assets manager.
  78621. * @param task the task to remove
  78622. */
  78623. removeTask(task: AbstractAssetTask): void;
  78624. private _decreaseWaitingTasksCount;
  78625. private _runTask;
  78626. /**
  78627. * Reset the AssetsManager and remove all tasks
  78628. * @return the current instance of the AssetsManager
  78629. */
  78630. reset(): AssetsManager;
  78631. /**
  78632. * Start the loading process
  78633. * @return the current instance of the AssetsManager
  78634. */
  78635. load(): AssetsManager;
  78636. /**
  78637. * Start the loading process as an async operation
  78638. * @return a promise returning the list of failed tasks
  78639. */
  78640. loadAsync(): Promise<void>;
  78641. }
  78642. }
  78643. declare module "babylonjs/Misc/deferred" {
  78644. /**
  78645. * Wrapper class for promise with external resolve and reject.
  78646. */
  78647. export class Deferred<T> {
  78648. /**
  78649. * The promise associated with this deferred object.
  78650. */
  78651. readonly promise: Promise<T>;
  78652. private _resolve;
  78653. private _reject;
  78654. /**
  78655. * The resolve method of the promise associated with this deferred object.
  78656. */
  78657. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  78658. /**
  78659. * The reject method of the promise associated with this deferred object.
  78660. */
  78661. get reject(): (reason?: any) => void;
  78662. /**
  78663. * Constructor for this deferred object.
  78664. */
  78665. constructor();
  78666. }
  78667. }
  78668. declare module "babylonjs/Misc/meshExploder" {
  78669. import { Mesh } from "babylonjs/Meshes/mesh";
  78670. /**
  78671. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78672. */
  78673. export class MeshExploder {
  78674. private _centerMesh;
  78675. private _meshes;
  78676. private _meshesOrigins;
  78677. private _toCenterVectors;
  78678. private _scaledDirection;
  78679. private _newPosition;
  78680. private _centerPosition;
  78681. /**
  78682. * Explodes meshes from a center mesh.
  78683. * @param meshes The meshes to explode.
  78684. * @param centerMesh The mesh to be center of explosion.
  78685. */
  78686. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78687. private _setCenterMesh;
  78688. /**
  78689. * Get class name
  78690. * @returns "MeshExploder"
  78691. */
  78692. getClassName(): string;
  78693. /**
  78694. * "Exploded meshes"
  78695. * @returns Array of meshes with the centerMesh at index 0.
  78696. */
  78697. getMeshes(): Array<Mesh>;
  78698. /**
  78699. * Explodes meshes giving a specific direction
  78700. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78701. */
  78702. explode(direction?: number): void;
  78703. }
  78704. }
  78705. declare module "babylonjs/Misc/filesInput" {
  78706. import { Engine } from "babylonjs/Engines/engine";
  78707. import { Scene } from "babylonjs/scene";
  78708. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78709. import { Nullable } from "babylonjs/types";
  78710. /**
  78711. * Class used to help managing file picking and drag'n'drop
  78712. */
  78713. export class FilesInput {
  78714. /**
  78715. * List of files ready to be loaded
  78716. */
  78717. static get FilesToLoad(): {
  78718. [key: string]: File;
  78719. };
  78720. /**
  78721. * Callback called when a file is processed
  78722. */
  78723. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78724. private _engine;
  78725. private _currentScene;
  78726. private _sceneLoadedCallback;
  78727. private _progressCallback;
  78728. private _additionalRenderLoopLogicCallback;
  78729. private _textureLoadingCallback;
  78730. private _startingProcessingFilesCallback;
  78731. private _onReloadCallback;
  78732. private _errorCallback;
  78733. private _elementToMonitor;
  78734. private _sceneFileToLoad;
  78735. private _filesToLoad;
  78736. /**
  78737. * Creates a new FilesInput
  78738. * @param engine defines the rendering engine
  78739. * @param scene defines the hosting scene
  78740. * @param sceneLoadedCallback callback called when scene is loaded
  78741. * @param progressCallback callback called to track progress
  78742. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78743. * @param textureLoadingCallback callback called when a texture is loading
  78744. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78745. * @param onReloadCallback callback called when a reload is requested
  78746. * @param errorCallback callback call if an error occurs
  78747. */
  78748. 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>);
  78749. private _dragEnterHandler;
  78750. private _dragOverHandler;
  78751. private _dropHandler;
  78752. /**
  78753. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78754. * @param elementToMonitor defines the DOM element to track
  78755. */
  78756. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78757. /** Gets the current list of files to load */
  78758. get filesToLoad(): File[];
  78759. /**
  78760. * Release all associated resources
  78761. */
  78762. dispose(): void;
  78763. private renderFunction;
  78764. private drag;
  78765. private drop;
  78766. private _traverseFolder;
  78767. private _processFiles;
  78768. /**
  78769. * Load files from a drop event
  78770. * @param event defines the drop event to use as source
  78771. */
  78772. loadFiles(event: any): void;
  78773. private _processReload;
  78774. /**
  78775. * Reload the current scene from the loaded files
  78776. */
  78777. reload(): void;
  78778. }
  78779. }
  78780. declare module "babylonjs/Misc/HighDynamicRange/index" {
  78781. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  78782. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  78783. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  78784. }
  78785. declare module "babylonjs/Misc/sceneOptimizer" {
  78786. import { Scene, IDisposable } from "babylonjs/scene";
  78787. import { Observable } from "babylonjs/Misc/observable";
  78788. /**
  78789. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78790. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78791. */
  78792. export class SceneOptimization {
  78793. /**
  78794. * Defines the priority of this optimization (0 by default which means first in the list)
  78795. */
  78796. priority: number;
  78797. /**
  78798. * Gets a string describing the action executed by the current optimization
  78799. * @returns description string
  78800. */
  78801. getDescription(): string;
  78802. /**
  78803. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78804. * @param scene defines the current scene where to apply this optimization
  78805. * @param optimizer defines the current optimizer
  78806. * @returns true if everything that can be done was applied
  78807. */
  78808. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78809. /**
  78810. * Creates the SceneOptimization object
  78811. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78812. * @param desc defines the description associated with the optimization
  78813. */
  78814. constructor(
  78815. /**
  78816. * Defines the priority of this optimization (0 by default which means first in the list)
  78817. */
  78818. priority?: number);
  78819. }
  78820. /**
  78821. * Defines an optimization used to reduce the size of render target textures
  78822. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78823. */
  78824. export class TextureOptimization extends SceneOptimization {
  78825. /**
  78826. * Defines the priority of this optimization (0 by default which means first in the list)
  78827. */
  78828. priority: number;
  78829. /**
  78830. * 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
  78831. */
  78832. maximumSize: number;
  78833. /**
  78834. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78835. */
  78836. step: number;
  78837. /**
  78838. * Gets a string describing the action executed by the current optimization
  78839. * @returns description string
  78840. */
  78841. getDescription(): string;
  78842. /**
  78843. * Creates the TextureOptimization object
  78844. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78845. * @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
  78846. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78847. */
  78848. constructor(
  78849. /**
  78850. * Defines the priority of this optimization (0 by default which means first in the list)
  78851. */
  78852. priority?: number,
  78853. /**
  78854. * 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
  78855. */
  78856. maximumSize?: number,
  78857. /**
  78858. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78859. */
  78860. step?: number);
  78861. /**
  78862. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78863. * @param scene defines the current scene where to apply this optimization
  78864. * @param optimizer defines the current optimizer
  78865. * @returns true if everything that can be done was applied
  78866. */
  78867. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78868. }
  78869. /**
  78870. * Defines an optimization used to increase or decrease the rendering resolution
  78871. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78872. */
  78873. export class HardwareScalingOptimization extends SceneOptimization {
  78874. /**
  78875. * Defines the priority of this optimization (0 by default which means first in the list)
  78876. */
  78877. priority: number;
  78878. /**
  78879. * Defines the maximum scale to use (2 by default)
  78880. */
  78881. maximumScale: number;
  78882. /**
  78883. * Defines the step to use between two passes (0.5 by default)
  78884. */
  78885. step: number;
  78886. private _currentScale;
  78887. private _directionOffset;
  78888. /**
  78889. * Gets a string describing the action executed by the current optimization
  78890. * @return description string
  78891. */
  78892. getDescription(): string;
  78893. /**
  78894. * Creates the HardwareScalingOptimization object
  78895. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78896. * @param maximumScale defines the maximum scale to use (2 by default)
  78897. * @param step defines the step to use between two passes (0.5 by default)
  78898. */
  78899. constructor(
  78900. /**
  78901. * Defines the priority of this optimization (0 by default which means first in the list)
  78902. */
  78903. priority?: number,
  78904. /**
  78905. * Defines the maximum scale to use (2 by default)
  78906. */
  78907. maximumScale?: number,
  78908. /**
  78909. * Defines the step to use between two passes (0.5 by default)
  78910. */
  78911. step?: number);
  78912. /**
  78913. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78914. * @param scene defines the current scene where to apply this optimization
  78915. * @param optimizer defines the current optimizer
  78916. * @returns true if everything that can be done was applied
  78917. */
  78918. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78919. }
  78920. /**
  78921. * Defines an optimization used to remove shadows
  78922. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78923. */
  78924. export class ShadowsOptimization extends SceneOptimization {
  78925. /**
  78926. * Gets a string describing the action executed by the current optimization
  78927. * @return description string
  78928. */
  78929. getDescription(): string;
  78930. /**
  78931. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78932. * @param scene defines the current scene where to apply this optimization
  78933. * @param optimizer defines the current optimizer
  78934. * @returns true if everything that can be done was applied
  78935. */
  78936. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78937. }
  78938. /**
  78939. * Defines an optimization used to turn post-processes off
  78940. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78941. */
  78942. export class PostProcessesOptimization extends SceneOptimization {
  78943. /**
  78944. * Gets a string describing the action executed by the current optimization
  78945. * @return description string
  78946. */
  78947. getDescription(): string;
  78948. /**
  78949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78950. * @param scene defines the current scene where to apply this optimization
  78951. * @param optimizer defines the current optimizer
  78952. * @returns true if everything that can be done was applied
  78953. */
  78954. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78955. }
  78956. /**
  78957. * Defines an optimization used to turn lens flares off
  78958. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78959. */
  78960. export class LensFlaresOptimization extends SceneOptimization {
  78961. /**
  78962. * Gets a string describing the action executed by the current optimization
  78963. * @return description string
  78964. */
  78965. getDescription(): string;
  78966. /**
  78967. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78968. * @param scene defines the current scene where to apply this optimization
  78969. * @param optimizer defines the current optimizer
  78970. * @returns true if everything that can be done was applied
  78971. */
  78972. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78973. }
  78974. /**
  78975. * Defines an optimization based on user defined callback.
  78976. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78977. */
  78978. export class CustomOptimization extends SceneOptimization {
  78979. /**
  78980. * Callback called to apply the custom optimization.
  78981. */
  78982. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78983. /**
  78984. * Callback called to get custom description
  78985. */
  78986. onGetDescription: () => string;
  78987. /**
  78988. * Gets a string describing the action executed by the current optimization
  78989. * @returns description string
  78990. */
  78991. getDescription(): string;
  78992. /**
  78993. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78994. * @param scene defines the current scene where to apply this optimization
  78995. * @param optimizer defines the current optimizer
  78996. * @returns true if everything that can be done was applied
  78997. */
  78998. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78999. }
  79000. /**
  79001. * Defines an optimization used to turn particles off
  79002. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79003. */
  79004. export class ParticlesOptimization extends SceneOptimization {
  79005. /**
  79006. * Gets a string describing the action executed by the current optimization
  79007. * @return description string
  79008. */
  79009. getDescription(): string;
  79010. /**
  79011. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79012. * @param scene defines the current scene where to apply this optimization
  79013. * @param optimizer defines the current optimizer
  79014. * @returns true if everything that can be done was applied
  79015. */
  79016. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79017. }
  79018. /**
  79019. * Defines an optimization used to turn render targets off
  79020. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79021. */
  79022. export class RenderTargetsOptimization extends SceneOptimization {
  79023. /**
  79024. * Gets a string describing the action executed by the current optimization
  79025. * @return description string
  79026. */
  79027. getDescription(): string;
  79028. /**
  79029. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79030. * @param scene defines the current scene where to apply this optimization
  79031. * @param optimizer defines the current optimizer
  79032. * @returns true if everything that can be done was applied
  79033. */
  79034. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79035. }
  79036. /**
  79037. * Defines an optimization used to merge meshes with compatible materials
  79038. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79039. */
  79040. export class MergeMeshesOptimization extends SceneOptimization {
  79041. private static _UpdateSelectionTree;
  79042. /**
  79043. * Gets or sets a boolean which defines if optimization octree has to be updated
  79044. */
  79045. static get UpdateSelectionTree(): boolean;
  79046. /**
  79047. * Gets or sets a boolean which defines if optimization octree has to be updated
  79048. */
  79049. static set UpdateSelectionTree(value: boolean);
  79050. /**
  79051. * Gets a string describing the action executed by the current optimization
  79052. * @return description string
  79053. */
  79054. getDescription(): string;
  79055. private _canBeMerged;
  79056. /**
  79057. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79058. * @param scene defines the current scene where to apply this optimization
  79059. * @param optimizer defines the current optimizer
  79060. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  79061. * @returns true if everything that can be done was applied
  79062. */
  79063. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  79064. }
  79065. /**
  79066. * Defines a list of options used by SceneOptimizer
  79067. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79068. */
  79069. export class SceneOptimizerOptions {
  79070. /**
  79071. * Defines the target frame rate to reach (60 by default)
  79072. */
  79073. targetFrameRate: number;
  79074. /**
  79075. * Defines the interval between two checkes (2000ms by default)
  79076. */
  79077. trackerDuration: number;
  79078. /**
  79079. * Gets the list of optimizations to apply
  79080. */
  79081. optimizations: SceneOptimization[];
  79082. /**
  79083. * Creates a new list of options used by SceneOptimizer
  79084. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  79085. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  79086. */
  79087. constructor(
  79088. /**
  79089. * Defines the target frame rate to reach (60 by default)
  79090. */
  79091. targetFrameRate?: number,
  79092. /**
  79093. * Defines the interval between two checkes (2000ms by default)
  79094. */
  79095. trackerDuration?: number);
  79096. /**
  79097. * Add a new optimization
  79098. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  79099. * @returns the current SceneOptimizerOptions
  79100. */
  79101. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  79102. /**
  79103. * Add a new custom optimization
  79104. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  79105. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  79106. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79107. * @returns the current SceneOptimizerOptions
  79108. */
  79109. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  79110. /**
  79111. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  79112. * @param targetFrameRate defines the target frame rate (60 by default)
  79113. * @returns a SceneOptimizerOptions object
  79114. */
  79115. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79116. /**
  79117. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  79118. * @param targetFrameRate defines the target frame rate (60 by default)
  79119. * @returns a SceneOptimizerOptions object
  79120. */
  79121. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79122. /**
  79123. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  79124. * @param targetFrameRate defines the target frame rate (60 by default)
  79125. * @returns a SceneOptimizerOptions object
  79126. */
  79127. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79128. }
  79129. /**
  79130. * Class used to run optimizations in order to reach a target frame rate
  79131. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79132. */
  79133. export class SceneOptimizer implements IDisposable {
  79134. private _isRunning;
  79135. private _options;
  79136. private _scene;
  79137. private _currentPriorityLevel;
  79138. private _targetFrameRate;
  79139. private _trackerDuration;
  79140. private _currentFrameRate;
  79141. private _sceneDisposeObserver;
  79142. private _improvementMode;
  79143. /**
  79144. * Defines an observable called when the optimizer reaches the target frame rate
  79145. */
  79146. onSuccessObservable: Observable<SceneOptimizer>;
  79147. /**
  79148. * Defines an observable called when the optimizer enables an optimization
  79149. */
  79150. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  79151. /**
  79152. * Defines an observable called when the optimizer is not able to reach the target frame rate
  79153. */
  79154. onFailureObservable: Observable<SceneOptimizer>;
  79155. /**
  79156. * Gets a boolean indicating if the optimizer is in improvement mode
  79157. */
  79158. get isInImprovementMode(): boolean;
  79159. /**
  79160. * Gets the current priority level (0 at start)
  79161. */
  79162. get currentPriorityLevel(): number;
  79163. /**
  79164. * Gets the current frame rate checked by the SceneOptimizer
  79165. */
  79166. get currentFrameRate(): number;
  79167. /**
  79168. * Gets or sets the current target frame rate (60 by default)
  79169. */
  79170. get targetFrameRate(): number;
  79171. /**
  79172. * Gets or sets the current target frame rate (60 by default)
  79173. */
  79174. set targetFrameRate(value: number);
  79175. /**
  79176. * Gets or sets the current interval between two checks (every 2000ms by default)
  79177. */
  79178. get trackerDuration(): number;
  79179. /**
  79180. * Gets or sets the current interval between two checks (every 2000ms by default)
  79181. */
  79182. set trackerDuration(value: number);
  79183. /**
  79184. * Gets the list of active optimizations
  79185. */
  79186. get optimizations(): SceneOptimization[];
  79187. /**
  79188. * Creates a new SceneOptimizer
  79189. * @param scene defines the scene to work on
  79190. * @param options defines the options to use with the SceneOptimizer
  79191. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  79192. * @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)
  79193. */
  79194. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  79195. /**
  79196. * Stops the current optimizer
  79197. */
  79198. stop(): void;
  79199. /**
  79200. * Reset the optimizer to initial step (current priority level = 0)
  79201. */
  79202. reset(): void;
  79203. /**
  79204. * Start the optimizer. By default it will try to reach a specific framerate
  79205. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  79206. */
  79207. start(): void;
  79208. private _checkCurrentState;
  79209. /**
  79210. * Release all resources
  79211. */
  79212. dispose(): void;
  79213. /**
  79214. * Helper function to create a SceneOptimizer with one single line of code
  79215. * @param scene defines the scene to work on
  79216. * @param options defines the options to use with the SceneOptimizer
  79217. * @param onSuccess defines a callback to call on success
  79218. * @param onFailure defines a callback to call on failure
  79219. * @returns the new SceneOptimizer object
  79220. */
  79221. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  79222. }
  79223. }
  79224. declare module "babylonjs/Misc/sceneSerializer" {
  79225. import { Scene } from "babylonjs/scene";
  79226. /**
  79227. * Class used to serialize a scene into a string
  79228. */
  79229. export class SceneSerializer {
  79230. /**
  79231. * Clear cache used by a previous serialization
  79232. */
  79233. static ClearCache(): void;
  79234. /**
  79235. * Serialize a scene into a JSON compatible object
  79236. * @param scene defines the scene to serialize
  79237. * @returns a JSON compatible object
  79238. */
  79239. static Serialize(scene: Scene): any;
  79240. /**
  79241. * Serialize a mesh into a JSON compatible object
  79242. * @param toSerialize defines the mesh to serialize
  79243. * @param withParents defines if parents must be serialized as well
  79244. * @param withChildren defines if children must be serialized as well
  79245. * @returns a JSON compatible object
  79246. */
  79247. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  79248. }
  79249. }
  79250. declare module "babylonjs/Misc/textureTools" {
  79251. import { Texture } from "babylonjs/Materials/Textures/texture";
  79252. /**
  79253. * Class used to host texture specific utilities
  79254. */
  79255. export class TextureTools {
  79256. /**
  79257. * Uses the GPU to create a copy texture rescaled at a given size
  79258. * @param texture Texture to copy from
  79259. * @param width defines the desired width
  79260. * @param height defines the desired height
  79261. * @param useBilinearMode defines if bilinear mode has to be used
  79262. * @return the generated texture
  79263. */
  79264. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  79265. }
  79266. }
  79267. declare module "babylonjs/Misc/videoRecorder" {
  79268. import { Nullable } from "babylonjs/types";
  79269. import { Engine } from "babylonjs/Engines/engine";
  79270. /**
  79271. * This represents the different options available for the video capture.
  79272. */
  79273. export interface VideoRecorderOptions {
  79274. /** Defines the mime type of the video. */
  79275. mimeType: string;
  79276. /** Defines the FPS the video should be recorded at. */
  79277. fps: number;
  79278. /** Defines the chunk size for the recording data. */
  79279. recordChunckSize: number;
  79280. /** The audio tracks to attach to the recording. */
  79281. audioTracks?: MediaStreamTrack[];
  79282. }
  79283. /**
  79284. * This can help with recording videos from BabylonJS.
  79285. * This is based on the available WebRTC functionalities of the browser.
  79286. *
  79287. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  79288. */
  79289. export class VideoRecorder {
  79290. private static readonly _defaultOptions;
  79291. /**
  79292. * Returns whether or not the VideoRecorder is available in your browser.
  79293. * @param engine Defines the Babylon Engine.
  79294. * @returns true if supported otherwise false.
  79295. */
  79296. static IsSupported(engine: Engine): boolean;
  79297. private readonly _options;
  79298. private _canvas;
  79299. private _mediaRecorder;
  79300. private _recordedChunks;
  79301. private _fileName;
  79302. private _resolve;
  79303. private _reject;
  79304. /**
  79305. * True when a recording is already in progress.
  79306. */
  79307. get isRecording(): boolean;
  79308. /**
  79309. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  79310. * @param engine Defines the BabylonJS Engine you wish to record.
  79311. * @param options Defines options that can be used to customize the capture.
  79312. */
  79313. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79314. /**
  79315. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79316. */
  79317. stopRecording(): void;
  79318. /**
  79319. * Starts recording the canvas for a max duration specified in parameters.
  79320. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79321. * If null no automatic download will start and you can rely on the promise to get the data back.
  79322. * @param maxDuration Defines the maximum recording time in seconds.
  79323. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79324. * @return A promise callback at the end of the recording with the video data in Blob.
  79325. */
  79326. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79327. /**
  79328. * Releases internal resources used during the recording.
  79329. */
  79330. dispose(): void;
  79331. private _handleDataAvailable;
  79332. private _handleError;
  79333. private _handleStop;
  79334. }
  79335. }
  79336. declare module "babylonjs/Misc/screenshotTools" {
  79337. import { Camera } from "babylonjs/Cameras/camera";
  79338. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  79339. import { Engine } from "babylonjs/Engines/engine";
  79340. /**
  79341. * Class containing a set of static utilities functions for screenshots
  79342. */
  79343. export class ScreenshotTools {
  79344. /**
  79345. * Captures a screenshot of the current rendering
  79346. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79347. * @param engine defines the rendering engine
  79348. * @param camera defines the source camera
  79349. * @param size This parameter can be set to a single number or to an object with the
  79350. * following (optional) properties: precision, width, height. If a single number is passed,
  79351. * it will be used for both width and height. If an object is passed, the screenshot size
  79352. * will be derived from the parameters. The precision property is a multiplier allowing
  79353. * rendering at a higher or lower resolution
  79354. * @param successCallback defines the callback receives a single parameter which contains the
  79355. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79356. * src parameter of an <img> to display it
  79357. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79358. * Check your browser for supported MIME types
  79359. */
  79360. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  79361. /**
  79362. * Captures a screenshot of the current rendering
  79363. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79364. * @param engine defines the rendering engine
  79365. * @param camera defines the source camera
  79366. * @param size This parameter can be set to a single number or to an object with the
  79367. * following (optional) properties: precision, width, height. If a single number is passed,
  79368. * it will be used for both width and height. If an object is passed, the screenshot size
  79369. * will be derived from the parameters. The precision property is a multiplier allowing
  79370. * rendering at a higher or lower resolution
  79371. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79372. * Check your browser for supported MIME types
  79373. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79374. * to the src parameter of an <img> to display it
  79375. */
  79376. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79377. /**
  79378. * Generates an image screenshot from the specified camera.
  79379. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79380. * @param engine The engine to use for rendering
  79381. * @param camera The camera to use for rendering
  79382. * @param size This parameter can be set to a single number or to an object with the
  79383. * following (optional) properties: precision, width, height. If a single number is passed,
  79384. * it will be used for both width and height. If an object is passed, the screenshot size
  79385. * will be derived from the parameters. The precision property is a multiplier allowing
  79386. * rendering at a higher or lower resolution
  79387. * @param successCallback The callback receives a single parameter which contains the
  79388. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79389. * src parameter of an <img> to display it
  79390. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79391. * Check your browser for supported MIME types
  79392. * @param samples Texture samples (default: 1)
  79393. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79394. * @param fileName A name for for the downloaded file.
  79395. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79396. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79397. */
  79398. 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;
  79399. /**
  79400. * Generates an image screenshot from the specified camera.
  79401. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79402. * @param engine The engine to use for rendering
  79403. * @param camera The camera to use for rendering
  79404. * @param size This parameter can be set to a single number or to an object with the
  79405. * following (optional) properties: precision, width, height. If a single number is passed,
  79406. * it will be used for both width and height. If an object is passed, the screenshot size
  79407. * will be derived from the parameters. The precision property is a multiplier allowing
  79408. * rendering at a higher or lower resolution
  79409. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79410. * Check your browser for supported MIME types
  79411. * @param samples Texture samples (default: 1)
  79412. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79413. * @param fileName A name for for the downloaded file.
  79414. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79415. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79416. * to the src parameter of an <img> to display it
  79417. */
  79418. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79419. /**
  79420. * Gets height and width for screenshot size
  79421. * @private
  79422. */
  79423. private static _getScreenshotSize;
  79424. }
  79425. }
  79426. declare module "babylonjs/Misc/dataReader" {
  79427. /**
  79428. * Interface for a data buffer
  79429. */
  79430. export interface IDataBuffer {
  79431. /**
  79432. * Reads bytes from the data buffer.
  79433. * @param byteOffset The byte offset to read
  79434. * @param byteLength The byte length to read
  79435. * @returns A promise that resolves when the bytes are read
  79436. */
  79437. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79438. /**
  79439. * The byte length of the buffer.
  79440. */
  79441. readonly byteLength: number;
  79442. }
  79443. /**
  79444. * Utility class for reading from a data buffer
  79445. */
  79446. export class DataReader {
  79447. /**
  79448. * The data buffer associated with this data reader.
  79449. */
  79450. readonly buffer: IDataBuffer;
  79451. /**
  79452. * The current byte offset from the beginning of the data buffer.
  79453. */
  79454. byteOffset: number;
  79455. private _dataView;
  79456. private _dataByteOffset;
  79457. /**
  79458. * Constructor
  79459. * @param buffer The buffer to read
  79460. */
  79461. constructor(buffer: IDataBuffer);
  79462. /**
  79463. * Loads the given byte length.
  79464. * @param byteLength The byte length to load
  79465. * @returns A promise that resolves when the load is complete
  79466. */
  79467. loadAsync(byteLength: number): Promise<void>;
  79468. /**
  79469. * Read a unsigned 32-bit integer from the currently loaded data range.
  79470. * @returns The 32-bit integer read
  79471. */
  79472. readUint32(): number;
  79473. /**
  79474. * Read a byte array from the currently loaded data range.
  79475. * @param byteLength The byte length to read
  79476. * @returns The byte array read
  79477. */
  79478. readUint8Array(byteLength: number): Uint8Array;
  79479. /**
  79480. * Read a string from the currently loaded data range.
  79481. * @param byteLength The byte length to read
  79482. * @returns The string read
  79483. */
  79484. readString(byteLength: number): string;
  79485. /**
  79486. * Skips the given byte length the currently loaded data range.
  79487. * @param byteLength The byte length to skip
  79488. */
  79489. skipBytes(byteLength: number): void;
  79490. }
  79491. }
  79492. declare module "babylonjs/Misc/dataStorage" {
  79493. /**
  79494. * Class for storing data to local storage if available or in-memory storage otherwise
  79495. */
  79496. export class DataStorage {
  79497. private static _Storage;
  79498. private static _GetStorage;
  79499. /**
  79500. * Reads a string from the data storage
  79501. * @param key The key to read
  79502. * @param defaultValue The value if the key doesn't exist
  79503. * @returns The string value
  79504. */
  79505. static ReadString(key: string, defaultValue: string): string;
  79506. /**
  79507. * Writes a string to the data storage
  79508. * @param key The key to write
  79509. * @param value The value to write
  79510. */
  79511. static WriteString(key: string, value: string): void;
  79512. /**
  79513. * Reads a boolean from the data storage
  79514. * @param key The key to read
  79515. * @param defaultValue The value if the key doesn't exist
  79516. * @returns The boolean value
  79517. */
  79518. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79519. /**
  79520. * Writes a boolean to the data storage
  79521. * @param key The key to write
  79522. * @param value The value to write
  79523. */
  79524. static WriteBoolean(key: string, value: boolean): void;
  79525. /**
  79526. * Reads a number from the data storage
  79527. * @param key The key to read
  79528. * @param defaultValue The value if the key doesn't exist
  79529. * @returns The number value
  79530. */
  79531. static ReadNumber(key: string, defaultValue: number): number;
  79532. /**
  79533. * Writes a number to the data storage
  79534. * @param key The key to write
  79535. * @param value The value to write
  79536. */
  79537. static WriteNumber(key: string, value: number): void;
  79538. }
  79539. }
  79540. declare module "babylonjs/Misc/sceneRecorder" {
  79541. import { Scene } from "babylonjs/scene";
  79542. /**
  79543. * Class used to record delta files between 2 scene states
  79544. */
  79545. export class SceneRecorder {
  79546. private _trackedScene;
  79547. private _savedJSON;
  79548. /**
  79549. * Track a given scene. This means the current scene state will be considered the original state
  79550. * @param scene defines the scene to track
  79551. */
  79552. track(scene: Scene): void;
  79553. /**
  79554. * Get the delta between current state and original state
  79555. * @returns a string containing the delta
  79556. */
  79557. getDelta(): any;
  79558. private _compareArray;
  79559. private _compareObjects;
  79560. private _compareCollections;
  79561. private static GetShadowGeneratorById;
  79562. /**
  79563. * Apply a given delta to a given scene
  79564. * @param deltaJSON defines the JSON containing the delta
  79565. * @param scene defines the scene to apply the delta to
  79566. */
  79567. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79568. private static _ApplyPropertiesToEntity;
  79569. private static _ApplyDeltaForEntity;
  79570. }
  79571. }
  79572. declare module "babylonjs/Misc/trajectoryClassifier" {
  79573. import { DeepImmutable, Nullable } from "babylonjs/types";
  79574. import { Vector3 } from "babylonjs/Maths/math.vector";
  79575. /**
  79576. * A 3D trajectory consisting of an order list of vectors describing a
  79577. * path of motion through 3D space.
  79578. */
  79579. export class Trajectory {
  79580. private _points;
  79581. private readonly _segmentLength;
  79582. /**
  79583. * Serialize to JSON.
  79584. * @returns serialized JSON string
  79585. */
  79586. serialize(): string;
  79587. /**
  79588. * Deserialize from JSON.
  79589. * @param json serialized JSON string
  79590. * @returns deserialized Trajectory
  79591. */
  79592. static Deserialize(json: string): Trajectory;
  79593. /**
  79594. * Create a new empty Trajectory.
  79595. * @param segmentLength radius of discretization for Trajectory points
  79596. */
  79597. constructor(segmentLength?: number);
  79598. /**
  79599. * Get the length of the Trajectory.
  79600. * @returns length of the Trajectory
  79601. */
  79602. getLength(): number;
  79603. /**
  79604. * Append a new point to the Trajectory.
  79605. * NOTE: This implementation has many allocations.
  79606. * @param point point to append to the Trajectory
  79607. */
  79608. add(point: DeepImmutable<Vector3>): void;
  79609. /**
  79610. * Create a new Trajectory with a segment length chosen to make it
  79611. * probable that the new Trajectory will have a specified number of
  79612. * segments. This operation is imprecise.
  79613. * @param targetResolution number of segments desired
  79614. * @returns new Trajectory with approximately the requested number of segments
  79615. */
  79616. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79617. /**
  79618. * Convert Trajectory segments into tokenized representation. This
  79619. * representation is an array of numbers where each nth number is the
  79620. * index of the token which is most similar to the nth segment of the
  79621. * Trajectory.
  79622. * @param tokens list of vectors which serve as discrete tokens
  79623. * @returns list of indices of most similar token per segment
  79624. */
  79625. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79626. private static _forwardDir;
  79627. private static _inverseFromVec;
  79628. private static _upDir;
  79629. private static _fromToVec;
  79630. private static _lookMatrix;
  79631. /**
  79632. * Transform the rotation (i.e., direction) of a segment to isolate
  79633. * the relative transformation represented by the segment. This operation
  79634. * may or may not succeed due to singularities in the equations that define
  79635. * motion relativity in this context.
  79636. * @param priorVec the origin of the prior segment
  79637. * @param fromVec the origin of the current segment
  79638. * @param toVec the destination of the current segment
  79639. * @param result reference to output variable
  79640. * @returns whether or not transformation was successful
  79641. */
  79642. private static _transformSegmentDirToRef;
  79643. private static _bestMatch;
  79644. private static _score;
  79645. private static _bestScore;
  79646. /**
  79647. * Determine which token vector is most similar to the
  79648. * segment vector.
  79649. * @param segment segment vector
  79650. * @param tokens token vector list
  79651. * @returns index of the most similar token to the segment
  79652. */
  79653. private static _tokenizeSegment;
  79654. }
  79655. /**
  79656. * Class representing a set of known, named trajectories to which Trajectories can be
  79657. * added and using which Trajectories can be recognized.
  79658. */
  79659. export class TrajectoryClassifier {
  79660. private _maximumAllowableMatchCost;
  79661. private _vector3Alphabet;
  79662. private _levenshteinAlphabet;
  79663. private _nameToDescribedTrajectory;
  79664. /**
  79665. * Serialize to JSON.
  79666. * @returns JSON serialization
  79667. */
  79668. serialize(): string;
  79669. /**
  79670. * Deserialize from JSON.
  79671. * @param json JSON serialization
  79672. * @returns deserialized TrajectorySet
  79673. */
  79674. static Deserialize(json: string): TrajectoryClassifier;
  79675. /**
  79676. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79677. * VERY naive, need to be generating these things from known
  79678. * sets. Better version later, probably eliminating this one.
  79679. * @returns auto-generated TrajectorySet
  79680. */
  79681. static Generate(): TrajectoryClassifier;
  79682. private constructor();
  79683. /**
  79684. * Add a new Trajectory to the set with a given name.
  79685. * @param trajectory new Trajectory to be added
  79686. * @param classification name to which to add the Trajectory
  79687. */
  79688. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79689. /**
  79690. * Remove a known named trajectory and all Trajectories associated with it.
  79691. * @param classification name to remove
  79692. * @returns whether anything was removed
  79693. */
  79694. deleteClassification(classification: string): boolean;
  79695. /**
  79696. * Attempt to recognize a Trajectory from among all the classifications
  79697. * already known to the classifier.
  79698. * @param trajectory Trajectory to be recognized
  79699. * @returns classification of Trajectory if recognized, null otherwise
  79700. */
  79701. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79702. }
  79703. }
  79704. declare module "babylonjs/Misc/index" {
  79705. export * from "babylonjs/Misc/andOrNotEvaluator";
  79706. export * from "babylonjs/Misc/assetsManager";
  79707. export * from "babylonjs/Misc/basis";
  79708. export * from "babylonjs/Misc/dds";
  79709. export * from "babylonjs/Misc/decorators";
  79710. export * from "babylonjs/Misc/deferred";
  79711. export * from "babylonjs/Misc/environmentTextureTools";
  79712. export * from "babylonjs/Misc/meshExploder";
  79713. export * from "babylonjs/Misc/filesInput";
  79714. export * from "babylonjs/Misc/HighDynamicRange/index";
  79715. export * from "babylonjs/Misc/khronosTextureContainer";
  79716. export * from "babylonjs/Misc/observable";
  79717. export * from "babylonjs/Misc/performanceMonitor";
  79718. export * from "babylonjs/Misc/promise";
  79719. export * from "babylonjs/Misc/sceneOptimizer";
  79720. export * from "babylonjs/Misc/sceneSerializer";
  79721. export * from "babylonjs/Misc/smartArray";
  79722. export * from "babylonjs/Misc/stringDictionary";
  79723. export * from "babylonjs/Misc/tags";
  79724. export * from "babylonjs/Misc/textureTools";
  79725. export * from "babylonjs/Misc/tga";
  79726. export * from "babylonjs/Misc/tools";
  79727. export * from "babylonjs/Misc/videoRecorder";
  79728. export * from "babylonjs/Misc/virtualJoystick";
  79729. export * from "babylonjs/Misc/workerPool";
  79730. export * from "babylonjs/Misc/logger";
  79731. export * from "babylonjs/Misc/typeStore";
  79732. export * from "babylonjs/Misc/filesInputStore";
  79733. export * from "babylonjs/Misc/deepCopier";
  79734. export * from "babylonjs/Misc/pivotTools";
  79735. export * from "babylonjs/Misc/precisionDate";
  79736. export * from "babylonjs/Misc/screenshotTools";
  79737. export * from "babylonjs/Misc/typeStore";
  79738. export * from "babylonjs/Misc/webRequest";
  79739. export * from "babylonjs/Misc/iInspectable";
  79740. export * from "babylonjs/Misc/brdfTextureTools";
  79741. export * from "babylonjs/Misc/rgbdTextureTools";
  79742. export * from "babylonjs/Misc/gradients";
  79743. export * from "babylonjs/Misc/perfCounter";
  79744. export * from "babylonjs/Misc/fileRequest";
  79745. export * from "babylonjs/Misc/customAnimationFrameRequester";
  79746. export * from "babylonjs/Misc/retryStrategy";
  79747. export * from "babylonjs/Misc/interfaces/screenshotSize";
  79748. export * from "babylonjs/Misc/canvasGenerator";
  79749. export * from "babylonjs/Misc/fileTools";
  79750. export * from "babylonjs/Misc/stringTools";
  79751. export * from "babylonjs/Misc/dataReader";
  79752. export * from "babylonjs/Misc/minMaxReducer";
  79753. export * from "babylonjs/Misc/depthReducer";
  79754. export * from "babylonjs/Misc/dataStorage";
  79755. export * from "babylonjs/Misc/sceneRecorder";
  79756. export * from "babylonjs/Misc/khronosTextureContainer2";
  79757. export * from "babylonjs/Misc/trajectoryClassifier";
  79758. export * from "babylonjs/Misc/timer";
  79759. }
  79760. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  79761. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  79762. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79763. import { Observable } from "babylonjs/Misc/observable";
  79764. import { Matrix } from "babylonjs/Maths/math.vector";
  79765. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79766. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79767. /**
  79768. * An interface for all Hit test features
  79769. */
  79770. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79771. /**
  79772. * Triggered when new babylon (transformed) hit test results are available
  79773. */
  79774. onHitTestResultObservable: Observable<T[]>;
  79775. }
  79776. /**
  79777. * Options used for hit testing
  79778. */
  79779. export interface IWebXRLegacyHitTestOptions {
  79780. /**
  79781. * Only test when user interacted with the scene. Default - hit test every frame
  79782. */
  79783. testOnPointerDownOnly?: boolean;
  79784. /**
  79785. * The node to use to transform the local results to world coordinates
  79786. */
  79787. worldParentNode?: TransformNode;
  79788. }
  79789. /**
  79790. * Interface defining the babylon result of raycasting/hit-test
  79791. */
  79792. export interface IWebXRLegacyHitResult {
  79793. /**
  79794. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79795. */
  79796. transformationMatrix: Matrix;
  79797. /**
  79798. * The native hit test result
  79799. */
  79800. xrHitResult: XRHitResult | XRHitTestResult;
  79801. }
  79802. /**
  79803. * The currently-working hit-test module.
  79804. * Hit test (or Ray-casting) is used to interact with the real world.
  79805. * For further information read here - https://github.com/immersive-web/hit-test
  79806. */
  79807. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79808. /**
  79809. * options to use when constructing this feature
  79810. */
  79811. readonly options: IWebXRLegacyHitTestOptions;
  79812. private _direction;
  79813. private _mat;
  79814. private _onSelectEnabled;
  79815. private _origin;
  79816. /**
  79817. * The module's name
  79818. */
  79819. static readonly Name: string;
  79820. /**
  79821. * The (Babylon) version of this module.
  79822. * This is an integer representing the implementation version.
  79823. * This number does not correspond to the WebXR specs version
  79824. */
  79825. static readonly Version: number;
  79826. /**
  79827. * Populated with the last native XR Hit Results
  79828. */
  79829. lastNativeXRHitResults: XRHitResult[];
  79830. /**
  79831. * Triggered when new babylon (transformed) hit test results are available
  79832. */
  79833. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79834. /**
  79835. * Creates a new instance of the (legacy version) hit test feature
  79836. * @param _xrSessionManager an instance of WebXRSessionManager
  79837. * @param options options to use when constructing this feature
  79838. */
  79839. constructor(_xrSessionManager: WebXRSessionManager,
  79840. /**
  79841. * options to use when constructing this feature
  79842. */
  79843. options?: IWebXRLegacyHitTestOptions);
  79844. /**
  79845. * execute a hit test with an XR Ray
  79846. *
  79847. * @param xrSession a native xrSession that will execute this hit test
  79848. * @param xrRay the ray (position and direction) to use for ray-casting
  79849. * @param referenceSpace native XR reference space to use for the hit-test
  79850. * @param filter filter function that will filter the results
  79851. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79852. */
  79853. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79854. /**
  79855. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79856. * @param event the (select) event to use to select with
  79857. * @param referenceSpace the reference space to use for this hit test
  79858. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79859. */
  79860. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79861. /**
  79862. * attach this feature
  79863. * Will usually be called by the features manager
  79864. *
  79865. * @returns true if successful.
  79866. */
  79867. attach(): boolean;
  79868. /**
  79869. * detach this feature.
  79870. * Will usually be called by the features manager
  79871. *
  79872. * @returns true if successful.
  79873. */
  79874. detach(): boolean;
  79875. /**
  79876. * Dispose this feature and all of the resources attached
  79877. */
  79878. dispose(): void;
  79879. protected _onXRFrame(frame: XRFrame): void;
  79880. private _onHitTestResults;
  79881. private _onSelect;
  79882. }
  79883. }
  79884. declare module "babylonjs/XR/features/WebXRHitTest" {
  79885. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79886. import { Observable } from "babylonjs/Misc/observable";
  79887. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79888. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79889. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79890. /**
  79891. * Options used for hit testing (version 2)
  79892. */
  79893. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79894. /**
  79895. * Do not create a permanent hit test. Will usually be used when only
  79896. * transient inputs are needed.
  79897. */
  79898. disablePermanentHitTest?: boolean;
  79899. /**
  79900. * Enable transient (for example touch-based) hit test inspections
  79901. */
  79902. enableTransientHitTest?: boolean;
  79903. /**
  79904. * Offset ray for the permanent hit test
  79905. */
  79906. offsetRay?: Vector3;
  79907. /**
  79908. * Offset ray for the transient hit test
  79909. */
  79910. transientOffsetRay?: Vector3;
  79911. /**
  79912. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79913. */
  79914. useReferenceSpace?: boolean;
  79915. /**
  79916. * Override the default entity type(s) of the hit-test result
  79917. */
  79918. entityTypes?: XRHitTestTrackableType[];
  79919. }
  79920. /**
  79921. * Interface defining the babylon result of hit-test
  79922. */
  79923. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79924. /**
  79925. * The input source that generated this hit test (if transient)
  79926. */
  79927. inputSource?: XRInputSource;
  79928. /**
  79929. * Is this a transient hit test
  79930. */
  79931. isTransient?: boolean;
  79932. /**
  79933. * Position of the hit test result
  79934. */
  79935. position: Vector3;
  79936. /**
  79937. * Rotation of the hit test result
  79938. */
  79939. rotationQuaternion: Quaternion;
  79940. /**
  79941. * The native hit test result
  79942. */
  79943. xrHitResult: XRHitTestResult;
  79944. }
  79945. /**
  79946. * The currently-working hit-test module.
  79947. * Hit test (or Ray-casting) is used to interact with the real world.
  79948. * For further information read here - https://github.com/immersive-web/hit-test
  79949. *
  79950. * Tested on chrome (mobile) 80.
  79951. */
  79952. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79953. /**
  79954. * options to use when constructing this feature
  79955. */
  79956. readonly options: IWebXRHitTestOptions;
  79957. private _tmpMat;
  79958. private _tmpPos;
  79959. private _tmpQuat;
  79960. private _transientXrHitTestSource;
  79961. private _xrHitTestSource;
  79962. private initHitTestSource;
  79963. /**
  79964. * The module's name
  79965. */
  79966. static readonly Name: string;
  79967. /**
  79968. * The (Babylon) version of this module.
  79969. * This is an integer representing the implementation version.
  79970. * This number does not correspond to the WebXR specs version
  79971. */
  79972. static readonly Version: number;
  79973. /**
  79974. * When set to true, each hit test will have its own position/rotation objects
  79975. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79976. * the developers will clone them or copy them as they see fit.
  79977. */
  79978. autoCloneTransformation: boolean;
  79979. /**
  79980. * Triggered when new babylon (transformed) hit test results are available
  79981. * Note - this will be called when results come back from the device. It can be an empty array!!
  79982. */
  79983. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79984. /**
  79985. * Use this to temporarily pause hit test checks.
  79986. */
  79987. paused: boolean;
  79988. /**
  79989. * Creates a new instance of the hit test feature
  79990. * @param _xrSessionManager an instance of WebXRSessionManager
  79991. * @param options options to use when constructing this feature
  79992. */
  79993. constructor(_xrSessionManager: WebXRSessionManager,
  79994. /**
  79995. * options to use when constructing this feature
  79996. */
  79997. options?: IWebXRHitTestOptions);
  79998. /**
  79999. * attach this feature
  80000. * Will usually be called by the features manager
  80001. *
  80002. * @returns true if successful.
  80003. */
  80004. attach(): boolean;
  80005. /**
  80006. * detach this feature.
  80007. * Will usually be called by the features manager
  80008. *
  80009. * @returns true if successful.
  80010. */
  80011. detach(): boolean;
  80012. /**
  80013. * Dispose this feature and all of the resources attached
  80014. */
  80015. dispose(): void;
  80016. protected _onXRFrame(frame: XRFrame): void;
  80017. private _processWebXRHitTestResult;
  80018. }
  80019. }
  80020. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  80021. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80022. import { Observable } from "babylonjs/Misc/observable";
  80023. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  80024. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80025. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80026. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  80027. /**
  80028. * Configuration options of the anchor system
  80029. */
  80030. export interface IWebXRAnchorSystemOptions {
  80031. /**
  80032. * a node that will be used to convert local to world coordinates
  80033. */
  80034. worldParentNode?: TransformNode;
  80035. /**
  80036. * If set to true a reference of the created anchors will be kept until the next session starts
  80037. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  80038. */
  80039. doNotRemoveAnchorsOnSessionEnded?: boolean;
  80040. }
  80041. /**
  80042. * A babylon container for an XR Anchor
  80043. */
  80044. export interface IWebXRAnchor {
  80045. /**
  80046. * A babylon-assigned ID for this anchor
  80047. */
  80048. id: number;
  80049. /**
  80050. * Transformation matrix to apply to an object attached to this anchor
  80051. */
  80052. transformationMatrix: Matrix;
  80053. /**
  80054. * The native anchor object
  80055. */
  80056. xrAnchor: XRAnchor;
  80057. /**
  80058. * if defined, this object will be constantly updated by the anchor's position and rotation
  80059. */
  80060. attachedNode?: TransformNode;
  80061. }
  80062. /**
  80063. * An implementation of the anchor system for WebXR.
  80064. * For further information see https://github.com/immersive-web/anchors/
  80065. */
  80066. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  80067. private _options;
  80068. private _lastFrameDetected;
  80069. private _trackedAnchors;
  80070. private _referenceSpaceForFrameAnchors;
  80071. private _futureAnchors;
  80072. /**
  80073. * The module's name
  80074. */
  80075. static readonly Name: string;
  80076. /**
  80077. * The (Babylon) version of this module.
  80078. * This is an integer representing the implementation version.
  80079. * This number does not correspond to the WebXR specs version
  80080. */
  80081. static readonly Version: number;
  80082. /**
  80083. * Observers registered here will be executed when a new anchor was added to the session
  80084. */
  80085. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  80086. /**
  80087. * Observers registered here will be executed when an anchor was removed from the session
  80088. */
  80089. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  80090. /**
  80091. * Observers registered here will be executed when an existing anchor updates
  80092. * This can execute N times every frame
  80093. */
  80094. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  80095. /**
  80096. * Set the reference space to use for anchor creation, when not using a hit test.
  80097. * Will default to the session's reference space if not defined
  80098. */
  80099. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  80100. /**
  80101. * constructs a new anchor system
  80102. * @param _xrSessionManager an instance of WebXRSessionManager
  80103. * @param _options configuration object for this feature
  80104. */
  80105. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  80106. private _tmpVector;
  80107. private _tmpQuaternion;
  80108. private _populateTmpTransformation;
  80109. /**
  80110. * Create a new anchor point using a hit test result at a specific point in the scene
  80111. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80112. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80113. *
  80114. * @param hitTestResult The hit test result to use for this anchor creation
  80115. * @param position an optional position offset for this anchor
  80116. * @param rotationQuaternion an optional rotation offset for this anchor
  80117. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  80118. */
  80119. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  80120. /**
  80121. * Add a new anchor at a specific position and rotation
  80122. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  80123. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  80124. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80125. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80126. *
  80127. * @param position the position in which to add an anchor
  80128. * @param rotationQuaternion an optional rotation for the anchor transformation
  80129. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  80130. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  80131. */
  80132. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  80133. /**
  80134. * detach this feature.
  80135. * Will usually be called by the features manager
  80136. *
  80137. * @returns true if successful.
  80138. */
  80139. detach(): boolean;
  80140. /**
  80141. * Dispose this feature and all of the resources attached
  80142. */
  80143. dispose(): void;
  80144. protected _onXRFrame(frame: XRFrame): void;
  80145. /**
  80146. * avoiding using Array.find for global support.
  80147. * @param xrAnchor the plane to find in the array
  80148. */
  80149. private _findIndexInAnchorArray;
  80150. private _updateAnchorWithXRFrame;
  80151. private _createAnchorAtTransformation;
  80152. }
  80153. }
  80154. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  80155. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80156. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80157. import { Observable } from "babylonjs/Misc/observable";
  80158. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  80159. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80160. /**
  80161. * Options used in the plane detector module
  80162. */
  80163. export interface IWebXRPlaneDetectorOptions {
  80164. /**
  80165. * The node to use to transform the local results to world coordinates
  80166. */
  80167. worldParentNode?: TransformNode;
  80168. /**
  80169. * If set to true a reference of the created planes will be kept until the next session starts
  80170. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  80171. */
  80172. doNotRemovePlanesOnSessionEnded?: boolean;
  80173. }
  80174. /**
  80175. * A babylon interface for a WebXR plane.
  80176. * A Plane is actually a polygon, built from N points in space
  80177. *
  80178. * Supported in chrome 79, not supported in canary 81 ATM
  80179. */
  80180. export interface IWebXRPlane {
  80181. /**
  80182. * a babylon-assigned ID for this polygon
  80183. */
  80184. id: number;
  80185. /**
  80186. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  80187. */
  80188. polygonDefinition: Array<Vector3>;
  80189. /**
  80190. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  80191. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  80192. */
  80193. transformationMatrix: Matrix;
  80194. /**
  80195. * the native xr-plane object
  80196. */
  80197. xrPlane: XRPlane;
  80198. }
  80199. /**
  80200. * The plane detector is used to detect planes in the real world when in AR
  80201. * For more information see https://github.com/immersive-web/real-world-geometry/
  80202. */
  80203. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  80204. private _options;
  80205. private _detectedPlanes;
  80206. private _enabled;
  80207. private _lastFrameDetected;
  80208. /**
  80209. * The module's name
  80210. */
  80211. static readonly Name: string;
  80212. /**
  80213. * The (Babylon) version of this module.
  80214. * This is an integer representing the implementation version.
  80215. * This number does not correspond to the WebXR specs version
  80216. */
  80217. static readonly Version: number;
  80218. /**
  80219. * Observers registered here will be executed when a new plane was added to the session
  80220. */
  80221. onPlaneAddedObservable: Observable<IWebXRPlane>;
  80222. /**
  80223. * Observers registered here will be executed when a plane is no longer detected in the session
  80224. */
  80225. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  80226. /**
  80227. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  80228. * This can execute N times every frame
  80229. */
  80230. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  80231. /**
  80232. * construct a new Plane Detector
  80233. * @param _xrSessionManager an instance of xr Session manager
  80234. * @param _options configuration to use when constructing this feature
  80235. */
  80236. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  80237. /**
  80238. * detach this feature.
  80239. * Will usually be called by the features manager
  80240. *
  80241. * @returns true if successful.
  80242. */
  80243. detach(): boolean;
  80244. /**
  80245. * Dispose this feature and all of the resources attached
  80246. */
  80247. dispose(): void;
  80248. /**
  80249. * Check if the needed objects are defined.
  80250. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80251. */
  80252. isCompatible(): boolean;
  80253. protected _onXRFrame(frame: XRFrame): void;
  80254. private _init;
  80255. private _updatePlaneWithXRPlane;
  80256. /**
  80257. * avoiding using Array.find for global support.
  80258. * @param xrPlane the plane to find in the array
  80259. */
  80260. private findIndexInPlaneArray;
  80261. }
  80262. }
  80263. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  80264. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80266. import { Observable } from "babylonjs/Misc/observable";
  80267. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80268. /**
  80269. * Options interface for the background remover plugin
  80270. */
  80271. export interface IWebXRBackgroundRemoverOptions {
  80272. /**
  80273. * Further background meshes to disable when entering AR
  80274. */
  80275. backgroundMeshes?: AbstractMesh[];
  80276. /**
  80277. * flags to configure the removal of the environment helper.
  80278. * If not set, the entire background will be removed. If set, flags should be set as well.
  80279. */
  80280. environmentHelperRemovalFlags?: {
  80281. /**
  80282. * Should the skybox be removed (default false)
  80283. */
  80284. skyBox?: boolean;
  80285. /**
  80286. * Should the ground be removed (default false)
  80287. */
  80288. ground?: boolean;
  80289. };
  80290. /**
  80291. * don't disable the environment helper
  80292. */
  80293. ignoreEnvironmentHelper?: boolean;
  80294. }
  80295. /**
  80296. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  80297. */
  80298. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  80299. /**
  80300. * read-only options to be used in this module
  80301. */
  80302. readonly options: IWebXRBackgroundRemoverOptions;
  80303. /**
  80304. * The module's name
  80305. */
  80306. static readonly Name: string;
  80307. /**
  80308. * The (Babylon) version of this module.
  80309. * This is an integer representing the implementation version.
  80310. * This number does not correspond to the WebXR specs version
  80311. */
  80312. static readonly Version: number;
  80313. /**
  80314. * registered observers will be triggered when the background state changes
  80315. */
  80316. onBackgroundStateChangedObservable: Observable<boolean>;
  80317. /**
  80318. * constructs a new background remover module
  80319. * @param _xrSessionManager the session manager for this module
  80320. * @param options read-only options to be used in this module
  80321. */
  80322. constructor(_xrSessionManager: WebXRSessionManager,
  80323. /**
  80324. * read-only options to be used in this module
  80325. */
  80326. options?: IWebXRBackgroundRemoverOptions);
  80327. /**
  80328. * attach this feature
  80329. * Will usually be called by the features manager
  80330. *
  80331. * @returns true if successful.
  80332. */
  80333. attach(): boolean;
  80334. /**
  80335. * detach this feature.
  80336. * Will usually be called by the features manager
  80337. *
  80338. * @returns true if successful.
  80339. */
  80340. detach(): boolean;
  80341. /**
  80342. * Dispose this feature and all of the resources attached
  80343. */
  80344. dispose(): void;
  80345. protected _onXRFrame(_xrFrame: XRFrame): void;
  80346. private _setBackgroundState;
  80347. }
  80348. }
  80349. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  80350. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80351. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80352. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  80353. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80354. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80355. import { Nullable } from "babylonjs/types";
  80356. /**
  80357. * Options for the controller physics feature
  80358. */
  80359. export class IWebXRControllerPhysicsOptions {
  80360. /**
  80361. * Should the headset get its own impostor
  80362. */
  80363. enableHeadsetImpostor?: boolean;
  80364. /**
  80365. * Optional parameters for the headset impostor
  80366. */
  80367. headsetImpostorParams?: {
  80368. /**
  80369. * The type of impostor to create. Default is sphere
  80370. */
  80371. impostorType: number;
  80372. /**
  80373. * the size of the impostor. Defaults to 10cm
  80374. */
  80375. impostorSize?: number | {
  80376. width: number;
  80377. height: number;
  80378. depth: number;
  80379. };
  80380. /**
  80381. * Friction definitions
  80382. */
  80383. friction?: number;
  80384. /**
  80385. * Restitution
  80386. */
  80387. restitution?: number;
  80388. };
  80389. /**
  80390. * The physics properties of the future impostors
  80391. */
  80392. physicsProperties?: {
  80393. /**
  80394. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80395. * Note that this requires a physics engine that supports mesh impostors!
  80396. */
  80397. useControllerMesh?: boolean;
  80398. /**
  80399. * The type of impostor to create. Default is sphere
  80400. */
  80401. impostorType?: number;
  80402. /**
  80403. * the size of the impostor. Defaults to 10cm
  80404. */
  80405. impostorSize?: number | {
  80406. width: number;
  80407. height: number;
  80408. depth: number;
  80409. };
  80410. /**
  80411. * Friction definitions
  80412. */
  80413. friction?: number;
  80414. /**
  80415. * Restitution
  80416. */
  80417. restitution?: number;
  80418. };
  80419. /**
  80420. * the xr input to use with this pointer selection
  80421. */
  80422. xrInput: WebXRInput;
  80423. }
  80424. /**
  80425. * Add physics impostor to your webxr controllers,
  80426. * including naive calculation of their linear and angular velocity
  80427. */
  80428. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80429. private readonly _options;
  80430. private _attachController;
  80431. private _controllers;
  80432. private _debugMode;
  80433. private _delta;
  80434. private _headsetImpostor?;
  80435. private _headsetMesh?;
  80436. private _lastTimestamp;
  80437. private _tmpQuaternion;
  80438. private _tmpVector;
  80439. /**
  80440. * The module's name
  80441. */
  80442. static readonly Name: string;
  80443. /**
  80444. * The (Babylon) version of this module.
  80445. * This is an integer representing the implementation version.
  80446. * This number does not correspond to the webxr specs version
  80447. */
  80448. static readonly Version: number;
  80449. /**
  80450. * Construct a new Controller Physics Feature
  80451. * @param _xrSessionManager the corresponding xr session manager
  80452. * @param _options options to create this feature with
  80453. */
  80454. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80455. /**
  80456. * @hidden
  80457. * enable debugging - will show console outputs and the impostor mesh
  80458. */
  80459. _enablePhysicsDebug(): void;
  80460. /**
  80461. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80462. * @param xrController the controller to add
  80463. */
  80464. addController(xrController: WebXRInputSource): void;
  80465. /**
  80466. * attach this feature
  80467. * Will usually be called by the features manager
  80468. *
  80469. * @returns true if successful.
  80470. */
  80471. attach(): boolean;
  80472. /**
  80473. * detach this feature.
  80474. * Will usually be called by the features manager
  80475. *
  80476. * @returns true if successful.
  80477. */
  80478. detach(): boolean;
  80479. /**
  80480. * Get the headset impostor, if enabled
  80481. * @returns the impostor
  80482. */
  80483. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80484. /**
  80485. * Get the physics impostor of a specific controller.
  80486. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80487. * @param controller the controller or the controller id of which to get the impostor
  80488. * @returns the impostor or null
  80489. */
  80490. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80491. /**
  80492. * Update the physics properties provided in the constructor
  80493. * @param newProperties the new properties object
  80494. */
  80495. setPhysicsProperties(newProperties: {
  80496. impostorType?: number;
  80497. impostorSize?: number | {
  80498. width: number;
  80499. height: number;
  80500. depth: number;
  80501. };
  80502. friction?: number;
  80503. restitution?: number;
  80504. }): void;
  80505. protected _onXRFrame(_xrFrame: any): void;
  80506. private _detachController;
  80507. }
  80508. }
  80509. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  80510. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80511. import { Observable } from "babylonjs/Misc/observable";
  80512. import { Vector3 } from "babylonjs/Maths/math.vector";
  80513. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80514. /**
  80515. * A babylon interface for a "WebXR" feature point.
  80516. * Represents the position and confidence value of a given feature point.
  80517. */
  80518. export interface IWebXRFeaturePoint {
  80519. /**
  80520. * Represents the position of the feature point in world space.
  80521. */
  80522. position: Vector3;
  80523. /**
  80524. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80525. */
  80526. confidenceValue: number;
  80527. }
  80528. /**
  80529. * The feature point system is used to detect feature points from real world geometry.
  80530. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80531. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80532. */
  80533. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80534. private _enabled;
  80535. private _featurePointCloud;
  80536. /**
  80537. * The module's name
  80538. */
  80539. static readonly Name: string;
  80540. /**
  80541. * The (Babylon) version of this module.
  80542. * This is an integer representing the implementation version.
  80543. * This number does not correspond to the WebXR specs version
  80544. */
  80545. static readonly Version: number;
  80546. /**
  80547. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80548. * Will notify the observers about which feature points have been added.
  80549. */
  80550. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80551. /**
  80552. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80553. * Will notify the observers about which feature points have been updated.
  80554. */
  80555. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80556. /**
  80557. * The current feature point cloud maintained across frames.
  80558. */
  80559. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80560. /**
  80561. * construct the feature point system
  80562. * @param _xrSessionManager an instance of xr Session manager
  80563. */
  80564. constructor(_xrSessionManager: WebXRSessionManager);
  80565. /**
  80566. * Detach this feature.
  80567. * Will usually be called by the features manager
  80568. *
  80569. * @returns true if successful.
  80570. */
  80571. detach(): boolean;
  80572. /**
  80573. * Dispose this feature and all of the resources attached
  80574. */
  80575. dispose(): void;
  80576. /**
  80577. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80578. */
  80579. protected _onXRFrame(frame: XRFrame): void;
  80580. /**
  80581. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80582. */
  80583. private _init;
  80584. }
  80585. }
  80586. declare module "babylonjs/XR/features/WebXRHandTracking" {
  80587. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80588. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80590. import { Mesh } from "babylonjs/Meshes/mesh";
  80591. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80592. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80593. import { Nullable } from "babylonjs/types";
  80594. import { IDisposable } from "babylonjs/scene";
  80595. import { Observable } from "babylonjs/Misc/observable";
  80596. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  80597. /**
  80598. * Configuration interface for the hand tracking feature
  80599. */
  80600. export interface IWebXRHandTrackingOptions {
  80601. /**
  80602. * The xrInput that will be used as source for new hands
  80603. */
  80604. xrInput: WebXRInput;
  80605. /**
  80606. * Configuration object for the joint meshes
  80607. */
  80608. jointMeshes?: {
  80609. /**
  80610. * Should the meshes created be invisible (defaults to false)
  80611. */
  80612. invisible?: boolean;
  80613. /**
  80614. * A source mesh to be used to create instances. Defaults to a sphere.
  80615. * This mesh will be the source for all other (25) meshes.
  80616. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80617. */
  80618. sourceMesh?: Mesh;
  80619. /**
  80620. * This function will be called after a mesh was created for a specific joint.
  80621. * Using this function you can either manipulate the instance or return a new mesh.
  80622. * When returning a new mesh the instance created before will be disposed
  80623. */
  80624. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80625. /**
  80626. * Should the source mesh stay visible. Defaults to false
  80627. */
  80628. keepOriginalVisible?: boolean;
  80629. /**
  80630. * Scale factor for all instances (defaults to 2)
  80631. */
  80632. scaleFactor?: number;
  80633. /**
  80634. * Should each instance have its own physics impostor
  80635. */
  80636. enablePhysics?: boolean;
  80637. /**
  80638. * If enabled, override default physics properties
  80639. */
  80640. physicsProps?: {
  80641. friction?: number;
  80642. restitution?: number;
  80643. impostorType?: number;
  80644. };
  80645. /**
  80646. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  80647. */
  80648. handMesh?: AbstractMesh;
  80649. };
  80650. }
  80651. /**
  80652. * Parts of the hands divided to writs and finger names
  80653. */
  80654. export const enum HandPart {
  80655. /**
  80656. * HandPart - Wrist
  80657. */
  80658. WRIST = "wrist",
  80659. /**
  80660. * HandPart - The THumb
  80661. */
  80662. THUMB = "thumb",
  80663. /**
  80664. * HandPart - Index finger
  80665. */
  80666. INDEX = "index",
  80667. /**
  80668. * HandPart - Middle finger
  80669. */
  80670. MIDDLE = "middle",
  80671. /**
  80672. * HandPart - Ring finger
  80673. */
  80674. RING = "ring",
  80675. /**
  80676. * HandPart - Little finger
  80677. */
  80678. LITTLE = "little"
  80679. }
  80680. /**
  80681. * Representing a single hand (with its corresponding native XRHand object)
  80682. */
  80683. export class WebXRHand implements IDisposable {
  80684. /** the controller to which the hand correlates */
  80685. readonly xrController: WebXRInputSource;
  80686. /** the meshes to be used to track the hand joints */
  80687. readonly trackedMeshes: AbstractMesh[];
  80688. /**
  80689. * Hand-parts definition (key is HandPart)
  80690. */
  80691. handPartsDefinition: {
  80692. [key: string]: number[];
  80693. };
  80694. /**
  80695. * Populate the HandPartsDefinition object.
  80696. * This is called as a side effect since certain browsers don't have XRHand defined.
  80697. */
  80698. private generateHandPartsDefinition;
  80699. /**
  80700. * Construct a new hand object
  80701. * @param xrController the controller to which the hand correlates
  80702. * @param trackedMeshes the meshes to be used to track the hand joints
  80703. */
  80704. constructor(
  80705. /** the controller to which the hand correlates */
  80706. xrController: WebXRInputSource,
  80707. /** the meshes to be used to track the hand joints */
  80708. trackedMeshes: AbstractMesh[]);
  80709. /**
  80710. * Update this hand from the latest xr frame
  80711. * @param xrFrame xrFrame to update from
  80712. * @param referenceSpace The current viewer reference space
  80713. * @param scaleFactor optional scale factor for the meshes
  80714. */
  80715. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80716. /**
  80717. * Get meshes of part of the hand
  80718. * @param part the part of hand to get
  80719. * @returns An array of meshes that correlate to the hand part requested
  80720. */
  80721. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80722. /**
  80723. * Dispose this Hand object
  80724. */
  80725. dispose(): void;
  80726. }
  80727. /**
  80728. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80729. */
  80730. export class WebXRHandTracking extends WebXRAbstractFeature {
  80731. /**
  80732. * options to use when constructing this feature
  80733. */
  80734. readonly options: IWebXRHandTrackingOptions;
  80735. private static _idCounter;
  80736. /**
  80737. * The module's name
  80738. */
  80739. static readonly Name: string;
  80740. /**
  80741. * The (Babylon) version of this module.
  80742. * This is an integer representing the implementation version.
  80743. * This number does not correspond to the WebXR specs version
  80744. */
  80745. static readonly Version: number;
  80746. /**
  80747. * This observable will notify registered observers when a new hand object was added and initialized
  80748. */
  80749. onHandAddedObservable: Observable<WebXRHand>;
  80750. /**
  80751. * This observable will notify its observers right before the hand object is disposed
  80752. */
  80753. onHandRemovedObservable: Observable<WebXRHand>;
  80754. private _hands;
  80755. /**
  80756. * Creates a new instance of the hit test feature
  80757. * @param _xrSessionManager an instance of WebXRSessionManager
  80758. * @param options options to use when constructing this feature
  80759. */
  80760. constructor(_xrSessionManager: WebXRSessionManager,
  80761. /**
  80762. * options to use when constructing this feature
  80763. */
  80764. options: IWebXRHandTrackingOptions);
  80765. /**
  80766. * Check if the needed objects are defined.
  80767. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80768. */
  80769. isCompatible(): boolean;
  80770. /**
  80771. * attach this feature
  80772. * Will usually be called by the features manager
  80773. *
  80774. * @returns true if successful.
  80775. */
  80776. attach(): boolean;
  80777. /**
  80778. * detach this feature.
  80779. * Will usually be called by the features manager
  80780. *
  80781. * @returns true if successful.
  80782. */
  80783. detach(): boolean;
  80784. /**
  80785. * Dispose this feature and all of the resources attached
  80786. */
  80787. dispose(): void;
  80788. /**
  80789. * Get the hand object according to the controller id
  80790. * @param controllerId the controller id to which we want to get the hand
  80791. * @returns null if not found or the WebXRHand object if found
  80792. */
  80793. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80794. /**
  80795. * Get a hand object according to the requested handedness
  80796. * @param handedness the handedness to request
  80797. * @returns null if not found or the WebXRHand object if found
  80798. */
  80799. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80800. protected _onXRFrame(_xrFrame: XRFrame): void;
  80801. private _attachHand;
  80802. private _detachHand;
  80803. }
  80804. }
  80805. declare module "babylonjs/XR/features/index" {
  80806. export * from "babylonjs/XR/features/WebXRAbstractFeature";
  80807. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  80808. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  80809. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  80810. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  80811. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  80812. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  80813. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  80814. export * from "babylonjs/XR/features/WebXRHitTest";
  80815. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  80816. export * from "babylonjs/XR/features/WebXRHandTracking";
  80817. }
  80818. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  80819. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80821. import { Scene } from "babylonjs/scene";
  80822. /**
  80823. * The motion controller class for all microsoft mixed reality controllers
  80824. */
  80825. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80826. protected readonly _mapping: {
  80827. defaultButton: {
  80828. valueNodeName: string;
  80829. unpressedNodeName: string;
  80830. pressedNodeName: string;
  80831. };
  80832. defaultAxis: {
  80833. valueNodeName: string;
  80834. minNodeName: string;
  80835. maxNodeName: string;
  80836. };
  80837. buttons: {
  80838. "xr-standard-trigger": {
  80839. rootNodeName: string;
  80840. componentProperty: string;
  80841. states: string[];
  80842. };
  80843. "xr-standard-squeeze": {
  80844. rootNodeName: string;
  80845. componentProperty: string;
  80846. states: string[];
  80847. };
  80848. "xr-standard-touchpad": {
  80849. rootNodeName: string;
  80850. labelAnchorNodeName: string;
  80851. touchPointNodeName: string;
  80852. };
  80853. "xr-standard-thumbstick": {
  80854. rootNodeName: string;
  80855. componentProperty: string;
  80856. states: string[];
  80857. };
  80858. };
  80859. axes: {
  80860. "xr-standard-touchpad": {
  80861. "x-axis": {
  80862. rootNodeName: string;
  80863. };
  80864. "y-axis": {
  80865. rootNodeName: string;
  80866. };
  80867. };
  80868. "xr-standard-thumbstick": {
  80869. "x-axis": {
  80870. rootNodeName: string;
  80871. };
  80872. "y-axis": {
  80873. rootNodeName: string;
  80874. };
  80875. };
  80876. };
  80877. };
  80878. /**
  80879. * The base url used to load the left and right controller models
  80880. */
  80881. static MODEL_BASE_URL: string;
  80882. /**
  80883. * The name of the left controller model file
  80884. */
  80885. static MODEL_LEFT_FILENAME: string;
  80886. /**
  80887. * The name of the right controller model file
  80888. */
  80889. static MODEL_RIGHT_FILENAME: string;
  80890. profileId: string;
  80891. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80892. protected _getFilenameAndPath(): {
  80893. filename: string;
  80894. path: string;
  80895. };
  80896. protected _getModelLoadingConstraints(): boolean;
  80897. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80898. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80899. protected _updateModel(): void;
  80900. }
  80901. }
  80902. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80903. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80905. import { Scene } from "babylonjs/scene";
  80906. /**
  80907. * The motion controller class for oculus touch (quest, rift).
  80908. * This class supports legacy mapping as well the standard xr mapping
  80909. */
  80910. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80911. private _forceLegacyControllers;
  80912. private _modelRootNode;
  80913. /**
  80914. * The base url used to load the left and right controller models
  80915. */
  80916. static MODEL_BASE_URL: string;
  80917. /**
  80918. * The name of the left controller model file
  80919. */
  80920. static MODEL_LEFT_FILENAME: string;
  80921. /**
  80922. * The name of the right controller model file
  80923. */
  80924. static MODEL_RIGHT_FILENAME: string;
  80925. /**
  80926. * Base Url for the Quest controller model.
  80927. */
  80928. static QUEST_MODEL_BASE_URL: string;
  80929. profileId: string;
  80930. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80931. protected _getFilenameAndPath(): {
  80932. filename: string;
  80933. path: string;
  80934. };
  80935. protected _getModelLoadingConstraints(): boolean;
  80936. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80937. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80938. protected _updateModel(): void;
  80939. /**
  80940. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80941. * between the touch and touch 2.
  80942. */
  80943. private _isQuest;
  80944. }
  80945. }
  80946. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80947. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80948. import { Scene } from "babylonjs/scene";
  80949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80950. /**
  80951. * The motion controller class for the standard HTC-Vive controllers
  80952. */
  80953. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80954. private _modelRootNode;
  80955. /**
  80956. * The base url used to load the left and right controller models
  80957. */
  80958. static MODEL_BASE_URL: string;
  80959. /**
  80960. * File name for the controller model.
  80961. */
  80962. static MODEL_FILENAME: string;
  80963. profileId: string;
  80964. /**
  80965. * Create a new Vive motion controller object
  80966. * @param scene the scene to use to create this controller
  80967. * @param gamepadObject the corresponding gamepad object
  80968. * @param handedness the handedness of the controller
  80969. */
  80970. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80971. protected _getFilenameAndPath(): {
  80972. filename: string;
  80973. path: string;
  80974. };
  80975. protected _getModelLoadingConstraints(): boolean;
  80976. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80977. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80978. protected _updateModel(): void;
  80979. }
  80980. }
  80981. declare module "babylonjs/XR/motionController/index" {
  80982. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80983. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80984. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80985. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80986. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80987. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80988. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80989. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80990. }
  80991. declare module "babylonjs/XR/index" {
  80992. export * from "babylonjs/XR/webXRCamera";
  80993. export * from "babylonjs/XR/webXREnterExitUI";
  80994. export * from "babylonjs/XR/webXRExperienceHelper";
  80995. export * from "babylonjs/XR/webXRInput";
  80996. export * from "babylonjs/XR/webXRInputSource";
  80997. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80998. export * from "babylonjs/XR/webXRTypes";
  80999. export * from "babylonjs/XR/webXRSessionManager";
  81000. export * from "babylonjs/XR/webXRDefaultExperience";
  81001. export * from "babylonjs/XR/webXRFeaturesManager";
  81002. export * from "babylonjs/XR/features/index";
  81003. export * from "babylonjs/XR/motionController/index";
  81004. }
  81005. declare module "babylonjs/index" {
  81006. export * from "babylonjs/abstractScene";
  81007. export * from "babylonjs/Actions/index";
  81008. export * from "babylonjs/Animations/index";
  81009. export * from "babylonjs/assetContainer";
  81010. export * from "babylonjs/Audio/index";
  81011. export * from "babylonjs/Behaviors/index";
  81012. export * from "babylonjs/Bones/index";
  81013. export * from "babylonjs/Cameras/index";
  81014. export * from "babylonjs/Collisions/index";
  81015. export * from "babylonjs/Culling/index";
  81016. export * from "babylonjs/Debug/index";
  81017. export * from "babylonjs/DeviceInput/index";
  81018. export * from "babylonjs/Engines/index";
  81019. export * from "babylonjs/Events/index";
  81020. export * from "babylonjs/Gamepads/index";
  81021. export * from "babylonjs/Gizmos/index";
  81022. export * from "babylonjs/Helpers/index";
  81023. export * from "babylonjs/Instrumentation/index";
  81024. export * from "babylonjs/Layers/index";
  81025. export * from "babylonjs/LensFlares/index";
  81026. export * from "babylonjs/Lights/index";
  81027. export * from "babylonjs/Loading/index";
  81028. export * from "babylonjs/Materials/index";
  81029. export * from "babylonjs/Maths/index";
  81030. export * from "babylonjs/Meshes/index";
  81031. export * from "babylonjs/Morph/index";
  81032. export * from "babylonjs/Navigation/index";
  81033. export * from "babylonjs/node";
  81034. export * from "babylonjs/Offline/index";
  81035. export * from "babylonjs/Particles/index";
  81036. export * from "babylonjs/Physics/index";
  81037. export * from "babylonjs/PostProcesses/index";
  81038. export * from "babylonjs/Probes/index";
  81039. export * from "babylonjs/Rendering/index";
  81040. export * from "babylonjs/scene";
  81041. export * from "babylonjs/sceneComponent";
  81042. export * from "babylonjs/Sprites/index";
  81043. export * from "babylonjs/States/index";
  81044. export * from "babylonjs/Misc/index";
  81045. export * from "babylonjs/XR/index";
  81046. export * from "babylonjs/types";
  81047. }
  81048. declare module "babylonjs/Animations/pathCursor" {
  81049. import { Vector3 } from "babylonjs/Maths/math.vector";
  81050. import { Path2 } from "babylonjs/Maths/math.path";
  81051. /**
  81052. * A cursor which tracks a point on a path
  81053. */
  81054. export class PathCursor {
  81055. private path;
  81056. /**
  81057. * Stores path cursor callbacks for when an onchange event is triggered
  81058. */
  81059. private _onchange;
  81060. /**
  81061. * The value of the path cursor
  81062. */
  81063. value: number;
  81064. /**
  81065. * The animation array of the path cursor
  81066. */
  81067. animations: Animation[];
  81068. /**
  81069. * Initializes the path cursor
  81070. * @param path The path to track
  81071. */
  81072. constructor(path: Path2);
  81073. /**
  81074. * Gets the cursor point on the path
  81075. * @returns A point on the path cursor at the cursor location
  81076. */
  81077. getPoint(): Vector3;
  81078. /**
  81079. * Moves the cursor ahead by the step amount
  81080. * @param step The amount to move the cursor forward
  81081. * @returns This path cursor
  81082. */
  81083. moveAhead(step?: number): PathCursor;
  81084. /**
  81085. * Moves the cursor behind by the step amount
  81086. * @param step The amount to move the cursor back
  81087. * @returns This path cursor
  81088. */
  81089. moveBack(step?: number): PathCursor;
  81090. /**
  81091. * Moves the cursor by the step amount
  81092. * If the step amount is greater than one, an exception is thrown
  81093. * @param step The amount to move the cursor
  81094. * @returns This path cursor
  81095. */
  81096. move(step: number): PathCursor;
  81097. /**
  81098. * Ensures that the value is limited between zero and one
  81099. * @returns This path cursor
  81100. */
  81101. private ensureLimits;
  81102. /**
  81103. * Runs onchange callbacks on change (used by the animation engine)
  81104. * @returns This path cursor
  81105. */
  81106. private raiseOnChange;
  81107. /**
  81108. * Executes a function on change
  81109. * @param f A path cursor onchange callback
  81110. * @returns This path cursor
  81111. */
  81112. onchange(f: (cursor: PathCursor) => void): PathCursor;
  81113. }
  81114. }
  81115. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  81116. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  81117. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  81118. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  81119. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  81120. }
  81121. declare module "babylonjs/Engines/Processors/Expressions/index" {
  81122. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  81123. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  81124. }
  81125. declare module "babylonjs/Engines/Processors/index" {
  81126. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  81127. export * from "babylonjs/Engines/Processors/Expressions/index";
  81128. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  81129. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  81130. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  81131. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  81132. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  81133. export * from "babylonjs/Engines/Processors/shaderProcessor";
  81134. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  81135. }
  81136. declare module "babylonjs/Legacy/legacy" {
  81137. import * as Babylon from "babylonjs/index";
  81138. export * from "babylonjs/index";
  81139. }
  81140. declare module "babylonjs/Shaders/blur.fragment" {
  81141. /** @hidden */
  81142. export var blurPixelShader: {
  81143. name: string;
  81144. shader: string;
  81145. };
  81146. }
  81147. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  81148. /** @hidden */
  81149. export var pointCloudVertexDeclaration: {
  81150. name: string;
  81151. shader: string;
  81152. };
  81153. }
  81154. declare module "babylonjs" {
  81155. export * from "babylonjs/Legacy/legacy";
  81156. }
  81157. declare module BABYLON {
  81158. /** Alias type for value that can be null */
  81159. export type Nullable<T> = T | null;
  81160. /**
  81161. * Alias type for number that are floats
  81162. * @ignorenaming
  81163. */
  81164. export type float = number;
  81165. /**
  81166. * Alias type for number that are doubles.
  81167. * @ignorenaming
  81168. */
  81169. export type double = number;
  81170. /**
  81171. * Alias type for number that are integer
  81172. * @ignorenaming
  81173. */
  81174. export type int = number;
  81175. /** Alias type for number array or Float32Array */
  81176. export type FloatArray = number[] | Float32Array;
  81177. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  81178. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  81179. /**
  81180. * Alias for types that can be used by a Buffer or VertexBuffer.
  81181. */
  81182. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  81183. /**
  81184. * Alias type for primitive types
  81185. * @ignorenaming
  81186. */
  81187. type Primitive = undefined | null | boolean | string | number | Function;
  81188. /**
  81189. * Type modifier to make all the properties of an object Readonly
  81190. */
  81191. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  81192. /**
  81193. * Type modifier to make all the properties of an object Readonly recursively
  81194. */
  81195. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  81196. /**
  81197. * Type modifier to make object properties readonly.
  81198. */
  81199. export type DeepImmutableObject<T> = {
  81200. readonly [K in keyof T]: DeepImmutable<T[K]>;
  81201. };
  81202. /** @hidden */
  81203. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  81204. }
  81205. }
  81206. declare module BABYLON {
  81207. /**
  81208. * A class serves as a medium between the observable and its observers
  81209. */
  81210. export class EventState {
  81211. /**
  81212. * Create a new EventState
  81213. * @param mask defines the mask associated with this state
  81214. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81215. * @param target defines the original target of the state
  81216. * @param currentTarget defines the current target of the state
  81217. */
  81218. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  81219. /**
  81220. * Initialize the current event state
  81221. * @param mask defines the mask associated with this state
  81222. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81223. * @param target defines the original target of the state
  81224. * @param currentTarget defines the current target of the state
  81225. * @returns the current event state
  81226. */
  81227. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  81228. /**
  81229. * An Observer can set this property to true to prevent subsequent observers of being notified
  81230. */
  81231. skipNextObservers: boolean;
  81232. /**
  81233. * Get the mask value that were used to trigger the event corresponding to this EventState object
  81234. */
  81235. mask: number;
  81236. /**
  81237. * The object that originally notified the event
  81238. */
  81239. target?: any;
  81240. /**
  81241. * The current object in the bubbling phase
  81242. */
  81243. currentTarget?: any;
  81244. /**
  81245. * This will be populated with the return value of the last function that was executed.
  81246. * If it is the first function in the callback chain it will be the event data.
  81247. */
  81248. lastReturnValue?: any;
  81249. /**
  81250. * User defined information that will be sent to observers
  81251. */
  81252. userInfo?: any;
  81253. }
  81254. /**
  81255. * Represent an Observer registered to a given Observable object.
  81256. */
  81257. export class Observer<T> {
  81258. /**
  81259. * Defines the callback to call when the observer is notified
  81260. */
  81261. callback: (eventData: T, eventState: EventState) => void;
  81262. /**
  81263. * Defines the mask of the observer (used to filter notifications)
  81264. */
  81265. mask: number;
  81266. /**
  81267. * Defines the current scope used to restore the JS context
  81268. */
  81269. scope: any;
  81270. /** @hidden */
  81271. _willBeUnregistered: boolean;
  81272. /**
  81273. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  81274. */
  81275. unregisterOnNextCall: boolean;
  81276. /**
  81277. * Creates a new observer
  81278. * @param callback defines the callback to call when the observer is notified
  81279. * @param mask defines the mask of the observer (used to filter notifications)
  81280. * @param scope defines the current scope used to restore the JS context
  81281. */
  81282. constructor(
  81283. /**
  81284. * Defines the callback to call when the observer is notified
  81285. */
  81286. callback: (eventData: T, eventState: EventState) => void,
  81287. /**
  81288. * Defines the mask of the observer (used to filter notifications)
  81289. */
  81290. mask: number,
  81291. /**
  81292. * Defines the current scope used to restore the JS context
  81293. */
  81294. scope?: any);
  81295. }
  81296. /**
  81297. * Represent a list of observers registered to multiple Observables object.
  81298. */
  81299. export class MultiObserver<T> {
  81300. private _observers;
  81301. private _observables;
  81302. /**
  81303. * Release associated resources
  81304. */
  81305. dispose(): void;
  81306. /**
  81307. * Raise a callback when one of the observable will notify
  81308. * @param observables defines a list of observables to watch
  81309. * @param callback defines the callback to call on notification
  81310. * @param mask defines the mask used to filter notifications
  81311. * @param scope defines the current scope used to restore the JS context
  81312. * @returns the new MultiObserver
  81313. */
  81314. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  81315. }
  81316. /**
  81317. * The Observable class is a simple implementation of the Observable pattern.
  81318. *
  81319. * 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.
  81320. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  81321. * 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).
  81322. * 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.
  81323. */
  81324. export class Observable<T> {
  81325. private _observers;
  81326. private _eventState;
  81327. private _onObserverAdded;
  81328. /**
  81329. * Gets the list of observers
  81330. */
  81331. get observers(): Array<Observer<T>>;
  81332. /**
  81333. * Creates a new observable
  81334. * @param onObserverAdded defines a callback to call when a new observer is added
  81335. */
  81336. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  81337. /**
  81338. * Create a new Observer with the specified callback
  81339. * @param callback the callback that will be executed for that Observer
  81340. * @param mask the mask used to filter observers
  81341. * @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.
  81342. * @param scope optional scope for the callback to be called from
  81343. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  81344. * @returns the new observer created for the callback
  81345. */
  81346. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  81347. /**
  81348. * Create a new Observer with the specified callback and unregisters after the next notification
  81349. * @param callback the callback that will be executed for that Observer
  81350. * @returns the new observer created for the callback
  81351. */
  81352. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  81353. /**
  81354. * Remove an Observer from the Observable object
  81355. * @param observer the instance of the Observer to remove
  81356. * @returns false if it doesn't belong to this Observable
  81357. */
  81358. remove(observer: Nullable<Observer<T>>): boolean;
  81359. /**
  81360. * Remove a callback from the Observable object
  81361. * @param callback the callback to remove
  81362. * @param scope optional scope. If used only the callbacks with this scope will be removed
  81363. * @returns false if it doesn't belong to this Observable
  81364. */
  81365. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  81366. private _deferUnregister;
  81367. private _remove;
  81368. /**
  81369. * Moves the observable to the top of the observer list making it get called first when notified
  81370. * @param observer the observer to move
  81371. */
  81372. makeObserverTopPriority(observer: Observer<T>): void;
  81373. /**
  81374. * Moves the observable to the bottom of the observer list making it get called last when notified
  81375. * @param observer the observer to move
  81376. */
  81377. makeObserverBottomPriority(observer: Observer<T>): void;
  81378. /**
  81379. * Notify all Observers by calling their respective callback with the given data
  81380. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  81381. * @param eventData defines the data to send to all observers
  81382. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  81383. * @param target defines the original target of the state
  81384. * @param currentTarget defines the current target of the state
  81385. * @param userInfo defines any user info to send to observers
  81386. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  81387. */
  81388. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  81389. /**
  81390. * Calling this will execute each callback, expecting it to be a promise or return a value.
  81391. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  81392. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  81393. * and it is crucial that all callbacks will be executed.
  81394. * The order of the callbacks is kept, callbacks are not executed parallel.
  81395. *
  81396. * @param eventData The data to be sent to each callback
  81397. * @param mask is used to filter observers defaults to -1
  81398. * @param target defines the callback target (see EventState)
  81399. * @param currentTarget defines he current object in the bubbling phase
  81400. * @param userInfo defines any user info to send to observers
  81401. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  81402. */
  81403. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  81404. /**
  81405. * Notify a specific observer
  81406. * @param observer defines the observer to notify
  81407. * @param eventData defines the data to be sent to each callback
  81408. * @param mask is used to filter observers defaults to -1
  81409. */
  81410. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  81411. /**
  81412. * Gets a boolean indicating if the observable has at least one observer
  81413. * @returns true is the Observable has at least one Observer registered
  81414. */
  81415. hasObservers(): boolean;
  81416. /**
  81417. * Clear the list of observers
  81418. */
  81419. clear(): void;
  81420. /**
  81421. * Clone the current observable
  81422. * @returns a new observable
  81423. */
  81424. clone(): Observable<T>;
  81425. /**
  81426. * Does this observable handles observer registered with a given mask
  81427. * @param mask defines the mask to be tested
  81428. * @return whether or not one observer registered with the given mask is handeled
  81429. **/
  81430. hasSpecificMask(mask?: number): boolean;
  81431. }
  81432. }
  81433. declare module BABYLON {
  81434. /**
  81435. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  81436. * Babylon.js
  81437. */
  81438. export class DomManagement {
  81439. /**
  81440. * Checks if the window object exists
  81441. * @returns true if the window object exists
  81442. */
  81443. static IsWindowObjectExist(): boolean;
  81444. /**
  81445. * Checks if the navigator object exists
  81446. * @returns true if the navigator object exists
  81447. */
  81448. static IsNavigatorAvailable(): boolean;
  81449. /**
  81450. * Check if the document object exists
  81451. * @returns true if the document object exists
  81452. */
  81453. static IsDocumentAvailable(): boolean;
  81454. /**
  81455. * Extracts text content from a DOM element hierarchy
  81456. * @param element defines the root element
  81457. * @returns a string
  81458. */
  81459. static GetDOMTextContent(element: HTMLElement): string;
  81460. }
  81461. }
  81462. declare module BABYLON {
  81463. /**
  81464. * Logger used througouht the application to allow configuration of
  81465. * the log level required for the messages.
  81466. */
  81467. export class Logger {
  81468. /**
  81469. * No log
  81470. */
  81471. static readonly NoneLogLevel: number;
  81472. /**
  81473. * Only message logs
  81474. */
  81475. static readonly MessageLogLevel: number;
  81476. /**
  81477. * Only warning logs
  81478. */
  81479. static readonly WarningLogLevel: number;
  81480. /**
  81481. * Only error logs
  81482. */
  81483. static readonly ErrorLogLevel: number;
  81484. /**
  81485. * All logs
  81486. */
  81487. static readonly AllLogLevel: number;
  81488. private static _LogCache;
  81489. /**
  81490. * Gets a value indicating the number of loading errors
  81491. * @ignorenaming
  81492. */
  81493. static errorsCount: number;
  81494. /**
  81495. * Callback called when a new log is added
  81496. */
  81497. static OnNewCacheEntry: (entry: string) => void;
  81498. private static _AddLogEntry;
  81499. private static _FormatMessage;
  81500. private static _LogDisabled;
  81501. private static _LogEnabled;
  81502. private static _WarnDisabled;
  81503. private static _WarnEnabled;
  81504. private static _ErrorDisabled;
  81505. private static _ErrorEnabled;
  81506. /**
  81507. * Log a message to the console
  81508. */
  81509. static Log: (message: string) => void;
  81510. /**
  81511. * Write a warning message to the console
  81512. */
  81513. static Warn: (message: string) => void;
  81514. /**
  81515. * Write an error message to the console
  81516. */
  81517. static Error: (message: string) => void;
  81518. /**
  81519. * Gets current log cache (list of logs)
  81520. */
  81521. static get LogCache(): string;
  81522. /**
  81523. * Clears the log cache
  81524. */
  81525. static ClearLogCache(): void;
  81526. /**
  81527. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  81528. */
  81529. static set LogLevels(level: number);
  81530. }
  81531. }
  81532. declare module BABYLON {
  81533. /** @hidden */
  81534. export class _TypeStore {
  81535. /** @hidden */
  81536. static RegisteredTypes: {
  81537. [key: string]: Object;
  81538. };
  81539. /** @hidden */
  81540. static GetClass(fqdn: string): any;
  81541. }
  81542. }
  81543. declare module BABYLON {
  81544. /**
  81545. * Helper to manipulate strings
  81546. */
  81547. export class StringTools {
  81548. /**
  81549. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  81550. * @param str Source string
  81551. * @param suffix Suffix to search for in the source string
  81552. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81553. */
  81554. static EndsWith(str: string, suffix: string): boolean;
  81555. /**
  81556. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  81557. * @param str Source string
  81558. * @param suffix Suffix to search for in the source string
  81559. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81560. */
  81561. static StartsWith(str: string, suffix: string): boolean;
  81562. /**
  81563. * Decodes a buffer into a string
  81564. * @param buffer The buffer to decode
  81565. * @returns The decoded string
  81566. */
  81567. static Decode(buffer: Uint8Array | Uint16Array): string;
  81568. /**
  81569. * Encode a buffer to a base64 string
  81570. * @param buffer defines the buffer to encode
  81571. * @returns the encoded string
  81572. */
  81573. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  81574. /**
  81575. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  81576. * @param num the number to convert and pad
  81577. * @param length the expected length of the string
  81578. * @returns the padded string
  81579. */
  81580. static PadNumber(num: number, length: number): string;
  81581. }
  81582. }
  81583. declare module BABYLON {
  81584. /**
  81585. * Class containing a set of static utilities functions for deep copy.
  81586. */
  81587. export class DeepCopier {
  81588. /**
  81589. * Tries to copy an object by duplicating every property
  81590. * @param source defines the source object
  81591. * @param destination defines the target object
  81592. * @param doNotCopyList defines a list of properties to avoid
  81593. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  81594. */
  81595. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  81596. }
  81597. }
  81598. declare module BABYLON {
  81599. /**
  81600. * Class containing a set of static utilities functions for precision date
  81601. */
  81602. export class PrecisionDate {
  81603. /**
  81604. * Gets either window.performance.now() if supported or Date.now() else
  81605. */
  81606. static get Now(): number;
  81607. }
  81608. }
  81609. declare module BABYLON {
  81610. /** @hidden */
  81611. export class _DevTools {
  81612. static WarnImport(name: string): string;
  81613. }
  81614. }
  81615. declare module BABYLON {
  81616. /**
  81617. * Interface used to define the mechanism to get data from the network
  81618. */
  81619. export interface IWebRequest {
  81620. /**
  81621. * Returns client's response url
  81622. */
  81623. responseURL: string;
  81624. /**
  81625. * Returns client's status
  81626. */
  81627. status: number;
  81628. /**
  81629. * Returns client's status as a text
  81630. */
  81631. statusText: string;
  81632. }
  81633. }
  81634. declare module BABYLON {
  81635. /**
  81636. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  81637. */
  81638. export class WebRequest implements IWebRequest {
  81639. private readonly _xhr;
  81640. /**
  81641. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  81642. * i.e. when loading files, where the server/service expects an Authorization header
  81643. */
  81644. static CustomRequestHeaders: {
  81645. [key: string]: string;
  81646. };
  81647. /**
  81648. * Add callback functions in this array to update all the requests before they get sent to the network
  81649. */
  81650. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  81651. private _injectCustomRequestHeaders;
  81652. /**
  81653. * Gets or sets a function to be called when loading progress changes
  81654. */
  81655. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  81656. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  81657. /**
  81658. * Returns client's state
  81659. */
  81660. get readyState(): number;
  81661. /**
  81662. * Returns client's status
  81663. */
  81664. get status(): number;
  81665. /**
  81666. * Returns client's status as a text
  81667. */
  81668. get statusText(): string;
  81669. /**
  81670. * Returns client's response
  81671. */
  81672. get response(): any;
  81673. /**
  81674. * Returns client's response url
  81675. */
  81676. get responseURL(): string;
  81677. /**
  81678. * Returns client's response as text
  81679. */
  81680. get responseText(): string;
  81681. /**
  81682. * Gets or sets the expected response type
  81683. */
  81684. get responseType(): XMLHttpRequestResponseType;
  81685. set responseType(value: XMLHttpRequestResponseType);
  81686. /** @hidden */
  81687. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81688. /** @hidden */
  81689. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81690. /**
  81691. * Cancels any network activity
  81692. */
  81693. abort(): void;
  81694. /**
  81695. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81696. * @param body defines an optional request body
  81697. */
  81698. send(body?: Document | BodyInit | null): void;
  81699. /**
  81700. * Sets the request method, request URL
  81701. * @param method defines the method to use (GET, POST, etc..)
  81702. * @param url defines the url to connect with
  81703. */
  81704. open(method: string, url: string): void;
  81705. /**
  81706. * Sets the value of a request header.
  81707. * @param name The name of the header whose value is to be set
  81708. * @param value The value to set as the body of the header
  81709. */
  81710. setRequestHeader(name: string, value: string): void;
  81711. /**
  81712. * Get the string containing the text of a particular header's value.
  81713. * @param name The name of the header
  81714. * @returns The string containing the text of the given header name
  81715. */
  81716. getResponseHeader(name: string): Nullable<string>;
  81717. }
  81718. }
  81719. declare module BABYLON {
  81720. /**
  81721. * File request interface
  81722. */
  81723. export interface IFileRequest {
  81724. /**
  81725. * Raised when the request is complete (success or error).
  81726. */
  81727. onCompleteObservable: Observable<IFileRequest>;
  81728. /**
  81729. * Aborts the request for a file.
  81730. */
  81731. abort: () => void;
  81732. }
  81733. }
  81734. declare module BABYLON {
  81735. /**
  81736. * Define options used to create a render target texture
  81737. */
  81738. export class RenderTargetCreationOptions {
  81739. /**
  81740. * Specifies is mipmaps must be generated
  81741. */
  81742. generateMipMaps?: boolean;
  81743. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  81744. generateDepthBuffer?: boolean;
  81745. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  81746. generateStencilBuffer?: boolean;
  81747. /** Defines texture type (int by default) */
  81748. type?: number;
  81749. /** Defines sampling mode (trilinear by default) */
  81750. samplingMode?: number;
  81751. /** Defines format (RGBA by default) */
  81752. format?: number;
  81753. }
  81754. }
  81755. declare module BABYLON {
  81756. /** Defines the cross module used constants to avoid circular dependncies */
  81757. export class Constants {
  81758. /** Defines that alpha blending is disabled */
  81759. static readonly ALPHA_DISABLE: number;
  81760. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  81761. static readonly ALPHA_ADD: number;
  81762. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  81763. static readonly ALPHA_COMBINE: number;
  81764. /** Defines that alpha blending is DEST - SRC * DEST */
  81765. static readonly ALPHA_SUBTRACT: number;
  81766. /** Defines that alpha blending is SRC * DEST */
  81767. static readonly ALPHA_MULTIPLY: number;
  81768. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  81769. static readonly ALPHA_MAXIMIZED: number;
  81770. /** Defines that alpha blending is SRC + DEST */
  81771. static readonly ALPHA_ONEONE: number;
  81772. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  81773. static readonly ALPHA_PREMULTIPLIED: number;
  81774. /**
  81775. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  81776. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  81777. */
  81778. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  81779. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  81780. static readonly ALPHA_INTERPOLATE: number;
  81781. /**
  81782. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  81783. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  81784. */
  81785. static readonly ALPHA_SCREENMODE: number;
  81786. /**
  81787. * Defines that alpha blending is SRC + DST
  81788. * Alpha will be set to SRC ALPHA + DST ALPHA
  81789. */
  81790. static readonly ALPHA_ONEONE_ONEONE: number;
  81791. /**
  81792. * Defines that alpha blending is SRC * DST ALPHA + DST
  81793. * Alpha will be set to 0
  81794. */
  81795. static readonly ALPHA_ALPHATOCOLOR: number;
  81796. /**
  81797. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81798. */
  81799. static readonly ALPHA_REVERSEONEMINUS: number;
  81800. /**
  81801. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  81802. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  81803. */
  81804. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  81805. /**
  81806. * Defines that alpha blending is SRC + DST
  81807. * Alpha will be set to SRC ALPHA
  81808. */
  81809. static readonly ALPHA_ONEONE_ONEZERO: number;
  81810. /**
  81811. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81812. * Alpha will be set to DST ALPHA
  81813. */
  81814. static readonly ALPHA_EXCLUSION: number;
  81815. /** Defines that alpha blending equation a SUM */
  81816. static readonly ALPHA_EQUATION_ADD: number;
  81817. /** Defines that alpha blending equation a SUBSTRACTION */
  81818. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  81819. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  81820. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  81821. /** Defines that alpha blending equation a MAX operation */
  81822. static readonly ALPHA_EQUATION_MAX: number;
  81823. /** Defines that alpha blending equation a MIN operation */
  81824. static readonly ALPHA_EQUATION_MIN: number;
  81825. /**
  81826. * Defines that alpha blending equation a DARKEN operation:
  81827. * It takes the min of the src and sums the alpha channels.
  81828. */
  81829. static readonly ALPHA_EQUATION_DARKEN: number;
  81830. /** Defines that the ressource is not delayed*/
  81831. static readonly DELAYLOADSTATE_NONE: number;
  81832. /** Defines that the ressource was successfully delay loaded */
  81833. static readonly DELAYLOADSTATE_LOADED: number;
  81834. /** Defines that the ressource is currently delay loading */
  81835. static readonly DELAYLOADSTATE_LOADING: number;
  81836. /** Defines that the ressource is delayed and has not started loading */
  81837. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81838. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81839. static readonly NEVER: number;
  81840. /** 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 */
  81841. static readonly ALWAYS: number;
  81842. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81843. static readonly LESS: number;
  81844. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81845. static readonly EQUAL: number;
  81846. /** 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 */
  81847. static readonly LEQUAL: number;
  81848. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81849. static readonly GREATER: number;
  81850. /** 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 */
  81851. static readonly GEQUAL: number;
  81852. /** 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 */
  81853. static readonly NOTEQUAL: number;
  81854. /** Passed to stencilOperation to specify that stencil value must be kept */
  81855. static readonly KEEP: number;
  81856. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81857. static readonly REPLACE: number;
  81858. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81859. static readonly INCR: number;
  81860. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81861. static readonly DECR: number;
  81862. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81863. static readonly INVERT: number;
  81864. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81865. static readonly INCR_WRAP: number;
  81866. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81867. static readonly DECR_WRAP: number;
  81868. /** Texture is not repeating outside of 0..1 UVs */
  81869. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81870. /** Texture is repeating outside of 0..1 UVs */
  81871. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81872. /** Texture is repeating and mirrored */
  81873. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81874. /** ALPHA */
  81875. static readonly TEXTUREFORMAT_ALPHA: number;
  81876. /** LUMINANCE */
  81877. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81878. /** LUMINANCE_ALPHA */
  81879. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81880. /** RGB */
  81881. static readonly TEXTUREFORMAT_RGB: number;
  81882. /** RGBA */
  81883. static readonly TEXTUREFORMAT_RGBA: number;
  81884. /** RED */
  81885. static readonly TEXTUREFORMAT_RED: number;
  81886. /** RED (2nd reference) */
  81887. static readonly TEXTUREFORMAT_R: number;
  81888. /** RG */
  81889. static readonly TEXTUREFORMAT_RG: number;
  81890. /** RED_INTEGER */
  81891. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81892. /** RED_INTEGER (2nd reference) */
  81893. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81894. /** RG_INTEGER */
  81895. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81896. /** RGB_INTEGER */
  81897. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81898. /** RGBA_INTEGER */
  81899. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81900. /** UNSIGNED_BYTE */
  81901. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81902. /** UNSIGNED_BYTE (2nd reference) */
  81903. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81904. /** FLOAT */
  81905. static readonly TEXTURETYPE_FLOAT: number;
  81906. /** HALF_FLOAT */
  81907. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81908. /** BYTE */
  81909. static readonly TEXTURETYPE_BYTE: number;
  81910. /** SHORT */
  81911. static readonly TEXTURETYPE_SHORT: number;
  81912. /** UNSIGNED_SHORT */
  81913. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81914. /** INT */
  81915. static readonly TEXTURETYPE_INT: number;
  81916. /** UNSIGNED_INT */
  81917. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81918. /** UNSIGNED_SHORT_4_4_4_4 */
  81919. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81920. /** UNSIGNED_SHORT_5_5_5_1 */
  81921. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81922. /** UNSIGNED_SHORT_5_6_5 */
  81923. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81924. /** UNSIGNED_INT_2_10_10_10_REV */
  81925. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81926. /** UNSIGNED_INT_24_8 */
  81927. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81928. /** UNSIGNED_INT_10F_11F_11F_REV */
  81929. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81930. /** UNSIGNED_INT_5_9_9_9_REV */
  81931. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81932. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81933. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81934. /** nearest is mag = nearest and min = nearest and no mip */
  81935. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81936. /** mag = nearest and min = nearest and mip = none */
  81937. static readonly TEXTURE_NEAREST_NEAREST: number;
  81938. /** Bilinear is mag = linear and min = linear and no mip */
  81939. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81940. /** mag = linear and min = linear and mip = none */
  81941. static readonly TEXTURE_LINEAR_LINEAR: number;
  81942. /** Trilinear is mag = linear and min = linear and mip = linear */
  81943. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81944. /** Trilinear is mag = linear and min = linear and mip = linear */
  81945. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81946. /** mag = nearest and min = nearest and mip = nearest */
  81947. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81948. /** mag = nearest and min = linear and mip = nearest */
  81949. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81950. /** mag = nearest and min = linear and mip = linear */
  81951. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81952. /** mag = nearest and min = linear and mip = none */
  81953. static readonly TEXTURE_NEAREST_LINEAR: number;
  81954. /** nearest is mag = nearest and min = nearest and mip = linear */
  81955. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81956. /** mag = linear and min = nearest and mip = nearest */
  81957. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81958. /** mag = linear and min = nearest and mip = linear */
  81959. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81960. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81961. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81962. /** mag = linear and min = nearest and mip = none */
  81963. static readonly TEXTURE_LINEAR_NEAREST: number;
  81964. /** Explicit coordinates mode */
  81965. static readonly TEXTURE_EXPLICIT_MODE: number;
  81966. /** Spherical coordinates mode */
  81967. static readonly TEXTURE_SPHERICAL_MODE: number;
  81968. /** Planar coordinates mode */
  81969. static readonly TEXTURE_PLANAR_MODE: number;
  81970. /** Cubic coordinates mode */
  81971. static readonly TEXTURE_CUBIC_MODE: number;
  81972. /** Projection coordinates mode */
  81973. static readonly TEXTURE_PROJECTION_MODE: number;
  81974. /** Skybox coordinates mode */
  81975. static readonly TEXTURE_SKYBOX_MODE: number;
  81976. /** Inverse Cubic coordinates mode */
  81977. static readonly TEXTURE_INVCUBIC_MODE: number;
  81978. /** Equirectangular coordinates mode */
  81979. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81980. /** Equirectangular Fixed coordinates mode */
  81981. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81982. /** Equirectangular Fixed Mirrored coordinates mode */
  81983. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81984. /** Offline (baking) quality for texture filtering */
  81985. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81986. /** High quality for texture filtering */
  81987. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81988. /** Medium quality for texture filtering */
  81989. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81990. /** Low quality for texture filtering */
  81991. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81992. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81993. static readonly SCALEMODE_FLOOR: number;
  81994. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81995. static readonly SCALEMODE_NEAREST: number;
  81996. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81997. static readonly SCALEMODE_CEILING: number;
  81998. /**
  81999. * The dirty texture flag value
  82000. */
  82001. static readonly MATERIAL_TextureDirtyFlag: number;
  82002. /**
  82003. * The dirty light flag value
  82004. */
  82005. static readonly MATERIAL_LightDirtyFlag: number;
  82006. /**
  82007. * The dirty fresnel flag value
  82008. */
  82009. static readonly MATERIAL_FresnelDirtyFlag: number;
  82010. /**
  82011. * The dirty attribute flag value
  82012. */
  82013. static readonly MATERIAL_AttributesDirtyFlag: number;
  82014. /**
  82015. * The dirty misc flag value
  82016. */
  82017. static readonly MATERIAL_MiscDirtyFlag: number;
  82018. /**
  82019. * The dirty prepass flag value
  82020. */
  82021. static readonly MATERIAL_PrePassDirtyFlag: number;
  82022. /**
  82023. * The all dirty flag value
  82024. */
  82025. static readonly MATERIAL_AllDirtyFlag: number;
  82026. /**
  82027. * Returns the triangle fill mode
  82028. */
  82029. static readonly MATERIAL_TriangleFillMode: number;
  82030. /**
  82031. * Returns the wireframe mode
  82032. */
  82033. static readonly MATERIAL_WireFrameFillMode: number;
  82034. /**
  82035. * Returns the point fill mode
  82036. */
  82037. static readonly MATERIAL_PointFillMode: number;
  82038. /**
  82039. * Returns the point list draw mode
  82040. */
  82041. static readonly MATERIAL_PointListDrawMode: number;
  82042. /**
  82043. * Returns the line list draw mode
  82044. */
  82045. static readonly MATERIAL_LineListDrawMode: number;
  82046. /**
  82047. * Returns the line loop draw mode
  82048. */
  82049. static readonly MATERIAL_LineLoopDrawMode: number;
  82050. /**
  82051. * Returns the line strip draw mode
  82052. */
  82053. static readonly MATERIAL_LineStripDrawMode: number;
  82054. /**
  82055. * Returns the triangle strip draw mode
  82056. */
  82057. static readonly MATERIAL_TriangleStripDrawMode: number;
  82058. /**
  82059. * Returns the triangle fan draw mode
  82060. */
  82061. static readonly MATERIAL_TriangleFanDrawMode: number;
  82062. /**
  82063. * Stores the clock-wise side orientation
  82064. */
  82065. static readonly MATERIAL_ClockWiseSideOrientation: number;
  82066. /**
  82067. * Stores the counter clock-wise side orientation
  82068. */
  82069. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  82070. /**
  82071. * Nothing
  82072. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82073. */
  82074. static readonly ACTION_NothingTrigger: number;
  82075. /**
  82076. * On pick
  82077. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82078. */
  82079. static readonly ACTION_OnPickTrigger: number;
  82080. /**
  82081. * On left pick
  82082. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82083. */
  82084. static readonly ACTION_OnLeftPickTrigger: number;
  82085. /**
  82086. * On right pick
  82087. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82088. */
  82089. static readonly ACTION_OnRightPickTrigger: number;
  82090. /**
  82091. * On center pick
  82092. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82093. */
  82094. static readonly ACTION_OnCenterPickTrigger: number;
  82095. /**
  82096. * On pick down
  82097. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82098. */
  82099. static readonly ACTION_OnPickDownTrigger: number;
  82100. /**
  82101. * On double pick
  82102. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82103. */
  82104. static readonly ACTION_OnDoublePickTrigger: number;
  82105. /**
  82106. * On pick up
  82107. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82108. */
  82109. static readonly ACTION_OnPickUpTrigger: number;
  82110. /**
  82111. * On pick out.
  82112. * This trigger will only be raised if you also declared a OnPickDown
  82113. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82114. */
  82115. static readonly ACTION_OnPickOutTrigger: number;
  82116. /**
  82117. * On long press
  82118. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82119. */
  82120. static readonly ACTION_OnLongPressTrigger: number;
  82121. /**
  82122. * On pointer over
  82123. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82124. */
  82125. static readonly ACTION_OnPointerOverTrigger: number;
  82126. /**
  82127. * On pointer out
  82128. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82129. */
  82130. static readonly ACTION_OnPointerOutTrigger: number;
  82131. /**
  82132. * On every frame
  82133. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82134. */
  82135. static readonly ACTION_OnEveryFrameTrigger: number;
  82136. /**
  82137. * On intersection enter
  82138. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82139. */
  82140. static readonly ACTION_OnIntersectionEnterTrigger: number;
  82141. /**
  82142. * On intersection exit
  82143. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82144. */
  82145. static readonly ACTION_OnIntersectionExitTrigger: number;
  82146. /**
  82147. * On key down
  82148. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82149. */
  82150. static readonly ACTION_OnKeyDownTrigger: number;
  82151. /**
  82152. * On key up
  82153. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82154. */
  82155. static readonly ACTION_OnKeyUpTrigger: number;
  82156. /**
  82157. * Billboard mode will only apply to Y axis
  82158. */
  82159. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  82160. /**
  82161. * Billboard mode will apply to all axes
  82162. */
  82163. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  82164. /**
  82165. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82166. */
  82167. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  82168. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82169. * Test order :
  82170. * Is the bounding sphere outside the frustum ?
  82171. * If not, are the bounding box vertices outside the frustum ?
  82172. * It not, then the cullable object is in the frustum.
  82173. */
  82174. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  82175. /** Culling strategy : Bounding Sphere Only.
  82176. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82177. * It's also less accurate than the standard because some not visible objects can still be selected.
  82178. * Test : is the bounding sphere outside the frustum ?
  82179. * If not, then the cullable object is in the frustum.
  82180. */
  82181. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82182. /** Culling strategy : Optimistic Inclusion.
  82183. * This in an inclusion test first, then the standard exclusion test.
  82184. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82185. * 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.
  82186. * Anyway, it's as accurate as the standard strategy.
  82187. * Test :
  82188. * Is the cullable object bounding sphere center in the frustum ?
  82189. * If not, apply the default culling strategy.
  82190. */
  82191. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82192. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82193. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82194. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82195. * 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.
  82196. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82197. * Test :
  82198. * Is the cullable object bounding sphere center in the frustum ?
  82199. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82200. */
  82201. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82202. /**
  82203. * No logging while loading
  82204. */
  82205. static readonly SCENELOADER_NO_LOGGING: number;
  82206. /**
  82207. * Minimal logging while loading
  82208. */
  82209. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  82210. /**
  82211. * Summary logging while loading
  82212. */
  82213. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  82214. /**
  82215. * Detailled logging while loading
  82216. */
  82217. static readonly SCENELOADER_DETAILED_LOGGING: number;
  82218. /**
  82219. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  82220. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  82221. */
  82222. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  82223. /**
  82224. * Constant used to retrieve the position texture index in the textures array in the prepass
  82225. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  82226. */
  82227. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  82228. /**
  82229. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  82230. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  82231. */
  82232. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  82233. /**
  82234. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  82235. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  82236. */
  82237. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  82238. /**
  82239. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  82240. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  82241. */
  82242. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  82243. /**
  82244. * Constant used to retrieve depth + normal index in the textures array in the prepass
  82245. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  82246. */
  82247. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  82248. /**
  82249. * Constant used to retrieve albedo index in the textures array in the prepass
  82250. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  82251. */
  82252. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  82253. }
  82254. }
  82255. declare module BABYLON {
  82256. /**
  82257. * This represents the required contract to create a new type of texture loader.
  82258. */
  82259. export interface IInternalTextureLoader {
  82260. /**
  82261. * Defines wether the loader supports cascade loading the different faces.
  82262. */
  82263. supportCascades: boolean;
  82264. /**
  82265. * This returns if the loader support the current file information.
  82266. * @param extension defines the file extension of the file being loaded
  82267. * @param mimeType defines the optional mime type of the file being loaded
  82268. * @returns true if the loader can load the specified file
  82269. */
  82270. canLoad(extension: string, mimeType?: string): boolean;
  82271. /**
  82272. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  82273. * @param data contains the texture data
  82274. * @param texture defines the BabylonJS internal texture
  82275. * @param createPolynomials will be true if polynomials have been requested
  82276. * @param onLoad defines the callback to trigger once the texture is ready
  82277. * @param onError defines the callback to trigger in case of error
  82278. * @param options options to be passed to the loader
  82279. */
  82280. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  82281. /**
  82282. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  82283. * @param data contains the texture data
  82284. * @param texture defines the BabylonJS internal texture
  82285. * @param callback defines the method to call once ready to upload
  82286. * @param options options to be passed to the loader
  82287. */
  82288. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  82289. }
  82290. }
  82291. declare module BABYLON {
  82292. /**
  82293. * Class used to store and describe the pipeline context associated with an effect
  82294. */
  82295. export interface IPipelineContext {
  82296. /**
  82297. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  82298. */
  82299. isAsync: boolean;
  82300. /**
  82301. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  82302. */
  82303. isReady: boolean;
  82304. /** @hidden */
  82305. _getVertexShaderCode(): string | null;
  82306. /** @hidden */
  82307. _getFragmentShaderCode(): string | null;
  82308. /** @hidden */
  82309. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  82310. }
  82311. }
  82312. declare module BABYLON {
  82313. /**
  82314. * Class used to store gfx data (like WebGLBuffer)
  82315. */
  82316. export class DataBuffer {
  82317. /**
  82318. * Gets or sets the number of objects referencing this buffer
  82319. */
  82320. references: number;
  82321. /** Gets or sets the size of the underlying buffer */
  82322. capacity: number;
  82323. /**
  82324. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  82325. */
  82326. is32Bits: boolean;
  82327. /**
  82328. * Gets the underlying buffer
  82329. */
  82330. get underlyingResource(): any;
  82331. }
  82332. }
  82333. declare module BABYLON {
  82334. /** @hidden */
  82335. export interface IShaderProcessor {
  82336. attributeProcessor?: (attribute: string) => string;
  82337. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  82338. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  82339. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  82340. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  82341. lineProcessor?: (line: string, isFragment: boolean) => string;
  82342. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  82343. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  82344. }
  82345. }
  82346. declare module BABYLON {
  82347. /** @hidden */
  82348. export interface ProcessingOptions {
  82349. defines: string[];
  82350. indexParameters: any;
  82351. isFragment: boolean;
  82352. shouldUseHighPrecisionShader: boolean;
  82353. supportsUniformBuffers: boolean;
  82354. shadersRepository: string;
  82355. includesShadersStore: {
  82356. [key: string]: string;
  82357. };
  82358. processor?: IShaderProcessor;
  82359. version: string;
  82360. platformName: string;
  82361. lookForClosingBracketForUniformBuffer?: boolean;
  82362. }
  82363. }
  82364. declare module BABYLON {
  82365. /** @hidden */
  82366. export class ShaderCodeNode {
  82367. line: string;
  82368. children: ShaderCodeNode[];
  82369. additionalDefineKey?: string;
  82370. additionalDefineValue?: string;
  82371. isValid(preprocessors: {
  82372. [key: string]: string;
  82373. }): boolean;
  82374. process(preprocessors: {
  82375. [key: string]: string;
  82376. }, options: ProcessingOptions): string;
  82377. }
  82378. }
  82379. declare module BABYLON {
  82380. /** @hidden */
  82381. export class ShaderCodeCursor {
  82382. private _lines;
  82383. lineIndex: number;
  82384. get currentLine(): string;
  82385. get canRead(): boolean;
  82386. set lines(value: string[]);
  82387. }
  82388. }
  82389. declare module BABYLON {
  82390. /** @hidden */
  82391. export class ShaderCodeConditionNode extends ShaderCodeNode {
  82392. process(preprocessors: {
  82393. [key: string]: string;
  82394. }, options: ProcessingOptions): string;
  82395. }
  82396. }
  82397. declare module BABYLON {
  82398. /** @hidden */
  82399. export class ShaderDefineExpression {
  82400. isTrue(preprocessors: {
  82401. [key: string]: string;
  82402. }): boolean;
  82403. private static _OperatorPriority;
  82404. private static _Stack;
  82405. static postfixToInfix(postfix: string[]): string;
  82406. static infixToPostfix(infix: string): string[];
  82407. }
  82408. }
  82409. declare module BABYLON {
  82410. /** @hidden */
  82411. export class ShaderCodeTestNode extends ShaderCodeNode {
  82412. testExpression: ShaderDefineExpression;
  82413. isValid(preprocessors: {
  82414. [key: string]: string;
  82415. }): boolean;
  82416. }
  82417. }
  82418. declare module BABYLON {
  82419. /** @hidden */
  82420. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  82421. define: string;
  82422. not: boolean;
  82423. constructor(define: string, not?: boolean);
  82424. isTrue(preprocessors: {
  82425. [key: string]: string;
  82426. }): boolean;
  82427. }
  82428. }
  82429. declare module BABYLON {
  82430. /** @hidden */
  82431. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  82432. leftOperand: ShaderDefineExpression;
  82433. rightOperand: ShaderDefineExpression;
  82434. isTrue(preprocessors: {
  82435. [key: string]: string;
  82436. }): boolean;
  82437. }
  82438. }
  82439. declare module BABYLON {
  82440. /** @hidden */
  82441. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  82442. leftOperand: ShaderDefineExpression;
  82443. rightOperand: ShaderDefineExpression;
  82444. isTrue(preprocessors: {
  82445. [key: string]: string;
  82446. }): boolean;
  82447. }
  82448. }
  82449. declare module BABYLON {
  82450. /** @hidden */
  82451. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  82452. define: string;
  82453. operand: string;
  82454. testValue: string;
  82455. constructor(define: string, operand: string, testValue: string);
  82456. isTrue(preprocessors: {
  82457. [key: string]: string;
  82458. }): boolean;
  82459. }
  82460. }
  82461. declare module BABYLON {
  82462. /**
  82463. * Class used to enable access to offline support
  82464. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  82465. */
  82466. export interface IOfflineProvider {
  82467. /**
  82468. * Gets a boolean indicating if scene must be saved in the database
  82469. */
  82470. enableSceneOffline: boolean;
  82471. /**
  82472. * Gets a boolean indicating if textures must be saved in the database
  82473. */
  82474. enableTexturesOffline: boolean;
  82475. /**
  82476. * Open the offline support and make it available
  82477. * @param successCallback defines the callback to call on success
  82478. * @param errorCallback defines the callback to call on error
  82479. */
  82480. open(successCallback: () => void, errorCallback: () => void): void;
  82481. /**
  82482. * Loads an image from the offline support
  82483. * @param url defines the url to load from
  82484. * @param image defines the target DOM image
  82485. */
  82486. loadImage(url: string, image: HTMLImageElement): void;
  82487. /**
  82488. * Loads a file from offline support
  82489. * @param url defines the URL to load from
  82490. * @param sceneLoaded defines a callback to call on success
  82491. * @param progressCallBack defines a callback to call when progress changed
  82492. * @param errorCallback defines a callback to call on error
  82493. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  82494. */
  82495. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  82496. }
  82497. }
  82498. declare module BABYLON {
  82499. /**
  82500. * Class used to help managing file picking and drag'n'drop
  82501. * File Storage
  82502. */
  82503. export class FilesInputStore {
  82504. /**
  82505. * List of files ready to be loaded
  82506. */
  82507. static FilesToLoad: {
  82508. [key: string]: File;
  82509. };
  82510. }
  82511. }
  82512. declare module BABYLON {
  82513. /**
  82514. * Class used to define a retry strategy when error happens while loading assets
  82515. */
  82516. export class RetryStrategy {
  82517. /**
  82518. * Function used to defines an exponential back off strategy
  82519. * @param maxRetries defines the maximum number of retries (3 by default)
  82520. * @param baseInterval defines the interval between retries
  82521. * @returns the strategy function to use
  82522. */
  82523. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  82524. }
  82525. }
  82526. declare module BABYLON {
  82527. /**
  82528. * @ignore
  82529. * Application error to support additional information when loading a file
  82530. */
  82531. export abstract class BaseError extends Error {
  82532. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  82533. }
  82534. }
  82535. declare module BABYLON {
  82536. /** @ignore */
  82537. export class LoadFileError extends BaseError {
  82538. request?: WebRequest;
  82539. file?: File;
  82540. /**
  82541. * Creates a new LoadFileError
  82542. * @param message defines the message of the error
  82543. * @param request defines the optional web request
  82544. * @param file defines the optional file
  82545. */
  82546. constructor(message: string, object?: WebRequest | File);
  82547. }
  82548. /** @ignore */
  82549. export class RequestFileError extends BaseError {
  82550. request: WebRequest;
  82551. /**
  82552. * Creates a new LoadFileError
  82553. * @param message defines the message of the error
  82554. * @param request defines the optional web request
  82555. */
  82556. constructor(message: string, request: WebRequest);
  82557. }
  82558. /** @ignore */
  82559. export class ReadFileError extends BaseError {
  82560. file: File;
  82561. /**
  82562. * Creates a new ReadFileError
  82563. * @param message defines the message of the error
  82564. * @param file defines the optional file
  82565. */
  82566. constructor(message: string, file: File);
  82567. }
  82568. /**
  82569. * @hidden
  82570. */
  82571. export class FileTools {
  82572. /**
  82573. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  82574. */
  82575. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  82576. /**
  82577. * Gets or sets the base URL to use to load assets
  82578. */
  82579. static BaseUrl: string;
  82580. /**
  82581. * Default behaviour for cors in the application.
  82582. * It can be a string if the expected behavior is identical in the entire app.
  82583. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  82584. */
  82585. static CorsBehavior: string | ((url: string | string[]) => string);
  82586. /**
  82587. * Gets or sets a function used to pre-process url before using them to load assets
  82588. */
  82589. static PreprocessUrl: (url: string) => string;
  82590. /**
  82591. * Removes unwanted characters from an url
  82592. * @param url defines the url to clean
  82593. * @returns the cleaned url
  82594. */
  82595. private static _CleanUrl;
  82596. /**
  82597. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  82598. * @param url define the url we are trying
  82599. * @param element define the dom element where to configure the cors policy
  82600. */
  82601. static SetCorsBehavior(url: string | string[], element: {
  82602. crossOrigin: string | null;
  82603. }): void;
  82604. /**
  82605. * Loads an image as an HTMLImageElement.
  82606. * @param input url string, ArrayBuffer, or Blob to load
  82607. * @param onLoad callback called when the image successfully loads
  82608. * @param onError callback called when the image fails to load
  82609. * @param offlineProvider offline provider for caching
  82610. * @param mimeType optional mime type
  82611. * @returns the HTMLImageElement of the loaded image
  82612. */
  82613. 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>;
  82614. /**
  82615. * Reads a file from a File object
  82616. * @param file defines the file to load
  82617. * @param onSuccess defines the callback to call when data is loaded
  82618. * @param onProgress defines the callback to call during loading process
  82619. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  82620. * @param onError defines the callback to call when an error occurs
  82621. * @returns a file request object
  82622. */
  82623. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  82624. /**
  82625. * Loads a file from a url
  82626. * @param url url to load
  82627. * @param onSuccess callback called when the file successfully loads
  82628. * @param onProgress callback called while file is loading (if the server supports this mode)
  82629. * @param offlineProvider defines the offline provider for caching
  82630. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82631. * @param onError callback called when the file fails to load
  82632. * @returns a file request object
  82633. */
  82634. 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;
  82635. /**
  82636. * Loads a file
  82637. * @param url url to load
  82638. * @param onSuccess callback called when the file successfully loads
  82639. * @param onProgress callback called while file is loading (if the server supports this mode)
  82640. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82641. * @param onError callback called when the file fails to load
  82642. * @param onOpened callback called when the web request is opened
  82643. * @returns a file request object
  82644. */
  82645. 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;
  82646. /**
  82647. * Checks if the loaded document was accessed via `file:`-Protocol.
  82648. * @returns boolean
  82649. */
  82650. static IsFileURL(): boolean;
  82651. }
  82652. }
  82653. declare module BABYLON {
  82654. /** @hidden */
  82655. export class ShaderProcessor {
  82656. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  82657. private static _ProcessPrecision;
  82658. private static _ExtractOperation;
  82659. private static _BuildSubExpression;
  82660. private static _BuildExpression;
  82661. private static _MoveCursorWithinIf;
  82662. private static _MoveCursor;
  82663. private static _EvaluatePreProcessors;
  82664. private static _PreparePreProcessors;
  82665. private static _ProcessShaderConversion;
  82666. private static _ProcessIncludes;
  82667. /**
  82668. * Loads a file from a url
  82669. * @param url url to load
  82670. * @param onSuccess callback called when the file successfully loads
  82671. * @param onProgress callback called while file is loading (if the server supports this mode)
  82672. * @param offlineProvider defines the offline provider for caching
  82673. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82674. * @param onError callback called when the file fails to load
  82675. * @returns a file request object
  82676. * @hidden
  82677. */
  82678. 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;
  82679. }
  82680. }
  82681. declare module BABYLON {
  82682. /**
  82683. * @hidden
  82684. */
  82685. export interface IColor4Like {
  82686. r: float;
  82687. g: float;
  82688. b: float;
  82689. a: float;
  82690. }
  82691. /**
  82692. * @hidden
  82693. */
  82694. export interface IColor3Like {
  82695. r: float;
  82696. g: float;
  82697. b: float;
  82698. }
  82699. /**
  82700. * @hidden
  82701. */
  82702. export interface IVector4Like {
  82703. x: float;
  82704. y: float;
  82705. z: float;
  82706. w: float;
  82707. }
  82708. /**
  82709. * @hidden
  82710. */
  82711. export interface IVector3Like {
  82712. x: float;
  82713. y: float;
  82714. z: float;
  82715. }
  82716. /**
  82717. * @hidden
  82718. */
  82719. export interface IVector2Like {
  82720. x: float;
  82721. y: float;
  82722. }
  82723. /**
  82724. * @hidden
  82725. */
  82726. export interface IMatrixLike {
  82727. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82728. updateFlag: int;
  82729. }
  82730. /**
  82731. * @hidden
  82732. */
  82733. export interface IViewportLike {
  82734. x: float;
  82735. y: float;
  82736. width: float;
  82737. height: float;
  82738. }
  82739. /**
  82740. * @hidden
  82741. */
  82742. export interface IPlaneLike {
  82743. normal: IVector3Like;
  82744. d: float;
  82745. normalize(): void;
  82746. }
  82747. }
  82748. declare module BABYLON {
  82749. /**
  82750. * Interface used to define common properties for effect fallbacks
  82751. */
  82752. export interface IEffectFallbacks {
  82753. /**
  82754. * Removes the defines that should be removed when falling back.
  82755. * @param currentDefines defines the current define statements for the shader.
  82756. * @param effect defines the current effect we try to compile
  82757. * @returns The resulting defines with defines of the current rank removed.
  82758. */
  82759. reduce(currentDefines: string, effect: Effect): string;
  82760. /**
  82761. * Removes the fallback from the bound mesh.
  82762. */
  82763. unBindMesh(): void;
  82764. /**
  82765. * Checks to see if more fallbacks are still availible.
  82766. */
  82767. hasMoreFallbacks: boolean;
  82768. }
  82769. }
  82770. declare module BABYLON {
  82771. /**
  82772. * Class used to evalaute queries containing `and` and `or` operators
  82773. */
  82774. export class AndOrNotEvaluator {
  82775. /**
  82776. * Evaluate a query
  82777. * @param query defines the query to evaluate
  82778. * @param evaluateCallback defines the callback used to filter result
  82779. * @returns true if the query matches
  82780. */
  82781. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  82782. private static _HandleParenthesisContent;
  82783. private static _SimplifyNegation;
  82784. }
  82785. }
  82786. declare module BABYLON {
  82787. /**
  82788. * Class used to store custom tags
  82789. */
  82790. export class Tags {
  82791. /**
  82792. * Adds support for tags on the given object
  82793. * @param obj defines the object to use
  82794. */
  82795. static EnableFor(obj: any): void;
  82796. /**
  82797. * Removes tags support
  82798. * @param obj defines the object to use
  82799. */
  82800. static DisableFor(obj: any): void;
  82801. /**
  82802. * Gets a boolean indicating if the given object has tags
  82803. * @param obj defines the object to use
  82804. * @returns a boolean
  82805. */
  82806. static HasTags(obj: any): boolean;
  82807. /**
  82808. * Gets the tags available on a given object
  82809. * @param obj defines the object to use
  82810. * @param asString defines if the tags must be returned as a string instead of an array of strings
  82811. * @returns the tags
  82812. */
  82813. static GetTags(obj: any, asString?: boolean): any;
  82814. /**
  82815. * Adds tags to an object
  82816. * @param obj defines the object to use
  82817. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  82818. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  82819. */
  82820. static AddTagsTo(obj: any, tagsString: string): void;
  82821. /**
  82822. * @hidden
  82823. */
  82824. static _AddTagTo(obj: any, tag: string): void;
  82825. /**
  82826. * Removes specific tags from a specific object
  82827. * @param obj defines the object to use
  82828. * @param tagsString defines the tags to remove
  82829. */
  82830. static RemoveTagsFrom(obj: any, tagsString: string): void;
  82831. /**
  82832. * @hidden
  82833. */
  82834. static _RemoveTagFrom(obj: any, tag: string): void;
  82835. /**
  82836. * Defines if tags hosted on an object match a given query
  82837. * @param obj defines the object to use
  82838. * @param tagsQuery defines the tag query
  82839. * @returns a boolean
  82840. */
  82841. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82842. }
  82843. }
  82844. declare module BABYLON {
  82845. /**
  82846. * Scalar computation library
  82847. */
  82848. export class Scalar {
  82849. /**
  82850. * Two pi constants convenient for computation.
  82851. */
  82852. static TwoPi: number;
  82853. /**
  82854. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82855. * @param a number
  82856. * @param b number
  82857. * @param epsilon (default = 1.401298E-45)
  82858. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82859. */
  82860. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82861. /**
  82862. * Returns a string : the upper case translation of the number i to hexadecimal.
  82863. * @param i number
  82864. * @returns the upper case translation of the number i to hexadecimal.
  82865. */
  82866. static ToHex(i: number): string;
  82867. /**
  82868. * Returns -1 if value is negative and +1 is value is positive.
  82869. * @param value the value
  82870. * @returns the value itself if it's equal to zero.
  82871. */
  82872. static Sign(value: number): number;
  82873. /**
  82874. * Returns the value itself if it's between min and max.
  82875. * Returns min if the value is lower than min.
  82876. * Returns max if the value is greater than max.
  82877. * @param value the value to clmap
  82878. * @param min the min value to clamp to (default: 0)
  82879. * @param max the max value to clamp to (default: 1)
  82880. * @returns the clamped value
  82881. */
  82882. static Clamp(value: number, min?: number, max?: number): number;
  82883. /**
  82884. * the log2 of value.
  82885. * @param value the value to compute log2 of
  82886. * @returns the log2 of value.
  82887. */
  82888. static Log2(value: number): number;
  82889. /**
  82890. * Loops the value, so that it is never larger than length and never smaller than 0.
  82891. *
  82892. * This is similar to the modulo operator but it works with floating point numbers.
  82893. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82894. * With t = 5 and length = 2.5, the result would be 0.0.
  82895. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82896. * @param value the value
  82897. * @param length the length
  82898. * @returns the looped value
  82899. */
  82900. static Repeat(value: number, length: number): number;
  82901. /**
  82902. * Normalize the value between 0.0 and 1.0 using min and max values
  82903. * @param value value to normalize
  82904. * @param min max to normalize between
  82905. * @param max min to normalize between
  82906. * @returns the normalized value
  82907. */
  82908. static Normalize(value: number, min: number, max: number): number;
  82909. /**
  82910. * Denormalize the value from 0.0 and 1.0 using min and max values
  82911. * @param normalized value to denormalize
  82912. * @param min max to denormalize between
  82913. * @param max min to denormalize between
  82914. * @returns the denormalized value
  82915. */
  82916. static Denormalize(normalized: number, min: number, max: number): number;
  82917. /**
  82918. * Calculates the shortest difference between two given angles given in degrees.
  82919. * @param current current angle in degrees
  82920. * @param target target angle in degrees
  82921. * @returns the delta
  82922. */
  82923. static DeltaAngle(current: number, target: number): number;
  82924. /**
  82925. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82926. * @param tx value
  82927. * @param length length
  82928. * @returns The returned value will move back and forth between 0 and length
  82929. */
  82930. static PingPong(tx: number, length: number): number;
  82931. /**
  82932. * Interpolates between min and max with smoothing at the limits.
  82933. *
  82934. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82935. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82936. * @param from from
  82937. * @param to to
  82938. * @param tx value
  82939. * @returns the smooth stepped value
  82940. */
  82941. static SmoothStep(from: number, to: number, tx: number): number;
  82942. /**
  82943. * Moves a value current towards target.
  82944. *
  82945. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82946. * Negative values of maxDelta pushes the value away from target.
  82947. * @param current current value
  82948. * @param target target value
  82949. * @param maxDelta max distance to move
  82950. * @returns resulting value
  82951. */
  82952. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82953. /**
  82954. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82955. *
  82956. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82957. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82958. * @param current current value
  82959. * @param target target value
  82960. * @param maxDelta max distance to move
  82961. * @returns resulting angle
  82962. */
  82963. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82964. /**
  82965. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82966. * @param start start value
  82967. * @param end target value
  82968. * @param amount amount to lerp between
  82969. * @returns the lerped value
  82970. */
  82971. static Lerp(start: number, end: number, amount: number): number;
  82972. /**
  82973. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82974. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82975. * @param start start value
  82976. * @param end target value
  82977. * @param amount amount to lerp between
  82978. * @returns the lerped value
  82979. */
  82980. static LerpAngle(start: number, end: number, amount: number): number;
  82981. /**
  82982. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82983. * @param a start value
  82984. * @param b target value
  82985. * @param value value between a and b
  82986. * @returns the inverseLerp value
  82987. */
  82988. static InverseLerp(a: number, b: number, value: number): number;
  82989. /**
  82990. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82991. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82992. * @param value1 spline value
  82993. * @param tangent1 spline value
  82994. * @param value2 spline value
  82995. * @param tangent2 spline value
  82996. * @param amount input value
  82997. * @returns hermite result
  82998. */
  82999. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  83000. /**
  83001. * Returns a random float number between and min and max values
  83002. * @param min min value of random
  83003. * @param max max value of random
  83004. * @returns random value
  83005. */
  83006. static RandomRange(min: number, max: number): number;
  83007. /**
  83008. * This function returns percentage of a number in a given range.
  83009. *
  83010. * RangeToPercent(40,20,60) will return 0.5 (50%)
  83011. * RangeToPercent(34,0,100) will return 0.34 (34%)
  83012. * @param number to convert to percentage
  83013. * @param min min range
  83014. * @param max max range
  83015. * @returns the percentage
  83016. */
  83017. static RangeToPercent(number: number, min: number, max: number): number;
  83018. /**
  83019. * This function returns number that corresponds to the percentage in a given range.
  83020. *
  83021. * PercentToRange(0.34,0,100) will return 34.
  83022. * @param percent to convert to number
  83023. * @param min min range
  83024. * @param max max range
  83025. * @returns the number
  83026. */
  83027. static PercentToRange(percent: number, min: number, max: number): number;
  83028. /**
  83029. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  83030. * @param angle The angle to normalize in radian.
  83031. * @return The converted angle.
  83032. */
  83033. static NormalizeRadians(angle: number): number;
  83034. }
  83035. }
  83036. declare module BABYLON {
  83037. /**
  83038. * Constant used to convert a value to gamma space
  83039. * @ignorenaming
  83040. */
  83041. export const ToGammaSpace: number;
  83042. /**
  83043. * Constant used to convert a value to linear space
  83044. * @ignorenaming
  83045. */
  83046. export const ToLinearSpace = 2.2;
  83047. /**
  83048. * Constant used to define the minimal number value in Babylon.js
  83049. * @ignorenaming
  83050. */
  83051. let Epsilon: number;
  83052. }
  83053. declare module BABYLON {
  83054. /**
  83055. * Class used to represent a viewport on screen
  83056. */
  83057. export class Viewport {
  83058. /** viewport left coordinate */
  83059. x: number;
  83060. /** viewport top coordinate */
  83061. y: number;
  83062. /**viewport width */
  83063. width: number;
  83064. /** viewport height */
  83065. height: number;
  83066. /**
  83067. * Creates a Viewport object located at (x, y) and sized (width, height)
  83068. * @param x defines viewport left coordinate
  83069. * @param y defines viewport top coordinate
  83070. * @param width defines the viewport width
  83071. * @param height defines the viewport height
  83072. */
  83073. constructor(
  83074. /** viewport left coordinate */
  83075. x: number,
  83076. /** viewport top coordinate */
  83077. y: number,
  83078. /**viewport width */
  83079. width: number,
  83080. /** viewport height */
  83081. height: number);
  83082. /**
  83083. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  83084. * @param renderWidth defines the rendering width
  83085. * @param renderHeight defines the rendering height
  83086. * @returns a new Viewport
  83087. */
  83088. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  83089. /**
  83090. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  83091. * @param renderWidth defines the rendering width
  83092. * @param renderHeight defines the rendering height
  83093. * @param ref defines the target viewport
  83094. * @returns the current viewport
  83095. */
  83096. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  83097. /**
  83098. * Returns a new Viewport copied from the current one
  83099. * @returns a new Viewport
  83100. */
  83101. clone(): Viewport;
  83102. }
  83103. }
  83104. declare module BABYLON {
  83105. /**
  83106. * Class containing a set of static utilities functions for arrays.
  83107. */
  83108. export class ArrayTools {
  83109. /**
  83110. * Returns an array of the given size filled with element built from the given constructor and the paramters
  83111. * @param size the number of element to construct and put in the array
  83112. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  83113. * @returns a new array filled with new objects
  83114. */
  83115. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  83116. }
  83117. }
  83118. declare module BABYLON {
  83119. /**
  83120. * Represents a plane by the equation ax + by + cz + d = 0
  83121. */
  83122. export class Plane {
  83123. private static _TmpMatrix;
  83124. /**
  83125. * Normal of the plane (a,b,c)
  83126. */
  83127. normal: Vector3;
  83128. /**
  83129. * d component of the plane
  83130. */
  83131. d: number;
  83132. /**
  83133. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  83134. * @param a a component of the plane
  83135. * @param b b component of the plane
  83136. * @param c c component of the plane
  83137. * @param d d component of the plane
  83138. */
  83139. constructor(a: number, b: number, c: number, d: number);
  83140. /**
  83141. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  83142. */
  83143. asArray(): number[];
  83144. /**
  83145. * @returns a new plane copied from the current Plane.
  83146. */
  83147. clone(): Plane;
  83148. /**
  83149. * @returns the string "Plane".
  83150. */
  83151. getClassName(): string;
  83152. /**
  83153. * @returns the Plane hash code.
  83154. */
  83155. getHashCode(): number;
  83156. /**
  83157. * Normalize the current Plane in place.
  83158. * @returns the updated Plane.
  83159. */
  83160. normalize(): Plane;
  83161. /**
  83162. * Applies a transformation the plane and returns the result
  83163. * @param transformation the transformation matrix to be applied to the plane
  83164. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  83165. */
  83166. transform(transformation: DeepImmutable<Matrix>): Plane;
  83167. /**
  83168. * Compute the dot product between the point and the plane normal
  83169. * @param point point to calculate the dot product with
  83170. * @returns the dot product (float) of the point coordinates and the plane normal.
  83171. */
  83172. dotCoordinate(point: DeepImmutable<Vector3>): number;
  83173. /**
  83174. * Updates the current Plane from the plane defined by the three given points.
  83175. * @param point1 one of the points used to contruct the plane
  83176. * @param point2 one of the points used to contruct the plane
  83177. * @param point3 one of the points used to contruct the plane
  83178. * @returns the updated Plane.
  83179. */
  83180. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  83181. /**
  83182. * Checks if the plane is facing a given direction
  83183. * @param direction the direction to check if the plane is facing
  83184. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  83185. * @returns True is the vector "direction" is the same side than the plane normal.
  83186. */
  83187. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  83188. /**
  83189. * Calculates the distance to a point
  83190. * @param point point to calculate distance to
  83191. * @returns the signed distance (float) from the given point to the Plane.
  83192. */
  83193. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  83194. /**
  83195. * Creates a plane from an array
  83196. * @param array the array to create a plane from
  83197. * @returns a new Plane from the given array.
  83198. */
  83199. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  83200. /**
  83201. * Creates a plane from three points
  83202. * @param point1 point used to create the plane
  83203. * @param point2 point used to create the plane
  83204. * @param point3 point used to create the plane
  83205. * @returns a new Plane defined by the three given points.
  83206. */
  83207. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  83208. /**
  83209. * Creates a plane from an origin point and a normal
  83210. * @param origin origin of the plane to be constructed
  83211. * @param normal normal of the plane to be constructed
  83212. * @returns a new Plane the normal vector to this plane at the given origin point.
  83213. * Note : the vector "normal" is updated because normalized.
  83214. */
  83215. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  83216. /**
  83217. * Calculates the distance from a plane and a point
  83218. * @param origin origin of the plane to be constructed
  83219. * @param normal normal of the plane to be constructed
  83220. * @param point point to calculate distance to
  83221. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  83222. */
  83223. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  83224. }
  83225. }
  83226. declare module BABYLON {
  83227. /** @hidden */
  83228. export class PerformanceConfigurator {
  83229. /** @hidden */
  83230. static MatrixUse64Bits: boolean;
  83231. /** @hidden */
  83232. static MatrixTrackPrecisionChange: boolean;
  83233. /** @hidden */
  83234. static MatrixCurrentType: any;
  83235. /** @hidden */
  83236. static MatrixTrackedMatrices: Array<any> | null;
  83237. /** @hidden */
  83238. static SetMatrixPrecision(use64bits: boolean): void;
  83239. }
  83240. }
  83241. declare module BABYLON {
  83242. /**
  83243. * Class representing a vector containing 2 coordinates
  83244. */
  83245. export class Vector2 {
  83246. /** defines the first coordinate */
  83247. x: number;
  83248. /** defines the second coordinate */
  83249. y: number;
  83250. /**
  83251. * Creates a new Vector2 from the given x and y coordinates
  83252. * @param x defines the first coordinate
  83253. * @param y defines the second coordinate
  83254. */
  83255. constructor(
  83256. /** defines the first coordinate */
  83257. x?: number,
  83258. /** defines the second coordinate */
  83259. y?: number);
  83260. /**
  83261. * Gets a string with the Vector2 coordinates
  83262. * @returns a string with the Vector2 coordinates
  83263. */
  83264. toString(): string;
  83265. /**
  83266. * Gets class name
  83267. * @returns the string "Vector2"
  83268. */
  83269. getClassName(): string;
  83270. /**
  83271. * Gets current vector hash code
  83272. * @returns the Vector2 hash code as a number
  83273. */
  83274. getHashCode(): number;
  83275. /**
  83276. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  83277. * @param array defines the source array
  83278. * @param index defines the offset in source array
  83279. * @returns the current Vector2
  83280. */
  83281. toArray(array: FloatArray, index?: number): Vector2;
  83282. /**
  83283. * Update the current vector from an array
  83284. * @param array defines the destination array
  83285. * @param index defines the offset in the destination array
  83286. * @returns the current Vector3
  83287. */
  83288. fromArray(array: FloatArray, index?: number): Vector2;
  83289. /**
  83290. * Copy the current vector to an array
  83291. * @returns a new array with 2 elements: the Vector2 coordinates.
  83292. */
  83293. asArray(): number[];
  83294. /**
  83295. * Sets the Vector2 coordinates with the given Vector2 coordinates
  83296. * @param source defines the source Vector2
  83297. * @returns the current updated Vector2
  83298. */
  83299. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  83300. /**
  83301. * Sets the Vector2 coordinates with the given floats
  83302. * @param x defines the first coordinate
  83303. * @param y defines the second coordinate
  83304. * @returns the current updated Vector2
  83305. */
  83306. copyFromFloats(x: number, y: number): Vector2;
  83307. /**
  83308. * Sets the Vector2 coordinates with the given floats
  83309. * @param x defines the first coordinate
  83310. * @param y defines the second coordinate
  83311. * @returns the current updated Vector2
  83312. */
  83313. set(x: number, y: number): Vector2;
  83314. /**
  83315. * Add another vector with the current one
  83316. * @param otherVector defines the other vector
  83317. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  83318. */
  83319. add(otherVector: DeepImmutable<Vector2>): Vector2;
  83320. /**
  83321. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  83322. * @param otherVector defines the other vector
  83323. * @param result defines the target vector
  83324. * @returns the unmodified current Vector2
  83325. */
  83326. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83327. /**
  83328. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  83329. * @param otherVector defines the other vector
  83330. * @returns the current updated Vector2
  83331. */
  83332. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83333. /**
  83334. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  83335. * @param otherVector defines the other vector
  83336. * @returns a new Vector2
  83337. */
  83338. addVector3(otherVector: Vector3): Vector2;
  83339. /**
  83340. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  83341. * @param otherVector defines the other vector
  83342. * @returns a new Vector2
  83343. */
  83344. subtract(otherVector: Vector2): Vector2;
  83345. /**
  83346. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  83347. * @param otherVector defines the other vector
  83348. * @param result defines the target vector
  83349. * @returns the unmodified current Vector2
  83350. */
  83351. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83352. /**
  83353. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  83354. * @param otherVector defines the other vector
  83355. * @returns the current updated Vector2
  83356. */
  83357. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83358. /**
  83359. * Multiplies in place the current Vector2 coordinates by the given ones
  83360. * @param otherVector defines the other vector
  83361. * @returns the current updated Vector2
  83362. */
  83363. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83364. /**
  83365. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  83366. * @param otherVector defines the other vector
  83367. * @returns a new Vector2
  83368. */
  83369. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  83370. /**
  83371. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  83372. * @param otherVector defines the other vector
  83373. * @param result defines the target vector
  83374. * @returns the unmodified current Vector2
  83375. */
  83376. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83377. /**
  83378. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  83379. * @param x defines the first coordinate
  83380. * @param y defines the second coordinate
  83381. * @returns a new Vector2
  83382. */
  83383. multiplyByFloats(x: number, y: number): Vector2;
  83384. /**
  83385. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  83386. * @param otherVector defines the other vector
  83387. * @returns a new Vector2
  83388. */
  83389. divide(otherVector: Vector2): Vector2;
  83390. /**
  83391. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  83392. * @param otherVector defines the other vector
  83393. * @param result defines the target vector
  83394. * @returns the unmodified current Vector2
  83395. */
  83396. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83397. /**
  83398. * Divides the current Vector2 coordinates by the given ones
  83399. * @param otherVector defines the other vector
  83400. * @returns the current updated Vector2
  83401. */
  83402. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83403. /**
  83404. * Gets a new Vector2 with current Vector2 negated coordinates
  83405. * @returns a new Vector2
  83406. */
  83407. negate(): Vector2;
  83408. /**
  83409. * Negate this vector in place
  83410. * @returns this
  83411. */
  83412. negateInPlace(): Vector2;
  83413. /**
  83414. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  83415. * @param result defines the Vector3 object where to store the result
  83416. * @returns the current Vector2
  83417. */
  83418. negateToRef(result: Vector2): Vector2;
  83419. /**
  83420. * Multiply the Vector2 coordinates by scale
  83421. * @param scale defines the scaling factor
  83422. * @returns the current updated Vector2
  83423. */
  83424. scaleInPlace(scale: number): Vector2;
  83425. /**
  83426. * Returns a new Vector2 scaled by "scale" from the current Vector2
  83427. * @param scale defines the scaling factor
  83428. * @returns a new Vector2
  83429. */
  83430. scale(scale: number): Vector2;
  83431. /**
  83432. * Scale the current Vector2 values by a factor to a given Vector2
  83433. * @param scale defines the scale factor
  83434. * @param result defines the Vector2 object where to store the result
  83435. * @returns the unmodified current Vector2
  83436. */
  83437. scaleToRef(scale: number, result: Vector2): Vector2;
  83438. /**
  83439. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  83440. * @param scale defines the scale factor
  83441. * @param result defines the Vector2 object where to store the result
  83442. * @returns the unmodified current Vector2
  83443. */
  83444. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  83445. /**
  83446. * Gets a boolean if two vectors are equals
  83447. * @param otherVector defines the other vector
  83448. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  83449. */
  83450. equals(otherVector: DeepImmutable<Vector2>): boolean;
  83451. /**
  83452. * Gets a boolean if two vectors are equals (using an epsilon value)
  83453. * @param otherVector defines the other vector
  83454. * @param epsilon defines the minimal distance to consider equality
  83455. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  83456. */
  83457. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  83458. /**
  83459. * Gets a new Vector2 from current Vector2 floored values
  83460. * @returns a new Vector2
  83461. */
  83462. floor(): Vector2;
  83463. /**
  83464. * Gets a new Vector2 from current Vector2 floored values
  83465. * @returns a new Vector2
  83466. */
  83467. fract(): Vector2;
  83468. /**
  83469. * Gets the length of the vector
  83470. * @returns the vector length (float)
  83471. */
  83472. length(): number;
  83473. /**
  83474. * Gets the vector squared length
  83475. * @returns the vector squared length (float)
  83476. */
  83477. lengthSquared(): number;
  83478. /**
  83479. * Normalize the vector
  83480. * @returns the current updated Vector2
  83481. */
  83482. normalize(): Vector2;
  83483. /**
  83484. * Gets a new Vector2 copied from the Vector2
  83485. * @returns a new Vector2
  83486. */
  83487. clone(): Vector2;
  83488. /**
  83489. * Gets a new Vector2(0, 0)
  83490. * @returns a new Vector2
  83491. */
  83492. static Zero(): Vector2;
  83493. /**
  83494. * Gets a new Vector2(1, 1)
  83495. * @returns a new Vector2
  83496. */
  83497. static One(): Vector2;
  83498. /**
  83499. * Gets a new Vector2 set from the given index element of the given array
  83500. * @param array defines the data source
  83501. * @param offset defines the offset in the data source
  83502. * @returns a new Vector2
  83503. */
  83504. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  83505. /**
  83506. * Sets "result" from the given index element of the given array
  83507. * @param array defines the data source
  83508. * @param offset defines the offset in the data source
  83509. * @param result defines the target vector
  83510. */
  83511. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  83512. /**
  83513. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  83514. * @param value1 defines 1st point of control
  83515. * @param value2 defines 2nd point of control
  83516. * @param value3 defines 3rd point of control
  83517. * @param value4 defines 4th point of control
  83518. * @param amount defines the interpolation factor
  83519. * @returns a new Vector2
  83520. */
  83521. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  83522. /**
  83523. * 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".
  83524. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  83525. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  83526. * @param value defines the value to clamp
  83527. * @param min defines the lower limit
  83528. * @param max defines the upper limit
  83529. * @returns a new Vector2
  83530. */
  83531. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  83532. /**
  83533. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  83534. * @param value1 defines the 1st control point
  83535. * @param tangent1 defines the outgoing tangent
  83536. * @param value2 defines the 2nd control point
  83537. * @param tangent2 defines the incoming tangent
  83538. * @param amount defines the interpolation factor
  83539. * @returns a new Vector2
  83540. */
  83541. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  83542. /**
  83543. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  83544. * @param start defines the start vector
  83545. * @param end defines the end vector
  83546. * @param amount defines the interpolation factor
  83547. * @returns a new Vector2
  83548. */
  83549. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  83550. /**
  83551. * Gets the dot product of the vector "left" and the vector "right"
  83552. * @param left defines first vector
  83553. * @param right defines second vector
  83554. * @returns the dot product (float)
  83555. */
  83556. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  83557. /**
  83558. * Returns a new Vector2 equal to the normalized given vector
  83559. * @param vector defines the vector to normalize
  83560. * @returns a new Vector2
  83561. */
  83562. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  83563. /**
  83564. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  83565. * @param left defines 1st vector
  83566. * @param right defines 2nd vector
  83567. * @returns a new Vector2
  83568. */
  83569. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83570. /**
  83571. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  83572. * @param left defines 1st vector
  83573. * @param right defines 2nd vector
  83574. * @returns a new Vector2
  83575. */
  83576. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83577. /**
  83578. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  83579. * @param vector defines the vector to transform
  83580. * @param transformation defines the matrix to apply
  83581. * @returns a new Vector2
  83582. */
  83583. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  83584. /**
  83585. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  83586. * @param vector defines the vector to transform
  83587. * @param transformation defines the matrix to apply
  83588. * @param result defines the target vector
  83589. */
  83590. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  83591. /**
  83592. * Determines if a given vector is included in a triangle
  83593. * @param p defines the vector to test
  83594. * @param p0 defines 1st triangle point
  83595. * @param p1 defines 2nd triangle point
  83596. * @param p2 defines 3rd triangle point
  83597. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  83598. */
  83599. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  83600. /**
  83601. * Gets the distance between the vectors "value1" and "value2"
  83602. * @param value1 defines first vector
  83603. * @param value2 defines second vector
  83604. * @returns the distance between vectors
  83605. */
  83606. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83607. /**
  83608. * Returns the squared distance between the vectors "value1" and "value2"
  83609. * @param value1 defines first vector
  83610. * @param value2 defines second vector
  83611. * @returns the squared distance between vectors
  83612. */
  83613. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83614. /**
  83615. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  83616. * @param value1 defines first vector
  83617. * @param value2 defines second vector
  83618. * @returns a new Vector2
  83619. */
  83620. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  83621. /**
  83622. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  83623. * @param p defines the middle point
  83624. * @param segA defines one point of the segment
  83625. * @param segB defines the other point of the segment
  83626. * @returns the shortest distance
  83627. */
  83628. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  83629. }
  83630. /**
  83631. * Class used to store (x,y,z) vector representation
  83632. * A Vector3 is the main object used in 3D geometry
  83633. * It can represent etiher the coordinates of a point the space, either a direction
  83634. * Reminder: js uses a left handed forward facing system
  83635. */
  83636. export class Vector3 {
  83637. private static _UpReadOnly;
  83638. private static _ZeroReadOnly;
  83639. /** @hidden */
  83640. _x: number;
  83641. /** @hidden */
  83642. _y: number;
  83643. /** @hidden */
  83644. _z: number;
  83645. /** @hidden */
  83646. _isDirty: boolean;
  83647. /** Gets or sets the x coordinate */
  83648. get x(): number;
  83649. set x(value: number);
  83650. /** Gets or sets the y coordinate */
  83651. get y(): number;
  83652. set y(value: number);
  83653. /** Gets or sets the z coordinate */
  83654. get z(): number;
  83655. set z(value: number);
  83656. /**
  83657. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  83658. * @param x defines the first coordinates (on X axis)
  83659. * @param y defines the second coordinates (on Y axis)
  83660. * @param z defines the third coordinates (on Z axis)
  83661. */
  83662. constructor(x?: number, y?: number, z?: number);
  83663. /**
  83664. * Creates a string representation of the Vector3
  83665. * @returns a string with the Vector3 coordinates.
  83666. */
  83667. toString(): string;
  83668. /**
  83669. * Gets the class name
  83670. * @returns the string "Vector3"
  83671. */
  83672. getClassName(): string;
  83673. /**
  83674. * Creates the Vector3 hash code
  83675. * @returns a number which tends to be unique between Vector3 instances
  83676. */
  83677. getHashCode(): number;
  83678. /**
  83679. * Creates an array containing three elements : the coordinates of the Vector3
  83680. * @returns a new array of numbers
  83681. */
  83682. asArray(): number[];
  83683. /**
  83684. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83685. * @param array defines the destination array
  83686. * @param index defines the offset in the destination array
  83687. * @returns the current Vector3
  83688. */
  83689. toArray(array: FloatArray, index?: number): Vector3;
  83690. /**
  83691. * Update the current vector from an array
  83692. * @param array defines the destination array
  83693. * @param index defines the offset in the destination array
  83694. * @returns the current Vector3
  83695. */
  83696. fromArray(array: FloatArray, index?: number): Vector3;
  83697. /**
  83698. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83699. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83700. */
  83701. toQuaternion(): Quaternion;
  83702. /**
  83703. * Adds the given vector to the current Vector3
  83704. * @param otherVector defines the second operand
  83705. * @returns the current updated Vector3
  83706. */
  83707. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83708. /**
  83709. * Adds the given coordinates to the current Vector3
  83710. * @param x defines the x coordinate of the operand
  83711. * @param y defines the y coordinate of the operand
  83712. * @param z defines the z coordinate of the operand
  83713. * @returns the current updated Vector3
  83714. */
  83715. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83716. /**
  83717. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83718. * @param otherVector defines the second operand
  83719. * @returns the resulting Vector3
  83720. */
  83721. add(otherVector: DeepImmutable<Vector3>): Vector3;
  83722. /**
  83723. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83724. * @param otherVector defines the second operand
  83725. * @param result defines the Vector3 object where to store the result
  83726. * @returns the current Vector3
  83727. */
  83728. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83729. /**
  83730. * Subtract the given vector from the current Vector3
  83731. * @param otherVector defines the second operand
  83732. * @returns the current updated Vector3
  83733. */
  83734. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83735. /**
  83736. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83737. * @param otherVector defines the second operand
  83738. * @returns the resulting Vector3
  83739. */
  83740. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  83741. /**
  83742. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83743. * @param otherVector defines the second operand
  83744. * @param result defines the Vector3 object where to store the result
  83745. * @returns the current Vector3
  83746. */
  83747. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83748. /**
  83749. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83750. * @param x defines the x coordinate of the operand
  83751. * @param y defines the y coordinate of the operand
  83752. * @param z defines the z coordinate of the operand
  83753. * @returns the resulting Vector3
  83754. */
  83755. subtractFromFloats(x: number, y: number, z: number): Vector3;
  83756. /**
  83757. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83758. * @param x defines the x coordinate of the operand
  83759. * @param y defines the y coordinate of the operand
  83760. * @param z defines the z coordinate of the operand
  83761. * @param result defines the Vector3 object where to store the result
  83762. * @returns the current Vector3
  83763. */
  83764. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  83765. /**
  83766. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83767. * @returns a new Vector3
  83768. */
  83769. negate(): Vector3;
  83770. /**
  83771. * Negate this vector in place
  83772. * @returns this
  83773. */
  83774. negateInPlace(): Vector3;
  83775. /**
  83776. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  83777. * @param result defines the Vector3 object where to store the result
  83778. * @returns the current Vector3
  83779. */
  83780. negateToRef(result: Vector3): Vector3;
  83781. /**
  83782. * Multiplies the Vector3 coordinates by the float "scale"
  83783. * @param scale defines the multiplier factor
  83784. * @returns the current updated Vector3
  83785. */
  83786. scaleInPlace(scale: number): Vector3;
  83787. /**
  83788. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83789. * @param scale defines the multiplier factor
  83790. * @returns a new Vector3
  83791. */
  83792. scale(scale: number): Vector3;
  83793. /**
  83794. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83795. * @param scale defines the multiplier factor
  83796. * @param result defines the Vector3 object where to store the result
  83797. * @returns the current Vector3
  83798. */
  83799. scaleToRef(scale: number, result: Vector3): Vector3;
  83800. /**
  83801. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83802. * @param scale defines the scale factor
  83803. * @param result defines the Vector3 object where to store the result
  83804. * @returns the unmodified current Vector3
  83805. */
  83806. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  83807. /**
  83808. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83809. * @param origin defines the origin of the projection ray
  83810. * @param plane defines the plane to project to
  83811. * @returns the projected vector3
  83812. */
  83813. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  83814. /**
  83815. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83816. * @param origin defines the origin of the projection ray
  83817. * @param plane defines the plane to project to
  83818. * @param result defines the Vector3 where to store the result
  83819. */
  83820. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  83821. /**
  83822. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83823. * @param otherVector defines the second operand
  83824. * @returns true if both vectors are equals
  83825. */
  83826. equals(otherVector: DeepImmutable<Vector3>): boolean;
  83827. /**
  83828. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83829. * @param otherVector defines the second operand
  83830. * @param epsilon defines the minimal distance to define values as equals
  83831. * @returns true if both vectors are distant less than epsilon
  83832. */
  83833. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  83834. /**
  83835. * Returns true if the current Vector3 coordinates equals the given floats
  83836. * @param x defines the x coordinate of the operand
  83837. * @param y defines the y coordinate of the operand
  83838. * @param z defines the z coordinate of the operand
  83839. * @returns true if both vectors are equals
  83840. */
  83841. equalsToFloats(x: number, y: number, z: number): boolean;
  83842. /**
  83843. * Multiplies the current Vector3 coordinates by the given ones
  83844. * @param otherVector defines the second operand
  83845. * @returns the current updated Vector3
  83846. */
  83847. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83848. /**
  83849. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83850. * @param otherVector defines the second operand
  83851. * @returns the new Vector3
  83852. */
  83853. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83854. /**
  83855. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83856. * @param otherVector defines the second operand
  83857. * @param result defines the Vector3 object where to store the result
  83858. * @returns the current Vector3
  83859. */
  83860. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83861. /**
  83862. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83863. * @param x defines the x coordinate of the operand
  83864. * @param y defines the y coordinate of the operand
  83865. * @param z defines the z coordinate of the operand
  83866. * @returns the new Vector3
  83867. */
  83868. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83869. /**
  83870. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83871. * @param otherVector defines the second operand
  83872. * @returns the new Vector3
  83873. */
  83874. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83875. /**
  83876. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83877. * @param otherVector defines the second operand
  83878. * @param result defines the Vector3 object where to store the result
  83879. * @returns the current Vector3
  83880. */
  83881. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83882. /**
  83883. * Divides the current Vector3 coordinates by the given ones.
  83884. * @param otherVector defines the second operand
  83885. * @returns the current updated Vector3
  83886. */
  83887. divideInPlace(otherVector: Vector3): Vector3;
  83888. /**
  83889. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83890. * @param other defines the second operand
  83891. * @returns the current updated Vector3
  83892. */
  83893. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83894. /**
  83895. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83896. * @param other defines the second operand
  83897. * @returns the current updated Vector3
  83898. */
  83899. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83900. /**
  83901. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83902. * @param x defines the x coordinate of the operand
  83903. * @param y defines the y coordinate of the operand
  83904. * @param z defines the z coordinate of the operand
  83905. * @returns the current updated Vector3
  83906. */
  83907. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83908. /**
  83909. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83910. * @param x defines the x coordinate of the operand
  83911. * @param y defines the y coordinate of the operand
  83912. * @param z defines the z coordinate of the operand
  83913. * @returns the current updated Vector3
  83914. */
  83915. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83916. /**
  83917. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83918. * Check if is non uniform within a certain amount of decimal places to account for this
  83919. * @param epsilon the amount the values can differ
  83920. * @returns if the the vector is non uniform to a certain number of decimal places
  83921. */
  83922. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83923. /**
  83924. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83925. */
  83926. get isNonUniform(): boolean;
  83927. /**
  83928. * Gets a new Vector3 from current Vector3 floored values
  83929. * @returns a new Vector3
  83930. */
  83931. floor(): Vector3;
  83932. /**
  83933. * Gets a new Vector3 from current Vector3 floored values
  83934. * @returns a new Vector3
  83935. */
  83936. fract(): Vector3;
  83937. /**
  83938. * Gets the length of the Vector3
  83939. * @returns the length of the Vector3
  83940. */
  83941. length(): number;
  83942. /**
  83943. * Gets the squared length of the Vector3
  83944. * @returns squared length of the Vector3
  83945. */
  83946. lengthSquared(): number;
  83947. /**
  83948. * Normalize the current Vector3.
  83949. * Please note that this is an in place operation.
  83950. * @returns the current updated Vector3
  83951. */
  83952. normalize(): Vector3;
  83953. /**
  83954. * Reorders the x y z properties of the vector in place
  83955. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83956. * @returns the current updated vector
  83957. */
  83958. reorderInPlace(order: string): this;
  83959. /**
  83960. * Rotates the vector around 0,0,0 by a quaternion
  83961. * @param quaternion the rotation quaternion
  83962. * @param result vector to store the result
  83963. * @returns the resulting vector
  83964. */
  83965. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83966. /**
  83967. * Rotates a vector around a given point
  83968. * @param quaternion the rotation quaternion
  83969. * @param point the point to rotate around
  83970. * @param result vector to store the result
  83971. * @returns the resulting vector
  83972. */
  83973. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83974. /**
  83975. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83976. * The cross product is then orthogonal to both current and "other"
  83977. * @param other defines the right operand
  83978. * @returns the cross product
  83979. */
  83980. cross(other: Vector3): Vector3;
  83981. /**
  83982. * Normalize the current Vector3 with the given input length.
  83983. * Please note that this is an in place operation.
  83984. * @param len the length of the vector
  83985. * @returns the current updated Vector3
  83986. */
  83987. normalizeFromLength(len: number): Vector3;
  83988. /**
  83989. * Normalize the current Vector3 to a new vector
  83990. * @returns the new Vector3
  83991. */
  83992. normalizeToNew(): Vector3;
  83993. /**
  83994. * Normalize the current Vector3 to the reference
  83995. * @param reference define the Vector3 to update
  83996. * @returns the updated Vector3
  83997. */
  83998. normalizeToRef(reference: Vector3): Vector3;
  83999. /**
  84000. * Creates a new Vector3 copied from the current Vector3
  84001. * @returns the new Vector3
  84002. */
  84003. clone(): Vector3;
  84004. /**
  84005. * Copies the given vector coordinates to the current Vector3 ones
  84006. * @param source defines the source Vector3
  84007. * @returns the current updated Vector3
  84008. */
  84009. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  84010. /**
  84011. * Copies the given floats to the current Vector3 coordinates
  84012. * @param x defines the x coordinate of the operand
  84013. * @param y defines the y coordinate of the operand
  84014. * @param z defines the z coordinate of the operand
  84015. * @returns the current updated Vector3
  84016. */
  84017. copyFromFloats(x: number, y: number, z: number): Vector3;
  84018. /**
  84019. * Copies the given floats to the current Vector3 coordinates
  84020. * @param x defines the x coordinate of the operand
  84021. * @param y defines the y coordinate of the operand
  84022. * @param z defines the z coordinate of the operand
  84023. * @returns the current updated Vector3
  84024. */
  84025. set(x: number, y: number, z: number): Vector3;
  84026. /**
  84027. * Copies the given float to the current Vector3 coordinates
  84028. * @param v defines the x, y and z coordinates of the operand
  84029. * @returns the current updated Vector3
  84030. */
  84031. setAll(v: number): Vector3;
  84032. /**
  84033. * Get the clip factor between two vectors
  84034. * @param vector0 defines the first operand
  84035. * @param vector1 defines the second operand
  84036. * @param axis defines the axis to use
  84037. * @param size defines the size along the axis
  84038. * @returns the clip factor
  84039. */
  84040. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  84041. /**
  84042. * Get angle between two vectors
  84043. * @param vector0 angle between vector0 and vector1
  84044. * @param vector1 angle between vector0 and vector1
  84045. * @param normal direction of the normal
  84046. * @return the angle between vector0 and vector1
  84047. */
  84048. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  84049. /**
  84050. * Returns a new Vector3 set from the index "offset" of the given array
  84051. * @param array defines the source array
  84052. * @param offset defines the offset in the source array
  84053. * @returns the new Vector3
  84054. */
  84055. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  84056. /**
  84057. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  84058. * @param array defines the source array
  84059. * @param offset defines the offset in the source array
  84060. * @returns the new Vector3
  84061. * @deprecated Please use FromArray instead.
  84062. */
  84063. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  84064. /**
  84065. * Sets the given vector "result" with the element values from the index "offset" of the given array
  84066. * @param array defines the source array
  84067. * @param offset defines the offset in the source array
  84068. * @param result defines the Vector3 where to store the result
  84069. */
  84070. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  84071. /**
  84072. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  84073. * @param array defines the source array
  84074. * @param offset defines the offset in the source array
  84075. * @param result defines the Vector3 where to store the result
  84076. * @deprecated Please use FromArrayToRef instead.
  84077. */
  84078. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  84079. /**
  84080. * Sets the given vector "result" with the given floats.
  84081. * @param x defines the x coordinate of the source
  84082. * @param y defines the y coordinate of the source
  84083. * @param z defines the z coordinate of the source
  84084. * @param result defines the Vector3 where to store the result
  84085. */
  84086. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  84087. /**
  84088. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  84089. * @returns a new empty Vector3
  84090. */
  84091. static Zero(): Vector3;
  84092. /**
  84093. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  84094. * @returns a new unit Vector3
  84095. */
  84096. static One(): Vector3;
  84097. /**
  84098. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  84099. * @returns a new up Vector3
  84100. */
  84101. static Up(): Vector3;
  84102. /**
  84103. * Gets a up Vector3 that must not be updated
  84104. */
  84105. static get UpReadOnly(): DeepImmutable<Vector3>;
  84106. /**
  84107. * Gets a zero Vector3 that must not be updated
  84108. */
  84109. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  84110. /**
  84111. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  84112. * @returns a new down Vector3
  84113. */
  84114. static Down(): Vector3;
  84115. /**
  84116. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  84117. * @param rightHandedSystem is the scene right-handed (negative z)
  84118. * @returns a new forward Vector3
  84119. */
  84120. static Forward(rightHandedSystem?: boolean): Vector3;
  84121. /**
  84122. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  84123. * @param rightHandedSystem is the scene right-handed (negative-z)
  84124. * @returns a new forward Vector3
  84125. */
  84126. static Backward(rightHandedSystem?: boolean): Vector3;
  84127. /**
  84128. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  84129. * @returns a new right Vector3
  84130. */
  84131. static Right(): Vector3;
  84132. /**
  84133. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  84134. * @returns a new left Vector3
  84135. */
  84136. static Left(): Vector3;
  84137. /**
  84138. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  84139. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84140. * @param vector defines the Vector3 to transform
  84141. * @param transformation defines the transformation matrix
  84142. * @returns the transformed Vector3
  84143. */
  84144. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  84145. /**
  84146. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  84147. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84148. * @param vector defines the Vector3 to transform
  84149. * @param transformation defines the transformation matrix
  84150. * @param result defines the Vector3 where to store the result
  84151. */
  84152. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84153. /**
  84154. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  84155. * This method computes tranformed coordinates only, not transformed direction vectors
  84156. * @param x define the x coordinate of the source vector
  84157. * @param y define the y coordinate of the source vector
  84158. * @param z define the z coordinate of the source vector
  84159. * @param transformation defines the transformation matrix
  84160. * @param result defines the Vector3 where to store the result
  84161. */
  84162. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84163. /**
  84164. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  84165. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84166. * @param vector defines the Vector3 to transform
  84167. * @param transformation defines the transformation matrix
  84168. * @returns the new Vector3
  84169. */
  84170. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  84171. /**
  84172. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  84173. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84174. * @param vector defines the Vector3 to transform
  84175. * @param transformation defines the transformation matrix
  84176. * @param result defines the Vector3 where to store the result
  84177. */
  84178. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84179. /**
  84180. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  84181. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84182. * @param x define the x coordinate of the source vector
  84183. * @param y define the y coordinate of the source vector
  84184. * @param z define the z coordinate of the source vector
  84185. * @param transformation defines the transformation matrix
  84186. * @param result defines the Vector3 where to store the result
  84187. */
  84188. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84189. /**
  84190. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  84191. * @param value1 defines the first control point
  84192. * @param value2 defines the second control point
  84193. * @param value3 defines the third control point
  84194. * @param value4 defines the fourth control point
  84195. * @param amount defines the amount on the spline to use
  84196. * @returns the new Vector3
  84197. */
  84198. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  84199. /**
  84200. * 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"
  84201. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  84202. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  84203. * @param value defines the current value
  84204. * @param min defines the lower range value
  84205. * @param max defines the upper range value
  84206. * @returns the new Vector3
  84207. */
  84208. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  84209. /**
  84210. * 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"
  84211. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  84212. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  84213. * @param value defines the current value
  84214. * @param min defines the lower range value
  84215. * @param max defines the upper range value
  84216. * @param result defines the Vector3 where to store the result
  84217. */
  84218. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  84219. /**
  84220. * Checks if a given vector is inside a specific range
  84221. * @param v defines the vector to test
  84222. * @param min defines the minimum range
  84223. * @param max defines the maximum range
  84224. */
  84225. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  84226. /**
  84227. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  84228. * @param value1 defines the first control point
  84229. * @param tangent1 defines the first tangent vector
  84230. * @param value2 defines the second control point
  84231. * @param tangent2 defines the second tangent vector
  84232. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  84233. * @returns the new Vector3
  84234. */
  84235. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  84236. /**
  84237. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  84238. * @param start defines the start value
  84239. * @param end defines the end value
  84240. * @param amount max defines amount between both (between 0 and 1)
  84241. * @returns the new Vector3
  84242. */
  84243. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  84244. /**
  84245. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  84246. * @param start defines the start value
  84247. * @param end defines the end value
  84248. * @param amount max defines amount between both (between 0 and 1)
  84249. * @param result defines the Vector3 where to store the result
  84250. */
  84251. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  84252. /**
  84253. * Returns the dot product (float) between the vectors "left" and "right"
  84254. * @param left defines the left operand
  84255. * @param right defines the right operand
  84256. * @returns the dot product
  84257. */
  84258. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  84259. /**
  84260. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  84261. * The cross product is then orthogonal to both "left" and "right"
  84262. * @param left defines the left operand
  84263. * @param right defines the right operand
  84264. * @returns the cross product
  84265. */
  84266. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84267. /**
  84268. * Sets the given vector "result" with the cross product of "left" and "right"
  84269. * The cross product is then orthogonal to both "left" and "right"
  84270. * @param left defines the left operand
  84271. * @param right defines the right operand
  84272. * @param result defines the Vector3 where to store the result
  84273. */
  84274. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  84275. /**
  84276. * Returns a new Vector3 as the normalization of the given vector
  84277. * @param vector defines the Vector3 to normalize
  84278. * @returns the new Vector3
  84279. */
  84280. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  84281. /**
  84282. * Sets the given vector "result" with the normalization of the given first vector
  84283. * @param vector defines the Vector3 to normalize
  84284. * @param result defines the Vector3 where to store the result
  84285. */
  84286. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  84287. /**
  84288. * Project a Vector3 onto screen space
  84289. * @param vector defines the Vector3 to project
  84290. * @param world defines the world matrix to use
  84291. * @param transform defines the transform (view x projection) matrix to use
  84292. * @param viewport defines the screen viewport to use
  84293. * @returns the new Vector3
  84294. */
  84295. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  84296. /**
  84297. * Project a Vector3 onto screen space to reference
  84298. * @param vector defines the Vector3 to project
  84299. * @param world defines the world matrix to use
  84300. * @param transform defines the transform (view x projection) matrix to use
  84301. * @param viewport defines the screen viewport to use
  84302. * @param result the vector in which the screen space will be stored
  84303. * @returns the new Vector3
  84304. */
  84305. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  84306. /** @hidden */
  84307. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  84308. /**
  84309. * Unproject from screen space to object space
  84310. * @param source defines the screen space Vector3 to use
  84311. * @param viewportWidth defines the current width of the viewport
  84312. * @param viewportHeight defines the current height of the viewport
  84313. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84314. * @param transform defines the transform (view x projection) matrix to use
  84315. * @returns the new Vector3
  84316. */
  84317. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  84318. /**
  84319. * Unproject from screen space to object space
  84320. * @param source defines the screen space Vector3 to use
  84321. * @param viewportWidth defines the current width of the viewport
  84322. * @param viewportHeight defines the current height of the viewport
  84323. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84324. * @param view defines the view matrix to use
  84325. * @param projection defines the projection matrix to use
  84326. * @returns the new Vector3
  84327. */
  84328. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  84329. /**
  84330. * Unproject from screen space to object space
  84331. * @param source defines the screen space Vector3 to use
  84332. * @param viewportWidth defines the current width of the viewport
  84333. * @param viewportHeight defines the current height of the viewport
  84334. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84335. * @param view defines the view matrix to use
  84336. * @param projection defines the projection matrix to use
  84337. * @param result defines the Vector3 where to store the result
  84338. */
  84339. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  84340. /**
  84341. * Unproject from screen space to object space
  84342. * @param sourceX defines the screen space x coordinate to use
  84343. * @param sourceY defines the screen space y coordinate to use
  84344. * @param sourceZ defines the screen space z coordinate to use
  84345. * @param viewportWidth defines the current width of the viewport
  84346. * @param viewportHeight defines the current height of the viewport
  84347. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84348. * @param view defines the view matrix to use
  84349. * @param projection defines the projection matrix to use
  84350. * @param result defines the Vector3 where to store the result
  84351. */
  84352. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  84353. /**
  84354. * Gets the minimal coordinate values between two Vector3
  84355. * @param left defines the first operand
  84356. * @param right defines the second operand
  84357. * @returns the new Vector3
  84358. */
  84359. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84360. /**
  84361. * Gets the maximal coordinate values between two Vector3
  84362. * @param left defines the first operand
  84363. * @param right defines the second operand
  84364. * @returns the new Vector3
  84365. */
  84366. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84367. /**
  84368. * Returns the distance between the vectors "value1" and "value2"
  84369. * @param value1 defines the first operand
  84370. * @param value2 defines the second operand
  84371. * @returns the distance
  84372. */
  84373. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  84374. /**
  84375. * Returns the squared distance between the vectors "value1" and "value2"
  84376. * @param value1 defines the first operand
  84377. * @param value2 defines the second operand
  84378. * @returns the squared distance
  84379. */
  84380. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  84381. /**
  84382. * Returns a new Vector3 located at the center between "value1" and "value2"
  84383. * @param value1 defines the first operand
  84384. * @param value2 defines the second operand
  84385. * @returns the new Vector3
  84386. */
  84387. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  84388. /**
  84389. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  84390. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  84391. * to something in order to rotate it from its local system to the given target system
  84392. * Note: axis1, axis2 and axis3 are normalized during this operation
  84393. * @param axis1 defines the first axis
  84394. * @param axis2 defines the second axis
  84395. * @param axis3 defines the third axis
  84396. * @returns a new Vector3
  84397. */
  84398. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  84399. /**
  84400. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  84401. * @param axis1 defines the first axis
  84402. * @param axis2 defines the second axis
  84403. * @param axis3 defines the third axis
  84404. * @param ref defines the Vector3 where to store the result
  84405. */
  84406. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  84407. }
  84408. /**
  84409. * Vector4 class created for EulerAngle class conversion to Quaternion
  84410. */
  84411. export class Vector4 {
  84412. /** x value of the vector */
  84413. x: number;
  84414. /** y value of the vector */
  84415. y: number;
  84416. /** z value of the vector */
  84417. z: number;
  84418. /** w value of the vector */
  84419. w: number;
  84420. /**
  84421. * Creates a Vector4 object from the given floats.
  84422. * @param x x value of the vector
  84423. * @param y y value of the vector
  84424. * @param z z value of the vector
  84425. * @param w w value of the vector
  84426. */
  84427. constructor(
  84428. /** x value of the vector */
  84429. x: number,
  84430. /** y value of the vector */
  84431. y: number,
  84432. /** z value of the vector */
  84433. z: number,
  84434. /** w value of the vector */
  84435. w: number);
  84436. /**
  84437. * Returns the string with the Vector4 coordinates.
  84438. * @returns a string containing all the vector values
  84439. */
  84440. toString(): string;
  84441. /**
  84442. * Returns the string "Vector4".
  84443. * @returns "Vector4"
  84444. */
  84445. getClassName(): string;
  84446. /**
  84447. * Returns the Vector4 hash code.
  84448. * @returns a unique hash code
  84449. */
  84450. getHashCode(): number;
  84451. /**
  84452. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  84453. * @returns the resulting array
  84454. */
  84455. asArray(): number[];
  84456. /**
  84457. * Populates the given array from the given index with the Vector4 coordinates.
  84458. * @param array array to populate
  84459. * @param index index of the array to start at (default: 0)
  84460. * @returns the Vector4.
  84461. */
  84462. toArray(array: FloatArray, index?: number): Vector4;
  84463. /**
  84464. * Update the current vector from an array
  84465. * @param array defines the destination array
  84466. * @param index defines the offset in the destination array
  84467. * @returns the current Vector3
  84468. */
  84469. fromArray(array: FloatArray, index?: number): Vector4;
  84470. /**
  84471. * Adds the given vector to the current Vector4.
  84472. * @param otherVector the vector to add
  84473. * @returns the updated Vector4.
  84474. */
  84475. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84476. /**
  84477. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  84478. * @param otherVector the vector to add
  84479. * @returns the resulting vector
  84480. */
  84481. add(otherVector: DeepImmutable<Vector4>): Vector4;
  84482. /**
  84483. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  84484. * @param otherVector the vector to add
  84485. * @param result the vector to store the result
  84486. * @returns the current Vector4.
  84487. */
  84488. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84489. /**
  84490. * Subtract in place the given vector from the current Vector4.
  84491. * @param otherVector the vector to subtract
  84492. * @returns the updated Vector4.
  84493. */
  84494. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84495. /**
  84496. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  84497. * @param otherVector the vector to add
  84498. * @returns the new vector with the result
  84499. */
  84500. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  84501. /**
  84502. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  84503. * @param otherVector the vector to subtract
  84504. * @param result the vector to store the result
  84505. * @returns the current Vector4.
  84506. */
  84507. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84508. /**
  84509. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84510. */
  84511. /**
  84512. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84513. * @param x value to subtract
  84514. * @param y value to subtract
  84515. * @param z value to subtract
  84516. * @param w value to subtract
  84517. * @returns new vector containing the result
  84518. */
  84519. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84520. /**
  84521. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84522. * @param x value to subtract
  84523. * @param y value to subtract
  84524. * @param z value to subtract
  84525. * @param w value to subtract
  84526. * @param result the vector to store the result in
  84527. * @returns the current Vector4.
  84528. */
  84529. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  84530. /**
  84531. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  84532. * @returns a new vector with the negated values
  84533. */
  84534. negate(): Vector4;
  84535. /**
  84536. * Negate this vector in place
  84537. * @returns this
  84538. */
  84539. negateInPlace(): Vector4;
  84540. /**
  84541. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  84542. * @param result defines the Vector3 object where to store the result
  84543. * @returns the current Vector4
  84544. */
  84545. negateToRef(result: Vector4): Vector4;
  84546. /**
  84547. * Multiplies the current Vector4 coordinates by scale (float).
  84548. * @param scale the number to scale with
  84549. * @returns the updated Vector4.
  84550. */
  84551. scaleInPlace(scale: number): Vector4;
  84552. /**
  84553. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  84554. * @param scale the number to scale with
  84555. * @returns a new vector with the result
  84556. */
  84557. scale(scale: number): Vector4;
  84558. /**
  84559. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  84560. * @param scale the number to scale with
  84561. * @param result a vector to store the result in
  84562. * @returns the current Vector4.
  84563. */
  84564. scaleToRef(scale: number, result: Vector4): Vector4;
  84565. /**
  84566. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  84567. * @param scale defines the scale factor
  84568. * @param result defines the Vector4 object where to store the result
  84569. * @returns the unmodified current Vector4
  84570. */
  84571. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  84572. /**
  84573. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  84574. * @param otherVector the vector to compare against
  84575. * @returns true if they are equal
  84576. */
  84577. equals(otherVector: DeepImmutable<Vector4>): boolean;
  84578. /**
  84579. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  84580. * @param otherVector vector to compare against
  84581. * @param epsilon (Default: very small number)
  84582. * @returns true if they are equal
  84583. */
  84584. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  84585. /**
  84586. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  84587. * @param x x value to compare against
  84588. * @param y y value to compare against
  84589. * @param z z value to compare against
  84590. * @param w w value to compare against
  84591. * @returns true if equal
  84592. */
  84593. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  84594. /**
  84595. * Multiplies in place the current Vector4 by the given one.
  84596. * @param otherVector vector to multiple with
  84597. * @returns the updated Vector4.
  84598. */
  84599. multiplyInPlace(otherVector: Vector4): Vector4;
  84600. /**
  84601. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  84602. * @param otherVector vector to multiple with
  84603. * @returns resulting new vector
  84604. */
  84605. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  84606. /**
  84607. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  84608. * @param otherVector vector to multiple with
  84609. * @param result vector to store the result
  84610. * @returns the current Vector4.
  84611. */
  84612. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84613. /**
  84614. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  84615. * @param x x value multiply with
  84616. * @param y y value multiply with
  84617. * @param z z value multiply with
  84618. * @param w w value multiply with
  84619. * @returns resulting new vector
  84620. */
  84621. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  84622. /**
  84623. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  84624. * @param otherVector vector to devide with
  84625. * @returns resulting new vector
  84626. */
  84627. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  84628. /**
  84629. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  84630. * @param otherVector vector to devide with
  84631. * @param result vector to store the result
  84632. * @returns the current Vector4.
  84633. */
  84634. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84635. /**
  84636. * Divides the current Vector3 coordinates by the given ones.
  84637. * @param otherVector vector to devide with
  84638. * @returns the updated Vector3.
  84639. */
  84640. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84641. /**
  84642. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  84643. * @param other defines the second operand
  84644. * @returns the current updated Vector4
  84645. */
  84646. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84647. /**
  84648. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  84649. * @param other defines the second operand
  84650. * @returns the current updated Vector4
  84651. */
  84652. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84653. /**
  84654. * Gets a new Vector4 from current Vector4 floored values
  84655. * @returns a new Vector4
  84656. */
  84657. floor(): Vector4;
  84658. /**
  84659. * Gets a new Vector4 from current Vector3 floored values
  84660. * @returns a new Vector4
  84661. */
  84662. fract(): Vector4;
  84663. /**
  84664. * Returns the Vector4 length (float).
  84665. * @returns the length
  84666. */
  84667. length(): number;
  84668. /**
  84669. * Returns the Vector4 squared length (float).
  84670. * @returns the length squared
  84671. */
  84672. lengthSquared(): number;
  84673. /**
  84674. * Normalizes in place the Vector4.
  84675. * @returns the updated Vector4.
  84676. */
  84677. normalize(): Vector4;
  84678. /**
  84679. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  84680. * @returns this converted to a new vector3
  84681. */
  84682. toVector3(): Vector3;
  84683. /**
  84684. * Returns a new Vector4 copied from the current one.
  84685. * @returns the new cloned vector
  84686. */
  84687. clone(): Vector4;
  84688. /**
  84689. * Updates the current Vector4 with the given one coordinates.
  84690. * @param source the source vector to copy from
  84691. * @returns the updated Vector4.
  84692. */
  84693. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  84694. /**
  84695. * Updates the current Vector4 coordinates with the given floats.
  84696. * @param x float to copy from
  84697. * @param y float to copy from
  84698. * @param z float to copy from
  84699. * @param w float to copy from
  84700. * @returns the updated Vector4.
  84701. */
  84702. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84703. /**
  84704. * Updates the current Vector4 coordinates with the given floats.
  84705. * @param x float to set from
  84706. * @param y float to set from
  84707. * @param z float to set from
  84708. * @param w float to set from
  84709. * @returns the updated Vector4.
  84710. */
  84711. set(x: number, y: number, z: number, w: number): Vector4;
  84712. /**
  84713. * Copies the given float to the current Vector3 coordinates
  84714. * @param v defines the x, y, z and w coordinates of the operand
  84715. * @returns the current updated Vector3
  84716. */
  84717. setAll(v: number): Vector4;
  84718. /**
  84719. * Returns a new Vector4 set from the starting index of the given array.
  84720. * @param array the array to pull values from
  84721. * @param offset the offset into the array to start at
  84722. * @returns the new vector
  84723. */
  84724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  84725. /**
  84726. * Updates the given vector "result" from the starting index of the given array.
  84727. * @param array the array to pull values from
  84728. * @param offset the offset into the array to start at
  84729. * @param result the vector to store the result in
  84730. */
  84731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  84732. /**
  84733. * Updates the given vector "result" from the starting index of the given Float32Array.
  84734. * @param array the array to pull values from
  84735. * @param offset the offset into the array to start at
  84736. * @param result the vector to store the result in
  84737. */
  84738. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  84739. /**
  84740. * Updates the given vector "result" coordinates from the given floats.
  84741. * @param x float to set from
  84742. * @param y float to set from
  84743. * @param z float to set from
  84744. * @param w float to set from
  84745. * @param result the vector to the floats in
  84746. */
  84747. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  84748. /**
  84749. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  84750. * @returns the new vector
  84751. */
  84752. static Zero(): Vector4;
  84753. /**
  84754. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  84755. * @returns the new vector
  84756. */
  84757. static One(): Vector4;
  84758. /**
  84759. * Returns a new normalized Vector4 from the given one.
  84760. * @param vector the vector to normalize
  84761. * @returns the vector
  84762. */
  84763. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  84764. /**
  84765. * Updates the given vector "result" from the normalization of the given one.
  84766. * @param vector the vector to normalize
  84767. * @param result the vector to store the result in
  84768. */
  84769. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  84770. /**
  84771. * Returns a vector with the minimum values from the left and right vectors
  84772. * @param left left vector to minimize
  84773. * @param right right vector to minimize
  84774. * @returns a new vector with the minimum of the left and right vector values
  84775. */
  84776. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84777. /**
  84778. * Returns a vector with the maximum values from the left and right vectors
  84779. * @param left left vector to maximize
  84780. * @param right right vector to maximize
  84781. * @returns a new vector with the maximum of the left and right vector values
  84782. */
  84783. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84784. /**
  84785. * Returns the distance (float) between the vectors "value1" and "value2".
  84786. * @param value1 value to calulate the distance between
  84787. * @param value2 value to calulate the distance between
  84788. * @return the distance between the two vectors
  84789. */
  84790. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84791. /**
  84792. * Returns the squared distance (float) between the vectors "value1" and "value2".
  84793. * @param value1 value to calulate the distance between
  84794. * @param value2 value to calulate the distance between
  84795. * @return the distance between the two vectors squared
  84796. */
  84797. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84798. /**
  84799. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  84800. * @param value1 value to calulate the center between
  84801. * @param value2 value to calulate the center between
  84802. * @return the center between the two vectors
  84803. */
  84804. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  84805. /**
  84806. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  84807. * This methods computes transformed normalized direction vectors only.
  84808. * @param vector the vector to transform
  84809. * @param transformation the transformation matrix to apply
  84810. * @returns the new vector
  84811. */
  84812. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  84813. /**
  84814. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  84815. * This methods computes transformed normalized direction vectors only.
  84816. * @param vector the vector to transform
  84817. * @param transformation the transformation matrix to apply
  84818. * @param result the vector to store the result in
  84819. */
  84820. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84821. /**
  84822. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  84823. * This methods computes transformed normalized direction vectors only.
  84824. * @param x value to transform
  84825. * @param y value to transform
  84826. * @param z value to transform
  84827. * @param w value to transform
  84828. * @param transformation the transformation matrix to apply
  84829. * @param result the vector to store the results in
  84830. */
  84831. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84832. /**
  84833. * Creates a new Vector4 from a Vector3
  84834. * @param source defines the source data
  84835. * @param w defines the 4th component (default is 0)
  84836. * @returns a new Vector4
  84837. */
  84838. static FromVector3(source: Vector3, w?: number): Vector4;
  84839. }
  84840. /**
  84841. * Class used to store quaternion data
  84842. * @see https://en.wikipedia.org/wiki/Quaternion
  84843. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  84844. */
  84845. export class Quaternion {
  84846. /** @hidden */
  84847. _x: number;
  84848. /** @hidden */
  84849. _y: number;
  84850. /** @hidden */
  84851. _z: number;
  84852. /** @hidden */
  84853. _w: number;
  84854. /** @hidden */
  84855. _isDirty: boolean;
  84856. /** Gets or sets the x coordinate */
  84857. get x(): number;
  84858. set x(value: number);
  84859. /** Gets or sets the y coordinate */
  84860. get y(): number;
  84861. set y(value: number);
  84862. /** Gets or sets the z coordinate */
  84863. get z(): number;
  84864. set z(value: number);
  84865. /** Gets or sets the w coordinate */
  84866. get w(): number;
  84867. set w(value: number);
  84868. /**
  84869. * Creates a new Quaternion from the given floats
  84870. * @param x defines the first component (0 by default)
  84871. * @param y defines the second component (0 by default)
  84872. * @param z defines the third component (0 by default)
  84873. * @param w defines the fourth component (1.0 by default)
  84874. */
  84875. constructor(x?: number, y?: number, z?: number, w?: number);
  84876. /**
  84877. * Gets a string representation for the current quaternion
  84878. * @returns a string with the Quaternion coordinates
  84879. */
  84880. toString(): string;
  84881. /**
  84882. * Gets the class name of the quaternion
  84883. * @returns the string "Quaternion"
  84884. */
  84885. getClassName(): string;
  84886. /**
  84887. * Gets a hash code for this quaternion
  84888. * @returns the quaternion hash code
  84889. */
  84890. getHashCode(): number;
  84891. /**
  84892. * Copy the quaternion to an array
  84893. * @returns a new array populated with 4 elements from the quaternion coordinates
  84894. */
  84895. asArray(): number[];
  84896. /**
  84897. * Check if two quaternions are equals
  84898. * @param otherQuaternion defines the second operand
  84899. * @return true if the current quaternion and the given one coordinates are strictly equals
  84900. */
  84901. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84902. /**
  84903. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84904. * @param otherQuaternion defines the other quaternion
  84905. * @param epsilon defines the minimal distance to consider equality
  84906. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84907. */
  84908. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84909. /**
  84910. * Clone the current quaternion
  84911. * @returns a new quaternion copied from the current one
  84912. */
  84913. clone(): Quaternion;
  84914. /**
  84915. * Copy a quaternion to the current one
  84916. * @param other defines the other quaternion
  84917. * @returns the updated current quaternion
  84918. */
  84919. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84920. /**
  84921. * Updates the current quaternion with the given float coordinates
  84922. * @param x defines the x coordinate
  84923. * @param y defines the y coordinate
  84924. * @param z defines the z coordinate
  84925. * @param w defines the w coordinate
  84926. * @returns the updated current quaternion
  84927. */
  84928. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84929. /**
  84930. * Updates the current quaternion from the given float coordinates
  84931. * @param x defines the x coordinate
  84932. * @param y defines the y coordinate
  84933. * @param z defines the z coordinate
  84934. * @param w defines the w coordinate
  84935. * @returns the updated current quaternion
  84936. */
  84937. set(x: number, y: number, z: number, w: number): Quaternion;
  84938. /**
  84939. * Adds two quaternions
  84940. * @param other defines the second operand
  84941. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84942. */
  84943. add(other: DeepImmutable<Quaternion>): Quaternion;
  84944. /**
  84945. * Add a quaternion to the current one
  84946. * @param other defines the quaternion to add
  84947. * @returns the current quaternion
  84948. */
  84949. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84950. /**
  84951. * Subtract two quaternions
  84952. * @param other defines the second operand
  84953. * @returns a new quaternion as the subtraction result of the given one from the current one
  84954. */
  84955. subtract(other: Quaternion): Quaternion;
  84956. /**
  84957. * Multiplies the current quaternion by a scale factor
  84958. * @param value defines the scale factor
  84959. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84960. */
  84961. scale(value: number): Quaternion;
  84962. /**
  84963. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84964. * @param scale defines the scale factor
  84965. * @param result defines the Quaternion object where to store the result
  84966. * @returns the unmodified current quaternion
  84967. */
  84968. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84969. /**
  84970. * Multiplies in place the current quaternion by a scale factor
  84971. * @param value defines the scale factor
  84972. * @returns the current modified quaternion
  84973. */
  84974. scaleInPlace(value: number): Quaternion;
  84975. /**
  84976. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84977. * @param scale defines the scale factor
  84978. * @param result defines the Quaternion object where to store the result
  84979. * @returns the unmodified current quaternion
  84980. */
  84981. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84982. /**
  84983. * Multiplies two quaternions
  84984. * @param q1 defines the second operand
  84985. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84986. */
  84987. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84988. /**
  84989. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84990. * @param q1 defines the second operand
  84991. * @param result defines the target quaternion
  84992. * @returns the current quaternion
  84993. */
  84994. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84995. /**
  84996. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84997. * @param q1 defines the second operand
  84998. * @returns the currentupdated quaternion
  84999. */
  85000. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  85001. /**
  85002. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  85003. * @param ref defines the target quaternion
  85004. * @returns the current quaternion
  85005. */
  85006. conjugateToRef(ref: Quaternion): Quaternion;
  85007. /**
  85008. * Conjugates in place (1-q) the current quaternion
  85009. * @returns the current updated quaternion
  85010. */
  85011. conjugateInPlace(): Quaternion;
  85012. /**
  85013. * Conjugates in place (1-q) the current quaternion
  85014. * @returns a new quaternion
  85015. */
  85016. conjugate(): Quaternion;
  85017. /**
  85018. * Gets length of current quaternion
  85019. * @returns the quaternion length (float)
  85020. */
  85021. length(): number;
  85022. /**
  85023. * Normalize in place the current quaternion
  85024. * @returns the current updated quaternion
  85025. */
  85026. normalize(): Quaternion;
  85027. /**
  85028. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  85029. * @param order is a reserved parameter and is ignored for now
  85030. * @returns a new Vector3 containing the Euler angles
  85031. */
  85032. toEulerAngles(order?: string): Vector3;
  85033. /**
  85034. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  85035. * @param result defines the vector which will be filled with the Euler angles
  85036. * @returns the current unchanged quaternion
  85037. */
  85038. toEulerAnglesToRef(result: Vector3): Quaternion;
  85039. /**
  85040. * Updates the given rotation matrix with the current quaternion values
  85041. * @param result defines the target matrix
  85042. * @returns the current unchanged quaternion
  85043. */
  85044. toRotationMatrix(result: Matrix): Quaternion;
  85045. /**
  85046. * Updates the current quaternion from the given rotation matrix values
  85047. * @param matrix defines the source matrix
  85048. * @returns the current updated quaternion
  85049. */
  85050. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85051. /**
  85052. * Creates a new quaternion from a rotation matrix
  85053. * @param matrix defines the source matrix
  85054. * @returns a new quaternion created from the given rotation matrix values
  85055. */
  85056. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85057. /**
  85058. * Updates the given quaternion with the given rotation matrix values
  85059. * @param matrix defines the source matrix
  85060. * @param result defines the target quaternion
  85061. */
  85062. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  85063. /**
  85064. * Returns the dot product (float) between the quaternions "left" and "right"
  85065. * @param left defines the left operand
  85066. * @param right defines the right operand
  85067. * @returns the dot product
  85068. */
  85069. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  85070. /**
  85071. * Checks if the two quaternions are close to each other
  85072. * @param quat0 defines the first quaternion to check
  85073. * @param quat1 defines the second quaternion to check
  85074. * @returns true if the two quaternions are close to each other
  85075. */
  85076. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  85077. /**
  85078. * Creates an empty quaternion
  85079. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  85080. */
  85081. static Zero(): Quaternion;
  85082. /**
  85083. * Inverse a given quaternion
  85084. * @param q defines the source quaternion
  85085. * @returns a new quaternion as the inverted current quaternion
  85086. */
  85087. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  85088. /**
  85089. * Inverse a given quaternion
  85090. * @param q defines the source quaternion
  85091. * @param result the quaternion the result will be stored in
  85092. * @returns the result quaternion
  85093. */
  85094. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  85095. /**
  85096. * Creates an identity quaternion
  85097. * @returns the identity quaternion
  85098. */
  85099. static Identity(): Quaternion;
  85100. /**
  85101. * Gets a boolean indicating if the given quaternion is identity
  85102. * @param quaternion defines the quaternion to check
  85103. * @returns true if the quaternion is identity
  85104. */
  85105. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  85106. /**
  85107. * Creates a quaternion from a rotation around an axis
  85108. * @param axis defines the axis to use
  85109. * @param angle defines the angle to use
  85110. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  85111. */
  85112. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  85113. /**
  85114. * Creates a rotation around an axis and stores it into the given quaternion
  85115. * @param axis defines the axis to use
  85116. * @param angle defines the angle to use
  85117. * @param result defines the target quaternion
  85118. * @returns the target quaternion
  85119. */
  85120. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  85121. /**
  85122. * Creates a new quaternion from data stored into an array
  85123. * @param array defines the data source
  85124. * @param offset defines the offset in the source array where the data starts
  85125. * @returns a new quaternion
  85126. */
  85127. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  85128. /**
  85129. * Updates the given quaternion "result" from the starting index of the given array.
  85130. * @param array the array to pull values from
  85131. * @param offset the offset into the array to start at
  85132. * @param result the quaternion to store the result in
  85133. */
  85134. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  85135. /**
  85136. * Create a quaternion from Euler rotation angles
  85137. * @param x Pitch
  85138. * @param y Yaw
  85139. * @param z Roll
  85140. * @returns the new Quaternion
  85141. */
  85142. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  85143. /**
  85144. * Updates a quaternion from Euler rotation angles
  85145. * @param x Pitch
  85146. * @param y Yaw
  85147. * @param z Roll
  85148. * @param result the quaternion to store the result
  85149. * @returns the updated quaternion
  85150. */
  85151. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  85152. /**
  85153. * Create a quaternion from Euler rotation vector
  85154. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85155. * @returns the new Quaternion
  85156. */
  85157. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  85158. /**
  85159. * Updates a quaternion from Euler rotation vector
  85160. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85161. * @param result the quaternion to store the result
  85162. * @returns the updated quaternion
  85163. */
  85164. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  85165. /**
  85166. * Creates a new quaternion from the given Euler float angles (y, x, z)
  85167. * @param yaw defines the rotation around Y axis
  85168. * @param pitch defines the rotation around X axis
  85169. * @param roll defines the rotation around Z axis
  85170. * @returns the new quaternion
  85171. */
  85172. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  85173. /**
  85174. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  85175. * @param yaw defines the rotation around Y axis
  85176. * @param pitch defines the rotation around X axis
  85177. * @param roll defines the rotation around Z axis
  85178. * @param result defines the target quaternion
  85179. */
  85180. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  85181. /**
  85182. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  85183. * @param alpha defines the rotation around first axis
  85184. * @param beta defines the rotation around second axis
  85185. * @param gamma defines the rotation around third axis
  85186. * @returns the new quaternion
  85187. */
  85188. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  85189. /**
  85190. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  85191. * @param alpha defines the rotation around first axis
  85192. * @param beta defines the rotation around second axis
  85193. * @param gamma defines the rotation around third axis
  85194. * @param result defines the target quaternion
  85195. */
  85196. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  85197. /**
  85198. * 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)
  85199. * @param axis1 defines the first axis
  85200. * @param axis2 defines the second axis
  85201. * @param axis3 defines the third axis
  85202. * @returns the new quaternion
  85203. */
  85204. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  85205. /**
  85206. * 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
  85207. * @param axis1 defines the first axis
  85208. * @param axis2 defines the second axis
  85209. * @param axis3 defines the third axis
  85210. * @param ref defines the target quaternion
  85211. */
  85212. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  85213. /**
  85214. * Interpolates between two quaternions
  85215. * @param left defines first quaternion
  85216. * @param right defines second quaternion
  85217. * @param amount defines the gradient to use
  85218. * @returns the new interpolated quaternion
  85219. */
  85220. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  85221. /**
  85222. * Interpolates between two quaternions and stores it into a target quaternion
  85223. * @param left defines first quaternion
  85224. * @param right defines second quaternion
  85225. * @param amount defines the gradient to use
  85226. * @param result defines the target quaternion
  85227. */
  85228. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  85229. /**
  85230. * Interpolate between two quaternions using Hermite interpolation
  85231. * @param value1 defines first quaternion
  85232. * @param tangent1 defines the incoming tangent
  85233. * @param value2 defines second quaternion
  85234. * @param tangent2 defines the outgoing tangent
  85235. * @param amount defines the target quaternion
  85236. * @returns the new interpolated quaternion
  85237. */
  85238. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  85239. }
  85240. /**
  85241. * Class used to store matrix data (4x4)
  85242. */
  85243. export class Matrix {
  85244. /**
  85245. * Gets the precision of matrix computations
  85246. */
  85247. static get Use64Bits(): boolean;
  85248. private static _updateFlagSeed;
  85249. private static _identityReadOnly;
  85250. private _isIdentity;
  85251. private _isIdentityDirty;
  85252. private _isIdentity3x2;
  85253. private _isIdentity3x2Dirty;
  85254. /**
  85255. * Gets the update flag of the matrix which is an unique number for the matrix.
  85256. * It will be incremented every time the matrix data change.
  85257. * You can use it to speed the comparison between two versions of the same matrix.
  85258. */
  85259. updateFlag: number;
  85260. private readonly _m;
  85261. /**
  85262. * Gets the internal data of the matrix
  85263. */
  85264. get m(): DeepImmutable<Float32Array | Array<number>>;
  85265. /** @hidden */
  85266. _markAsUpdated(): void;
  85267. /** @hidden */
  85268. private _updateIdentityStatus;
  85269. /**
  85270. * Creates an empty matrix (filled with zeros)
  85271. */
  85272. constructor();
  85273. /**
  85274. * Check if the current matrix is identity
  85275. * @returns true is the matrix is the identity matrix
  85276. */
  85277. isIdentity(): boolean;
  85278. /**
  85279. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  85280. * @returns true is the matrix is the identity matrix
  85281. */
  85282. isIdentityAs3x2(): boolean;
  85283. /**
  85284. * Gets the determinant of the matrix
  85285. * @returns the matrix determinant
  85286. */
  85287. determinant(): number;
  85288. /**
  85289. * Returns the matrix as a Float32Array or Array<number>
  85290. * @returns the matrix underlying array
  85291. */
  85292. toArray(): DeepImmutable<Float32Array | Array<number>>;
  85293. /**
  85294. * Returns the matrix as a Float32Array or Array<number>
  85295. * @returns the matrix underlying array.
  85296. */
  85297. asArray(): DeepImmutable<Float32Array | Array<number>>;
  85298. /**
  85299. * Inverts the current matrix in place
  85300. * @returns the current inverted matrix
  85301. */
  85302. invert(): Matrix;
  85303. /**
  85304. * Sets all the matrix elements to zero
  85305. * @returns the current matrix
  85306. */
  85307. reset(): Matrix;
  85308. /**
  85309. * Adds the current matrix with a second one
  85310. * @param other defines the matrix to add
  85311. * @returns a new matrix as the addition of the current matrix and the given one
  85312. */
  85313. add(other: DeepImmutable<Matrix>): Matrix;
  85314. /**
  85315. * Sets the given matrix "result" to the addition of the current matrix and the given one
  85316. * @param other defines the matrix to add
  85317. * @param result defines the target matrix
  85318. * @returns the current matrix
  85319. */
  85320. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  85321. /**
  85322. * Adds in place the given matrix to the current matrix
  85323. * @param other defines the second operand
  85324. * @returns the current updated matrix
  85325. */
  85326. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  85327. /**
  85328. * Sets the given matrix to the current inverted Matrix
  85329. * @param other defines the target matrix
  85330. * @returns the unmodified current matrix
  85331. */
  85332. invertToRef(other: Matrix): Matrix;
  85333. /**
  85334. * add a value at the specified position in the current Matrix
  85335. * @param index the index of the value within the matrix. between 0 and 15.
  85336. * @param value the value to be added
  85337. * @returns the current updated matrix
  85338. */
  85339. addAtIndex(index: number, value: number): Matrix;
  85340. /**
  85341. * mutiply the specified position in the current Matrix by a value
  85342. * @param index the index of the value within the matrix. between 0 and 15.
  85343. * @param value the value to be added
  85344. * @returns the current updated matrix
  85345. */
  85346. multiplyAtIndex(index: number, value: number): Matrix;
  85347. /**
  85348. * Inserts the translation vector (using 3 floats) in the current matrix
  85349. * @param x defines the 1st component of the translation
  85350. * @param y defines the 2nd component of the translation
  85351. * @param z defines the 3rd component of the translation
  85352. * @returns the current updated matrix
  85353. */
  85354. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  85355. /**
  85356. * Adds the translation vector (using 3 floats) in the current matrix
  85357. * @param x defines the 1st component of the translation
  85358. * @param y defines the 2nd component of the translation
  85359. * @param z defines the 3rd component of the translation
  85360. * @returns the current updated matrix
  85361. */
  85362. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  85363. /**
  85364. * Inserts the translation vector in the current matrix
  85365. * @param vector3 defines the translation to insert
  85366. * @returns the current updated matrix
  85367. */
  85368. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  85369. /**
  85370. * Gets the translation value of the current matrix
  85371. * @returns a new Vector3 as the extracted translation from the matrix
  85372. */
  85373. getTranslation(): Vector3;
  85374. /**
  85375. * Fill a Vector3 with the extracted translation from the matrix
  85376. * @param result defines the Vector3 where to store the translation
  85377. * @returns the current matrix
  85378. */
  85379. getTranslationToRef(result: Vector3): Matrix;
  85380. /**
  85381. * Remove rotation and scaling part from the matrix
  85382. * @returns the updated matrix
  85383. */
  85384. removeRotationAndScaling(): Matrix;
  85385. /**
  85386. * Multiply two matrices
  85387. * @param other defines the second operand
  85388. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  85389. */
  85390. multiply(other: DeepImmutable<Matrix>): Matrix;
  85391. /**
  85392. * Copy the current matrix from the given one
  85393. * @param other defines the source matrix
  85394. * @returns the current updated matrix
  85395. */
  85396. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  85397. /**
  85398. * Populates the given array from the starting index with the current matrix values
  85399. * @param array defines the target array
  85400. * @param offset defines the offset in the target array where to start storing values
  85401. * @returns the current matrix
  85402. */
  85403. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  85404. /**
  85405. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  85406. * @param other defines the second operand
  85407. * @param result defines the matrix where to store the multiplication
  85408. * @returns the current matrix
  85409. */
  85410. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  85411. /**
  85412. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  85413. * @param other defines the second operand
  85414. * @param result defines the array where to store the multiplication
  85415. * @param offset defines the offset in the target array where to start storing values
  85416. * @returns the current matrix
  85417. */
  85418. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  85419. /**
  85420. * Check equality between this matrix and a second one
  85421. * @param value defines the second matrix to compare
  85422. * @returns true is the current matrix and the given one values are strictly equal
  85423. */
  85424. equals(value: DeepImmutable<Matrix>): boolean;
  85425. /**
  85426. * Clone the current matrix
  85427. * @returns a new matrix from the current matrix
  85428. */
  85429. clone(): Matrix;
  85430. /**
  85431. * Returns the name of the current matrix class
  85432. * @returns the string "Matrix"
  85433. */
  85434. getClassName(): string;
  85435. /**
  85436. * Gets the hash code of the current matrix
  85437. * @returns the hash code
  85438. */
  85439. getHashCode(): number;
  85440. /**
  85441. * Decomposes the current Matrix into a translation, rotation and scaling components
  85442. * @param scale defines the scale vector3 given as a reference to update
  85443. * @param rotation defines the rotation quaternion given as a reference to update
  85444. * @param translation defines the translation vector3 given as a reference to update
  85445. * @returns true if operation was successful
  85446. */
  85447. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  85448. /**
  85449. * Gets specific row of the matrix
  85450. * @param index defines the number of the row to get
  85451. * @returns the index-th row of the current matrix as a new Vector4
  85452. */
  85453. getRow(index: number): Nullable<Vector4>;
  85454. /**
  85455. * Sets the index-th row of the current matrix to the vector4 values
  85456. * @param index defines the number of the row to set
  85457. * @param row defines the target vector4
  85458. * @returns the updated current matrix
  85459. */
  85460. setRow(index: number, row: Vector4): Matrix;
  85461. /**
  85462. * Compute the transpose of the matrix
  85463. * @returns the new transposed matrix
  85464. */
  85465. transpose(): Matrix;
  85466. /**
  85467. * Compute the transpose of the matrix and store it in a given matrix
  85468. * @param result defines the target matrix
  85469. * @returns the current matrix
  85470. */
  85471. transposeToRef(result: Matrix): Matrix;
  85472. /**
  85473. * Sets the index-th row of the current matrix with the given 4 x float values
  85474. * @param index defines the row index
  85475. * @param x defines the x component to set
  85476. * @param y defines the y component to set
  85477. * @param z defines the z component to set
  85478. * @param w defines the w component to set
  85479. * @returns the updated current matrix
  85480. */
  85481. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  85482. /**
  85483. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  85484. * @param scale defines the scale factor
  85485. * @returns a new matrix
  85486. */
  85487. scale(scale: number): Matrix;
  85488. /**
  85489. * Scale the current matrix values by a factor to a given result matrix
  85490. * @param scale defines the scale factor
  85491. * @param result defines the matrix to store the result
  85492. * @returns the current matrix
  85493. */
  85494. scaleToRef(scale: number, result: Matrix): Matrix;
  85495. /**
  85496. * Scale the current matrix values by a factor and add the result to a given matrix
  85497. * @param scale defines the scale factor
  85498. * @param result defines the Matrix to store the result
  85499. * @returns the current matrix
  85500. */
  85501. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  85502. /**
  85503. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  85504. * @param ref matrix to store the result
  85505. */
  85506. toNormalMatrix(ref: Matrix): void;
  85507. /**
  85508. * Gets only rotation part of the current matrix
  85509. * @returns a new matrix sets to the extracted rotation matrix from the current one
  85510. */
  85511. getRotationMatrix(): Matrix;
  85512. /**
  85513. * Extracts the rotation matrix from the current one and sets it as the given "result"
  85514. * @param result defines the target matrix to store data to
  85515. * @returns the current matrix
  85516. */
  85517. getRotationMatrixToRef(result: Matrix): Matrix;
  85518. /**
  85519. * Toggles model matrix from being right handed to left handed in place and vice versa
  85520. */
  85521. toggleModelMatrixHandInPlace(): void;
  85522. /**
  85523. * Toggles projection matrix from being right handed to left handed in place and vice versa
  85524. */
  85525. toggleProjectionMatrixHandInPlace(): void;
  85526. /**
  85527. * Creates a matrix from an array
  85528. * @param array defines the source array
  85529. * @param offset defines an offset in the source array
  85530. * @returns a new Matrix set from the starting index of the given array
  85531. */
  85532. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  85533. /**
  85534. * Copy the content of an array into a given matrix
  85535. * @param array defines the source array
  85536. * @param offset defines an offset in the source array
  85537. * @param result defines the target matrix
  85538. */
  85539. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  85540. /**
  85541. * Stores an array into a matrix after having multiplied each component by a given factor
  85542. * @param array defines the source array
  85543. * @param offset defines the offset in the source array
  85544. * @param scale defines the scaling factor
  85545. * @param result defines the target matrix
  85546. */
  85547. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  85548. /**
  85549. * Gets an identity matrix that must not be updated
  85550. */
  85551. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  85552. /**
  85553. * Stores a list of values (16) inside a given matrix
  85554. * @param initialM11 defines 1st value of 1st row
  85555. * @param initialM12 defines 2nd value of 1st row
  85556. * @param initialM13 defines 3rd value of 1st row
  85557. * @param initialM14 defines 4th value of 1st row
  85558. * @param initialM21 defines 1st value of 2nd row
  85559. * @param initialM22 defines 2nd value of 2nd row
  85560. * @param initialM23 defines 3rd value of 2nd row
  85561. * @param initialM24 defines 4th value of 2nd row
  85562. * @param initialM31 defines 1st value of 3rd row
  85563. * @param initialM32 defines 2nd value of 3rd row
  85564. * @param initialM33 defines 3rd value of 3rd row
  85565. * @param initialM34 defines 4th value of 3rd row
  85566. * @param initialM41 defines 1st value of 4th row
  85567. * @param initialM42 defines 2nd value of 4th row
  85568. * @param initialM43 defines 3rd value of 4th row
  85569. * @param initialM44 defines 4th value of 4th row
  85570. * @param result defines the target matrix
  85571. */
  85572. 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;
  85573. /**
  85574. * Creates new matrix from a list of values (16)
  85575. * @param initialM11 defines 1st value of 1st row
  85576. * @param initialM12 defines 2nd value of 1st row
  85577. * @param initialM13 defines 3rd value of 1st row
  85578. * @param initialM14 defines 4th value of 1st row
  85579. * @param initialM21 defines 1st value of 2nd row
  85580. * @param initialM22 defines 2nd value of 2nd row
  85581. * @param initialM23 defines 3rd value of 2nd row
  85582. * @param initialM24 defines 4th value of 2nd row
  85583. * @param initialM31 defines 1st value of 3rd row
  85584. * @param initialM32 defines 2nd value of 3rd row
  85585. * @param initialM33 defines 3rd value of 3rd row
  85586. * @param initialM34 defines 4th value of 3rd row
  85587. * @param initialM41 defines 1st value of 4th row
  85588. * @param initialM42 defines 2nd value of 4th row
  85589. * @param initialM43 defines 3rd value of 4th row
  85590. * @param initialM44 defines 4th value of 4th row
  85591. * @returns the new matrix
  85592. */
  85593. 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;
  85594. /**
  85595. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85596. * @param scale defines the scale vector3
  85597. * @param rotation defines the rotation quaternion
  85598. * @param translation defines the translation vector3
  85599. * @returns a new matrix
  85600. */
  85601. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  85602. /**
  85603. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85604. * @param scale defines the scale vector3
  85605. * @param rotation defines the rotation quaternion
  85606. * @param translation defines the translation vector3
  85607. * @param result defines the target matrix
  85608. */
  85609. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  85610. /**
  85611. * Creates a new identity matrix
  85612. * @returns a new identity matrix
  85613. */
  85614. static Identity(): Matrix;
  85615. /**
  85616. * Creates a new identity matrix and stores the result in a given matrix
  85617. * @param result defines the target matrix
  85618. */
  85619. static IdentityToRef(result: Matrix): void;
  85620. /**
  85621. * Creates a new zero matrix
  85622. * @returns a new zero matrix
  85623. */
  85624. static Zero(): Matrix;
  85625. /**
  85626. * Creates a new rotation matrix for "angle" radians around the X axis
  85627. * @param angle defines the angle (in radians) to use
  85628. * @return the new matrix
  85629. */
  85630. static RotationX(angle: number): Matrix;
  85631. /**
  85632. * Creates a new matrix as the invert of a given matrix
  85633. * @param source defines the source matrix
  85634. * @returns the new matrix
  85635. */
  85636. static Invert(source: DeepImmutable<Matrix>): Matrix;
  85637. /**
  85638. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  85639. * @param angle defines the angle (in radians) to use
  85640. * @param result defines the target matrix
  85641. */
  85642. static RotationXToRef(angle: number, result: Matrix): void;
  85643. /**
  85644. * Creates a new rotation matrix for "angle" radians around the Y axis
  85645. * @param angle defines the angle (in radians) to use
  85646. * @return the new matrix
  85647. */
  85648. static RotationY(angle: number): Matrix;
  85649. /**
  85650. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  85651. * @param angle defines the angle (in radians) to use
  85652. * @param result defines the target matrix
  85653. */
  85654. static RotationYToRef(angle: number, result: Matrix): void;
  85655. /**
  85656. * Creates a new rotation matrix for "angle" radians around the Z axis
  85657. * @param angle defines the angle (in radians) to use
  85658. * @return the new matrix
  85659. */
  85660. static RotationZ(angle: number): Matrix;
  85661. /**
  85662. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  85663. * @param angle defines the angle (in radians) to use
  85664. * @param result defines the target matrix
  85665. */
  85666. static RotationZToRef(angle: number, result: Matrix): void;
  85667. /**
  85668. * Creates a new rotation matrix for "angle" radians around the given axis
  85669. * @param axis defines the axis to use
  85670. * @param angle defines the angle (in radians) to use
  85671. * @return the new matrix
  85672. */
  85673. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  85674. /**
  85675. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  85676. * @param axis defines the axis to use
  85677. * @param angle defines the angle (in radians) to use
  85678. * @param result defines the target matrix
  85679. */
  85680. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  85681. /**
  85682. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  85683. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  85684. * @param from defines the vector to align
  85685. * @param to defines the vector to align to
  85686. * @param result defines the target matrix
  85687. */
  85688. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  85689. /**
  85690. * Creates a rotation matrix
  85691. * @param yaw defines the yaw angle in radians (Y axis)
  85692. * @param pitch defines the pitch angle in radians (X axis)
  85693. * @param roll defines the roll angle in radians (Z axis)
  85694. * @returns the new rotation matrix
  85695. */
  85696. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  85697. /**
  85698. * Creates a rotation matrix and stores it in a given matrix
  85699. * @param yaw defines the yaw angle in radians (Y axis)
  85700. * @param pitch defines the pitch angle in radians (X axis)
  85701. * @param roll defines the roll angle in radians (Z axis)
  85702. * @param result defines the target matrix
  85703. */
  85704. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  85705. /**
  85706. * Creates a scaling matrix
  85707. * @param x defines the scale factor on X axis
  85708. * @param y defines the scale factor on Y axis
  85709. * @param z defines the scale factor on Z axis
  85710. * @returns the new matrix
  85711. */
  85712. static Scaling(x: number, y: number, z: number): Matrix;
  85713. /**
  85714. * Creates a scaling matrix and stores it in a given matrix
  85715. * @param x defines the scale factor on X axis
  85716. * @param y defines the scale factor on Y axis
  85717. * @param z defines the scale factor on Z axis
  85718. * @param result defines the target matrix
  85719. */
  85720. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  85721. /**
  85722. * Creates a translation matrix
  85723. * @param x defines the translation on X axis
  85724. * @param y defines the translation on Y axis
  85725. * @param z defines the translationon Z axis
  85726. * @returns the new matrix
  85727. */
  85728. static Translation(x: number, y: number, z: number): Matrix;
  85729. /**
  85730. * Creates a translation matrix and stores it in a given matrix
  85731. * @param x defines the translation on X axis
  85732. * @param y defines the translation on Y axis
  85733. * @param z defines the translationon Z axis
  85734. * @param result defines the target matrix
  85735. */
  85736. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  85737. /**
  85738. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85739. * @param startValue defines the start value
  85740. * @param endValue defines the end value
  85741. * @param gradient defines the gradient factor
  85742. * @returns the new matrix
  85743. */
  85744. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85745. /**
  85746. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85747. * @param startValue defines the start value
  85748. * @param endValue defines the end value
  85749. * @param gradient defines the gradient factor
  85750. * @param result defines the Matrix object where to store data
  85751. */
  85752. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85753. /**
  85754. * Builds a new matrix whose values are computed by:
  85755. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85756. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85757. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85758. * @param startValue defines the first matrix
  85759. * @param endValue defines the second matrix
  85760. * @param gradient defines the gradient between the two matrices
  85761. * @returns the new matrix
  85762. */
  85763. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85764. /**
  85765. * Update a matrix to values which are computed by:
  85766. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85767. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85768. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85769. * @param startValue defines the first matrix
  85770. * @param endValue defines the second matrix
  85771. * @param gradient defines the gradient between the two matrices
  85772. * @param result defines the target matrix
  85773. */
  85774. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85775. /**
  85776. * 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"
  85777. * This function works in left handed mode
  85778. * @param eye defines the final position of the entity
  85779. * @param target defines where the entity should look at
  85780. * @param up defines the up vector for the entity
  85781. * @returns the new matrix
  85782. */
  85783. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85784. /**
  85785. * 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".
  85786. * This function works in left handed mode
  85787. * @param eye defines the final position of the entity
  85788. * @param target defines where the entity should look at
  85789. * @param up defines the up vector for the entity
  85790. * @param result defines the target matrix
  85791. */
  85792. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85793. /**
  85794. * 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"
  85795. * This function works in right handed mode
  85796. * @param eye defines the final position of the entity
  85797. * @param target defines where the entity should look at
  85798. * @param up defines the up vector for the entity
  85799. * @returns the new matrix
  85800. */
  85801. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85802. /**
  85803. * 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".
  85804. * This function works in right handed mode
  85805. * @param eye defines the final position of the entity
  85806. * @param target defines where the entity should look at
  85807. * @param up defines the up vector for the entity
  85808. * @param result defines the target matrix
  85809. */
  85810. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85811. /**
  85812. * Create a left-handed orthographic projection matrix
  85813. * @param width defines the viewport width
  85814. * @param height defines the viewport height
  85815. * @param znear defines the near clip plane
  85816. * @param zfar defines the far clip plane
  85817. * @returns a new matrix as a left-handed orthographic projection matrix
  85818. */
  85819. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85820. /**
  85821. * Store a left-handed orthographic projection to a given matrix
  85822. * @param width defines the viewport width
  85823. * @param height defines the viewport height
  85824. * @param znear defines the near clip plane
  85825. * @param zfar defines the far clip plane
  85826. * @param result defines the target matrix
  85827. */
  85828. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  85829. /**
  85830. * Create a left-handed orthographic projection matrix
  85831. * @param left defines the viewport left coordinate
  85832. * @param right defines the viewport right coordinate
  85833. * @param bottom defines the viewport bottom coordinate
  85834. * @param top defines the viewport top coordinate
  85835. * @param znear defines the near clip plane
  85836. * @param zfar defines the far clip plane
  85837. * @returns a new matrix as a left-handed orthographic projection matrix
  85838. */
  85839. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85840. /**
  85841. * Stores a left-handed orthographic projection into a given matrix
  85842. * @param left defines the viewport left coordinate
  85843. * @param right defines the viewport right coordinate
  85844. * @param bottom defines the viewport bottom coordinate
  85845. * @param top defines the viewport top coordinate
  85846. * @param znear defines the near clip plane
  85847. * @param zfar defines the far clip plane
  85848. * @param result defines the target matrix
  85849. */
  85850. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85851. /**
  85852. * Creates a right-handed orthographic projection matrix
  85853. * @param left defines the viewport left coordinate
  85854. * @param right defines the viewport right coordinate
  85855. * @param bottom defines the viewport bottom coordinate
  85856. * @param top defines the viewport top coordinate
  85857. * @param znear defines the near clip plane
  85858. * @param zfar defines the far clip plane
  85859. * @returns a new matrix as a right-handed orthographic projection matrix
  85860. */
  85861. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85862. /**
  85863. * Stores a right-handed orthographic projection into a given matrix
  85864. * @param left defines the viewport left coordinate
  85865. * @param right defines the viewport right coordinate
  85866. * @param bottom defines the viewport bottom coordinate
  85867. * @param top defines the viewport top coordinate
  85868. * @param znear defines the near clip plane
  85869. * @param zfar defines the far clip plane
  85870. * @param result defines the target matrix
  85871. */
  85872. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85873. /**
  85874. * Creates a left-handed perspective projection matrix
  85875. * @param width defines the viewport width
  85876. * @param height defines the viewport height
  85877. * @param znear defines the near clip plane
  85878. * @param zfar defines the far clip plane
  85879. * @returns a new matrix as a left-handed perspective projection matrix
  85880. */
  85881. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85882. /**
  85883. * Creates a left-handed perspective projection matrix
  85884. * @param fov defines the horizontal field of view
  85885. * @param aspect defines the aspect ratio
  85886. * @param znear defines the near clip plane
  85887. * @param zfar defines the far clip plane
  85888. * @returns a new matrix as a left-handed perspective projection matrix
  85889. */
  85890. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85891. /**
  85892. * Stores a left-handed perspective projection into a given matrix
  85893. * @param fov defines the horizontal field of view
  85894. * @param aspect defines the aspect ratio
  85895. * @param znear defines the near clip plane
  85896. * @param zfar defines the far clip plane
  85897. * @param result defines the target matrix
  85898. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85899. */
  85900. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85901. /**
  85902. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85903. * @param fov defines the horizontal field of view
  85904. * @param aspect defines the aspect ratio
  85905. * @param znear defines the near clip plane
  85906. * @param zfar not used as infinity is used as far clip
  85907. * @param result defines the target matrix
  85908. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85909. */
  85910. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85911. /**
  85912. * Creates a right-handed perspective projection matrix
  85913. * @param fov defines the horizontal field of view
  85914. * @param aspect defines the aspect ratio
  85915. * @param znear defines the near clip plane
  85916. * @param zfar defines the far clip plane
  85917. * @returns a new matrix as a right-handed perspective projection matrix
  85918. */
  85919. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85920. /**
  85921. * Stores a right-handed perspective projection into a given matrix
  85922. * @param fov defines the horizontal field of view
  85923. * @param aspect defines the aspect ratio
  85924. * @param znear defines the near clip plane
  85925. * @param zfar defines the far clip plane
  85926. * @param result defines the target matrix
  85927. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85928. */
  85929. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85930. /**
  85931. * Stores a right-handed perspective projection into a given matrix
  85932. * @param fov defines the horizontal field of view
  85933. * @param aspect defines the aspect ratio
  85934. * @param znear defines the near clip plane
  85935. * @param zfar not used as infinity is used as far clip
  85936. * @param result defines the target matrix
  85937. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85938. */
  85939. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85940. /**
  85941. * Stores a perspective projection for WebVR info a given matrix
  85942. * @param fov defines the field of view
  85943. * @param znear defines the near clip plane
  85944. * @param zfar defines the far clip plane
  85945. * @param result defines the target matrix
  85946. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85947. */
  85948. static PerspectiveFovWebVRToRef(fov: {
  85949. upDegrees: number;
  85950. downDegrees: number;
  85951. leftDegrees: number;
  85952. rightDegrees: number;
  85953. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85954. /**
  85955. * Computes a complete transformation matrix
  85956. * @param viewport defines the viewport to use
  85957. * @param world defines the world matrix
  85958. * @param view defines the view matrix
  85959. * @param projection defines the projection matrix
  85960. * @param zmin defines the near clip plane
  85961. * @param zmax defines the far clip plane
  85962. * @returns the transformation matrix
  85963. */
  85964. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85965. /**
  85966. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85967. * @param matrix defines the matrix to use
  85968. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85969. */
  85970. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85971. /**
  85972. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85973. * @param matrix defines the matrix to use
  85974. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85975. */
  85976. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85977. /**
  85978. * Compute the transpose of a given matrix
  85979. * @param matrix defines the matrix to transpose
  85980. * @returns the new matrix
  85981. */
  85982. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85983. /**
  85984. * Compute the transpose of a matrix and store it in a target matrix
  85985. * @param matrix defines the matrix to transpose
  85986. * @param result defines the target matrix
  85987. */
  85988. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85989. /**
  85990. * Computes a reflection matrix from a plane
  85991. * @param plane defines the reflection plane
  85992. * @returns a new matrix
  85993. */
  85994. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85995. /**
  85996. * Computes a reflection matrix from a plane
  85997. * @param plane defines the reflection plane
  85998. * @param result defines the target matrix
  85999. */
  86000. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  86001. /**
  86002. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  86003. * @param xaxis defines the value of the 1st axis
  86004. * @param yaxis defines the value of the 2nd axis
  86005. * @param zaxis defines the value of the 3rd axis
  86006. * @param result defines the target matrix
  86007. */
  86008. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  86009. /**
  86010. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  86011. * @param quat defines the quaternion to use
  86012. * @param result defines the target matrix
  86013. */
  86014. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  86015. }
  86016. /**
  86017. * @hidden
  86018. */
  86019. export class TmpVectors {
  86020. static Vector2: Vector2[];
  86021. static Vector3: Vector3[];
  86022. static Vector4: Vector4[];
  86023. static Quaternion: Quaternion[];
  86024. static Matrix: Matrix[];
  86025. }
  86026. }
  86027. declare module BABYLON {
  86028. /**
  86029. * Defines potential orientation for back face culling
  86030. */
  86031. export enum Orientation {
  86032. /**
  86033. * Clockwise
  86034. */
  86035. CW = 0,
  86036. /** Counter clockwise */
  86037. CCW = 1
  86038. }
  86039. /** Class used to represent a Bezier curve */
  86040. export class BezierCurve {
  86041. /**
  86042. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  86043. * @param t defines the time
  86044. * @param x1 defines the left coordinate on X axis
  86045. * @param y1 defines the left coordinate on Y axis
  86046. * @param x2 defines the right coordinate on X axis
  86047. * @param y2 defines the right coordinate on Y axis
  86048. * @returns the interpolated value
  86049. */
  86050. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  86051. }
  86052. /**
  86053. * Defines angle representation
  86054. */
  86055. export class Angle {
  86056. private _radians;
  86057. /**
  86058. * Creates an Angle object of "radians" radians (float).
  86059. * @param radians the angle in radians
  86060. */
  86061. constructor(radians: number);
  86062. /**
  86063. * Get value in degrees
  86064. * @returns the Angle value in degrees (float)
  86065. */
  86066. degrees(): number;
  86067. /**
  86068. * Get value in radians
  86069. * @returns the Angle value in radians (float)
  86070. */
  86071. radians(): number;
  86072. /**
  86073. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  86074. * @param a defines first point as the origin
  86075. * @param b defines point
  86076. * @returns a new Angle
  86077. */
  86078. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  86079. /**
  86080. * Gets a new Angle object from the given float in radians
  86081. * @param radians defines the angle value in radians
  86082. * @returns a new Angle
  86083. */
  86084. static FromRadians(radians: number): Angle;
  86085. /**
  86086. * Gets a new Angle object from the given float in degrees
  86087. * @param degrees defines the angle value in degrees
  86088. * @returns a new Angle
  86089. */
  86090. static FromDegrees(degrees: number): Angle;
  86091. }
  86092. /**
  86093. * This represents an arc in a 2d space.
  86094. */
  86095. export class Arc2 {
  86096. /** Defines the start point of the arc */
  86097. startPoint: Vector2;
  86098. /** Defines the mid point of the arc */
  86099. midPoint: Vector2;
  86100. /** Defines the end point of the arc */
  86101. endPoint: Vector2;
  86102. /**
  86103. * Defines the center point of the arc.
  86104. */
  86105. centerPoint: Vector2;
  86106. /**
  86107. * Defines the radius of the arc.
  86108. */
  86109. radius: number;
  86110. /**
  86111. * Defines the angle of the arc (from mid point to end point).
  86112. */
  86113. angle: Angle;
  86114. /**
  86115. * Defines the start angle of the arc (from start point to middle point).
  86116. */
  86117. startAngle: Angle;
  86118. /**
  86119. * Defines the orientation of the arc (clock wise/counter clock wise).
  86120. */
  86121. orientation: Orientation;
  86122. /**
  86123. * Creates an Arc object from the three given points : start, middle and end.
  86124. * @param startPoint Defines the start point of the arc
  86125. * @param midPoint Defines the midlle point of the arc
  86126. * @param endPoint Defines the end point of the arc
  86127. */
  86128. constructor(
  86129. /** Defines the start point of the arc */
  86130. startPoint: Vector2,
  86131. /** Defines the mid point of the arc */
  86132. midPoint: Vector2,
  86133. /** Defines the end point of the arc */
  86134. endPoint: Vector2);
  86135. }
  86136. /**
  86137. * Represents a 2D path made up of multiple 2D points
  86138. */
  86139. export class Path2 {
  86140. private _points;
  86141. private _length;
  86142. /**
  86143. * If the path start and end point are the same
  86144. */
  86145. closed: boolean;
  86146. /**
  86147. * Creates a Path2 object from the starting 2D coordinates x and y.
  86148. * @param x the starting points x value
  86149. * @param y the starting points y value
  86150. */
  86151. constructor(x: number, y: number);
  86152. /**
  86153. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  86154. * @param x the added points x value
  86155. * @param y the added points y value
  86156. * @returns the updated Path2.
  86157. */
  86158. addLineTo(x: number, y: number): Path2;
  86159. /**
  86160. * 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.
  86161. * @param midX middle point x value
  86162. * @param midY middle point y value
  86163. * @param endX end point x value
  86164. * @param endY end point y value
  86165. * @param numberOfSegments (default: 36)
  86166. * @returns the updated Path2.
  86167. */
  86168. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  86169. /**
  86170. * Closes the Path2.
  86171. * @returns the Path2.
  86172. */
  86173. close(): Path2;
  86174. /**
  86175. * Gets the sum of the distance between each sequential point in the path
  86176. * @returns the Path2 total length (float).
  86177. */
  86178. length(): number;
  86179. /**
  86180. * Gets the points which construct the path
  86181. * @returns the Path2 internal array of points.
  86182. */
  86183. getPoints(): Vector2[];
  86184. /**
  86185. * Retreives the point at the distance aways from the starting point
  86186. * @param normalizedLengthPosition the length along the path to retreive the point from
  86187. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  86188. */
  86189. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  86190. /**
  86191. * Creates a new path starting from an x and y position
  86192. * @param x starting x value
  86193. * @param y starting y value
  86194. * @returns a new Path2 starting at the coordinates (x, y).
  86195. */
  86196. static StartingAt(x: number, y: number): Path2;
  86197. }
  86198. /**
  86199. * Represents a 3D path made up of multiple 3D points
  86200. */
  86201. export class Path3D {
  86202. /**
  86203. * an array of Vector3, the curve axis of the Path3D
  86204. */
  86205. path: Vector3[];
  86206. private _curve;
  86207. private _distances;
  86208. private _tangents;
  86209. private _normals;
  86210. private _binormals;
  86211. private _raw;
  86212. private _alignTangentsWithPath;
  86213. private readonly _pointAtData;
  86214. /**
  86215. * new Path3D(path, normal, raw)
  86216. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  86217. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  86218. * @param path an array of Vector3, the curve axis of the Path3D
  86219. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  86220. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  86221. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  86222. */
  86223. constructor(
  86224. /**
  86225. * an array of Vector3, the curve axis of the Path3D
  86226. */
  86227. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  86228. /**
  86229. * Returns the Path3D array of successive Vector3 designing its curve.
  86230. * @returns the Path3D array of successive Vector3 designing its curve.
  86231. */
  86232. getCurve(): Vector3[];
  86233. /**
  86234. * Returns the Path3D array of successive Vector3 designing its curve.
  86235. * @returns the Path3D array of successive Vector3 designing its curve.
  86236. */
  86237. getPoints(): Vector3[];
  86238. /**
  86239. * @returns the computed length (float) of the path.
  86240. */
  86241. length(): number;
  86242. /**
  86243. * Returns an array populated with tangent vectors on each Path3D curve point.
  86244. * @returns an array populated with tangent vectors on each Path3D curve point.
  86245. */
  86246. getTangents(): Vector3[];
  86247. /**
  86248. * Returns an array populated with normal vectors on each Path3D curve point.
  86249. * @returns an array populated with normal vectors on each Path3D curve point.
  86250. */
  86251. getNormals(): Vector3[];
  86252. /**
  86253. * Returns an array populated with binormal vectors on each Path3D curve point.
  86254. * @returns an array populated with binormal vectors on each Path3D curve point.
  86255. */
  86256. getBinormals(): Vector3[];
  86257. /**
  86258. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  86259. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  86260. */
  86261. getDistances(): number[];
  86262. /**
  86263. * Returns an interpolated point along this path
  86264. * @param position the position of the point along this path, from 0.0 to 1.0
  86265. * @returns a new Vector3 as the point
  86266. */
  86267. getPointAt(position: number): Vector3;
  86268. /**
  86269. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  86270. * @param position the position of the point along this path, from 0.0 to 1.0
  86271. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  86272. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  86273. */
  86274. getTangentAt(position: number, interpolated?: boolean): Vector3;
  86275. /**
  86276. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  86277. * @param position the position of the point along this path, from 0.0 to 1.0
  86278. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  86279. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  86280. */
  86281. getNormalAt(position: number, interpolated?: boolean): Vector3;
  86282. /**
  86283. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  86284. * @param position the position of the point along this path, from 0.0 to 1.0
  86285. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  86286. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  86287. */
  86288. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  86289. /**
  86290. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  86291. * @param position the position of the point along this path, from 0.0 to 1.0
  86292. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  86293. */
  86294. getDistanceAt(position: number): number;
  86295. /**
  86296. * Returns the array index of the previous point of an interpolated point along this path
  86297. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  86298. * @returns the array index
  86299. */
  86300. getPreviousPointIndexAt(position: number): number;
  86301. /**
  86302. * 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)
  86303. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  86304. * @returns the sub position
  86305. */
  86306. getSubPositionAt(position: number): number;
  86307. /**
  86308. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  86309. * @param target the vector of which to get the closest position to
  86310. * @returns the position of the closest virtual point on this path to the target vector
  86311. */
  86312. getClosestPositionTo(target: Vector3): number;
  86313. /**
  86314. * Returns a sub path (slice) of this path
  86315. * @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
  86316. * @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
  86317. * @returns a sub path (slice) of this path
  86318. */
  86319. slice(start?: number, end?: number): Path3D;
  86320. /**
  86321. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  86322. * @param path path which all values are copied into the curves points
  86323. * @param firstNormal which should be projected onto the curve
  86324. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  86325. * @returns the same object updated.
  86326. */
  86327. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  86328. private _compute;
  86329. private _getFirstNonNullVector;
  86330. private _getLastNonNullVector;
  86331. private _normalVector;
  86332. /**
  86333. * Updates the point at data for an interpolated point along this curve
  86334. * @param position the position of the point along this curve, from 0.0 to 1.0
  86335. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  86336. * @returns the (updated) point at data
  86337. */
  86338. private _updatePointAtData;
  86339. /**
  86340. * Updates the point at data from the specified parameters
  86341. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  86342. * @param point the interpolated point
  86343. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  86344. */
  86345. private _setPointAtData;
  86346. /**
  86347. * Updates the point at interpolation matrix for the tangents, normals and binormals
  86348. */
  86349. private _updateInterpolationMatrix;
  86350. }
  86351. /**
  86352. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  86353. * A Curve3 is designed from a series of successive Vector3.
  86354. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  86355. */
  86356. export class Curve3 {
  86357. private _points;
  86358. private _length;
  86359. /**
  86360. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  86361. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  86362. * @param v1 (Vector3) the control point
  86363. * @param v2 (Vector3) the end point of the Quadratic Bezier
  86364. * @param nbPoints (integer) the wanted number of points in the curve
  86365. * @returns the created Curve3
  86366. */
  86367. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86368. /**
  86369. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  86370. * @param v0 (Vector3) the origin point of the Cubic Bezier
  86371. * @param v1 (Vector3) the first control point
  86372. * @param v2 (Vector3) the second control point
  86373. * @param v3 (Vector3) the end point of the Cubic Bezier
  86374. * @param nbPoints (integer) the wanted number of points in the curve
  86375. * @returns the created Curve3
  86376. */
  86377. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86378. /**
  86379. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  86380. * @param p1 (Vector3) the origin point of the Hermite Spline
  86381. * @param t1 (Vector3) the tangent vector at the origin point
  86382. * @param p2 (Vector3) the end point of the Hermite Spline
  86383. * @param t2 (Vector3) the tangent vector at the end point
  86384. * @param nbPoints (integer) the wanted number of points in the curve
  86385. * @returns the created Curve3
  86386. */
  86387. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86388. /**
  86389. * Returns a Curve3 object along a CatmullRom Spline curve :
  86390. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  86391. * @param nbPoints (integer) the wanted number of points between each curve control points
  86392. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  86393. * @returns the created Curve3
  86394. */
  86395. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  86396. /**
  86397. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  86398. * A Curve3 is designed from a series of successive Vector3.
  86399. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  86400. * @param points points which make up the curve
  86401. */
  86402. constructor(points: Vector3[]);
  86403. /**
  86404. * @returns the Curve3 stored array of successive Vector3
  86405. */
  86406. getPoints(): Vector3[];
  86407. /**
  86408. * @returns the computed length (float) of the curve.
  86409. */
  86410. length(): number;
  86411. /**
  86412. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  86413. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  86414. * curveA and curveB keep unchanged.
  86415. * @param curve the curve to continue from this curve
  86416. * @returns the newly constructed curve
  86417. */
  86418. continue(curve: DeepImmutable<Curve3>): Curve3;
  86419. private _computeLength;
  86420. }
  86421. }
  86422. declare module BABYLON {
  86423. /**
  86424. * This represents the main contract an easing function should follow.
  86425. * Easing functions are used throughout the animation system.
  86426. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86427. */
  86428. export interface IEasingFunction {
  86429. /**
  86430. * Given an input gradient between 0 and 1, this returns the corrseponding value
  86431. * of the easing function.
  86432. * The link below provides some of the most common examples of easing functions.
  86433. * @see https://easings.net/
  86434. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86435. * @returns the corresponding value on the curve defined by the easing function
  86436. */
  86437. ease(gradient: number): number;
  86438. }
  86439. /**
  86440. * Base class used for every default easing function.
  86441. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86442. */
  86443. export class EasingFunction implements IEasingFunction {
  86444. /**
  86445. * Interpolation follows the mathematical formula associated with the easing function.
  86446. */
  86447. static readonly EASINGMODE_EASEIN: number;
  86448. /**
  86449. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  86450. */
  86451. static readonly EASINGMODE_EASEOUT: number;
  86452. /**
  86453. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  86454. */
  86455. static readonly EASINGMODE_EASEINOUT: number;
  86456. private _easingMode;
  86457. /**
  86458. * Sets the easing mode of the current function.
  86459. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  86460. */
  86461. setEasingMode(easingMode: number): void;
  86462. /**
  86463. * Gets the current easing mode.
  86464. * @returns the easing mode
  86465. */
  86466. getEasingMode(): number;
  86467. /**
  86468. * @hidden
  86469. */
  86470. easeInCore(gradient: number): number;
  86471. /**
  86472. * Given an input gradient between 0 and 1, this returns the corresponding value
  86473. * of the easing function.
  86474. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86475. * @returns the corresponding value on the curve defined by the easing function
  86476. */
  86477. ease(gradient: number): number;
  86478. }
  86479. /**
  86480. * Easing function with a circle shape (see link below).
  86481. * @see https://easings.net/#easeInCirc
  86482. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86483. */
  86484. export class CircleEase extends EasingFunction implements IEasingFunction {
  86485. /** @hidden */
  86486. easeInCore(gradient: number): number;
  86487. }
  86488. /**
  86489. * Easing function with a ease back shape (see link below).
  86490. * @see https://easings.net/#easeInBack
  86491. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86492. */
  86493. export class BackEase extends EasingFunction implements IEasingFunction {
  86494. /** Defines the amplitude of the function */
  86495. amplitude: number;
  86496. /**
  86497. * Instantiates a back ease easing
  86498. * @see https://easings.net/#easeInBack
  86499. * @param amplitude Defines the amplitude of the function
  86500. */
  86501. constructor(
  86502. /** Defines the amplitude of the function */
  86503. amplitude?: number);
  86504. /** @hidden */
  86505. easeInCore(gradient: number): number;
  86506. }
  86507. /**
  86508. * Easing function with a bouncing shape (see link below).
  86509. * @see https://easings.net/#easeInBounce
  86510. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86511. */
  86512. export class BounceEase extends EasingFunction implements IEasingFunction {
  86513. /** Defines the number of bounces */
  86514. bounces: number;
  86515. /** Defines the amplitude of the bounce */
  86516. bounciness: number;
  86517. /**
  86518. * Instantiates a bounce easing
  86519. * @see https://easings.net/#easeInBounce
  86520. * @param bounces Defines the number of bounces
  86521. * @param bounciness Defines the amplitude of the bounce
  86522. */
  86523. constructor(
  86524. /** Defines the number of bounces */
  86525. bounces?: number,
  86526. /** Defines the amplitude of the bounce */
  86527. bounciness?: number);
  86528. /** @hidden */
  86529. easeInCore(gradient: number): number;
  86530. }
  86531. /**
  86532. * Easing function with a power of 3 shape (see link below).
  86533. * @see https://easings.net/#easeInCubic
  86534. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86535. */
  86536. export class CubicEase extends EasingFunction implements IEasingFunction {
  86537. /** @hidden */
  86538. easeInCore(gradient: number): number;
  86539. }
  86540. /**
  86541. * Easing function with an elastic shape (see link below).
  86542. * @see https://easings.net/#easeInElastic
  86543. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86544. */
  86545. export class ElasticEase extends EasingFunction implements IEasingFunction {
  86546. /** Defines the number of oscillations*/
  86547. oscillations: number;
  86548. /** Defines the amplitude of the oscillations*/
  86549. springiness: number;
  86550. /**
  86551. * Instantiates an elastic easing function
  86552. * @see https://easings.net/#easeInElastic
  86553. * @param oscillations Defines the number of oscillations
  86554. * @param springiness Defines the amplitude of the oscillations
  86555. */
  86556. constructor(
  86557. /** Defines the number of oscillations*/
  86558. oscillations?: number,
  86559. /** Defines the amplitude of the oscillations*/
  86560. springiness?: number);
  86561. /** @hidden */
  86562. easeInCore(gradient: number): number;
  86563. }
  86564. /**
  86565. * Easing function with an exponential shape (see link below).
  86566. * @see https://easings.net/#easeInExpo
  86567. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86568. */
  86569. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  86570. /** Defines the exponent of the function */
  86571. exponent: number;
  86572. /**
  86573. * Instantiates an exponential easing function
  86574. * @see https://easings.net/#easeInExpo
  86575. * @param exponent Defines the exponent of the function
  86576. */
  86577. constructor(
  86578. /** Defines the exponent of the function */
  86579. exponent?: number);
  86580. /** @hidden */
  86581. easeInCore(gradient: number): number;
  86582. }
  86583. /**
  86584. * Easing function with a power shape (see link below).
  86585. * @see https://easings.net/#easeInQuad
  86586. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86587. */
  86588. export class PowerEase extends EasingFunction implements IEasingFunction {
  86589. /** Defines the power of the function */
  86590. power: number;
  86591. /**
  86592. * Instantiates an power base easing function
  86593. * @see https://easings.net/#easeInQuad
  86594. * @param power Defines the power of the function
  86595. */
  86596. constructor(
  86597. /** Defines the power of the function */
  86598. power?: number);
  86599. /** @hidden */
  86600. easeInCore(gradient: number): number;
  86601. }
  86602. /**
  86603. * Easing function with a power of 2 shape (see link below).
  86604. * @see https://easings.net/#easeInQuad
  86605. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86606. */
  86607. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  86608. /** @hidden */
  86609. easeInCore(gradient: number): number;
  86610. }
  86611. /**
  86612. * Easing function with a power of 4 shape (see link below).
  86613. * @see https://easings.net/#easeInQuart
  86614. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86615. */
  86616. export class QuarticEase extends EasingFunction implements IEasingFunction {
  86617. /** @hidden */
  86618. easeInCore(gradient: number): number;
  86619. }
  86620. /**
  86621. * Easing function with a power of 5 shape (see link below).
  86622. * @see https://easings.net/#easeInQuint
  86623. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86624. */
  86625. export class QuinticEase extends EasingFunction implements IEasingFunction {
  86626. /** @hidden */
  86627. easeInCore(gradient: number): number;
  86628. }
  86629. /**
  86630. * Easing function with a sin shape (see link below).
  86631. * @see https://easings.net/#easeInSine
  86632. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86633. */
  86634. export class SineEase extends EasingFunction implements IEasingFunction {
  86635. /** @hidden */
  86636. easeInCore(gradient: number): number;
  86637. }
  86638. /**
  86639. * Easing function with a bezier shape (see link below).
  86640. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86641. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86642. */
  86643. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  86644. /** Defines the x component of the start tangent in the bezier curve */
  86645. x1: number;
  86646. /** Defines the y component of the start tangent in the bezier curve */
  86647. y1: number;
  86648. /** Defines the x component of the end tangent in the bezier curve */
  86649. x2: number;
  86650. /** Defines the y component of the end tangent in the bezier curve */
  86651. y2: number;
  86652. /**
  86653. * Instantiates a bezier function
  86654. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86655. * @param x1 Defines the x component of the start tangent in the bezier curve
  86656. * @param y1 Defines the y component of the start tangent in the bezier curve
  86657. * @param x2 Defines the x component of the end tangent in the bezier curve
  86658. * @param y2 Defines the y component of the end tangent in the bezier curve
  86659. */
  86660. constructor(
  86661. /** Defines the x component of the start tangent in the bezier curve */
  86662. x1?: number,
  86663. /** Defines the y component of the start tangent in the bezier curve */
  86664. y1?: number,
  86665. /** Defines the x component of the end tangent in the bezier curve */
  86666. x2?: number,
  86667. /** Defines the y component of the end tangent in the bezier curve */
  86668. y2?: number);
  86669. /** @hidden */
  86670. easeInCore(gradient: number): number;
  86671. }
  86672. }
  86673. declare module BABYLON {
  86674. /**
  86675. * Class used to hold a RBG color
  86676. */
  86677. export class Color3 {
  86678. /**
  86679. * Defines the red component (between 0 and 1, default is 0)
  86680. */
  86681. r: number;
  86682. /**
  86683. * Defines the green component (between 0 and 1, default is 0)
  86684. */
  86685. g: number;
  86686. /**
  86687. * Defines the blue component (between 0 and 1, default is 0)
  86688. */
  86689. b: number;
  86690. /**
  86691. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  86692. * @param r defines the red component (between 0 and 1, default is 0)
  86693. * @param g defines the green component (between 0 and 1, default is 0)
  86694. * @param b defines the blue component (between 0 and 1, default is 0)
  86695. */
  86696. constructor(
  86697. /**
  86698. * Defines the red component (between 0 and 1, default is 0)
  86699. */
  86700. r?: number,
  86701. /**
  86702. * Defines the green component (between 0 and 1, default is 0)
  86703. */
  86704. g?: number,
  86705. /**
  86706. * Defines the blue component (between 0 and 1, default is 0)
  86707. */
  86708. b?: number);
  86709. /**
  86710. * Creates a string with the Color3 current values
  86711. * @returns the string representation of the Color3 object
  86712. */
  86713. toString(): string;
  86714. /**
  86715. * Returns the string "Color3"
  86716. * @returns "Color3"
  86717. */
  86718. getClassName(): string;
  86719. /**
  86720. * Compute the Color3 hash code
  86721. * @returns an unique number that can be used to hash Color3 objects
  86722. */
  86723. getHashCode(): number;
  86724. /**
  86725. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  86726. * @param array defines the array where to store the r,g,b components
  86727. * @param index defines an optional index in the target array to define where to start storing values
  86728. * @returns the current Color3 object
  86729. */
  86730. toArray(array: FloatArray, index?: number): Color3;
  86731. /**
  86732. * Update the current color with values stored in an array from the starting index of the given array
  86733. * @param array defines the source array
  86734. * @param offset defines an offset in the source array
  86735. * @returns the current Color3 object
  86736. */
  86737. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86738. /**
  86739. * Returns a new Color4 object from the current Color3 and the given alpha
  86740. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  86741. * @returns a new Color4 object
  86742. */
  86743. toColor4(alpha?: number): Color4;
  86744. /**
  86745. * Returns a new array populated with 3 numeric elements : red, green and blue values
  86746. * @returns the new array
  86747. */
  86748. asArray(): number[];
  86749. /**
  86750. * Returns the luminance value
  86751. * @returns a float value
  86752. */
  86753. toLuminance(): number;
  86754. /**
  86755. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  86756. * @param otherColor defines the second operand
  86757. * @returns the new Color3 object
  86758. */
  86759. multiply(otherColor: DeepImmutable<Color3>): Color3;
  86760. /**
  86761. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  86762. * @param otherColor defines the second operand
  86763. * @param result defines the Color3 object where to store the result
  86764. * @returns the current Color3
  86765. */
  86766. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86767. /**
  86768. * Determines equality between Color3 objects
  86769. * @param otherColor defines the second operand
  86770. * @returns true if the rgb values are equal to the given ones
  86771. */
  86772. equals(otherColor: DeepImmutable<Color3>): boolean;
  86773. /**
  86774. * Determines equality between the current Color3 object and a set of r,b,g values
  86775. * @param r defines the red component to check
  86776. * @param g defines the green component to check
  86777. * @param b defines the blue component to check
  86778. * @returns true if the rgb values are equal to the given ones
  86779. */
  86780. equalsFloats(r: number, g: number, b: number): boolean;
  86781. /**
  86782. * Multiplies in place each rgb value by scale
  86783. * @param scale defines the scaling factor
  86784. * @returns the updated Color3
  86785. */
  86786. scale(scale: number): Color3;
  86787. /**
  86788. * Multiplies the rgb values by scale and stores the result into "result"
  86789. * @param scale defines the scaling factor
  86790. * @param result defines the Color3 object where to store the result
  86791. * @returns the unmodified current Color3
  86792. */
  86793. scaleToRef(scale: number, result: Color3): Color3;
  86794. /**
  86795. * Scale the current Color3 values by a factor and add the result to a given Color3
  86796. * @param scale defines the scale factor
  86797. * @param result defines color to store the result into
  86798. * @returns the unmodified current Color3
  86799. */
  86800. scaleAndAddToRef(scale: number, result: Color3): Color3;
  86801. /**
  86802. * Clamps the rgb values by the min and max values and stores the result into "result"
  86803. * @param min defines minimum clamping value (default is 0)
  86804. * @param max defines maximum clamping value (default is 1)
  86805. * @param result defines color to store the result into
  86806. * @returns the original Color3
  86807. */
  86808. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  86809. /**
  86810. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  86811. * @param otherColor defines the second operand
  86812. * @returns the new Color3
  86813. */
  86814. add(otherColor: DeepImmutable<Color3>): Color3;
  86815. /**
  86816. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  86817. * @param otherColor defines the second operand
  86818. * @param result defines Color3 object to store the result into
  86819. * @returns the unmodified current Color3
  86820. */
  86821. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86822. /**
  86823. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  86824. * @param otherColor defines the second operand
  86825. * @returns the new Color3
  86826. */
  86827. subtract(otherColor: DeepImmutable<Color3>): Color3;
  86828. /**
  86829. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  86830. * @param otherColor defines the second operand
  86831. * @param result defines Color3 object to store the result into
  86832. * @returns the unmodified current Color3
  86833. */
  86834. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86835. /**
  86836. * Copy the current object
  86837. * @returns a new Color3 copied the current one
  86838. */
  86839. clone(): Color3;
  86840. /**
  86841. * Copies the rgb values from the source in the current Color3
  86842. * @param source defines the source Color3 object
  86843. * @returns the updated Color3 object
  86844. */
  86845. copyFrom(source: DeepImmutable<Color3>): Color3;
  86846. /**
  86847. * Updates the Color3 rgb values from the given floats
  86848. * @param r defines the red component to read from
  86849. * @param g defines the green component to read from
  86850. * @param b defines the blue component to read from
  86851. * @returns the current Color3 object
  86852. */
  86853. copyFromFloats(r: number, g: number, b: number): Color3;
  86854. /**
  86855. * Updates the Color3 rgb values from the given floats
  86856. * @param r defines the red component to read from
  86857. * @param g defines the green component to read from
  86858. * @param b defines the blue component to read from
  86859. * @returns the current Color3 object
  86860. */
  86861. set(r: number, g: number, b: number): Color3;
  86862. /**
  86863. * Compute the Color3 hexadecimal code as a string
  86864. * @returns a string containing the hexadecimal representation of the Color3 object
  86865. */
  86866. toHexString(): string;
  86867. /**
  86868. * Computes a new Color3 converted from the current one to linear space
  86869. * @returns a new Color3 object
  86870. */
  86871. toLinearSpace(): Color3;
  86872. /**
  86873. * Converts current color in rgb space to HSV values
  86874. * @returns a new color3 representing the HSV values
  86875. */
  86876. toHSV(): Color3;
  86877. /**
  86878. * Converts current color in rgb space to HSV values
  86879. * @param result defines the Color3 where to store the HSV values
  86880. */
  86881. toHSVToRef(result: Color3): void;
  86882. /**
  86883. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86884. * @param convertedColor defines the Color3 object where to store the linear space version
  86885. * @returns the unmodified Color3
  86886. */
  86887. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86888. /**
  86889. * Computes a new Color3 converted from the current one to gamma space
  86890. * @returns a new Color3 object
  86891. */
  86892. toGammaSpace(): Color3;
  86893. /**
  86894. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86895. * @param convertedColor defines the Color3 object where to store the gamma space version
  86896. * @returns the unmodified Color3
  86897. */
  86898. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86899. private static _BlackReadOnly;
  86900. /**
  86901. * Convert Hue, saturation and value to a Color3 (RGB)
  86902. * @param hue defines the hue
  86903. * @param saturation defines the saturation
  86904. * @param value defines the value
  86905. * @param result defines the Color3 where to store the RGB values
  86906. */
  86907. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86908. /**
  86909. * Creates a new Color3 from the string containing valid hexadecimal values
  86910. * @param hex defines a string containing valid hexadecimal values
  86911. * @returns a new Color3 object
  86912. */
  86913. static FromHexString(hex: string): Color3;
  86914. /**
  86915. * Creates a new Color3 from the starting index of the given array
  86916. * @param array defines the source array
  86917. * @param offset defines an offset in the source array
  86918. * @returns a new Color3 object
  86919. */
  86920. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86921. /**
  86922. * Creates a new Color3 from the starting index element of the given array
  86923. * @param array defines the source array to read from
  86924. * @param offset defines the offset in the source array
  86925. * @param result defines the target Color3 object
  86926. */
  86927. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86928. /**
  86929. * Creates a new Color3 from integer values (< 256)
  86930. * @param r defines the red component to read from (value between 0 and 255)
  86931. * @param g defines the green component to read from (value between 0 and 255)
  86932. * @param b defines the blue component to read from (value between 0 and 255)
  86933. * @returns a new Color3 object
  86934. */
  86935. static FromInts(r: number, g: number, b: number): Color3;
  86936. /**
  86937. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86938. * @param start defines the start Color3 value
  86939. * @param end defines the end Color3 value
  86940. * @param amount defines the gradient value between start and end
  86941. * @returns a new Color3 object
  86942. */
  86943. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86944. /**
  86945. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86946. * @param left defines the start value
  86947. * @param right defines the end value
  86948. * @param amount defines the gradient factor
  86949. * @param result defines the Color3 object where to store the result
  86950. */
  86951. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86952. /**
  86953. * Returns a Color3 value containing a red color
  86954. * @returns a new Color3 object
  86955. */
  86956. static Red(): Color3;
  86957. /**
  86958. * Returns a Color3 value containing a green color
  86959. * @returns a new Color3 object
  86960. */
  86961. static Green(): Color3;
  86962. /**
  86963. * Returns a Color3 value containing a blue color
  86964. * @returns a new Color3 object
  86965. */
  86966. static Blue(): Color3;
  86967. /**
  86968. * Returns a Color3 value containing a black color
  86969. * @returns a new Color3 object
  86970. */
  86971. static Black(): Color3;
  86972. /**
  86973. * Gets a Color3 value containing a black color that must not be updated
  86974. */
  86975. static get BlackReadOnly(): DeepImmutable<Color3>;
  86976. /**
  86977. * Returns a Color3 value containing a white color
  86978. * @returns a new Color3 object
  86979. */
  86980. static White(): Color3;
  86981. /**
  86982. * Returns a Color3 value containing a purple color
  86983. * @returns a new Color3 object
  86984. */
  86985. static Purple(): Color3;
  86986. /**
  86987. * Returns a Color3 value containing a magenta color
  86988. * @returns a new Color3 object
  86989. */
  86990. static Magenta(): Color3;
  86991. /**
  86992. * Returns a Color3 value containing a yellow color
  86993. * @returns a new Color3 object
  86994. */
  86995. static Yellow(): Color3;
  86996. /**
  86997. * Returns a Color3 value containing a gray color
  86998. * @returns a new Color3 object
  86999. */
  87000. static Gray(): Color3;
  87001. /**
  87002. * Returns a Color3 value containing a teal color
  87003. * @returns a new Color3 object
  87004. */
  87005. static Teal(): Color3;
  87006. /**
  87007. * Returns a Color3 value containing a random color
  87008. * @returns a new Color3 object
  87009. */
  87010. static Random(): Color3;
  87011. }
  87012. /**
  87013. * Class used to hold a RBGA color
  87014. */
  87015. export class Color4 {
  87016. /**
  87017. * Defines the red component (between 0 and 1, default is 0)
  87018. */
  87019. r: number;
  87020. /**
  87021. * Defines the green component (between 0 and 1, default is 0)
  87022. */
  87023. g: number;
  87024. /**
  87025. * Defines the blue component (between 0 and 1, default is 0)
  87026. */
  87027. b: number;
  87028. /**
  87029. * Defines the alpha component (between 0 and 1, default is 1)
  87030. */
  87031. a: number;
  87032. /**
  87033. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  87034. * @param r defines the red component (between 0 and 1, default is 0)
  87035. * @param g defines the green component (between 0 and 1, default is 0)
  87036. * @param b defines the blue component (between 0 and 1, default is 0)
  87037. * @param a defines the alpha component (between 0 and 1, default is 1)
  87038. */
  87039. constructor(
  87040. /**
  87041. * Defines the red component (between 0 and 1, default is 0)
  87042. */
  87043. r?: number,
  87044. /**
  87045. * Defines the green component (between 0 and 1, default is 0)
  87046. */
  87047. g?: number,
  87048. /**
  87049. * Defines the blue component (between 0 and 1, default is 0)
  87050. */
  87051. b?: number,
  87052. /**
  87053. * Defines the alpha component (between 0 and 1, default is 1)
  87054. */
  87055. a?: number);
  87056. /**
  87057. * Adds in place the given Color4 values to the current Color4 object
  87058. * @param right defines the second operand
  87059. * @returns the current updated Color4 object
  87060. */
  87061. addInPlace(right: DeepImmutable<Color4>): Color4;
  87062. /**
  87063. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  87064. * @returns the new array
  87065. */
  87066. asArray(): number[];
  87067. /**
  87068. * Stores from the starting index in the given array the Color4 successive values
  87069. * @param array defines the array where to store the r,g,b components
  87070. * @param index defines an optional index in the target array to define where to start storing values
  87071. * @returns the current Color4 object
  87072. */
  87073. toArray(array: number[], index?: number): Color4;
  87074. /**
  87075. * Update the current color with values stored in an array from the starting index of the given array
  87076. * @param array defines the source array
  87077. * @param offset defines an offset in the source array
  87078. * @returns the current Color4 object
  87079. */
  87080. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87081. /**
  87082. * Determines equality between Color4 objects
  87083. * @param otherColor defines the second operand
  87084. * @returns true if the rgba values are equal to the given ones
  87085. */
  87086. equals(otherColor: DeepImmutable<Color4>): boolean;
  87087. /**
  87088. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  87089. * @param right defines the second operand
  87090. * @returns a new Color4 object
  87091. */
  87092. add(right: DeepImmutable<Color4>): Color4;
  87093. /**
  87094. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  87095. * @param right defines the second operand
  87096. * @returns a new Color4 object
  87097. */
  87098. subtract(right: DeepImmutable<Color4>): Color4;
  87099. /**
  87100. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  87101. * @param right defines the second operand
  87102. * @param result defines the Color4 object where to store the result
  87103. * @returns the current Color4 object
  87104. */
  87105. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  87106. /**
  87107. * Creates a new Color4 with the current Color4 values multiplied by scale
  87108. * @param scale defines the scaling factor to apply
  87109. * @returns a new Color4 object
  87110. */
  87111. scale(scale: number): Color4;
  87112. /**
  87113. * Multiplies the current Color4 values by scale and stores the result in "result"
  87114. * @param scale defines the scaling factor to apply
  87115. * @param result defines the Color4 object where to store the result
  87116. * @returns the current unmodified Color4
  87117. */
  87118. scaleToRef(scale: number, result: Color4): Color4;
  87119. /**
  87120. * Scale the current Color4 values by a factor and add the result to a given Color4
  87121. * @param scale defines the scale factor
  87122. * @param result defines the Color4 object where to store the result
  87123. * @returns the unmodified current Color4
  87124. */
  87125. scaleAndAddToRef(scale: number, result: Color4): Color4;
  87126. /**
  87127. * Clamps the rgb values by the min and max values and stores the result into "result"
  87128. * @param min defines minimum clamping value (default is 0)
  87129. * @param max defines maximum clamping value (default is 1)
  87130. * @param result defines color to store the result into.
  87131. * @returns the cuurent Color4
  87132. */
  87133. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  87134. /**
  87135. * Multipy an Color4 value by another and return a new Color4 object
  87136. * @param color defines the Color4 value to multiply by
  87137. * @returns a new Color4 object
  87138. */
  87139. multiply(color: Color4): Color4;
  87140. /**
  87141. * Multipy a Color4 value by another and push the result in a reference value
  87142. * @param color defines the Color4 value to multiply by
  87143. * @param result defines the Color4 to fill the result in
  87144. * @returns the result Color4
  87145. */
  87146. multiplyToRef(color: Color4, result: Color4): Color4;
  87147. /**
  87148. * Creates a string with the Color4 current values
  87149. * @returns the string representation of the Color4 object
  87150. */
  87151. toString(): string;
  87152. /**
  87153. * Returns the string "Color4"
  87154. * @returns "Color4"
  87155. */
  87156. getClassName(): string;
  87157. /**
  87158. * Compute the Color4 hash code
  87159. * @returns an unique number that can be used to hash Color4 objects
  87160. */
  87161. getHashCode(): number;
  87162. /**
  87163. * Creates a new Color4 copied from the current one
  87164. * @returns a new Color4 object
  87165. */
  87166. clone(): Color4;
  87167. /**
  87168. * Copies the given Color4 values into the current one
  87169. * @param source defines the source Color4 object
  87170. * @returns the current updated Color4 object
  87171. */
  87172. copyFrom(source: Color4): Color4;
  87173. /**
  87174. * Copies the given float values into the current one
  87175. * @param r defines the red component to read from
  87176. * @param g defines the green component to read from
  87177. * @param b defines the blue component to read from
  87178. * @param a defines the alpha component to read from
  87179. * @returns the current updated Color4 object
  87180. */
  87181. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  87182. /**
  87183. * Copies the given float values into the current one
  87184. * @param r defines the red component to read from
  87185. * @param g defines the green component to read from
  87186. * @param b defines the blue component to read from
  87187. * @param a defines the alpha component to read from
  87188. * @returns the current updated Color4 object
  87189. */
  87190. set(r: number, g: number, b: number, a: number): Color4;
  87191. /**
  87192. * Compute the Color4 hexadecimal code as a string
  87193. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  87194. * @returns a string containing the hexadecimal representation of the Color4 object
  87195. */
  87196. toHexString(returnAsColor3?: boolean): string;
  87197. /**
  87198. * Computes a new Color4 converted from the current one to linear space
  87199. * @returns a new Color4 object
  87200. */
  87201. toLinearSpace(): Color4;
  87202. /**
  87203. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  87204. * @param convertedColor defines the Color4 object where to store the linear space version
  87205. * @returns the unmodified Color4
  87206. */
  87207. toLinearSpaceToRef(convertedColor: Color4): Color4;
  87208. /**
  87209. * Computes a new Color4 converted from the current one to gamma space
  87210. * @returns a new Color4 object
  87211. */
  87212. toGammaSpace(): Color4;
  87213. /**
  87214. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  87215. * @param convertedColor defines the Color4 object where to store the gamma space version
  87216. * @returns the unmodified Color4
  87217. */
  87218. toGammaSpaceToRef(convertedColor: Color4): Color4;
  87219. /**
  87220. * Creates a new Color4 from the string containing valid hexadecimal values
  87221. * @param hex defines a string containing valid hexadecimal values
  87222. * @returns a new Color4 object
  87223. */
  87224. static FromHexString(hex: string): Color4;
  87225. /**
  87226. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  87227. * @param left defines the start value
  87228. * @param right defines the end value
  87229. * @param amount defines the gradient factor
  87230. * @returns a new Color4 object
  87231. */
  87232. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  87233. /**
  87234. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  87235. * @param left defines the start value
  87236. * @param right defines the end value
  87237. * @param amount defines the gradient factor
  87238. * @param result defines the Color4 object where to store data
  87239. */
  87240. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  87241. /**
  87242. * Creates a new Color4 from a Color3 and an alpha value
  87243. * @param color3 defines the source Color3 to read from
  87244. * @param alpha defines the alpha component (1.0 by default)
  87245. * @returns a new Color4 object
  87246. */
  87247. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  87248. /**
  87249. * Creates a new Color4 from the starting index element of the given array
  87250. * @param array defines the source array to read from
  87251. * @param offset defines the offset in the source array
  87252. * @returns a new Color4 object
  87253. */
  87254. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87255. /**
  87256. * Creates a new Color4 from the starting index element of the given array
  87257. * @param array defines the source array to read from
  87258. * @param offset defines the offset in the source array
  87259. * @param result defines the target Color4 object
  87260. */
  87261. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  87262. /**
  87263. * Creates a new Color3 from integer values (< 256)
  87264. * @param r defines the red component to read from (value between 0 and 255)
  87265. * @param g defines the green component to read from (value between 0 and 255)
  87266. * @param b defines the blue component to read from (value between 0 and 255)
  87267. * @param a defines the alpha component to read from (value between 0 and 255)
  87268. * @returns a new Color3 object
  87269. */
  87270. static FromInts(r: number, g: number, b: number, a: number): Color4;
  87271. /**
  87272. * Check the content of a given array and convert it to an array containing RGBA data
  87273. * If the original array was already containing count * 4 values then it is returned directly
  87274. * @param colors defines the array to check
  87275. * @param count defines the number of RGBA data to expect
  87276. * @returns an array containing count * 4 values (RGBA)
  87277. */
  87278. static CheckColors4(colors: number[], count: number): number[];
  87279. }
  87280. /**
  87281. * @hidden
  87282. */
  87283. export class TmpColors {
  87284. static Color3: Color3[];
  87285. static Color4: Color4[];
  87286. }
  87287. }
  87288. declare module BABYLON {
  87289. /**
  87290. * Defines an interface which represents an animation key frame
  87291. */
  87292. export interface IAnimationKey {
  87293. /**
  87294. * Frame of the key frame
  87295. */
  87296. frame: number;
  87297. /**
  87298. * Value at the specifies key frame
  87299. */
  87300. value: any;
  87301. /**
  87302. * The input tangent for the cubic hermite spline
  87303. */
  87304. inTangent?: any;
  87305. /**
  87306. * The output tangent for the cubic hermite spline
  87307. */
  87308. outTangent?: any;
  87309. /**
  87310. * The animation interpolation type
  87311. */
  87312. interpolation?: AnimationKeyInterpolation;
  87313. }
  87314. /**
  87315. * Enum for the animation key frame interpolation type
  87316. */
  87317. export enum AnimationKeyInterpolation {
  87318. /**
  87319. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  87320. */
  87321. STEP = 1
  87322. }
  87323. }
  87324. declare module BABYLON {
  87325. /**
  87326. * Represents the range of an animation
  87327. */
  87328. export class AnimationRange {
  87329. /**The name of the animation range**/
  87330. name: string;
  87331. /**The starting frame of the animation */
  87332. from: number;
  87333. /**The ending frame of the animation*/
  87334. to: number;
  87335. /**
  87336. * Initializes the range of an animation
  87337. * @param name The name of the animation range
  87338. * @param from The starting frame of the animation
  87339. * @param to The ending frame of the animation
  87340. */
  87341. constructor(
  87342. /**The name of the animation range**/
  87343. name: string,
  87344. /**The starting frame of the animation */
  87345. from: number,
  87346. /**The ending frame of the animation*/
  87347. to: number);
  87348. /**
  87349. * Makes a copy of the animation range
  87350. * @returns A copy of the animation range
  87351. */
  87352. clone(): AnimationRange;
  87353. }
  87354. }
  87355. declare module BABYLON {
  87356. /**
  87357. * Composed of a frame, and an action function
  87358. */
  87359. export class AnimationEvent {
  87360. /** The frame for which the event is triggered **/
  87361. frame: number;
  87362. /** The event to perform when triggered **/
  87363. action: (currentFrame: number) => void;
  87364. /** Specifies if the event should be triggered only once**/
  87365. onlyOnce?: boolean | undefined;
  87366. /**
  87367. * Specifies if the animation event is done
  87368. */
  87369. isDone: boolean;
  87370. /**
  87371. * Initializes the animation event
  87372. * @param frame The frame for which the event is triggered
  87373. * @param action The event to perform when triggered
  87374. * @param onlyOnce Specifies if the event should be triggered only once
  87375. */
  87376. constructor(
  87377. /** The frame for which the event is triggered **/
  87378. frame: number,
  87379. /** The event to perform when triggered **/
  87380. action: (currentFrame: number) => void,
  87381. /** Specifies if the event should be triggered only once**/
  87382. onlyOnce?: boolean | undefined);
  87383. /** @hidden */
  87384. _clone(): AnimationEvent;
  87385. }
  87386. }
  87387. declare module BABYLON {
  87388. /**
  87389. * Interface used to define a behavior
  87390. */
  87391. export interface Behavior<T> {
  87392. /** gets or sets behavior's name */
  87393. name: string;
  87394. /**
  87395. * Function called when the behavior needs to be initialized (after attaching it to a target)
  87396. */
  87397. init(): void;
  87398. /**
  87399. * Called when the behavior is attached to a target
  87400. * @param target defines the target where the behavior is attached to
  87401. */
  87402. attach(target: T): void;
  87403. /**
  87404. * Called when the behavior is detached from its target
  87405. */
  87406. detach(): void;
  87407. }
  87408. /**
  87409. * Interface implemented by classes supporting behaviors
  87410. */
  87411. export interface IBehaviorAware<T> {
  87412. /**
  87413. * Attach a behavior
  87414. * @param behavior defines the behavior to attach
  87415. * @returns the current host
  87416. */
  87417. addBehavior(behavior: Behavior<T>): T;
  87418. /**
  87419. * Remove a behavior from the current object
  87420. * @param behavior defines the behavior to detach
  87421. * @returns the current host
  87422. */
  87423. removeBehavior(behavior: Behavior<T>): T;
  87424. /**
  87425. * Gets a behavior using its name to search
  87426. * @param name defines the name to search
  87427. * @returns the behavior or null if not found
  87428. */
  87429. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  87430. }
  87431. }
  87432. declare module BABYLON {
  87433. /**
  87434. * Defines an array and its length.
  87435. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  87436. */
  87437. export interface ISmartArrayLike<T> {
  87438. /**
  87439. * The data of the array.
  87440. */
  87441. data: Array<T>;
  87442. /**
  87443. * The active length of the array.
  87444. */
  87445. length: number;
  87446. }
  87447. /**
  87448. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87449. */
  87450. export class SmartArray<T> implements ISmartArrayLike<T> {
  87451. /**
  87452. * The full set of data from the array.
  87453. */
  87454. data: Array<T>;
  87455. /**
  87456. * The active length of the array.
  87457. */
  87458. length: number;
  87459. protected _id: number;
  87460. /**
  87461. * Instantiates a Smart Array.
  87462. * @param capacity defines the default capacity of the array.
  87463. */
  87464. constructor(capacity: number);
  87465. /**
  87466. * Pushes a value at the end of the active data.
  87467. * @param value defines the object to push in the array.
  87468. */
  87469. push(value: T): void;
  87470. /**
  87471. * Iterates over the active data and apply the lambda to them.
  87472. * @param func defines the action to apply on each value.
  87473. */
  87474. forEach(func: (content: T) => void): void;
  87475. /**
  87476. * Sorts the full sets of data.
  87477. * @param compareFn defines the comparison function to apply.
  87478. */
  87479. sort(compareFn: (a: T, b: T) => number): void;
  87480. /**
  87481. * Resets the active data to an empty array.
  87482. */
  87483. reset(): void;
  87484. /**
  87485. * Releases all the data from the array as well as the array.
  87486. */
  87487. dispose(): void;
  87488. /**
  87489. * Concats the active data with a given array.
  87490. * @param array defines the data to concatenate with.
  87491. */
  87492. concat(array: any): void;
  87493. /**
  87494. * Returns the position of a value in the active data.
  87495. * @param value defines the value to find the index for
  87496. * @returns the index if found in the active data otherwise -1
  87497. */
  87498. indexOf(value: T): number;
  87499. /**
  87500. * Returns whether an element is part of the active data.
  87501. * @param value defines the value to look for
  87502. * @returns true if found in the active data otherwise false
  87503. */
  87504. contains(value: T): boolean;
  87505. private static _GlobalId;
  87506. }
  87507. /**
  87508. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87509. * The data in this array can only be present once
  87510. */
  87511. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  87512. private _duplicateId;
  87513. /**
  87514. * Pushes a value at the end of the active data.
  87515. * THIS DOES NOT PREVENT DUPPLICATE DATA
  87516. * @param value defines the object to push in the array.
  87517. */
  87518. push(value: T): void;
  87519. /**
  87520. * Pushes a value at the end of the active data.
  87521. * If the data is already present, it won t be added again
  87522. * @param value defines the object to push in the array.
  87523. * @returns true if added false if it was already present
  87524. */
  87525. pushNoDuplicate(value: T): boolean;
  87526. /**
  87527. * Resets the active data to an empty array.
  87528. */
  87529. reset(): void;
  87530. /**
  87531. * Concats the active data with a given array.
  87532. * This ensures no dupplicate will be present in the result.
  87533. * @param array defines the data to concatenate with.
  87534. */
  87535. concatWithNoDuplicate(array: any): void;
  87536. }
  87537. }
  87538. declare module BABYLON {
  87539. /**
  87540. * @ignore
  87541. * This is a list of all the different input types that are available in the application.
  87542. * Fo instance: ArcRotateCameraGamepadInput...
  87543. */
  87544. export var CameraInputTypes: {};
  87545. /**
  87546. * This is the contract to implement in order to create a new input class.
  87547. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  87548. */
  87549. export interface ICameraInput<TCamera extends Camera> {
  87550. /**
  87551. * Defines the camera the input is attached to.
  87552. */
  87553. camera: Nullable<TCamera>;
  87554. /**
  87555. * Gets the class name of the current intput.
  87556. * @returns the class name
  87557. */
  87558. getClassName(): string;
  87559. /**
  87560. * Get the friendly name associated with the input class.
  87561. * @returns the input friendly name
  87562. */
  87563. getSimpleName(): string;
  87564. /**
  87565. * Attach the input controls to a specific dom element to get the input from.
  87566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87567. */
  87568. attachControl(noPreventDefault?: boolean): void;
  87569. /**
  87570. * Detach the current controls from the specified dom element.
  87571. */
  87572. detachControl(): void;
  87573. /**
  87574. * Update the current camera state depending on the inputs that have been used this frame.
  87575. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87576. */
  87577. checkInputs?: () => void;
  87578. }
  87579. /**
  87580. * Represents a map of input types to input instance or input index to input instance.
  87581. */
  87582. export interface CameraInputsMap<TCamera extends Camera> {
  87583. /**
  87584. * Accessor to the input by input type.
  87585. */
  87586. [name: string]: ICameraInput<TCamera>;
  87587. /**
  87588. * Accessor to the input by input index.
  87589. */
  87590. [idx: number]: ICameraInput<TCamera>;
  87591. }
  87592. /**
  87593. * This represents the input manager used within a camera.
  87594. * It helps dealing with all the different kind of input attached to a camera.
  87595. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87596. */
  87597. export class CameraInputsManager<TCamera extends Camera> {
  87598. /**
  87599. * Defines the list of inputs attahed to the camera.
  87600. */
  87601. attached: CameraInputsMap<TCamera>;
  87602. /**
  87603. * Defines the dom element the camera is collecting inputs from.
  87604. * This is null if the controls have not been attached.
  87605. */
  87606. attachedToElement: boolean;
  87607. /**
  87608. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87609. */
  87610. noPreventDefault: boolean;
  87611. /**
  87612. * Defined the camera the input manager belongs to.
  87613. */
  87614. camera: TCamera;
  87615. /**
  87616. * Update the current camera state depending on the inputs that have been used this frame.
  87617. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87618. */
  87619. checkInputs: () => void;
  87620. /**
  87621. * Instantiate a new Camera Input Manager.
  87622. * @param camera Defines the camera the input manager blongs to
  87623. */
  87624. constructor(camera: TCamera);
  87625. /**
  87626. * Add an input method to a camera
  87627. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87628. * @param input camera input method
  87629. */
  87630. add(input: ICameraInput<TCamera>): void;
  87631. /**
  87632. * Remove a specific input method from a camera
  87633. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  87634. * @param inputToRemove camera input method
  87635. */
  87636. remove(inputToRemove: ICameraInput<TCamera>): void;
  87637. /**
  87638. * Remove a specific input type from a camera
  87639. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  87640. * @param inputType the type of the input to remove
  87641. */
  87642. removeByType(inputType: string): void;
  87643. private _addCheckInputs;
  87644. /**
  87645. * Attach the input controls to the currently attached dom element to listen the events from.
  87646. * @param input Defines the input to attach
  87647. */
  87648. attachInput(input: ICameraInput<TCamera>): void;
  87649. /**
  87650. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  87651. * @param element Defines the dom element to collect the events from
  87652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87653. */
  87654. attachElement(noPreventDefault?: boolean): void;
  87655. /**
  87656. * Detach the current manager inputs controls from a specific dom element.
  87657. * @param element Defines the dom element to collect the events from
  87658. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  87659. */
  87660. detachElement(disconnect?: boolean): void;
  87661. /**
  87662. * Rebuild the dynamic inputCheck function from the current list of
  87663. * defined inputs in the manager.
  87664. */
  87665. rebuildInputCheck(): void;
  87666. /**
  87667. * Remove all attached input methods from a camera
  87668. */
  87669. clear(): void;
  87670. /**
  87671. * Serialize the current input manager attached to a camera.
  87672. * This ensures than once parsed,
  87673. * the input associated to the camera will be identical to the current ones
  87674. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  87675. */
  87676. serialize(serializedCamera: any): void;
  87677. /**
  87678. * Parses an input manager serialized JSON to restore the previous list of inputs
  87679. * and states associated to a camera.
  87680. * @param parsedCamera Defines the JSON to parse
  87681. */
  87682. parse(parsedCamera: any): void;
  87683. }
  87684. }
  87685. declare module BABYLON {
  87686. /**
  87687. * Class used to store data that will be store in GPU memory
  87688. */
  87689. export class Buffer {
  87690. private _engine;
  87691. private _buffer;
  87692. /** @hidden */
  87693. _data: Nullable<DataArray>;
  87694. private _updatable;
  87695. private _instanced;
  87696. private _divisor;
  87697. /**
  87698. * Gets the byte stride.
  87699. */
  87700. readonly byteStride: number;
  87701. /**
  87702. * Constructor
  87703. * @param engine the engine
  87704. * @param data the data to use for this buffer
  87705. * @param updatable whether the data is updatable
  87706. * @param stride the stride (optional)
  87707. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87708. * @param instanced whether the buffer is instanced (optional)
  87709. * @param useBytes set to true if the stride in in bytes (optional)
  87710. * @param divisor sets an optional divisor for instances (1 by default)
  87711. */
  87712. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  87713. /**
  87714. * Create a new VertexBuffer based on the current buffer
  87715. * @param kind defines the vertex buffer kind (position, normal, etc.)
  87716. * @param offset defines offset in the buffer (0 by default)
  87717. * @param size defines the size in floats of attributes (position is 3 for instance)
  87718. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  87719. * @param instanced defines if the vertex buffer contains indexed data
  87720. * @param useBytes defines if the offset and stride are in bytes *
  87721. * @param divisor sets an optional divisor for instances (1 by default)
  87722. * @returns the new vertex buffer
  87723. */
  87724. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  87725. /**
  87726. * Gets a boolean indicating if the Buffer is updatable?
  87727. * @returns true if the buffer is updatable
  87728. */
  87729. isUpdatable(): boolean;
  87730. /**
  87731. * Gets current buffer's data
  87732. * @returns a DataArray or null
  87733. */
  87734. getData(): Nullable<DataArray>;
  87735. /**
  87736. * Gets underlying native buffer
  87737. * @returns underlying native buffer
  87738. */
  87739. getBuffer(): Nullable<DataBuffer>;
  87740. /**
  87741. * Gets the stride in float32 units (i.e. byte stride / 4).
  87742. * May not be an integer if the byte stride is not divisible by 4.
  87743. * @returns the stride in float32 units
  87744. * @deprecated Please use byteStride instead.
  87745. */
  87746. getStrideSize(): number;
  87747. /**
  87748. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87749. * @param data defines the data to store
  87750. */
  87751. create(data?: Nullable<DataArray>): void;
  87752. /** @hidden */
  87753. _rebuild(): void;
  87754. /**
  87755. * Update current buffer data
  87756. * @param data defines the data to store
  87757. */
  87758. update(data: DataArray): void;
  87759. /**
  87760. * Updates the data directly.
  87761. * @param data the new data
  87762. * @param offset the new offset
  87763. * @param vertexCount the vertex count (optional)
  87764. * @param useBytes set to true if the offset is in bytes
  87765. */
  87766. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  87767. /**
  87768. * Release all resources
  87769. */
  87770. dispose(): void;
  87771. }
  87772. /**
  87773. * Specialized buffer used to store vertex data
  87774. */
  87775. export class VertexBuffer {
  87776. /** @hidden */
  87777. _buffer: Buffer;
  87778. private _kind;
  87779. private _size;
  87780. private _ownsBuffer;
  87781. private _instanced;
  87782. private _instanceDivisor;
  87783. /**
  87784. * The byte type.
  87785. */
  87786. static readonly BYTE: number;
  87787. /**
  87788. * The unsigned byte type.
  87789. */
  87790. static readonly UNSIGNED_BYTE: number;
  87791. /**
  87792. * The short type.
  87793. */
  87794. static readonly SHORT: number;
  87795. /**
  87796. * The unsigned short type.
  87797. */
  87798. static readonly UNSIGNED_SHORT: number;
  87799. /**
  87800. * The integer type.
  87801. */
  87802. static readonly INT: number;
  87803. /**
  87804. * The unsigned integer type.
  87805. */
  87806. static readonly UNSIGNED_INT: number;
  87807. /**
  87808. * The float type.
  87809. */
  87810. static readonly FLOAT: number;
  87811. /**
  87812. * Gets or sets the instance divisor when in instanced mode
  87813. */
  87814. get instanceDivisor(): number;
  87815. set instanceDivisor(value: number);
  87816. /**
  87817. * Gets the byte stride.
  87818. */
  87819. readonly byteStride: number;
  87820. /**
  87821. * Gets the byte offset.
  87822. */
  87823. readonly byteOffset: number;
  87824. /**
  87825. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  87826. */
  87827. readonly normalized: boolean;
  87828. /**
  87829. * Gets the data type of each component in the array.
  87830. */
  87831. readonly type: number;
  87832. /**
  87833. * Constructor
  87834. * @param engine the engine
  87835. * @param data the data to use for this vertex buffer
  87836. * @param kind the vertex buffer kind
  87837. * @param updatable whether the data is updatable
  87838. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87839. * @param stride the stride (optional)
  87840. * @param instanced whether the buffer is instanced (optional)
  87841. * @param offset the offset of the data (optional)
  87842. * @param size the number of components (optional)
  87843. * @param type the type of the component (optional)
  87844. * @param normalized whether the data contains normalized data (optional)
  87845. * @param useBytes set to true if stride and offset are in bytes (optional)
  87846. * @param divisor defines the instance divisor to use (1 by default)
  87847. */
  87848. 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);
  87849. /** @hidden */
  87850. _rebuild(): void;
  87851. /**
  87852. * Returns the kind of the VertexBuffer (string)
  87853. * @returns a string
  87854. */
  87855. getKind(): string;
  87856. /**
  87857. * Gets a boolean indicating if the VertexBuffer is updatable?
  87858. * @returns true if the buffer is updatable
  87859. */
  87860. isUpdatable(): boolean;
  87861. /**
  87862. * Gets current buffer's data
  87863. * @returns a DataArray or null
  87864. */
  87865. getData(): Nullable<DataArray>;
  87866. /**
  87867. * Gets underlying native buffer
  87868. * @returns underlying native buffer
  87869. */
  87870. getBuffer(): Nullable<DataBuffer>;
  87871. /**
  87872. * Gets the stride in float32 units (i.e. byte stride / 4).
  87873. * May not be an integer if the byte stride is not divisible by 4.
  87874. * @returns the stride in float32 units
  87875. * @deprecated Please use byteStride instead.
  87876. */
  87877. getStrideSize(): number;
  87878. /**
  87879. * Returns the offset as a multiple of the type byte length.
  87880. * @returns the offset in bytes
  87881. * @deprecated Please use byteOffset instead.
  87882. */
  87883. getOffset(): number;
  87884. /**
  87885. * Returns the number of components per vertex attribute (integer)
  87886. * @returns the size in float
  87887. */
  87888. getSize(): number;
  87889. /**
  87890. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87891. * @returns true if this buffer is instanced
  87892. */
  87893. getIsInstanced(): boolean;
  87894. /**
  87895. * Returns the instancing divisor, zero for non-instanced (integer).
  87896. * @returns a number
  87897. */
  87898. getInstanceDivisor(): number;
  87899. /**
  87900. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87901. * @param data defines the data to store
  87902. */
  87903. create(data?: DataArray): void;
  87904. /**
  87905. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87906. * This function will create a new buffer if the current one is not updatable
  87907. * @param data defines the data to store
  87908. */
  87909. update(data: DataArray): void;
  87910. /**
  87911. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87912. * Returns the directly updated WebGLBuffer.
  87913. * @param data the new data
  87914. * @param offset the new offset
  87915. * @param useBytes set to true if the offset is in bytes
  87916. */
  87917. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87918. /**
  87919. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87920. */
  87921. dispose(): void;
  87922. /**
  87923. * Enumerates each value of this vertex buffer as numbers.
  87924. * @param count the number of values to enumerate
  87925. * @param callback the callback function called for each value
  87926. */
  87927. forEach(count: number, callback: (value: number, index: number) => void): void;
  87928. /**
  87929. * Positions
  87930. */
  87931. static readonly PositionKind: string;
  87932. /**
  87933. * Normals
  87934. */
  87935. static readonly NormalKind: string;
  87936. /**
  87937. * Tangents
  87938. */
  87939. static readonly TangentKind: string;
  87940. /**
  87941. * Texture coordinates
  87942. */
  87943. static readonly UVKind: string;
  87944. /**
  87945. * Texture coordinates 2
  87946. */
  87947. static readonly UV2Kind: string;
  87948. /**
  87949. * Texture coordinates 3
  87950. */
  87951. static readonly UV3Kind: string;
  87952. /**
  87953. * Texture coordinates 4
  87954. */
  87955. static readonly UV4Kind: string;
  87956. /**
  87957. * Texture coordinates 5
  87958. */
  87959. static readonly UV5Kind: string;
  87960. /**
  87961. * Texture coordinates 6
  87962. */
  87963. static readonly UV6Kind: string;
  87964. /**
  87965. * Colors
  87966. */
  87967. static readonly ColorKind: string;
  87968. /**
  87969. * Matrix indices (for bones)
  87970. */
  87971. static readonly MatricesIndicesKind: string;
  87972. /**
  87973. * Matrix weights (for bones)
  87974. */
  87975. static readonly MatricesWeightsKind: string;
  87976. /**
  87977. * Additional matrix indices (for bones)
  87978. */
  87979. static readonly MatricesIndicesExtraKind: string;
  87980. /**
  87981. * Additional matrix weights (for bones)
  87982. */
  87983. static readonly MatricesWeightsExtraKind: string;
  87984. /**
  87985. * Deduces the stride given a kind.
  87986. * @param kind The kind string to deduce
  87987. * @returns The deduced stride
  87988. */
  87989. static DeduceStride(kind: string): number;
  87990. /**
  87991. * Gets the byte length of the given type.
  87992. * @param type the type
  87993. * @returns the number of bytes
  87994. */
  87995. static GetTypeByteLength(type: number): number;
  87996. /**
  87997. * Enumerates each value of the given parameters as numbers.
  87998. * @param data the data to enumerate
  87999. * @param byteOffset the byte offset of the data
  88000. * @param byteStride the byte stride of the data
  88001. * @param componentCount the number of components per element
  88002. * @param componentType the type of the component
  88003. * @param count the number of values to enumerate
  88004. * @param normalized whether the data is normalized
  88005. * @param callback the callback function called for each value
  88006. */
  88007. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  88008. private static _GetFloatValue;
  88009. }
  88010. }
  88011. declare module BABYLON {
  88012. /**
  88013. * The options Interface for creating a Capsule Mesh
  88014. */
  88015. export interface ICreateCapsuleOptions {
  88016. /** The Orientation of the capsule. Default : Vector3.Up() */
  88017. orientation?: Vector3;
  88018. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  88019. subdivisions: number;
  88020. /** Number of cylindrical segments on the capsule. */
  88021. tessellation: number;
  88022. /** Height or Length of the capsule. */
  88023. height: number;
  88024. /** Radius of the capsule. */
  88025. radius: number;
  88026. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  88027. capSubdivisions: number;
  88028. /** Overwrite for the top radius. */
  88029. radiusTop?: number;
  88030. /** Overwrite for the bottom radius. */
  88031. radiusBottom?: number;
  88032. /** Overwrite for the top capSubdivisions. */
  88033. topCapSubdivisions?: number;
  88034. /** Overwrite for the bottom capSubdivisions. */
  88035. bottomCapSubdivisions?: number;
  88036. }
  88037. /**
  88038. * Class containing static functions to help procedurally build meshes
  88039. */
  88040. export class CapsuleBuilder {
  88041. /**
  88042. * Creates a capsule or a pill mesh
  88043. * @param name defines the name of the mesh
  88044. * @param options The constructors options.
  88045. * @param scene The scene the mesh is scoped to.
  88046. * @returns Capsule Mesh
  88047. */
  88048. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  88049. }
  88050. }
  88051. declare module BABYLON {
  88052. /**
  88053. * @hidden
  88054. */
  88055. export class IntersectionInfo {
  88056. bu: Nullable<number>;
  88057. bv: Nullable<number>;
  88058. distance: number;
  88059. faceId: number;
  88060. subMeshId: number;
  88061. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  88062. }
  88063. }
  88064. declare module BABYLON {
  88065. /**
  88066. * Class used to store bounding sphere information
  88067. */
  88068. export class BoundingSphere {
  88069. /**
  88070. * Gets the center of the bounding sphere in local space
  88071. */
  88072. readonly center: Vector3;
  88073. /**
  88074. * Radius of the bounding sphere in local space
  88075. */
  88076. radius: number;
  88077. /**
  88078. * Gets the center of the bounding sphere in world space
  88079. */
  88080. readonly centerWorld: Vector3;
  88081. /**
  88082. * Radius of the bounding sphere in world space
  88083. */
  88084. radiusWorld: number;
  88085. /**
  88086. * Gets the minimum vector in local space
  88087. */
  88088. readonly minimum: Vector3;
  88089. /**
  88090. * Gets the maximum vector in local space
  88091. */
  88092. readonly maximum: Vector3;
  88093. private _worldMatrix;
  88094. private static readonly TmpVector3;
  88095. /**
  88096. * Creates a new bounding sphere
  88097. * @param min defines the minimum vector (in local space)
  88098. * @param max defines the maximum vector (in local space)
  88099. * @param worldMatrix defines the new world matrix
  88100. */
  88101. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88102. /**
  88103. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  88104. * @param min defines the new minimum vector (in local space)
  88105. * @param max defines the new maximum vector (in local space)
  88106. * @param worldMatrix defines the new world matrix
  88107. */
  88108. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88109. /**
  88110. * Scale the current bounding sphere by applying a scale factor
  88111. * @param factor defines the scale factor to apply
  88112. * @returns the current bounding box
  88113. */
  88114. scale(factor: number): BoundingSphere;
  88115. /**
  88116. * Gets the world matrix of the bounding box
  88117. * @returns a matrix
  88118. */
  88119. getWorldMatrix(): DeepImmutable<Matrix>;
  88120. /** @hidden */
  88121. _update(worldMatrix: DeepImmutable<Matrix>): void;
  88122. /**
  88123. * Tests if the bounding sphere is intersecting the frustum planes
  88124. * @param frustumPlanes defines the frustum planes to test
  88125. * @returns true if there is an intersection
  88126. */
  88127. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88128. /**
  88129. * Tests if the bounding sphere center is in between the frustum planes.
  88130. * Used for optimistic fast inclusion.
  88131. * @param frustumPlanes defines the frustum planes to test
  88132. * @returns true if the sphere center is in between the frustum planes
  88133. */
  88134. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88135. /**
  88136. * Tests if a point is inside the bounding sphere
  88137. * @param point defines the point to test
  88138. * @returns true if the point is inside the bounding sphere
  88139. */
  88140. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88141. /**
  88142. * Checks if two sphere intersct
  88143. * @param sphere0 sphere 0
  88144. * @param sphere1 sphere 1
  88145. * @returns true if the speres intersect
  88146. */
  88147. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  88148. }
  88149. }
  88150. declare module BABYLON {
  88151. /**
  88152. * Class used to store bounding box information
  88153. */
  88154. export class BoundingBox implements ICullable {
  88155. /**
  88156. * Gets the 8 vectors representing the bounding box in local space
  88157. */
  88158. readonly vectors: Vector3[];
  88159. /**
  88160. * Gets the center of the bounding box in local space
  88161. */
  88162. readonly center: Vector3;
  88163. /**
  88164. * Gets the center of the bounding box in world space
  88165. */
  88166. readonly centerWorld: Vector3;
  88167. /**
  88168. * Gets the extend size in local space
  88169. */
  88170. readonly extendSize: Vector3;
  88171. /**
  88172. * Gets the extend size in world space
  88173. */
  88174. readonly extendSizeWorld: Vector3;
  88175. /**
  88176. * Gets the OBB (object bounding box) directions
  88177. */
  88178. readonly directions: Vector3[];
  88179. /**
  88180. * Gets the 8 vectors representing the bounding box in world space
  88181. */
  88182. readonly vectorsWorld: Vector3[];
  88183. /**
  88184. * Gets the minimum vector in world space
  88185. */
  88186. readonly minimumWorld: Vector3;
  88187. /**
  88188. * Gets the maximum vector in world space
  88189. */
  88190. readonly maximumWorld: Vector3;
  88191. /**
  88192. * Gets the minimum vector in local space
  88193. */
  88194. readonly minimum: Vector3;
  88195. /**
  88196. * Gets the maximum vector in local space
  88197. */
  88198. readonly maximum: Vector3;
  88199. private _worldMatrix;
  88200. private static readonly TmpVector3;
  88201. /**
  88202. * @hidden
  88203. */
  88204. _tag: number;
  88205. /**
  88206. * Creates a new bounding box
  88207. * @param min defines the minimum vector (in local space)
  88208. * @param max defines the maximum vector (in local space)
  88209. * @param worldMatrix defines the new world matrix
  88210. */
  88211. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88212. /**
  88213. * Recreates the entire bounding box from scratch as if we call the constructor in place
  88214. * @param min defines the new minimum vector (in local space)
  88215. * @param max defines the new maximum vector (in local space)
  88216. * @param worldMatrix defines the new world matrix
  88217. */
  88218. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88219. /**
  88220. * Scale the current bounding box by applying a scale factor
  88221. * @param factor defines the scale factor to apply
  88222. * @returns the current bounding box
  88223. */
  88224. scale(factor: number): BoundingBox;
  88225. /**
  88226. * Gets the world matrix of the bounding box
  88227. * @returns a matrix
  88228. */
  88229. getWorldMatrix(): DeepImmutable<Matrix>;
  88230. /** @hidden */
  88231. _update(world: DeepImmutable<Matrix>): void;
  88232. /**
  88233. * Tests if the bounding box is intersecting the frustum planes
  88234. * @param frustumPlanes defines the frustum planes to test
  88235. * @returns true if there is an intersection
  88236. */
  88237. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88238. /**
  88239. * Tests if the bounding box is entirely inside the frustum planes
  88240. * @param frustumPlanes defines the frustum planes to test
  88241. * @returns true if there is an inclusion
  88242. */
  88243. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88244. /**
  88245. * Tests if a point is inside the bounding box
  88246. * @param point defines the point to test
  88247. * @returns true if the point is inside the bounding box
  88248. */
  88249. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88250. /**
  88251. * Tests if the bounding box intersects with a bounding sphere
  88252. * @param sphere defines the sphere to test
  88253. * @returns true if there is an intersection
  88254. */
  88255. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  88256. /**
  88257. * Tests if the bounding box intersects with a box defined by a min and max vectors
  88258. * @param min defines the min vector to use
  88259. * @param max defines the max vector to use
  88260. * @returns true if there is an intersection
  88261. */
  88262. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  88263. /**
  88264. * Tests if two bounding boxes are intersections
  88265. * @param box0 defines the first box to test
  88266. * @param box1 defines the second box to test
  88267. * @returns true if there is an intersection
  88268. */
  88269. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  88270. /**
  88271. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  88272. * @param minPoint defines the minimum vector of the bounding box
  88273. * @param maxPoint defines the maximum vector of the bounding box
  88274. * @param sphereCenter defines the sphere center
  88275. * @param sphereRadius defines the sphere radius
  88276. * @returns true if there is an intersection
  88277. */
  88278. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  88279. /**
  88280. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  88281. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88282. * @param frustumPlanes defines the frustum planes to test
  88283. * @return true if there is an inclusion
  88284. */
  88285. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88286. /**
  88287. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  88288. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88289. * @param frustumPlanes defines the frustum planes to test
  88290. * @return true if there is an intersection
  88291. */
  88292. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88293. }
  88294. }
  88295. declare module BABYLON {
  88296. /** @hidden */
  88297. export class Collider {
  88298. /** Define if a collision was found */
  88299. collisionFound: boolean;
  88300. /**
  88301. * Define last intersection point in local space
  88302. */
  88303. intersectionPoint: Vector3;
  88304. /**
  88305. * Define last collided mesh
  88306. */
  88307. collidedMesh: Nullable<AbstractMesh>;
  88308. private _collisionPoint;
  88309. private _planeIntersectionPoint;
  88310. private _tempVector;
  88311. private _tempVector2;
  88312. private _tempVector3;
  88313. private _tempVector4;
  88314. private _edge;
  88315. private _baseToVertex;
  88316. private _destinationPoint;
  88317. private _slidePlaneNormal;
  88318. private _displacementVector;
  88319. /** @hidden */
  88320. _radius: Vector3;
  88321. /** @hidden */
  88322. _retry: number;
  88323. private _velocity;
  88324. private _basePoint;
  88325. private _epsilon;
  88326. /** @hidden */
  88327. _velocityWorldLength: number;
  88328. /** @hidden */
  88329. _basePointWorld: Vector3;
  88330. private _velocityWorld;
  88331. private _normalizedVelocity;
  88332. /** @hidden */
  88333. _initialVelocity: Vector3;
  88334. /** @hidden */
  88335. _initialPosition: Vector3;
  88336. private _nearestDistance;
  88337. private _collisionMask;
  88338. get collisionMask(): number;
  88339. set collisionMask(mask: number);
  88340. /**
  88341. * Gets the plane normal used to compute the sliding response (in local space)
  88342. */
  88343. get slidePlaneNormal(): Vector3;
  88344. /** @hidden */
  88345. _initialize(source: Vector3, dir: Vector3, e: number): void;
  88346. /** @hidden */
  88347. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  88348. /** @hidden */
  88349. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  88350. /** @hidden */
  88351. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88352. /** @hidden */
  88353. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88354. /** @hidden */
  88355. _getResponse(pos: Vector3, vel: Vector3): void;
  88356. }
  88357. }
  88358. declare module BABYLON {
  88359. /**
  88360. * Interface for cullable objects
  88361. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  88362. */
  88363. export interface ICullable {
  88364. /**
  88365. * Checks if the object or part of the object is in the frustum
  88366. * @param frustumPlanes Camera near/planes
  88367. * @returns true if the object is in frustum otherwise false
  88368. */
  88369. isInFrustum(frustumPlanes: Plane[]): boolean;
  88370. /**
  88371. * Checks if a cullable object (mesh...) is in the camera frustum
  88372. * Unlike isInFrustum this cheks the full bounding box
  88373. * @param frustumPlanes Camera near/planes
  88374. * @returns true if the object is in frustum otherwise false
  88375. */
  88376. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88377. }
  88378. /**
  88379. * Info for a bounding data of a mesh
  88380. */
  88381. export class BoundingInfo implements ICullable {
  88382. /**
  88383. * Bounding box for the mesh
  88384. */
  88385. readonly boundingBox: BoundingBox;
  88386. /**
  88387. * Bounding sphere for the mesh
  88388. */
  88389. readonly boundingSphere: BoundingSphere;
  88390. private _isLocked;
  88391. private static readonly TmpVector3;
  88392. /**
  88393. * Constructs bounding info
  88394. * @param minimum min vector of the bounding box/sphere
  88395. * @param maximum max vector of the bounding box/sphere
  88396. * @param worldMatrix defines the new world matrix
  88397. */
  88398. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88399. /**
  88400. * Recreates the entire bounding info from scratch as if we call the constructor in place
  88401. * @param min defines the new minimum vector (in local space)
  88402. * @param max defines the new maximum vector (in local space)
  88403. * @param worldMatrix defines the new world matrix
  88404. */
  88405. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88406. /**
  88407. * min vector of the bounding box/sphere
  88408. */
  88409. get minimum(): Vector3;
  88410. /**
  88411. * max vector of the bounding box/sphere
  88412. */
  88413. get maximum(): Vector3;
  88414. /**
  88415. * If the info is locked and won't be updated to avoid perf overhead
  88416. */
  88417. get isLocked(): boolean;
  88418. set isLocked(value: boolean);
  88419. /**
  88420. * Updates the bounding sphere and box
  88421. * @param world world matrix to be used to update
  88422. */
  88423. update(world: DeepImmutable<Matrix>): void;
  88424. /**
  88425. * Recreate the bounding info to be centered around a specific point given a specific extend.
  88426. * @param center New center of the bounding info
  88427. * @param extend New extend of the bounding info
  88428. * @returns the current bounding info
  88429. */
  88430. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  88431. /**
  88432. * Scale the current bounding info by applying a scale factor
  88433. * @param factor defines the scale factor to apply
  88434. * @returns the current bounding info
  88435. */
  88436. scale(factor: number): BoundingInfo;
  88437. /**
  88438. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  88439. * @param frustumPlanes defines the frustum to test
  88440. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  88441. * @returns true if the bounding info is in the frustum planes
  88442. */
  88443. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  88444. /**
  88445. * Gets the world distance between the min and max points of the bounding box
  88446. */
  88447. get diagonalLength(): number;
  88448. /**
  88449. * Checks if a cullable object (mesh...) is in the camera frustum
  88450. * Unlike isInFrustum this cheks the full bounding box
  88451. * @param frustumPlanes Camera near/planes
  88452. * @returns true if the object is in frustum otherwise false
  88453. */
  88454. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88455. /** @hidden */
  88456. _checkCollision(collider: Collider): boolean;
  88457. /**
  88458. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  88459. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88460. * @param point the point to check intersection with
  88461. * @returns if the point intersects
  88462. */
  88463. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88464. /**
  88465. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  88466. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88467. * @param boundingInfo the bounding info to check intersection with
  88468. * @param precise if the intersection should be done using OBB
  88469. * @returns if the bounding info intersects
  88470. */
  88471. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  88472. }
  88473. }
  88474. declare module BABYLON {
  88475. /**
  88476. * Extracts minimum and maximum values from a list of indexed positions
  88477. * @param positions defines the positions to use
  88478. * @param indices defines the indices to the positions
  88479. * @param indexStart defines the start index
  88480. * @param indexCount defines the end index
  88481. * @param bias defines bias value to add to the result
  88482. * @return minimum and maximum values
  88483. */
  88484. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88485. minimum: Vector3;
  88486. maximum: Vector3;
  88487. };
  88488. /**
  88489. * Extracts minimum and maximum values from a list of positions
  88490. * @param positions defines the positions to use
  88491. * @param start defines the start index in the positions array
  88492. * @param count defines the number of positions to handle
  88493. * @param bias defines bias value to add to the result
  88494. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88495. * @return minimum and maximum values
  88496. */
  88497. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88498. minimum: Vector3;
  88499. maximum: Vector3;
  88500. };
  88501. }
  88502. declare module BABYLON {
  88503. /** @hidden */
  88504. export class WebGLDataBuffer extends DataBuffer {
  88505. private _buffer;
  88506. constructor(resource: WebGLBuffer);
  88507. get underlyingResource(): any;
  88508. }
  88509. }
  88510. declare module BABYLON {
  88511. /** @hidden */
  88512. export class WebGLPipelineContext implements IPipelineContext {
  88513. engine: ThinEngine;
  88514. program: Nullable<WebGLProgram>;
  88515. context?: WebGLRenderingContext;
  88516. vertexShader?: WebGLShader;
  88517. fragmentShader?: WebGLShader;
  88518. isParallelCompiled: boolean;
  88519. onCompiled?: () => void;
  88520. transformFeedback?: WebGLTransformFeedback | null;
  88521. vertexCompilationError: Nullable<string>;
  88522. fragmentCompilationError: Nullable<string>;
  88523. programLinkError: Nullable<string>;
  88524. programValidationError: Nullable<string>;
  88525. get isAsync(): boolean;
  88526. get isReady(): boolean;
  88527. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  88528. _getVertexShaderCode(): string | null;
  88529. _getFragmentShaderCode(): string | null;
  88530. }
  88531. }
  88532. declare module BABYLON {
  88533. interface ThinEngine {
  88534. /**
  88535. * Create an uniform buffer
  88536. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88537. * @param elements defines the content of the uniform buffer
  88538. * @returns the webGL uniform buffer
  88539. */
  88540. createUniformBuffer(elements: FloatArray): DataBuffer;
  88541. /**
  88542. * Create a dynamic uniform buffer
  88543. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88544. * @param elements defines the content of the uniform buffer
  88545. * @returns the webGL uniform buffer
  88546. */
  88547. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88548. /**
  88549. * Update an existing uniform buffer
  88550. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88551. * @param uniformBuffer defines the target uniform buffer
  88552. * @param elements defines the content to update
  88553. * @param offset defines the offset in the uniform buffer where update should start
  88554. * @param count defines the size of the data to update
  88555. */
  88556. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88557. /**
  88558. * Bind an uniform buffer to the current webGL context
  88559. * @param buffer defines the buffer to bind
  88560. */
  88561. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88562. /**
  88563. * Bind a buffer to the current webGL context at a given location
  88564. * @param buffer defines the buffer to bind
  88565. * @param location defines the index where to bind the buffer
  88566. */
  88567. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88568. /**
  88569. * Bind a specific block at a given index in a specific shader program
  88570. * @param pipelineContext defines the pipeline context to use
  88571. * @param blockName defines the block name
  88572. * @param index defines the index where to bind the block
  88573. */
  88574. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88575. }
  88576. }
  88577. declare module BABYLON {
  88578. /**
  88579. * Uniform buffer objects.
  88580. *
  88581. * Handles blocks of uniform on the GPU.
  88582. *
  88583. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88584. *
  88585. * For more information, please refer to :
  88586. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88587. */
  88588. export class UniformBuffer {
  88589. private _engine;
  88590. private _buffer;
  88591. private _data;
  88592. private _bufferData;
  88593. private _dynamic?;
  88594. private _uniformLocations;
  88595. private _uniformSizes;
  88596. private _uniformLocationPointer;
  88597. private _needSync;
  88598. private _noUBO;
  88599. private _currentEffect;
  88600. /** @hidden */
  88601. _alreadyBound: boolean;
  88602. private static _MAX_UNIFORM_SIZE;
  88603. private static _tempBuffer;
  88604. /**
  88605. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88606. * This is dynamic to allow compat with webgl 1 and 2.
  88607. * You will need to pass the name of the uniform as well as the value.
  88608. */
  88609. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88610. /**
  88611. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88612. * This is dynamic to allow compat with webgl 1 and 2.
  88613. * You will need to pass the name of the uniform as well as the value.
  88614. */
  88615. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88616. /**
  88617. * Lambda to Update a single float in a uniform buffer.
  88618. * This is dynamic to allow compat with webgl 1 and 2.
  88619. * You will need to pass the name of the uniform as well as the value.
  88620. */
  88621. updateFloat: (name: string, x: number) => void;
  88622. /**
  88623. * Lambda to Update a vec2 of float in a uniform buffer.
  88624. * This is dynamic to allow compat with webgl 1 and 2.
  88625. * You will need to pass the name of the uniform as well as the value.
  88626. */
  88627. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88628. /**
  88629. * Lambda to Update a vec3 of float in a uniform buffer.
  88630. * This is dynamic to allow compat with webgl 1 and 2.
  88631. * You will need to pass the name of the uniform as well as the value.
  88632. */
  88633. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88634. /**
  88635. * Lambda to Update a vec4 of float in a uniform buffer.
  88636. * This is dynamic to allow compat with webgl 1 and 2.
  88637. * You will need to pass the name of the uniform as well as the value.
  88638. */
  88639. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88640. /**
  88641. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88642. * This is dynamic to allow compat with webgl 1 and 2.
  88643. * You will need to pass the name of the uniform as well as the value.
  88644. */
  88645. updateMatrix: (name: string, mat: Matrix) => void;
  88646. /**
  88647. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88648. * This is dynamic to allow compat with webgl 1 and 2.
  88649. * You will need to pass the name of the uniform as well as the value.
  88650. */
  88651. updateVector3: (name: string, vector: Vector3) => void;
  88652. /**
  88653. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88654. * This is dynamic to allow compat with webgl 1 and 2.
  88655. * You will need to pass the name of the uniform as well as the value.
  88656. */
  88657. updateVector4: (name: string, vector: Vector4) => void;
  88658. /**
  88659. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88660. * This is dynamic to allow compat with webgl 1 and 2.
  88661. * You will need to pass the name of the uniform as well as the value.
  88662. */
  88663. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88664. /**
  88665. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88666. * This is dynamic to allow compat with webgl 1 and 2.
  88667. * You will need to pass the name of the uniform as well as the value.
  88668. */
  88669. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88670. /**
  88671. * Instantiates a new Uniform buffer objects.
  88672. *
  88673. * Handles blocks of uniform on the GPU.
  88674. *
  88675. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88676. *
  88677. * For more information, please refer to :
  88678. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88679. * @param engine Define the engine the buffer is associated with
  88680. * @param data Define the data contained in the buffer
  88681. * @param dynamic Define if the buffer is updatable
  88682. */
  88683. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88684. /**
  88685. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88686. * or just falling back on setUniformXXX calls.
  88687. */
  88688. get useUbo(): boolean;
  88689. /**
  88690. * Indicates if the WebGL underlying uniform buffer is in sync
  88691. * with the javascript cache data.
  88692. */
  88693. get isSync(): boolean;
  88694. /**
  88695. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88696. * Also, a dynamic UniformBuffer will disable cache verification and always
  88697. * update the underlying WebGL uniform buffer to the GPU.
  88698. * @returns if Dynamic, otherwise false
  88699. */
  88700. isDynamic(): boolean;
  88701. /**
  88702. * The data cache on JS side.
  88703. * @returns the underlying data as a float array
  88704. */
  88705. getData(): Float32Array;
  88706. /**
  88707. * The underlying WebGL Uniform buffer.
  88708. * @returns the webgl buffer
  88709. */
  88710. getBuffer(): Nullable<DataBuffer>;
  88711. /**
  88712. * std140 layout specifies how to align data within an UBO structure.
  88713. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88714. * for specs.
  88715. */
  88716. private _fillAlignment;
  88717. /**
  88718. * Adds an uniform in the buffer.
  88719. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88720. * for the layout to be correct !
  88721. * @param name Name of the uniform, as used in the uniform block in the shader.
  88722. * @param size Data size, or data directly.
  88723. */
  88724. addUniform(name: string, size: number | number[]): void;
  88725. /**
  88726. * Adds a Matrix 4x4 to the uniform buffer.
  88727. * @param name Name of the uniform, as used in the uniform block in the shader.
  88728. * @param mat A 4x4 matrix.
  88729. */
  88730. addMatrix(name: string, mat: Matrix): void;
  88731. /**
  88732. * Adds a vec2 to the uniform buffer.
  88733. * @param name Name of the uniform, as used in the uniform block in the shader.
  88734. * @param x Define the x component value of the vec2
  88735. * @param y Define the y component value of the vec2
  88736. */
  88737. addFloat2(name: string, x: number, y: number): void;
  88738. /**
  88739. * Adds a vec3 to the uniform buffer.
  88740. * @param name Name of the uniform, as used in the uniform block in the shader.
  88741. * @param x Define the x component value of the vec3
  88742. * @param y Define the y component value of the vec3
  88743. * @param z Define the z component value of the vec3
  88744. */
  88745. addFloat3(name: string, x: number, y: number, z: number): void;
  88746. /**
  88747. * Adds a vec3 to the uniform buffer.
  88748. * @param name Name of the uniform, as used in the uniform block in the shader.
  88749. * @param color Define the vec3 from a Color
  88750. */
  88751. addColor3(name: string, color: Color3): void;
  88752. /**
  88753. * Adds a vec4 to the uniform buffer.
  88754. * @param name Name of the uniform, as used in the uniform block in the shader.
  88755. * @param color Define the rgb components from a Color
  88756. * @param alpha Define the a component of the vec4
  88757. */
  88758. addColor4(name: string, color: Color3, alpha: number): void;
  88759. /**
  88760. * Adds a vec3 to the uniform buffer.
  88761. * @param name Name of the uniform, as used in the uniform block in the shader.
  88762. * @param vector Define the vec3 components from a Vector
  88763. */
  88764. addVector3(name: string, vector: Vector3): void;
  88765. /**
  88766. * Adds a Matrix 3x3 to the uniform buffer.
  88767. * @param name Name of the uniform, as used in the uniform block in the shader.
  88768. */
  88769. addMatrix3x3(name: string): void;
  88770. /**
  88771. * Adds a Matrix 2x2 to the uniform buffer.
  88772. * @param name Name of the uniform, as used in the uniform block in the shader.
  88773. */
  88774. addMatrix2x2(name: string): void;
  88775. /**
  88776. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88777. */
  88778. create(): void;
  88779. /** @hidden */
  88780. _rebuild(): void;
  88781. /**
  88782. * Updates the WebGL Uniform Buffer on the GPU.
  88783. * If the `dynamic` flag is set to true, no cache comparison is done.
  88784. * Otherwise, the buffer will be updated only if the cache differs.
  88785. */
  88786. update(): void;
  88787. /**
  88788. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88789. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88790. * @param data Define the flattened data
  88791. * @param size Define the size of the data.
  88792. */
  88793. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88794. private _valueCache;
  88795. private _cacheMatrix;
  88796. private _updateMatrix3x3ForUniform;
  88797. private _updateMatrix3x3ForEffect;
  88798. private _updateMatrix2x2ForEffect;
  88799. private _updateMatrix2x2ForUniform;
  88800. private _updateFloatForEffect;
  88801. private _updateFloatForUniform;
  88802. private _updateFloat2ForEffect;
  88803. private _updateFloat2ForUniform;
  88804. private _updateFloat3ForEffect;
  88805. private _updateFloat3ForUniform;
  88806. private _updateFloat4ForEffect;
  88807. private _updateFloat4ForUniform;
  88808. private _updateMatrixForEffect;
  88809. private _updateMatrixForUniform;
  88810. private _updateVector3ForEffect;
  88811. private _updateVector3ForUniform;
  88812. private _updateVector4ForEffect;
  88813. private _updateVector4ForUniform;
  88814. private _updateColor3ForEffect;
  88815. private _updateColor3ForUniform;
  88816. private _updateColor4ForEffect;
  88817. private _updateColor4ForUniform;
  88818. /**
  88819. * Sets a sampler uniform on the effect.
  88820. * @param name Define the name of the sampler.
  88821. * @param texture Define the texture to set in the sampler
  88822. */
  88823. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88824. /**
  88825. * Directly updates the value of the uniform in the cache AND on the GPU.
  88826. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88827. * @param data Define the flattened data
  88828. */
  88829. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88830. /**
  88831. * Binds this uniform buffer to an effect.
  88832. * @param effect Define the effect to bind the buffer to
  88833. * @param name Name of the uniform block in the shader.
  88834. */
  88835. bindToEffect(effect: Effect, name: string): void;
  88836. /**
  88837. * Disposes the uniform buffer.
  88838. */
  88839. dispose(): void;
  88840. }
  88841. }
  88842. declare module BABYLON {
  88843. /**
  88844. * Enum that determines the text-wrapping mode to use.
  88845. */
  88846. export enum InspectableType {
  88847. /**
  88848. * Checkbox for booleans
  88849. */
  88850. Checkbox = 0,
  88851. /**
  88852. * Sliders for numbers
  88853. */
  88854. Slider = 1,
  88855. /**
  88856. * Vector3
  88857. */
  88858. Vector3 = 2,
  88859. /**
  88860. * Quaternions
  88861. */
  88862. Quaternion = 3,
  88863. /**
  88864. * Color3
  88865. */
  88866. Color3 = 4,
  88867. /**
  88868. * String
  88869. */
  88870. String = 5
  88871. }
  88872. /**
  88873. * Interface used to define custom inspectable properties.
  88874. * This interface is used by the inspector to display custom property grids
  88875. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88876. */
  88877. export interface IInspectable {
  88878. /**
  88879. * Gets the label to display
  88880. */
  88881. label: string;
  88882. /**
  88883. * Gets the name of the property to edit
  88884. */
  88885. propertyName: string;
  88886. /**
  88887. * Gets the type of the editor to use
  88888. */
  88889. type: InspectableType;
  88890. /**
  88891. * Gets the minimum value of the property when using in "slider" mode
  88892. */
  88893. min?: number;
  88894. /**
  88895. * Gets the maximum value of the property when using in "slider" mode
  88896. */
  88897. max?: number;
  88898. /**
  88899. * Gets the setp to use when using in "slider" mode
  88900. */
  88901. step?: number;
  88902. }
  88903. }
  88904. declare module BABYLON {
  88905. /**
  88906. * Class used to provide helper for timing
  88907. */
  88908. export class TimingTools {
  88909. /**
  88910. * Polyfill for setImmediate
  88911. * @param action defines the action to execute after the current execution block
  88912. */
  88913. static SetImmediate(action: () => void): void;
  88914. }
  88915. }
  88916. declare module BABYLON {
  88917. /**
  88918. * Class used to enable instatition of objects by class name
  88919. */
  88920. export class InstantiationTools {
  88921. /**
  88922. * Use this object to register external classes like custom textures or material
  88923. * to allow the laoders to instantiate them
  88924. */
  88925. static RegisteredExternalClasses: {
  88926. [key: string]: Object;
  88927. };
  88928. /**
  88929. * Tries to instantiate a new object from a given class name
  88930. * @param className defines the class name to instantiate
  88931. * @returns the new object or null if the system was not able to do the instantiation
  88932. */
  88933. static Instantiate(className: string): any;
  88934. }
  88935. }
  88936. declare module BABYLON {
  88937. /**
  88938. * Define options used to create a depth texture
  88939. */
  88940. export class DepthTextureCreationOptions {
  88941. /** Specifies whether or not a stencil should be allocated in the texture */
  88942. generateStencil?: boolean;
  88943. /** Specifies whether or not bilinear filtering is enable on the texture */
  88944. bilinearFiltering?: boolean;
  88945. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88946. comparisonFunction?: number;
  88947. /** Specifies if the created texture is a cube texture */
  88948. isCube?: boolean;
  88949. }
  88950. }
  88951. declare module BABYLON {
  88952. interface ThinEngine {
  88953. /**
  88954. * Creates a depth stencil cube texture.
  88955. * This is only available in WebGL 2.
  88956. * @param size The size of face edge in the cube texture.
  88957. * @param options The options defining the cube texture.
  88958. * @returns The cube texture
  88959. */
  88960. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88961. /**
  88962. * Creates a cube texture
  88963. * @param rootUrl defines the url where the files to load is located
  88964. * @param scene defines the current scene
  88965. * @param files defines the list of files to load (1 per face)
  88966. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88967. * @param onLoad defines an optional callback raised when the texture is loaded
  88968. * @param onError defines an optional callback raised if there is an issue to load the texture
  88969. * @param format defines the format of the data
  88970. * @param forcedExtension defines the extension to use to pick the right loader
  88971. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88972. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88973. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88974. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88975. * @param loaderOptions options to be passed to the loader
  88976. * @returns the cube texture as an InternalTexture
  88977. */
  88978. 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;
  88979. /**
  88980. * Creates a cube texture
  88981. * @param rootUrl defines the url where the files to load is located
  88982. * @param scene defines the current scene
  88983. * @param files defines the list of files to load (1 per face)
  88984. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88985. * @param onLoad defines an optional callback raised when the texture is loaded
  88986. * @param onError defines an optional callback raised if there is an issue to load the texture
  88987. * @param format defines the format of the data
  88988. * @param forcedExtension defines the extension to use to pick the right loader
  88989. * @returns the cube texture as an InternalTexture
  88990. */
  88991. 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;
  88992. /**
  88993. * Creates a cube texture
  88994. * @param rootUrl defines the url where the files to load is located
  88995. * @param scene defines the current scene
  88996. * @param files defines the list of files to load (1 per face)
  88997. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88998. * @param onLoad defines an optional callback raised when the texture is loaded
  88999. * @param onError defines an optional callback raised if there is an issue to load the texture
  89000. * @param format defines the format of the data
  89001. * @param forcedExtension defines the extension to use to pick the right loader
  89002. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  89003. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  89004. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  89005. * @returns the cube texture as an InternalTexture
  89006. */
  89007. 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;
  89008. /** @hidden */
  89009. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  89010. /** @hidden */
  89011. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  89012. /** @hidden */
  89013. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  89014. /** @hidden */
  89015. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  89016. /**
  89017. * @hidden
  89018. */
  89019. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  89020. }
  89021. }
  89022. declare module BABYLON {
  89023. /**
  89024. * Class for creating a cube texture
  89025. */
  89026. export class CubeTexture extends BaseTexture {
  89027. private _delayedOnLoad;
  89028. /**
  89029. * Observable triggered once the texture has been loaded.
  89030. */
  89031. onLoadObservable: Observable<CubeTexture>;
  89032. /**
  89033. * The url of the texture
  89034. */
  89035. url: string;
  89036. /**
  89037. * Gets or sets the center of the bounding box associated with the cube texture.
  89038. * It must define where the camera used to render the texture was set
  89039. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  89040. */
  89041. boundingBoxPosition: Vector3;
  89042. private _boundingBoxSize;
  89043. /**
  89044. * Gets or sets the size of the bounding box associated with the cube texture
  89045. * When defined, the cubemap will switch to local mode
  89046. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  89047. * @example https://www.babylonjs-playground.com/#RNASML
  89048. */
  89049. set boundingBoxSize(value: Vector3);
  89050. /**
  89051. * Returns the bounding box size
  89052. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  89053. */
  89054. get boundingBoxSize(): Vector3;
  89055. protected _rotationY: number;
  89056. /**
  89057. * Sets texture matrix rotation angle around Y axis in radians.
  89058. */
  89059. set rotationY(value: number);
  89060. /**
  89061. * Gets texture matrix rotation angle around Y axis radians.
  89062. */
  89063. get rotationY(): number;
  89064. /**
  89065. * Are mip maps generated for this texture or not.
  89066. */
  89067. get noMipmap(): boolean;
  89068. private _noMipmap;
  89069. private _files;
  89070. protected _forcedExtension: Nullable<string>;
  89071. private _extensions;
  89072. private _textureMatrix;
  89073. private _format;
  89074. private _createPolynomials;
  89075. private _loaderOptions;
  89076. /**
  89077. * Creates a cube texture from an array of image urls
  89078. * @param files defines an array of image urls
  89079. * @param scene defines the hosting scene
  89080. * @param noMipmap specifies if mip maps are not used
  89081. * @returns a cube texture
  89082. */
  89083. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  89084. /**
  89085. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  89086. * @param url defines the url of the prefiltered texture
  89087. * @param scene defines the scene the texture is attached to
  89088. * @param forcedExtension defines the extension of the file if different from the url
  89089. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  89090. * @return the prefiltered texture
  89091. */
  89092. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  89093. /**
  89094. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  89095. * as prefiltered data.
  89096. * @param rootUrl defines the url of the texture or the root name of the six images
  89097. * @param null defines the scene or engine the texture is attached to
  89098. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  89099. * @param noMipmap defines if mipmaps should be created or not
  89100. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  89101. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  89102. * @param onError defines a callback triggered in case of error during load
  89103. * @param format defines the internal format to use for the texture once loaded
  89104. * @param prefiltered defines whether or not the texture is created from prefiltered data
  89105. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  89106. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  89107. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  89108. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  89109. * @param loaderOptions options to be passed to the loader
  89110. * @return the cube texture
  89111. */
  89112. 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);
  89113. /**
  89114. * Get the current class name of the texture useful for serialization or dynamic coding.
  89115. * @returns "CubeTexture"
  89116. */
  89117. getClassName(): string;
  89118. /**
  89119. * Update the url (and optional buffer) of this texture if url was null during construction.
  89120. * @param url the url of the texture
  89121. * @param forcedExtension defines the extension to use
  89122. * @param onLoad callback called when the texture is loaded (defaults to null)
  89123. * @param prefiltered Defines whether the updated texture is prefiltered or not
  89124. */
  89125. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  89126. /**
  89127. * Delays loading of the cube texture
  89128. * @param forcedExtension defines the extension to use
  89129. */
  89130. delayLoad(forcedExtension?: string): void;
  89131. /**
  89132. * Returns the reflection texture matrix
  89133. * @returns the reflection texture matrix
  89134. */
  89135. getReflectionTextureMatrix(): Matrix;
  89136. /**
  89137. * Sets the reflection texture matrix
  89138. * @param value Reflection texture matrix
  89139. */
  89140. setReflectionTextureMatrix(value: Matrix): void;
  89141. /**
  89142. * Parses text to create a cube texture
  89143. * @param parsedTexture define the serialized text to read from
  89144. * @param scene defines the hosting scene
  89145. * @param rootUrl defines the root url of the cube texture
  89146. * @returns a cube texture
  89147. */
  89148. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  89149. /**
  89150. * Makes a clone, or deep copy, of the cube texture
  89151. * @returns a new cube texture
  89152. */
  89153. clone(): CubeTexture;
  89154. }
  89155. }
  89156. declare module BABYLON {
  89157. /**
  89158. * Manages the defines for the Material
  89159. */
  89160. export class MaterialDefines {
  89161. /** @hidden */
  89162. protected _keys: string[];
  89163. private _isDirty;
  89164. /** @hidden */
  89165. _renderId: number;
  89166. /** @hidden */
  89167. _areLightsDirty: boolean;
  89168. /** @hidden */
  89169. _areLightsDisposed: boolean;
  89170. /** @hidden */
  89171. _areAttributesDirty: boolean;
  89172. /** @hidden */
  89173. _areTexturesDirty: boolean;
  89174. /** @hidden */
  89175. _areFresnelDirty: boolean;
  89176. /** @hidden */
  89177. _areMiscDirty: boolean;
  89178. /** @hidden */
  89179. _arePrePassDirty: boolean;
  89180. /** @hidden */
  89181. _areImageProcessingDirty: boolean;
  89182. /** @hidden */
  89183. _normals: boolean;
  89184. /** @hidden */
  89185. _uvs: boolean;
  89186. /** @hidden */
  89187. _needNormals: boolean;
  89188. /** @hidden */
  89189. _needUVs: boolean;
  89190. [id: string]: any;
  89191. /**
  89192. * Specifies if the material needs to be re-calculated
  89193. */
  89194. get isDirty(): boolean;
  89195. /**
  89196. * Marks the material to indicate that it has been re-calculated
  89197. */
  89198. markAsProcessed(): void;
  89199. /**
  89200. * Marks the material to indicate that it needs to be re-calculated
  89201. */
  89202. markAsUnprocessed(): void;
  89203. /**
  89204. * Marks the material to indicate all of its defines need to be re-calculated
  89205. */
  89206. markAllAsDirty(): void;
  89207. /**
  89208. * Marks the material to indicate that image processing needs to be re-calculated
  89209. */
  89210. markAsImageProcessingDirty(): void;
  89211. /**
  89212. * Marks the material to indicate the lights need to be re-calculated
  89213. * @param disposed Defines whether the light is dirty due to dispose or not
  89214. */
  89215. markAsLightDirty(disposed?: boolean): void;
  89216. /**
  89217. * Marks the attribute state as changed
  89218. */
  89219. markAsAttributesDirty(): void;
  89220. /**
  89221. * Marks the texture state as changed
  89222. */
  89223. markAsTexturesDirty(): void;
  89224. /**
  89225. * Marks the fresnel state as changed
  89226. */
  89227. markAsFresnelDirty(): void;
  89228. /**
  89229. * Marks the misc state as changed
  89230. */
  89231. markAsMiscDirty(): void;
  89232. /**
  89233. * Marks the prepass state as changed
  89234. */
  89235. markAsPrePassDirty(): void;
  89236. /**
  89237. * Rebuilds the material defines
  89238. */
  89239. rebuild(): void;
  89240. /**
  89241. * Specifies if two material defines are equal
  89242. * @param other - A material define instance to compare to
  89243. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  89244. */
  89245. isEqual(other: MaterialDefines): boolean;
  89246. /**
  89247. * Clones this instance's defines to another instance
  89248. * @param other - material defines to clone values to
  89249. */
  89250. cloneTo(other: MaterialDefines): void;
  89251. /**
  89252. * Resets the material define values
  89253. */
  89254. reset(): void;
  89255. /**
  89256. * Converts the material define values to a string
  89257. * @returns - String of material define information
  89258. */
  89259. toString(): string;
  89260. }
  89261. }
  89262. declare module BABYLON {
  89263. /**
  89264. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89265. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89266. * 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;
  89267. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89268. */
  89269. export class ColorCurves {
  89270. private _dirty;
  89271. private _tempColor;
  89272. private _globalCurve;
  89273. private _highlightsCurve;
  89274. private _midtonesCurve;
  89275. private _shadowsCurve;
  89276. private _positiveCurve;
  89277. private _negativeCurve;
  89278. private _globalHue;
  89279. private _globalDensity;
  89280. private _globalSaturation;
  89281. private _globalExposure;
  89282. /**
  89283. * Gets the global Hue value.
  89284. * 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).
  89285. */
  89286. get globalHue(): number;
  89287. /**
  89288. * Sets the global Hue value.
  89289. * 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).
  89290. */
  89291. set globalHue(value: number);
  89292. /**
  89293. * Gets the global Density value.
  89294. * 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.
  89295. * Values less than zero provide a filter of opposite hue.
  89296. */
  89297. get globalDensity(): number;
  89298. /**
  89299. * Sets the global Density value.
  89300. * 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.
  89301. * Values less than zero provide a filter of opposite hue.
  89302. */
  89303. set globalDensity(value: number);
  89304. /**
  89305. * Gets the global Saturation value.
  89306. * 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.
  89307. */
  89308. get globalSaturation(): number;
  89309. /**
  89310. * Sets the global Saturation value.
  89311. * 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.
  89312. */
  89313. set globalSaturation(value: number);
  89314. /**
  89315. * Gets the global Exposure value.
  89316. * 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.
  89317. */
  89318. get globalExposure(): number;
  89319. /**
  89320. * Sets the global Exposure value.
  89321. * 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.
  89322. */
  89323. set globalExposure(value: number);
  89324. private _highlightsHue;
  89325. private _highlightsDensity;
  89326. private _highlightsSaturation;
  89327. private _highlightsExposure;
  89328. /**
  89329. * Gets the highlights Hue value.
  89330. * 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).
  89331. */
  89332. get highlightsHue(): number;
  89333. /**
  89334. * Sets the highlights Hue value.
  89335. * 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).
  89336. */
  89337. set highlightsHue(value: number);
  89338. /**
  89339. * Gets the highlights Density value.
  89340. * 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.
  89341. * Values less than zero provide a filter of opposite hue.
  89342. */
  89343. get highlightsDensity(): number;
  89344. /**
  89345. * Sets the highlights Density value.
  89346. * 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.
  89347. * Values less than zero provide a filter of opposite hue.
  89348. */
  89349. set highlightsDensity(value: number);
  89350. /**
  89351. * Gets the highlights Saturation value.
  89352. * 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.
  89353. */
  89354. get highlightsSaturation(): number;
  89355. /**
  89356. * Sets the highlights Saturation value.
  89357. * 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.
  89358. */
  89359. set highlightsSaturation(value: number);
  89360. /**
  89361. * Gets the highlights Exposure value.
  89362. * 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.
  89363. */
  89364. get highlightsExposure(): number;
  89365. /**
  89366. * Sets the highlights Exposure value.
  89367. * 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.
  89368. */
  89369. set highlightsExposure(value: number);
  89370. private _midtonesHue;
  89371. private _midtonesDensity;
  89372. private _midtonesSaturation;
  89373. private _midtonesExposure;
  89374. /**
  89375. * Gets the midtones Hue value.
  89376. * 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).
  89377. */
  89378. get midtonesHue(): number;
  89379. /**
  89380. * Sets the midtones Hue value.
  89381. * 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).
  89382. */
  89383. set midtonesHue(value: number);
  89384. /**
  89385. * Gets the midtones Density value.
  89386. * 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.
  89387. * Values less than zero provide a filter of opposite hue.
  89388. */
  89389. get midtonesDensity(): number;
  89390. /**
  89391. * Sets the midtones Density value.
  89392. * 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.
  89393. * Values less than zero provide a filter of opposite hue.
  89394. */
  89395. set midtonesDensity(value: number);
  89396. /**
  89397. * Gets the midtones Saturation value.
  89398. * 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.
  89399. */
  89400. get midtonesSaturation(): number;
  89401. /**
  89402. * Sets the midtones Saturation value.
  89403. * 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.
  89404. */
  89405. set midtonesSaturation(value: number);
  89406. /**
  89407. * Gets the midtones Exposure value.
  89408. * 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.
  89409. */
  89410. get midtonesExposure(): number;
  89411. /**
  89412. * Sets the midtones Exposure value.
  89413. * 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.
  89414. */
  89415. set midtonesExposure(value: number);
  89416. private _shadowsHue;
  89417. private _shadowsDensity;
  89418. private _shadowsSaturation;
  89419. private _shadowsExposure;
  89420. /**
  89421. * Gets the shadows Hue value.
  89422. * 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).
  89423. */
  89424. get shadowsHue(): number;
  89425. /**
  89426. * Sets the shadows Hue value.
  89427. * 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).
  89428. */
  89429. set shadowsHue(value: number);
  89430. /**
  89431. * Gets the shadows Density value.
  89432. * 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.
  89433. * Values less than zero provide a filter of opposite hue.
  89434. */
  89435. get shadowsDensity(): number;
  89436. /**
  89437. * Sets the shadows Density value.
  89438. * 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.
  89439. * Values less than zero provide a filter of opposite hue.
  89440. */
  89441. set shadowsDensity(value: number);
  89442. /**
  89443. * Gets the shadows Saturation value.
  89444. * 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.
  89445. */
  89446. get shadowsSaturation(): number;
  89447. /**
  89448. * Sets the shadows Saturation value.
  89449. * 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.
  89450. */
  89451. set shadowsSaturation(value: number);
  89452. /**
  89453. * Gets the shadows Exposure value.
  89454. * 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.
  89455. */
  89456. get shadowsExposure(): number;
  89457. /**
  89458. * Sets the shadows Exposure value.
  89459. * 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.
  89460. */
  89461. set shadowsExposure(value: number);
  89462. /**
  89463. * Returns the class name
  89464. * @returns The class name
  89465. */
  89466. getClassName(): string;
  89467. /**
  89468. * Binds the color curves to the shader.
  89469. * @param colorCurves The color curve to bind
  89470. * @param effect The effect to bind to
  89471. * @param positiveUniform The positive uniform shader parameter
  89472. * @param neutralUniform The neutral uniform shader parameter
  89473. * @param negativeUniform The negative uniform shader parameter
  89474. */
  89475. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89476. /**
  89477. * Prepare the list of uniforms associated with the ColorCurves effects.
  89478. * @param uniformsList The list of uniforms used in the effect
  89479. */
  89480. static PrepareUniforms(uniformsList: string[]): void;
  89481. /**
  89482. * Returns color grading data based on a hue, density, saturation and exposure value.
  89483. * @param filterHue The hue of the color filter.
  89484. * @param filterDensity The density of the color filter.
  89485. * @param saturation The saturation.
  89486. * @param exposure The exposure.
  89487. * @param result The result data container.
  89488. */
  89489. private getColorGradingDataToRef;
  89490. /**
  89491. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89492. * @param value The input slider value in range [-100,100].
  89493. * @returns Adjusted value.
  89494. */
  89495. private static applyColorGradingSliderNonlinear;
  89496. /**
  89497. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89498. * @param hue The hue (H) input.
  89499. * @param saturation The saturation (S) input.
  89500. * @param brightness The brightness (B) input.
  89501. * @result An RGBA color represented as Vector4.
  89502. */
  89503. private static fromHSBToRef;
  89504. /**
  89505. * Returns a value clamped between min and max
  89506. * @param value The value to clamp
  89507. * @param min The minimum of value
  89508. * @param max The maximum of value
  89509. * @returns The clamped value.
  89510. */
  89511. private static clamp;
  89512. /**
  89513. * Clones the current color curve instance.
  89514. * @return The cloned curves
  89515. */
  89516. clone(): ColorCurves;
  89517. /**
  89518. * Serializes the current color curve instance to a json representation.
  89519. * @return a JSON representation
  89520. */
  89521. serialize(): any;
  89522. /**
  89523. * Parses the color curve from a json representation.
  89524. * @param source the JSON source to parse
  89525. * @return The parsed curves
  89526. */
  89527. static Parse(source: any): ColorCurves;
  89528. }
  89529. }
  89530. declare module BABYLON {
  89531. /**
  89532. * Interface to follow in your material defines to integrate easily the
  89533. * Image proccessing functions.
  89534. * @hidden
  89535. */
  89536. export interface IImageProcessingConfigurationDefines {
  89537. IMAGEPROCESSING: boolean;
  89538. VIGNETTE: boolean;
  89539. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89540. VIGNETTEBLENDMODEOPAQUE: boolean;
  89541. TONEMAPPING: boolean;
  89542. TONEMAPPING_ACES: boolean;
  89543. CONTRAST: boolean;
  89544. EXPOSURE: boolean;
  89545. COLORCURVES: boolean;
  89546. COLORGRADING: boolean;
  89547. COLORGRADING3D: boolean;
  89548. SAMPLER3DGREENDEPTH: boolean;
  89549. SAMPLER3DBGRMAP: boolean;
  89550. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89551. }
  89552. /**
  89553. * @hidden
  89554. */
  89555. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89556. IMAGEPROCESSING: boolean;
  89557. VIGNETTE: boolean;
  89558. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89559. VIGNETTEBLENDMODEOPAQUE: boolean;
  89560. TONEMAPPING: boolean;
  89561. TONEMAPPING_ACES: boolean;
  89562. CONTRAST: boolean;
  89563. COLORCURVES: boolean;
  89564. COLORGRADING: boolean;
  89565. COLORGRADING3D: boolean;
  89566. SAMPLER3DGREENDEPTH: boolean;
  89567. SAMPLER3DBGRMAP: boolean;
  89568. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89569. EXPOSURE: boolean;
  89570. constructor();
  89571. }
  89572. /**
  89573. * This groups together the common properties used for image processing either in direct forward pass
  89574. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89575. * or not.
  89576. */
  89577. export class ImageProcessingConfiguration {
  89578. /**
  89579. * Default tone mapping applied in BabylonJS.
  89580. */
  89581. static readonly TONEMAPPING_STANDARD: number;
  89582. /**
  89583. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89584. * to other engines rendering to increase portability.
  89585. */
  89586. static readonly TONEMAPPING_ACES: number;
  89587. /**
  89588. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89589. */
  89590. colorCurves: Nullable<ColorCurves>;
  89591. private _colorCurvesEnabled;
  89592. /**
  89593. * Gets wether the color curves effect is enabled.
  89594. */
  89595. get colorCurvesEnabled(): boolean;
  89596. /**
  89597. * Sets wether the color curves effect is enabled.
  89598. */
  89599. set colorCurvesEnabled(value: boolean);
  89600. private _colorGradingTexture;
  89601. /**
  89602. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89603. */
  89604. get colorGradingTexture(): Nullable<BaseTexture>;
  89605. /**
  89606. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89607. */
  89608. set colorGradingTexture(value: Nullable<BaseTexture>);
  89609. private _colorGradingEnabled;
  89610. /**
  89611. * Gets wether the color grading effect is enabled.
  89612. */
  89613. get colorGradingEnabled(): boolean;
  89614. /**
  89615. * Sets wether the color grading effect is enabled.
  89616. */
  89617. set colorGradingEnabled(value: boolean);
  89618. private _colorGradingWithGreenDepth;
  89619. /**
  89620. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89621. */
  89622. get colorGradingWithGreenDepth(): boolean;
  89623. /**
  89624. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89625. */
  89626. set colorGradingWithGreenDepth(value: boolean);
  89627. private _colorGradingBGR;
  89628. /**
  89629. * Gets wether the color grading texture contains BGR values.
  89630. */
  89631. get colorGradingBGR(): boolean;
  89632. /**
  89633. * Sets wether the color grading texture contains BGR values.
  89634. */
  89635. set colorGradingBGR(value: boolean);
  89636. /** @hidden */
  89637. _exposure: number;
  89638. /**
  89639. * Gets the Exposure used in the effect.
  89640. */
  89641. get exposure(): number;
  89642. /**
  89643. * Sets the Exposure used in the effect.
  89644. */
  89645. set exposure(value: number);
  89646. private _toneMappingEnabled;
  89647. /**
  89648. * Gets wether the tone mapping effect is enabled.
  89649. */
  89650. get toneMappingEnabled(): boolean;
  89651. /**
  89652. * Sets wether the tone mapping effect is enabled.
  89653. */
  89654. set toneMappingEnabled(value: boolean);
  89655. private _toneMappingType;
  89656. /**
  89657. * Gets the type of tone mapping effect.
  89658. */
  89659. get toneMappingType(): number;
  89660. /**
  89661. * Sets the type of tone mapping effect used in BabylonJS.
  89662. */
  89663. set toneMappingType(value: number);
  89664. protected _contrast: number;
  89665. /**
  89666. * Gets the contrast used in the effect.
  89667. */
  89668. get contrast(): number;
  89669. /**
  89670. * Sets the contrast used in the effect.
  89671. */
  89672. set contrast(value: number);
  89673. /**
  89674. * Vignette stretch size.
  89675. */
  89676. vignetteStretch: number;
  89677. /**
  89678. * Vignette centre X Offset.
  89679. */
  89680. vignetteCentreX: number;
  89681. /**
  89682. * Vignette centre Y Offset.
  89683. */
  89684. vignetteCentreY: number;
  89685. /**
  89686. * Vignette weight or intensity of the vignette effect.
  89687. */
  89688. vignetteWeight: number;
  89689. /**
  89690. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89691. * if vignetteEnabled is set to true.
  89692. */
  89693. vignetteColor: Color4;
  89694. /**
  89695. * Camera field of view used by the Vignette effect.
  89696. */
  89697. vignetteCameraFov: number;
  89698. private _vignetteBlendMode;
  89699. /**
  89700. * Gets the vignette blend mode allowing different kind of effect.
  89701. */
  89702. get vignetteBlendMode(): number;
  89703. /**
  89704. * Sets the vignette blend mode allowing different kind of effect.
  89705. */
  89706. set vignetteBlendMode(value: number);
  89707. private _vignetteEnabled;
  89708. /**
  89709. * Gets wether the vignette effect is enabled.
  89710. */
  89711. get vignetteEnabled(): boolean;
  89712. /**
  89713. * Sets wether the vignette effect is enabled.
  89714. */
  89715. set vignetteEnabled(value: boolean);
  89716. private _applyByPostProcess;
  89717. /**
  89718. * Gets wether the image processing is applied through a post process or not.
  89719. */
  89720. get applyByPostProcess(): boolean;
  89721. /**
  89722. * Sets wether the image processing is applied through a post process or not.
  89723. */
  89724. set applyByPostProcess(value: boolean);
  89725. private _isEnabled;
  89726. /**
  89727. * Gets wether the image processing is enabled or not.
  89728. */
  89729. get isEnabled(): boolean;
  89730. /**
  89731. * Sets wether the image processing is enabled or not.
  89732. */
  89733. set isEnabled(value: boolean);
  89734. /**
  89735. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89736. */
  89737. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89738. /**
  89739. * Method called each time the image processing information changes requires to recompile the effect.
  89740. */
  89741. protected _updateParameters(): void;
  89742. /**
  89743. * Gets the current class name.
  89744. * @return "ImageProcessingConfiguration"
  89745. */
  89746. getClassName(): string;
  89747. /**
  89748. * Prepare the list of uniforms associated with the Image Processing effects.
  89749. * @param uniforms The list of uniforms used in the effect
  89750. * @param defines the list of defines currently in use
  89751. */
  89752. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89753. /**
  89754. * Prepare the list of samplers associated with the Image Processing effects.
  89755. * @param samplersList The list of uniforms used in the effect
  89756. * @param defines the list of defines currently in use
  89757. */
  89758. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89759. /**
  89760. * Prepare the list of defines associated to the shader.
  89761. * @param defines the list of defines to complete
  89762. * @param forPostProcess Define if we are currently in post process mode or not
  89763. */
  89764. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89765. /**
  89766. * Returns true if all the image processing information are ready.
  89767. * @returns True if ready, otherwise, false
  89768. */
  89769. isReady(): boolean;
  89770. /**
  89771. * Binds the image processing to the shader.
  89772. * @param effect The effect to bind to
  89773. * @param overrideAspectRatio Override the aspect ratio of the effect
  89774. */
  89775. bind(effect: Effect, overrideAspectRatio?: number): void;
  89776. /**
  89777. * Clones the current image processing instance.
  89778. * @return The cloned image processing
  89779. */
  89780. clone(): ImageProcessingConfiguration;
  89781. /**
  89782. * Serializes the current image processing instance to a json representation.
  89783. * @return a JSON representation
  89784. */
  89785. serialize(): any;
  89786. /**
  89787. * Parses the image processing from a json representation.
  89788. * @param source the JSON source to parse
  89789. * @return The parsed image processing
  89790. */
  89791. static Parse(source: any): ImageProcessingConfiguration;
  89792. private static _VIGNETTEMODE_MULTIPLY;
  89793. private static _VIGNETTEMODE_OPAQUE;
  89794. /**
  89795. * Used to apply the vignette as a mix with the pixel color.
  89796. */
  89797. static get VIGNETTEMODE_MULTIPLY(): number;
  89798. /**
  89799. * Used to apply the vignette as a replacement of the pixel color.
  89800. */
  89801. static get VIGNETTEMODE_OPAQUE(): number;
  89802. }
  89803. }
  89804. declare module BABYLON {
  89805. /** @hidden */
  89806. export var postprocessVertexShader: {
  89807. name: string;
  89808. shader: string;
  89809. };
  89810. }
  89811. declare module BABYLON {
  89812. /**
  89813. * Type used to define a render target texture size (either with a number or with a rect width and height)
  89814. */
  89815. export type RenderTargetTextureSize = number | {
  89816. width: number;
  89817. height: number;
  89818. layers?: number;
  89819. };
  89820. interface ThinEngine {
  89821. /**
  89822. * Creates a new render target texture
  89823. * @param size defines the size of the texture
  89824. * @param options defines the options used to create the texture
  89825. * @returns a new render target texture stored in an InternalTexture
  89826. */
  89827. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  89828. /**
  89829. * Creates a depth stencil texture.
  89830. * This is only available in WebGL 2 or with the depth texture extension available.
  89831. * @param size The size of face edge in the texture.
  89832. * @param options The options defining the texture.
  89833. * @returns The texture
  89834. */
  89835. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89836. /** @hidden */
  89837. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89838. }
  89839. }
  89840. declare module BABYLON {
  89841. /**
  89842. * Defines the kind of connection point for node based material
  89843. */
  89844. export enum NodeMaterialBlockConnectionPointTypes {
  89845. /** Float */
  89846. Float = 1,
  89847. /** Int */
  89848. Int = 2,
  89849. /** Vector2 */
  89850. Vector2 = 4,
  89851. /** Vector3 */
  89852. Vector3 = 8,
  89853. /** Vector4 */
  89854. Vector4 = 16,
  89855. /** Color3 */
  89856. Color3 = 32,
  89857. /** Color4 */
  89858. Color4 = 64,
  89859. /** Matrix */
  89860. Matrix = 128,
  89861. /** Custom object */
  89862. Object = 256,
  89863. /** Detect type based on connection */
  89864. AutoDetect = 1024,
  89865. /** Output type that will be defined by input type */
  89866. BasedOnInput = 2048
  89867. }
  89868. }
  89869. declare module BABYLON {
  89870. /**
  89871. * Enum used to define the target of a block
  89872. */
  89873. export enum NodeMaterialBlockTargets {
  89874. /** Vertex shader */
  89875. Vertex = 1,
  89876. /** Fragment shader */
  89877. Fragment = 2,
  89878. /** Neutral */
  89879. Neutral = 4,
  89880. /** Vertex and Fragment */
  89881. VertexAndFragment = 3
  89882. }
  89883. }
  89884. declare module BABYLON {
  89885. /**
  89886. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89887. */
  89888. export enum NodeMaterialBlockConnectionPointMode {
  89889. /** Value is an uniform */
  89890. Uniform = 0,
  89891. /** Value is a mesh attribute */
  89892. Attribute = 1,
  89893. /** Value is a varying between vertex and fragment shaders */
  89894. Varying = 2,
  89895. /** Mode is undefined */
  89896. Undefined = 3
  89897. }
  89898. }
  89899. declare module BABYLON {
  89900. /**
  89901. * Enum used to define system values e.g. values automatically provided by the system
  89902. */
  89903. export enum NodeMaterialSystemValues {
  89904. /** World */
  89905. World = 1,
  89906. /** View */
  89907. View = 2,
  89908. /** Projection */
  89909. Projection = 3,
  89910. /** ViewProjection */
  89911. ViewProjection = 4,
  89912. /** WorldView */
  89913. WorldView = 5,
  89914. /** WorldViewProjection */
  89915. WorldViewProjection = 6,
  89916. /** CameraPosition */
  89917. CameraPosition = 7,
  89918. /** Fog Color */
  89919. FogColor = 8,
  89920. /** Delta time */
  89921. DeltaTime = 9
  89922. }
  89923. }
  89924. declare module BABYLON {
  89925. /** Defines supported spaces */
  89926. export enum Space {
  89927. /** Local (object) space */
  89928. LOCAL = 0,
  89929. /** World space */
  89930. WORLD = 1,
  89931. /** Bone space */
  89932. BONE = 2
  89933. }
  89934. /** Defines the 3 main axes */
  89935. export class Axis {
  89936. /** X axis */
  89937. static X: Vector3;
  89938. /** Y axis */
  89939. static Y: Vector3;
  89940. /** Z axis */
  89941. static Z: Vector3;
  89942. }
  89943. /**
  89944. * Defines cartesian components.
  89945. */
  89946. export enum Coordinate {
  89947. /** X axis */
  89948. X = 0,
  89949. /** Y axis */
  89950. Y = 1,
  89951. /** Z axis */
  89952. Z = 2
  89953. }
  89954. }
  89955. declare module BABYLON {
  89956. /**
  89957. * Represents a camera frustum
  89958. */
  89959. export class Frustum {
  89960. /**
  89961. * Gets the planes representing the frustum
  89962. * @param transform matrix to be applied to the returned planes
  89963. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89964. */
  89965. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89966. /**
  89967. * Gets the near frustum plane transformed by the transform matrix
  89968. * @param transform transformation matrix to be applied to the resulting frustum plane
  89969. * @param frustumPlane the resuling frustum plane
  89970. */
  89971. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89972. /**
  89973. * Gets the far frustum plane transformed by the transform matrix
  89974. * @param transform transformation matrix to be applied to the resulting frustum plane
  89975. * @param frustumPlane the resuling frustum plane
  89976. */
  89977. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89978. /**
  89979. * Gets the left frustum plane transformed by the transform matrix
  89980. * @param transform transformation matrix to be applied to the resulting frustum plane
  89981. * @param frustumPlane the resuling frustum plane
  89982. */
  89983. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89984. /**
  89985. * Gets the right frustum plane transformed by the transform matrix
  89986. * @param transform transformation matrix to be applied to the resulting frustum plane
  89987. * @param frustumPlane the resuling frustum plane
  89988. */
  89989. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89990. /**
  89991. * Gets the top frustum plane transformed by the transform matrix
  89992. * @param transform transformation matrix to be applied to the resulting frustum plane
  89993. * @param frustumPlane the resuling frustum plane
  89994. */
  89995. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89996. /**
  89997. * Gets the bottom frustum plane transformed by the transform matrix
  89998. * @param transform transformation matrix to be applied to the resulting frustum plane
  89999. * @param frustumPlane the resuling frustum plane
  90000. */
  90001. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  90002. /**
  90003. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  90004. * @param transform transformation matrix to be applied to the resulting frustum planes
  90005. * @param frustumPlanes the resuling frustum planes
  90006. */
  90007. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  90008. }
  90009. }
  90010. declare module BABYLON {
  90011. /**
  90012. * Interface for the size containing width and height
  90013. */
  90014. export interface ISize {
  90015. /**
  90016. * Width
  90017. */
  90018. width: number;
  90019. /**
  90020. * Heighht
  90021. */
  90022. height: number;
  90023. }
  90024. /**
  90025. * Size containing widht and height
  90026. */
  90027. export class Size implements ISize {
  90028. /**
  90029. * Width
  90030. */
  90031. width: number;
  90032. /**
  90033. * Height
  90034. */
  90035. height: number;
  90036. /**
  90037. * Creates a Size object from the given width and height (floats).
  90038. * @param width width of the new size
  90039. * @param height height of the new size
  90040. */
  90041. constructor(width: number, height: number);
  90042. /**
  90043. * Returns a string with the Size width and height
  90044. * @returns a string with the Size width and height
  90045. */
  90046. toString(): string;
  90047. /**
  90048. * "Size"
  90049. * @returns the string "Size"
  90050. */
  90051. getClassName(): string;
  90052. /**
  90053. * Returns the Size hash code.
  90054. * @returns a hash code for a unique width and height
  90055. */
  90056. getHashCode(): number;
  90057. /**
  90058. * Updates the current size from the given one.
  90059. * @param src the given size
  90060. */
  90061. copyFrom(src: Size): void;
  90062. /**
  90063. * Updates in place the current Size from the given floats.
  90064. * @param width width of the new size
  90065. * @param height height of the new size
  90066. * @returns the updated Size.
  90067. */
  90068. copyFromFloats(width: number, height: number): Size;
  90069. /**
  90070. * Updates in place the current Size from the given floats.
  90071. * @param width width to set
  90072. * @param height height to set
  90073. * @returns the updated Size.
  90074. */
  90075. set(width: number, height: number): Size;
  90076. /**
  90077. * Multiplies the width and height by numbers
  90078. * @param w factor to multiple the width by
  90079. * @param h factor to multiple the height by
  90080. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  90081. */
  90082. multiplyByFloats(w: number, h: number): Size;
  90083. /**
  90084. * Clones the size
  90085. * @returns a new Size copied from the given one.
  90086. */
  90087. clone(): Size;
  90088. /**
  90089. * True if the current Size and the given one width and height are strictly equal.
  90090. * @param other the other size to compare against
  90091. * @returns True if the current Size and the given one width and height are strictly equal.
  90092. */
  90093. equals(other: Size): boolean;
  90094. /**
  90095. * The surface of the Size : width * height (float).
  90096. */
  90097. get surface(): number;
  90098. /**
  90099. * Create a new size of zero
  90100. * @returns a new Size set to (0.0, 0.0)
  90101. */
  90102. static Zero(): Size;
  90103. /**
  90104. * Sums the width and height of two sizes
  90105. * @param otherSize size to add to this size
  90106. * @returns a new Size set as the addition result of the current Size and the given one.
  90107. */
  90108. add(otherSize: Size): Size;
  90109. /**
  90110. * Subtracts the width and height of two
  90111. * @param otherSize size to subtract to this size
  90112. * @returns a new Size set as the subtraction result of the given one from the current Size.
  90113. */
  90114. subtract(otherSize: Size): Size;
  90115. /**
  90116. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  90117. * @param start starting size to lerp between
  90118. * @param end end size to lerp between
  90119. * @param amount amount to lerp between the start and end values
  90120. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  90121. */
  90122. static Lerp(start: Size, end: Size, amount: number): Size;
  90123. }
  90124. }
  90125. declare module BABYLON {
  90126. /**
  90127. * Contains position and normal vectors for a vertex
  90128. */
  90129. export class PositionNormalVertex {
  90130. /** the position of the vertex (defaut: 0,0,0) */
  90131. position: Vector3;
  90132. /** the normal of the vertex (defaut: 0,1,0) */
  90133. normal: Vector3;
  90134. /**
  90135. * Creates a PositionNormalVertex
  90136. * @param position the position of the vertex (defaut: 0,0,0)
  90137. * @param normal the normal of the vertex (defaut: 0,1,0)
  90138. */
  90139. constructor(
  90140. /** the position of the vertex (defaut: 0,0,0) */
  90141. position?: Vector3,
  90142. /** the normal of the vertex (defaut: 0,1,0) */
  90143. normal?: Vector3);
  90144. /**
  90145. * Clones the PositionNormalVertex
  90146. * @returns the cloned PositionNormalVertex
  90147. */
  90148. clone(): PositionNormalVertex;
  90149. }
  90150. /**
  90151. * Contains position, normal and uv vectors for a vertex
  90152. */
  90153. export class PositionNormalTextureVertex {
  90154. /** the position of the vertex (defaut: 0,0,0) */
  90155. position: Vector3;
  90156. /** the normal of the vertex (defaut: 0,1,0) */
  90157. normal: Vector3;
  90158. /** the uv of the vertex (default: 0,0) */
  90159. uv: Vector2;
  90160. /**
  90161. * Creates a PositionNormalTextureVertex
  90162. * @param position the position of the vertex (defaut: 0,0,0)
  90163. * @param normal the normal of the vertex (defaut: 0,1,0)
  90164. * @param uv the uv of the vertex (default: 0,0)
  90165. */
  90166. constructor(
  90167. /** the position of the vertex (defaut: 0,0,0) */
  90168. position?: Vector3,
  90169. /** the normal of the vertex (defaut: 0,1,0) */
  90170. normal?: Vector3,
  90171. /** the uv of the vertex (default: 0,0) */
  90172. uv?: Vector2);
  90173. /**
  90174. * Clones the PositionNormalTextureVertex
  90175. * @returns the cloned PositionNormalTextureVertex
  90176. */
  90177. clone(): PositionNormalTextureVertex;
  90178. }
  90179. }
  90180. declare module BABYLON {
  90181. /**
  90182. * Enum defining the type of animations supported by InputBlock
  90183. */
  90184. export enum AnimatedInputBlockTypes {
  90185. /** No animation */
  90186. None = 0,
  90187. /** Time based animation. Will only work for floats */
  90188. Time = 1
  90189. }
  90190. }
  90191. declare module BABYLON {
  90192. /**
  90193. * Interface describing all the common properties and methods a shadow light needs to implement.
  90194. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  90195. * as well as binding the different shadow properties to the effects.
  90196. */
  90197. export interface IShadowLight extends Light {
  90198. /**
  90199. * The light id in the scene (used in scene.findLighById for instance)
  90200. */
  90201. id: string;
  90202. /**
  90203. * The position the shdow will be casted from.
  90204. */
  90205. position: Vector3;
  90206. /**
  90207. * In 2d mode (needCube being false), the direction used to cast the shadow.
  90208. */
  90209. direction: Vector3;
  90210. /**
  90211. * The transformed position. Position of the light in world space taking parenting in account.
  90212. */
  90213. transformedPosition: Vector3;
  90214. /**
  90215. * The transformed direction. Direction of the light in world space taking parenting in account.
  90216. */
  90217. transformedDirection: Vector3;
  90218. /**
  90219. * The friendly name of the light in the scene.
  90220. */
  90221. name: string;
  90222. /**
  90223. * Defines the shadow projection clipping minimum z value.
  90224. */
  90225. shadowMinZ: number;
  90226. /**
  90227. * Defines the shadow projection clipping maximum z value.
  90228. */
  90229. shadowMaxZ: number;
  90230. /**
  90231. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90232. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90233. */
  90234. computeTransformedInformation(): boolean;
  90235. /**
  90236. * Gets the scene the light belongs to.
  90237. * @returns The scene
  90238. */
  90239. getScene(): Scene;
  90240. /**
  90241. * Callback defining a custom Projection Matrix Builder.
  90242. * This can be used to override the default projection matrix computation.
  90243. */
  90244. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90245. /**
  90246. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90247. * @param matrix The materix to updated with the projection information
  90248. * @param viewMatrix The transform matrix of the light
  90249. * @param renderList The list of mesh to render in the map
  90250. * @returns The current light
  90251. */
  90252. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90253. /**
  90254. * Gets the current depth scale used in ESM.
  90255. * @returns The scale
  90256. */
  90257. getDepthScale(): number;
  90258. /**
  90259. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90260. * @returns true if a cube texture needs to be use
  90261. */
  90262. needCube(): boolean;
  90263. /**
  90264. * Detects if the projection matrix requires to be recomputed this frame.
  90265. * @returns true if it requires to be recomputed otherwise, false.
  90266. */
  90267. needProjectionMatrixCompute(): boolean;
  90268. /**
  90269. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90270. */
  90271. forceProjectionMatrixCompute(): void;
  90272. /**
  90273. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90274. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90275. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90276. */
  90277. getShadowDirection(faceIndex?: number): Vector3;
  90278. /**
  90279. * Gets the minZ used for shadow according to both the scene and the light.
  90280. * @param activeCamera The camera we are returning the min for
  90281. * @returns the depth min z
  90282. */
  90283. getDepthMinZ(activeCamera: Camera): number;
  90284. /**
  90285. * Gets the maxZ used for shadow according to both the scene and the light.
  90286. * @param activeCamera The camera we are returning the max for
  90287. * @returns the depth max z
  90288. */
  90289. getDepthMaxZ(activeCamera: Camera): number;
  90290. }
  90291. /**
  90292. * Base implementation IShadowLight
  90293. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  90294. */
  90295. export abstract class ShadowLight extends Light implements IShadowLight {
  90296. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  90297. protected _position: Vector3;
  90298. protected _setPosition(value: Vector3): void;
  90299. /**
  90300. * Sets the position the shadow will be casted from. Also use as the light position for both
  90301. * point and spot lights.
  90302. */
  90303. get position(): Vector3;
  90304. /**
  90305. * Sets the position the shadow will be casted from. Also use as the light position for both
  90306. * point and spot lights.
  90307. */
  90308. set position(value: Vector3);
  90309. protected _direction: Vector3;
  90310. protected _setDirection(value: Vector3): void;
  90311. /**
  90312. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  90313. * Also use as the light direction on spot and directional lights.
  90314. */
  90315. get direction(): Vector3;
  90316. /**
  90317. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  90318. * Also use as the light direction on spot and directional lights.
  90319. */
  90320. set direction(value: Vector3);
  90321. protected _shadowMinZ: number;
  90322. /**
  90323. * Gets the shadow projection clipping minimum z value.
  90324. */
  90325. get shadowMinZ(): number;
  90326. /**
  90327. * Sets the shadow projection clipping minimum z value.
  90328. */
  90329. set shadowMinZ(value: number);
  90330. protected _shadowMaxZ: number;
  90331. /**
  90332. * Sets the shadow projection clipping maximum z value.
  90333. */
  90334. get shadowMaxZ(): number;
  90335. /**
  90336. * Gets the shadow projection clipping maximum z value.
  90337. */
  90338. set shadowMaxZ(value: number);
  90339. /**
  90340. * Callback defining a custom Projection Matrix Builder.
  90341. * This can be used to override the default projection matrix computation.
  90342. */
  90343. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90344. /**
  90345. * The transformed position. Position of the light in world space taking parenting in account.
  90346. */
  90347. transformedPosition: Vector3;
  90348. /**
  90349. * The transformed direction. Direction of the light in world space taking parenting in account.
  90350. */
  90351. transformedDirection: Vector3;
  90352. private _needProjectionMatrixCompute;
  90353. /**
  90354. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90355. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90356. */
  90357. computeTransformedInformation(): boolean;
  90358. /**
  90359. * Return the depth scale used for the shadow map.
  90360. * @returns the depth scale.
  90361. */
  90362. getDepthScale(): number;
  90363. /**
  90364. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90365. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90366. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90367. */
  90368. getShadowDirection(faceIndex?: number): Vector3;
  90369. /**
  90370. * Returns the ShadowLight absolute position in the World.
  90371. * @returns the position vector in world space
  90372. */
  90373. getAbsolutePosition(): Vector3;
  90374. /**
  90375. * Sets the ShadowLight direction toward the passed target.
  90376. * @param target The point to target in local space
  90377. * @returns the updated ShadowLight direction
  90378. */
  90379. setDirectionToTarget(target: Vector3): Vector3;
  90380. /**
  90381. * Returns the light rotation in euler definition.
  90382. * @returns the x y z rotation in local space.
  90383. */
  90384. getRotation(): Vector3;
  90385. /**
  90386. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90387. * @returns true if a cube texture needs to be use
  90388. */
  90389. needCube(): boolean;
  90390. /**
  90391. * Detects if the projection matrix requires to be recomputed this frame.
  90392. * @returns true if it requires to be recomputed otherwise, false.
  90393. */
  90394. needProjectionMatrixCompute(): boolean;
  90395. /**
  90396. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90397. */
  90398. forceProjectionMatrixCompute(): void;
  90399. /** @hidden */
  90400. _initCache(): void;
  90401. /** @hidden */
  90402. _isSynchronized(): boolean;
  90403. /**
  90404. * Computes the world matrix of the node
  90405. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90406. * @returns the world matrix
  90407. */
  90408. computeWorldMatrix(force?: boolean): Matrix;
  90409. /**
  90410. * Gets the minZ used for shadow according to both the scene and the light.
  90411. * @param activeCamera The camera we are returning the min for
  90412. * @returns the depth min z
  90413. */
  90414. getDepthMinZ(activeCamera: Camera): number;
  90415. /**
  90416. * Gets the maxZ used for shadow according to both the scene and the light.
  90417. * @param activeCamera The camera we are returning the max for
  90418. * @returns the depth max z
  90419. */
  90420. getDepthMaxZ(activeCamera: Camera): number;
  90421. /**
  90422. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90423. * @param matrix The materix to updated with the projection information
  90424. * @param viewMatrix The transform matrix of the light
  90425. * @param renderList The list of mesh to render in the map
  90426. * @returns The current light
  90427. */
  90428. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90429. }
  90430. }
  90431. declare module BABYLON {
  90432. /** @hidden */
  90433. export var packingFunctions: {
  90434. name: string;
  90435. shader: string;
  90436. };
  90437. }
  90438. declare module BABYLON {
  90439. /** @hidden */
  90440. export var bayerDitherFunctions: {
  90441. name: string;
  90442. shader: string;
  90443. };
  90444. }
  90445. declare module BABYLON {
  90446. /** @hidden */
  90447. export var shadowMapFragmentDeclaration: {
  90448. name: string;
  90449. shader: string;
  90450. };
  90451. }
  90452. declare module BABYLON {
  90453. /** @hidden */
  90454. export var clipPlaneFragmentDeclaration: {
  90455. name: string;
  90456. shader: string;
  90457. };
  90458. }
  90459. declare module BABYLON {
  90460. /** @hidden */
  90461. export var clipPlaneFragment: {
  90462. name: string;
  90463. shader: string;
  90464. };
  90465. }
  90466. declare module BABYLON {
  90467. /** @hidden */
  90468. export var shadowMapFragment: {
  90469. name: string;
  90470. shader: string;
  90471. };
  90472. }
  90473. declare module BABYLON {
  90474. /** @hidden */
  90475. export var shadowMapPixelShader: {
  90476. name: string;
  90477. shader: string;
  90478. };
  90479. }
  90480. declare module BABYLON {
  90481. /** @hidden */
  90482. export var bonesDeclaration: {
  90483. name: string;
  90484. shader: string;
  90485. };
  90486. }
  90487. declare module BABYLON {
  90488. /** @hidden */
  90489. export var morphTargetsVertexGlobalDeclaration: {
  90490. name: string;
  90491. shader: string;
  90492. };
  90493. }
  90494. declare module BABYLON {
  90495. /** @hidden */
  90496. export var morphTargetsVertexDeclaration: {
  90497. name: string;
  90498. shader: string;
  90499. };
  90500. }
  90501. declare module BABYLON {
  90502. /** @hidden */
  90503. export var instancesDeclaration: {
  90504. name: string;
  90505. shader: string;
  90506. };
  90507. }
  90508. declare module BABYLON {
  90509. /** @hidden */
  90510. export var helperFunctions: {
  90511. name: string;
  90512. shader: string;
  90513. };
  90514. }
  90515. declare module BABYLON {
  90516. /** @hidden */
  90517. export var shadowMapVertexDeclaration: {
  90518. name: string;
  90519. shader: string;
  90520. };
  90521. }
  90522. declare module BABYLON {
  90523. /** @hidden */
  90524. export var clipPlaneVertexDeclaration: {
  90525. name: string;
  90526. shader: string;
  90527. };
  90528. }
  90529. declare module BABYLON {
  90530. /** @hidden */
  90531. export var morphTargetsVertex: {
  90532. name: string;
  90533. shader: string;
  90534. };
  90535. }
  90536. declare module BABYLON {
  90537. /** @hidden */
  90538. export var instancesVertex: {
  90539. name: string;
  90540. shader: string;
  90541. };
  90542. }
  90543. declare module BABYLON {
  90544. /** @hidden */
  90545. export var bonesVertex: {
  90546. name: string;
  90547. shader: string;
  90548. };
  90549. }
  90550. declare module BABYLON {
  90551. /** @hidden */
  90552. export var shadowMapVertexNormalBias: {
  90553. name: string;
  90554. shader: string;
  90555. };
  90556. }
  90557. declare module BABYLON {
  90558. /** @hidden */
  90559. export var shadowMapVertexMetric: {
  90560. name: string;
  90561. shader: string;
  90562. };
  90563. }
  90564. declare module BABYLON {
  90565. /** @hidden */
  90566. export var clipPlaneVertex: {
  90567. name: string;
  90568. shader: string;
  90569. };
  90570. }
  90571. declare module BABYLON {
  90572. /** @hidden */
  90573. export var shadowMapVertexShader: {
  90574. name: string;
  90575. shader: string;
  90576. };
  90577. }
  90578. declare module BABYLON {
  90579. /** @hidden */
  90580. export var depthBoxBlurPixelShader: {
  90581. name: string;
  90582. shader: string;
  90583. };
  90584. }
  90585. declare module BABYLON {
  90586. /** @hidden */
  90587. export var shadowMapFragmentSoftTransparentShadow: {
  90588. name: string;
  90589. shader: string;
  90590. };
  90591. }
  90592. declare module BABYLON {
  90593. /**
  90594. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  90595. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  90596. */
  90597. export class EffectFallbacks implements IEffectFallbacks {
  90598. private _defines;
  90599. private _currentRank;
  90600. private _maxRank;
  90601. private _mesh;
  90602. /**
  90603. * Removes the fallback from the bound mesh.
  90604. */
  90605. unBindMesh(): void;
  90606. /**
  90607. * Adds a fallback on the specified property.
  90608. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90609. * @param define The name of the define in the shader
  90610. */
  90611. addFallback(rank: number, define: string): void;
  90612. /**
  90613. * Sets the mesh to use CPU skinning when needing to fallback.
  90614. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90615. * @param mesh The mesh to use the fallbacks.
  90616. */
  90617. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  90618. /**
  90619. * Checks to see if more fallbacks are still availible.
  90620. */
  90621. get hasMoreFallbacks(): boolean;
  90622. /**
  90623. * Removes the defines that should be removed when falling back.
  90624. * @param currentDefines defines the current define statements for the shader.
  90625. * @param effect defines the current effect we try to compile
  90626. * @returns The resulting defines with defines of the current rank removed.
  90627. */
  90628. reduce(currentDefines: string, effect: Effect): string;
  90629. }
  90630. }
  90631. declare module BABYLON {
  90632. /**
  90633. * Interface used to define Action
  90634. */
  90635. export interface IAction {
  90636. /**
  90637. * Trigger for the action
  90638. */
  90639. trigger: number;
  90640. /** Options of the trigger */
  90641. triggerOptions: any;
  90642. /**
  90643. * Gets the trigger parameters
  90644. * @returns the trigger parameters
  90645. */
  90646. getTriggerParameter(): any;
  90647. /**
  90648. * Internal only - executes current action event
  90649. * @hidden
  90650. */
  90651. _executeCurrent(evt?: ActionEvent): void;
  90652. /**
  90653. * Serialize placeholder for child classes
  90654. * @param parent of child
  90655. * @returns the serialized object
  90656. */
  90657. serialize(parent: any): any;
  90658. /**
  90659. * Internal only
  90660. * @hidden
  90661. */
  90662. _prepare(): void;
  90663. /**
  90664. * Internal only - manager for action
  90665. * @hidden
  90666. */
  90667. _actionManager: Nullable<AbstractActionManager>;
  90668. /**
  90669. * Adds action to chain of actions, may be a DoNothingAction
  90670. * @param action defines the next action to execute
  90671. * @returns The action passed in
  90672. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90673. */
  90674. then(action: IAction): IAction;
  90675. }
  90676. /**
  90677. * The action to be carried out following a trigger
  90678. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90679. */
  90680. export class Action implements IAction {
  90681. /** the trigger, with or without parameters, for the action */
  90682. triggerOptions: any;
  90683. /**
  90684. * Trigger for the action
  90685. */
  90686. trigger: number;
  90687. /**
  90688. * Internal only - manager for action
  90689. * @hidden
  90690. */
  90691. _actionManager: ActionManager;
  90692. private _nextActiveAction;
  90693. private _child;
  90694. private _condition?;
  90695. private _triggerParameter;
  90696. /**
  90697. * An event triggered prior to action being executed.
  90698. */
  90699. onBeforeExecuteObservable: Observable<Action>;
  90700. /**
  90701. * Creates a new Action
  90702. * @param triggerOptions the trigger, with or without parameters, for the action
  90703. * @param condition an optional determinant of action
  90704. */
  90705. constructor(
  90706. /** the trigger, with or without parameters, for the action */
  90707. triggerOptions: any, condition?: Condition);
  90708. /**
  90709. * Internal only
  90710. * @hidden
  90711. */
  90712. _prepare(): void;
  90713. /**
  90714. * Gets the trigger parameters
  90715. * @returns the trigger parameters
  90716. */
  90717. getTriggerParameter(): any;
  90718. /**
  90719. * Internal only - executes current action event
  90720. * @hidden
  90721. */
  90722. _executeCurrent(evt?: ActionEvent): void;
  90723. /**
  90724. * Execute placeholder for child classes
  90725. * @param evt optional action event
  90726. */
  90727. execute(evt?: ActionEvent): void;
  90728. /**
  90729. * Skips to next active action
  90730. */
  90731. skipToNextActiveAction(): void;
  90732. /**
  90733. * Adds action to chain of actions, may be a DoNothingAction
  90734. * @param action defines the next action to execute
  90735. * @returns The action passed in
  90736. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90737. */
  90738. then(action: Action): Action;
  90739. /**
  90740. * Internal only
  90741. * @hidden
  90742. */
  90743. _getProperty(propertyPath: string): string;
  90744. /**
  90745. * Internal only
  90746. * @hidden
  90747. */
  90748. _getEffectiveTarget(target: any, propertyPath: string): any;
  90749. /**
  90750. * Serialize placeholder for child classes
  90751. * @param parent of child
  90752. * @returns the serialized object
  90753. */
  90754. serialize(parent: any): any;
  90755. /**
  90756. * Internal only called by serialize
  90757. * @hidden
  90758. */
  90759. protected _serialize(serializedAction: any, parent?: any): any;
  90760. /**
  90761. * Internal only
  90762. * @hidden
  90763. */
  90764. static _SerializeValueAsString: (value: any) => string;
  90765. /**
  90766. * Internal only
  90767. * @hidden
  90768. */
  90769. static _GetTargetProperty: (target: Scene | Node) => {
  90770. name: string;
  90771. targetType: string;
  90772. value: string;
  90773. };
  90774. }
  90775. }
  90776. declare module BABYLON {
  90777. /**
  90778. * A Condition applied to an Action
  90779. */
  90780. export class Condition {
  90781. /**
  90782. * Internal only - manager for action
  90783. * @hidden
  90784. */
  90785. _actionManager: ActionManager;
  90786. /**
  90787. * Internal only
  90788. * @hidden
  90789. */
  90790. _evaluationId: number;
  90791. /**
  90792. * Internal only
  90793. * @hidden
  90794. */
  90795. _currentResult: boolean;
  90796. /**
  90797. * Creates a new Condition
  90798. * @param actionManager the manager of the action the condition is applied to
  90799. */
  90800. constructor(actionManager: ActionManager);
  90801. /**
  90802. * Check if the current condition is valid
  90803. * @returns a boolean
  90804. */
  90805. isValid(): boolean;
  90806. /**
  90807. * Internal only
  90808. * @hidden
  90809. */
  90810. _getProperty(propertyPath: string): string;
  90811. /**
  90812. * Internal only
  90813. * @hidden
  90814. */
  90815. _getEffectiveTarget(target: any, propertyPath: string): any;
  90816. /**
  90817. * Serialize placeholder for child classes
  90818. * @returns the serialized object
  90819. */
  90820. serialize(): any;
  90821. /**
  90822. * Internal only
  90823. * @hidden
  90824. */
  90825. protected _serialize(serializedCondition: any): any;
  90826. }
  90827. /**
  90828. * Defines specific conditional operators as extensions of Condition
  90829. */
  90830. export class ValueCondition extends Condition {
  90831. /** path to specify the property of the target the conditional operator uses */
  90832. propertyPath: string;
  90833. /** the value compared by the conditional operator against the current value of the property */
  90834. value: any;
  90835. /** the conditional operator, default ValueCondition.IsEqual */
  90836. operator: number;
  90837. /**
  90838. * Internal only
  90839. * @hidden
  90840. */
  90841. private static _IsEqual;
  90842. /**
  90843. * Internal only
  90844. * @hidden
  90845. */
  90846. private static _IsDifferent;
  90847. /**
  90848. * Internal only
  90849. * @hidden
  90850. */
  90851. private static _IsGreater;
  90852. /**
  90853. * Internal only
  90854. * @hidden
  90855. */
  90856. private static _IsLesser;
  90857. /**
  90858. * returns the number for IsEqual
  90859. */
  90860. static get IsEqual(): number;
  90861. /**
  90862. * Returns the number for IsDifferent
  90863. */
  90864. static get IsDifferent(): number;
  90865. /**
  90866. * Returns the number for IsGreater
  90867. */
  90868. static get IsGreater(): number;
  90869. /**
  90870. * Returns the number for IsLesser
  90871. */
  90872. static get IsLesser(): number;
  90873. /**
  90874. * Internal only The action manager for the condition
  90875. * @hidden
  90876. */
  90877. _actionManager: ActionManager;
  90878. /**
  90879. * Internal only
  90880. * @hidden
  90881. */
  90882. private _target;
  90883. /**
  90884. * Internal only
  90885. * @hidden
  90886. */
  90887. private _effectiveTarget;
  90888. /**
  90889. * Internal only
  90890. * @hidden
  90891. */
  90892. private _property;
  90893. /**
  90894. * Creates a new ValueCondition
  90895. * @param actionManager manager for the action the condition applies to
  90896. * @param target for the action
  90897. * @param propertyPath path to specify the property of the target the conditional operator uses
  90898. * @param value the value compared by the conditional operator against the current value of the property
  90899. * @param operator the conditional operator, default ValueCondition.IsEqual
  90900. */
  90901. constructor(actionManager: ActionManager, target: any,
  90902. /** path to specify the property of the target the conditional operator uses */
  90903. propertyPath: string,
  90904. /** the value compared by the conditional operator against the current value of the property */
  90905. value: any,
  90906. /** the conditional operator, default ValueCondition.IsEqual */
  90907. operator?: number);
  90908. /**
  90909. * Compares the given value with the property value for the specified conditional operator
  90910. * @returns the result of the comparison
  90911. */
  90912. isValid(): boolean;
  90913. /**
  90914. * Serialize the ValueCondition into a JSON compatible object
  90915. * @returns serialization object
  90916. */
  90917. serialize(): any;
  90918. /**
  90919. * Gets the name of the conditional operator for the ValueCondition
  90920. * @param operator the conditional operator
  90921. * @returns the name
  90922. */
  90923. static GetOperatorName(operator: number): string;
  90924. }
  90925. /**
  90926. * Defines a predicate condition as an extension of Condition
  90927. */
  90928. export class PredicateCondition extends Condition {
  90929. /** defines the predicate function used to validate the condition */
  90930. predicate: () => boolean;
  90931. /**
  90932. * Internal only - manager for action
  90933. * @hidden
  90934. */
  90935. _actionManager: ActionManager;
  90936. /**
  90937. * Creates a new PredicateCondition
  90938. * @param actionManager manager for the action the condition applies to
  90939. * @param predicate defines the predicate function used to validate the condition
  90940. */
  90941. constructor(actionManager: ActionManager,
  90942. /** defines the predicate function used to validate the condition */
  90943. predicate: () => boolean);
  90944. /**
  90945. * @returns the validity of the predicate condition
  90946. */
  90947. isValid(): boolean;
  90948. }
  90949. /**
  90950. * Defines a state condition as an extension of Condition
  90951. */
  90952. export class StateCondition extends Condition {
  90953. /** Value to compare with target state */
  90954. value: string;
  90955. /**
  90956. * Internal only - manager for action
  90957. * @hidden
  90958. */
  90959. _actionManager: ActionManager;
  90960. /**
  90961. * Internal only
  90962. * @hidden
  90963. */
  90964. private _target;
  90965. /**
  90966. * Creates a new StateCondition
  90967. * @param actionManager manager for the action the condition applies to
  90968. * @param target of the condition
  90969. * @param value to compare with target state
  90970. */
  90971. constructor(actionManager: ActionManager, target: any,
  90972. /** Value to compare with target state */
  90973. value: string);
  90974. /**
  90975. * Gets a boolean indicating if the current condition is met
  90976. * @returns the validity of the state
  90977. */
  90978. isValid(): boolean;
  90979. /**
  90980. * Serialize the StateCondition into a JSON compatible object
  90981. * @returns serialization object
  90982. */
  90983. serialize(): any;
  90984. }
  90985. }
  90986. declare module BABYLON {
  90987. /**
  90988. * This defines an action responsible to toggle a boolean once triggered.
  90989. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90990. */
  90991. export class SwitchBooleanAction extends Action {
  90992. /**
  90993. * The path to the boolean property in the target object
  90994. */
  90995. propertyPath: string;
  90996. private _target;
  90997. private _effectiveTarget;
  90998. private _property;
  90999. /**
  91000. * Instantiate the action
  91001. * @param triggerOptions defines the trigger options
  91002. * @param target defines the object containing the boolean
  91003. * @param propertyPath defines the path to the boolean property in the target object
  91004. * @param condition defines the trigger related conditions
  91005. */
  91006. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91007. /** @hidden */
  91008. _prepare(): void;
  91009. /**
  91010. * Execute the action toggle the boolean value.
  91011. */
  91012. execute(): void;
  91013. /**
  91014. * Serializes the actions and its related information.
  91015. * @param parent defines the object to serialize in
  91016. * @returns the serialized object
  91017. */
  91018. serialize(parent: any): any;
  91019. }
  91020. /**
  91021. * This defines an action responsible to set a the state field of the target
  91022. * to a desired value once triggered.
  91023. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91024. */
  91025. export class SetStateAction extends Action {
  91026. /**
  91027. * The value to store in the state field.
  91028. */
  91029. value: string;
  91030. private _target;
  91031. /**
  91032. * Instantiate the action
  91033. * @param triggerOptions defines the trigger options
  91034. * @param target defines the object containing the state property
  91035. * @param value defines the value to store in the state field
  91036. * @param condition defines the trigger related conditions
  91037. */
  91038. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91039. /**
  91040. * Execute the action and store the value on the target state property.
  91041. */
  91042. execute(): void;
  91043. /**
  91044. * Serializes the actions and its related information.
  91045. * @param parent defines the object to serialize in
  91046. * @returns the serialized object
  91047. */
  91048. serialize(parent: any): any;
  91049. }
  91050. /**
  91051. * This defines an action responsible to set a property of the target
  91052. * to a desired value once triggered.
  91053. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91054. */
  91055. export class SetValueAction extends Action {
  91056. /**
  91057. * The path of the property to set in the target.
  91058. */
  91059. propertyPath: string;
  91060. /**
  91061. * The value to set in the property
  91062. */
  91063. value: any;
  91064. private _target;
  91065. private _effectiveTarget;
  91066. private _property;
  91067. /**
  91068. * Instantiate the action
  91069. * @param triggerOptions defines the trigger options
  91070. * @param target defines the object containing the property
  91071. * @param propertyPath defines the path of the property to set in the target
  91072. * @param value defines the value to set in the property
  91073. * @param condition defines the trigger related conditions
  91074. */
  91075. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91076. /** @hidden */
  91077. _prepare(): void;
  91078. /**
  91079. * Execute the action and set the targetted property to the desired value.
  91080. */
  91081. execute(): void;
  91082. /**
  91083. * Serializes the actions and its related information.
  91084. * @param parent defines the object to serialize in
  91085. * @returns the serialized object
  91086. */
  91087. serialize(parent: any): any;
  91088. }
  91089. /**
  91090. * This defines an action responsible to increment the target value
  91091. * to a desired value once triggered.
  91092. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91093. */
  91094. export class IncrementValueAction extends Action {
  91095. /**
  91096. * The path of the property to increment in the target.
  91097. */
  91098. propertyPath: string;
  91099. /**
  91100. * The value we should increment the property by.
  91101. */
  91102. value: any;
  91103. private _target;
  91104. private _effectiveTarget;
  91105. private _property;
  91106. /**
  91107. * Instantiate the action
  91108. * @param triggerOptions defines the trigger options
  91109. * @param target defines the object containing the property
  91110. * @param propertyPath defines the path of the property to increment in the target
  91111. * @param value defines the value value we should increment the property by
  91112. * @param condition defines the trigger related conditions
  91113. */
  91114. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91115. /** @hidden */
  91116. _prepare(): void;
  91117. /**
  91118. * Execute the action and increment the target of the value amount.
  91119. */
  91120. execute(): void;
  91121. /**
  91122. * Serializes the actions and its related information.
  91123. * @param parent defines the object to serialize in
  91124. * @returns the serialized object
  91125. */
  91126. serialize(parent: any): any;
  91127. }
  91128. /**
  91129. * This defines an action responsible to start an animation once triggered.
  91130. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91131. */
  91132. export class PlayAnimationAction extends Action {
  91133. /**
  91134. * Where the animation should start (animation frame)
  91135. */
  91136. from: number;
  91137. /**
  91138. * Where the animation should stop (animation frame)
  91139. */
  91140. to: number;
  91141. /**
  91142. * Define if the animation should loop or stop after the first play.
  91143. */
  91144. loop?: boolean;
  91145. private _target;
  91146. /**
  91147. * Instantiate the action
  91148. * @param triggerOptions defines the trigger options
  91149. * @param target defines the target animation or animation name
  91150. * @param from defines from where the animation should start (animation frame)
  91151. * @param end defines where the animation should stop (animation frame)
  91152. * @param loop defines if the animation should loop or stop after the first play
  91153. * @param condition defines the trigger related conditions
  91154. */
  91155. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91156. /** @hidden */
  91157. _prepare(): void;
  91158. /**
  91159. * Execute the action and play the animation.
  91160. */
  91161. execute(): void;
  91162. /**
  91163. * Serializes the actions and its related information.
  91164. * @param parent defines the object to serialize in
  91165. * @returns the serialized object
  91166. */
  91167. serialize(parent: any): any;
  91168. }
  91169. /**
  91170. * This defines an action responsible to stop an animation once triggered.
  91171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91172. */
  91173. export class StopAnimationAction extends Action {
  91174. private _target;
  91175. /**
  91176. * Instantiate the action
  91177. * @param triggerOptions defines the trigger options
  91178. * @param target defines the target animation or animation name
  91179. * @param condition defines the trigger related conditions
  91180. */
  91181. constructor(triggerOptions: any, target: any, condition?: Condition);
  91182. /** @hidden */
  91183. _prepare(): void;
  91184. /**
  91185. * Execute the action and stop the animation.
  91186. */
  91187. execute(): void;
  91188. /**
  91189. * Serializes the actions and its related information.
  91190. * @param parent defines the object to serialize in
  91191. * @returns the serialized object
  91192. */
  91193. serialize(parent: any): any;
  91194. }
  91195. /**
  91196. * This defines an action responsible that does nothing once triggered.
  91197. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91198. */
  91199. export class DoNothingAction extends Action {
  91200. /**
  91201. * Instantiate the action
  91202. * @param triggerOptions defines the trigger options
  91203. * @param condition defines the trigger related conditions
  91204. */
  91205. constructor(triggerOptions?: any, condition?: Condition);
  91206. /**
  91207. * Execute the action and do nothing.
  91208. */
  91209. execute(): void;
  91210. /**
  91211. * Serializes the actions and its related information.
  91212. * @param parent defines the object to serialize in
  91213. * @returns the serialized object
  91214. */
  91215. serialize(parent: any): any;
  91216. }
  91217. /**
  91218. * This defines an action responsible to trigger several actions once triggered.
  91219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91220. */
  91221. export class CombineAction extends Action {
  91222. /**
  91223. * The list of aggregated animations to run.
  91224. */
  91225. children: Action[];
  91226. /**
  91227. * Instantiate the action
  91228. * @param triggerOptions defines the trigger options
  91229. * @param children defines the list of aggregated animations to run
  91230. * @param condition defines the trigger related conditions
  91231. */
  91232. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91233. /** @hidden */
  91234. _prepare(): void;
  91235. /**
  91236. * Execute the action and executes all the aggregated actions.
  91237. */
  91238. execute(evt: ActionEvent): void;
  91239. /**
  91240. * Serializes the actions and its related information.
  91241. * @param parent defines the object to serialize in
  91242. * @returns the serialized object
  91243. */
  91244. serialize(parent: any): any;
  91245. }
  91246. /**
  91247. * This defines an action responsible to run code (external event) once triggered.
  91248. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91249. */
  91250. export class ExecuteCodeAction extends Action {
  91251. /**
  91252. * The callback function to run.
  91253. */
  91254. func: (evt: ActionEvent) => void;
  91255. /**
  91256. * Instantiate the action
  91257. * @param triggerOptions defines the trigger options
  91258. * @param func defines the callback function to run
  91259. * @param condition defines the trigger related conditions
  91260. */
  91261. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91262. /**
  91263. * Execute the action and run the attached code.
  91264. */
  91265. execute(evt: ActionEvent): void;
  91266. }
  91267. /**
  91268. * This defines an action responsible to set the parent property of the target once triggered.
  91269. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91270. */
  91271. export class SetParentAction extends Action {
  91272. private _parent;
  91273. private _target;
  91274. /**
  91275. * Instantiate the action
  91276. * @param triggerOptions defines the trigger options
  91277. * @param target defines the target containing the parent property
  91278. * @param parent defines from where the animation should start (animation frame)
  91279. * @param condition defines the trigger related conditions
  91280. */
  91281. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91282. /** @hidden */
  91283. _prepare(): void;
  91284. /**
  91285. * Execute the action and set the parent property.
  91286. */
  91287. execute(): void;
  91288. /**
  91289. * Serializes the actions and its related information.
  91290. * @param parent defines the object to serialize in
  91291. * @returns the serialized object
  91292. */
  91293. serialize(parent: any): any;
  91294. }
  91295. }
  91296. declare module BABYLON {
  91297. /**
  91298. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91299. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91300. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91301. */
  91302. export class ActionManager extends AbstractActionManager {
  91303. /**
  91304. * Nothing
  91305. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91306. */
  91307. static readonly NothingTrigger: number;
  91308. /**
  91309. * On pick
  91310. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91311. */
  91312. static readonly OnPickTrigger: number;
  91313. /**
  91314. * On left pick
  91315. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91316. */
  91317. static readonly OnLeftPickTrigger: number;
  91318. /**
  91319. * On right pick
  91320. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91321. */
  91322. static readonly OnRightPickTrigger: number;
  91323. /**
  91324. * On center pick
  91325. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91326. */
  91327. static readonly OnCenterPickTrigger: number;
  91328. /**
  91329. * On pick down
  91330. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91331. */
  91332. static readonly OnPickDownTrigger: number;
  91333. /**
  91334. * On double pick
  91335. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91336. */
  91337. static readonly OnDoublePickTrigger: number;
  91338. /**
  91339. * On pick up
  91340. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91341. */
  91342. static readonly OnPickUpTrigger: number;
  91343. /**
  91344. * On pick out.
  91345. * This trigger will only be raised if you also declared a OnPickDown
  91346. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91347. */
  91348. static readonly OnPickOutTrigger: number;
  91349. /**
  91350. * On long press
  91351. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91352. */
  91353. static readonly OnLongPressTrigger: number;
  91354. /**
  91355. * On pointer over
  91356. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91357. */
  91358. static readonly OnPointerOverTrigger: number;
  91359. /**
  91360. * On pointer out
  91361. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91362. */
  91363. static readonly OnPointerOutTrigger: number;
  91364. /**
  91365. * On every frame
  91366. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91367. */
  91368. static readonly OnEveryFrameTrigger: number;
  91369. /**
  91370. * On intersection enter
  91371. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91372. */
  91373. static readonly OnIntersectionEnterTrigger: number;
  91374. /**
  91375. * On intersection exit
  91376. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91377. */
  91378. static readonly OnIntersectionExitTrigger: number;
  91379. /**
  91380. * On key down
  91381. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91382. */
  91383. static readonly OnKeyDownTrigger: number;
  91384. /**
  91385. * On key up
  91386. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91387. */
  91388. static readonly OnKeyUpTrigger: number;
  91389. private _scene;
  91390. /**
  91391. * Creates a new action manager
  91392. * @param scene defines the hosting scene
  91393. */
  91394. constructor(scene: Scene);
  91395. /**
  91396. * Releases all associated resources
  91397. */
  91398. dispose(): void;
  91399. /**
  91400. * Gets hosting scene
  91401. * @returns the hosting scene
  91402. */
  91403. getScene(): Scene;
  91404. /**
  91405. * Does this action manager handles actions of any of the given triggers
  91406. * @param triggers defines the triggers to be tested
  91407. * @return a boolean indicating whether one (or more) of the triggers is handled
  91408. */
  91409. hasSpecificTriggers(triggers: number[]): boolean;
  91410. /**
  91411. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91412. * speed.
  91413. * @param triggerA defines the trigger to be tested
  91414. * @param triggerB defines the trigger to be tested
  91415. * @return a boolean indicating whether one (or more) of the triggers is handled
  91416. */
  91417. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91418. /**
  91419. * Does this action manager handles actions of a given trigger
  91420. * @param trigger defines the trigger to be tested
  91421. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91422. * @return whether the trigger is handled
  91423. */
  91424. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91425. /**
  91426. * Does this action manager has pointer triggers
  91427. */
  91428. get hasPointerTriggers(): boolean;
  91429. /**
  91430. * Does this action manager has pick triggers
  91431. */
  91432. get hasPickTriggers(): boolean;
  91433. /**
  91434. * Registers an action to this action manager
  91435. * @param action defines the action to be registered
  91436. * @return the action amended (prepared) after registration
  91437. */
  91438. registerAction(action: IAction): Nullable<IAction>;
  91439. /**
  91440. * Unregisters an action to this action manager
  91441. * @param action defines the action to be unregistered
  91442. * @return a boolean indicating whether the action has been unregistered
  91443. */
  91444. unregisterAction(action: IAction): Boolean;
  91445. /**
  91446. * Process a specific trigger
  91447. * @param trigger defines the trigger to process
  91448. * @param evt defines the event details to be processed
  91449. */
  91450. processTrigger(trigger: number, evt?: IActionEvent): void;
  91451. /** @hidden */
  91452. _getEffectiveTarget(target: any, propertyPath: string): any;
  91453. /** @hidden */
  91454. _getProperty(propertyPath: string): string;
  91455. /**
  91456. * Serialize this manager to a JSON object
  91457. * @param name defines the property name to store this manager
  91458. * @returns a JSON representation of this manager
  91459. */
  91460. serialize(name: string): any;
  91461. /**
  91462. * Creates a new ActionManager from a JSON data
  91463. * @param parsedActions defines the JSON data to read from
  91464. * @param object defines the hosting mesh
  91465. * @param scene defines the hosting scene
  91466. */
  91467. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91468. /**
  91469. * Get a trigger name by index
  91470. * @param trigger defines the trigger index
  91471. * @returns a trigger name
  91472. */
  91473. static GetTriggerName(trigger: number): string;
  91474. }
  91475. }
  91476. declare module BABYLON {
  91477. /**
  91478. * Class used to represent a sprite
  91479. * @see https://doc.babylonjs.com/babylon101/sprites
  91480. */
  91481. export class Sprite implements IAnimatable {
  91482. /** defines the name */
  91483. name: string;
  91484. /** Gets or sets the current world position */
  91485. position: Vector3;
  91486. /** Gets or sets the main color */
  91487. color: Color4;
  91488. /** Gets or sets the width */
  91489. width: number;
  91490. /** Gets or sets the height */
  91491. height: number;
  91492. /** Gets or sets rotation angle */
  91493. angle: number;
  91494. /** Gets or sets the cell index in the sprite sheet */
  91495. cellIndex: number;
  91496. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91497. cellRef: string;
  91498. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91499. invertU: boolean;
  91500. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91501. invertV: boolean;
  91502. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91503. disposeWhenFinishedAnimating: boolean;
  91504. /** Gets the list of attached animations */
  91505. animations: Nullable<Array<Animation>>;
  91506. /** Gets or sets a boolean indicating if the sprite can be picked */
  91507. isPickable: boolean;
  91508. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  91509. useAlphaForPicking: boolean;
  91510. /** @hidden */
  91511. _xOffset: number;
  91512. /** @hidden */
  91513. _yOffset: number;
  91514. /** @hidden */
  91515. _xSize: number;
  91516. /** @hidden */
  91517. _ySize: number;
  91518. /**
  91519. * Gets or sets the associated action manager
  91520. */
  91521. actionManager: Nullable<ActionManager>;
  91522. /**
  91523. * An event triggered when the control has been disposed
  91524. */
  91525. onDisposeObservable: Observable<Sprite>;
  91526. private _animationStarted;
  91527. private _loopAnimation;
  91528. private _fromIndex;
  91529. private _toIndex;
  91530. private _delay;
  91531. private _direction;
  91532. private _manager;
  91533. private _time;
  91534. private _onAnimationEnd;
  91535. /**
  91536. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91537. */
  91538. isVisible: boolean;
  91539. /**
  91540. * Gets or sets the sprite size
  91541. */
  91542. get size(): number;
  91543. set size(value: number);
  91544. /**
  91545. * Returns a boolean indicating if the animation is started
  91546. */
  91547. get animationStarted(): boolean;
  91548. /**
  91549. * Gets or sets the unique id of the sprite
  91550. */
  91551. uniqueId: number;
  91552. /**
  91553. * Gets the manager of this sprite
  91554. */
  91555. get manager(): ISpriteManager;
  91556. /**
  91557. * Creates a new Sprite
  91558. * @param name defines the name
  91559. * @param manager defines the manager
  91560. */
  91561. constructor(
  91562. /** defines the name */
  91563. name: string, manager: ISpriteManager);
  91564. /**
  91565. * Returns the string "Sprite"
  91566. * @returns "Sprite"
  91567. */
  91568. getClassName(): string;
  91569. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  91570. get fromIndex(): number;
  91571. set fromIndex(value: number);
  91572. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  91573. get toIndex(): number;
  91574. set toIndex(value: number);
  91575. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  91576. get loopAnimation(): boolean;
  91577. set loopAnimation(value: boolean);
  91578. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  91579. get delay(): number;
  91580. set delay(value: number);
  91581. /**
  91582. * Starts an animation
  91583. * @param from defines the initial key
  91584. * @param to defines the end key
  91585. * @param loop defines if the animation must loop
  91586. * @param delay defines the start delay (in ms)
  91587. * @param onAnimationEnd defines a callback to call when animation ends
  91588. */
  91589. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  91590. /** Stops current animation (if any) */
  91591. stopAnimation(): void;
  91592. /** @hidden */
  91593. _animate(deltaTime: number): void;
  91594. /** Release associated resources */
  91595. dispose(): void;
  91596. /**
  91597. * Serializes the sprite to a JSON object
  91598. * @returns the JSON object
  91599. */
  91600. serialize(): any;
  91601. /**
  91602. * Parses a JSON object to create a new sprite
  91603. * @param parsedSprite The JSON object to parse
  91604. * @param manager defines the hosting manager
  91605. * @returns the new sprite
  91606. */
  91607. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  91608. }
  91609. }
  91610. declare module BABYLON {
  91611. /**
  91612. * Information about the result of picking within a scene
  91613. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91614. */
  91615. export class PickingInfo {
  91616. /** @hidden */
  91617. _pickingUnavailable: boolean;
  91618. /**
  91619. * If the pick collided with an object
  91620. */
  91621. hit: boolean;
  91622. /**
  91623. * Distance away where the pick collided
  91624. */
  91625. distance: number;
  91626. /**
  91627. * The location of pick collision
  91628. */
  91629. pickedPoint: Nullable<Vector3>;
  91630. /**
  91631. * The mesh corresponding the the pick collision
  91632. */
  91633. pickedMesh: Nullable<AbstractMesh>;
  91634. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91635. bu: number;
  91636. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91637. bv: number;
  91638. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91639. faceId: number;
  91640. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91641. subMeshFaceId: number;
  91642. /** Id of the the submesh that was picked */
  91643. subMeshId: number;
  91644. /** If a sprite was picked, this will be the sprite the pick collided with */
  91645. pickedSprite: Nullable<Sprite>;
  91646. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  91647. thinInstanceIndex: number;
  91648. /**
  91649. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91650. */
  91651. originMesh: Nullable<AbstractMesh>;
  91652. /**
  91653. * The ray that was used to perform the picking.
  91654. */
  91655. ray: Nullable<Ray>;
  91656. /**
  91657. * Gets the normal correspodning to the face the pick collided with
  91658. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91659. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91660. * @returns The normal correspodning to the face the pick collided with
  91661. */
  91662. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91663. /**
  91664. * Gets the texture coordinates of where the pick occured
  91665. * @returns the vector containing the coordnates of the texture
  91666. */
  91667. getTextureCoordinates(): Nullable<Vector2>;
  91668. }
  91669. }
  91670. declare module BABYLON {
  91671. /**
  91672. * Class representing a ray with position and direction
  91673. */
  91674. export class Ray {
  91675. /** origin point */
  91676. origin: Vector3;
  91677. /** direction */
  91678. direction: Vector3;
  91679. /** length of the ray */
  91680. length: number;
  91681. private static readonly _TmpVector3;
  91682. private _tmpRay;
  91683. /**
  91684. * Creates a new ray
  91685. * @param origin origin point
  91686. * @param direction direction
  91687. * @param length length of the ray
  91688. */
  91689. constructor(
  91690. /** origin point */
  91691. origin: Vector3,
  91692. /** direction */
  91693. direction: Vector3,
  91694. /** length of the ray */
  91695. length?: number);
  91696. /**
  91697. * Checks if the ray intersects a box
  91698. * This does not account for the ray lenght by design to improve perfs.
  91699. * @param minimum bound of the box
  91700. * @param maximum bound of the box
  91701. * @param intersectionTreshold extra extend to be added to the box in all direction
  91702. * @returns if the box was hit
  91703. */
  91704. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91705. /**
  91706. * Checks if the ray intersects a box
  91707. * This does not account for the ray lenght by design to improve perfs.
  91708. * @param box the bounding box to check
  91709. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91710. * @returns if the box was hit
  91711. */
  91712. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91713. /**
  91714. * If the ray hits a sphere
  91715. * @param sphere the bounding sphere to check
  91716. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91717. * @returns true if it hits the sphere
  91718. */
  91719. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91720. /**
  91721. * If the ray hits a triange
  91722. * @param vertex0 triangle vertex
  91723. * @param vertex1 triangle vertex
  91724. * @param vertex2 triangle vertex
  91725. * @returns intersection information if hit
  91726. */
  91727. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91728. /**
  91729. * Checks if ray intersects a plane
  91730. * @param plane the plane to check
  91731. * @returns the distance away it was hit
  91732. */
  91733. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91734. /**
  91735. * Calculate the intercept of a ray on a given axis
  91736. * @param axis to check 'x' | 'y' | 'z'
  91737. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91738. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91739. */
  91740. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91741. /**
  91742. * Checks if ray intersects a mesh
  91743. * @param mesh the mesh to check
  91744. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91745. * @returns picking info of the intersecton
  91746. */
  91747. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91748. /**
  91749. * Checks if ray intersects a mesh
  91750. * @param meshes the meshes to check
  91751. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91752. * @param results array to store result in
  91753. * @returns Array of picking infos
  91754. */
  91755. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91756. private _comparePickingInfo;
  91757. private static smallnum;
  91758. private static rayl;
  91759. /**
  91760. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91761. * @param sega the first point of the segment to test the intersection against
  91762. * @param segb the second point of the segment to test the intersection against
  91763. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91764. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91765. */
  91766. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91767. /**
  91768. * Update the ray from viewport position
  91769. * @param x position
  91770. * @param y y position
  91771. * @param viewportWidth viewport width
  91772. * @param viewportHeight viewport height
  91773. * @param world world matrix
  91774. * @param view view matrix
  91775. * @param projection projection matrix
  91776. * @returns this ray updated
  91777. */
  91778. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91779. /**
  91780. * Creates a ray with origin and direction of 0,0,0
  91781. * @returns the new ray
  91782. */
  91783. static Zero(): Ray;
  91784. /**
  91785. * Creates a new ray from screen space and viewport
  91786. * @param x position
  91787. * @param y y position
  91788. * @param viewportWidth viewport width
  91789. * @param viewportHeight viewport height
  91790. * @param world world matrix
  91791. * @param view view matrix
  91792. * @param projection projection matrix
  91793. * @returns new ray
  91794. */
  91795. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91796. /**
  91797. * 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
  91798. * transformed to the given world matrix.
  91799. * @param origin The origin point
  91800. * @param end The end point
  91801. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91802. * @returns the new ray
  91803. */
  91804. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91805. /**
  91806. * Transforms a ray by a matrix
  91807. * @param ray ray to transform
  91808. * @param matrix matrix to apply
  91809. * @returns the resulting new ray
  91810. */
  91811. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91812. /**
  91813. * Transforms a ray by a matrix
  91814. * @param ray ray to transform
  91815. * @param matrix matrix to apply
  91816. * @param result ray to store result in
  91817. */
  91818. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91819. /**
  91820. * Unproject a ray from screen space to object space
  91821. * @param sourceX defines the screen space x coordinate to use
  91822. * @param sourceY defines the screen space y coordinate to use
  91823. * @param viewportWidth defines the current width of the viewport
  91824. * @param viewportHeight defines the current height of the viewport
  91825. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91826. * @param view defines the view matrix to use
  91827. * @param projection defines the projection matrix to use
  91828. */
  91829. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91830. }
  91831. /**
  91832. * Type used to define predicate used to select faces when a mesh intersection is detected
  91833. */
  91834. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91835. interface Scene {
  91836. /** @hidden */
  91837. _tempPickingRay: Nullable<Ray>;
  91838. /** @hidden */
  91839. _cachedRayForTransform: Ray;
  91840. /** @hidden */
  91841. _pickWithRayInverseMatrix: Matrix;
  91842. /** @hidden */
  91843. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91844. /** @hidden */
  91845. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91846. /** @hidden */
  91847. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  91848. }
  91849. }
  91850. declare module BABYLON {
  91851. /**
  91852. * Groups all the scene component constants in one place to ease maintenance.
  91853. * @hidden
  91854. */
  91855. export class SceneComponentConstants {
  91856. static readonly NAME_EFFECTLAYER: string;
  91857. static readonly NAME_LAYER: string;
  91858. static readonly NAME_LENSFLARESYSTEM: string;
  91859. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91860. static readonly NAME_PARTICLESYSTEM: string;
  91861. static readonly NAME_GAMEPAD: string;
  91862. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91863. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91864. static readonly NAME_PREPASSRENDERER: string;
  91865. static readonly NAME_DEPTHRENDERER: string;
  91866. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91867. static readonly NAME_SPRITE: string;
  91868. static readonly NAME_SUBSURFACE: string;
  91869. static readonly NAME_OUTLINERENDERER: string;
  91870. static readonly NAME_PROCEDURALTEXTURE: string;
  91871. static readonly NAME_SHADOWGENERATOR: string;
  91872. static readonly NAME_OCTREE: string;
  91873. static readonly NAME_PHYSICSENGINE: string;
  91874. static readonly NAME_AUDIO: string;
  91875. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91876. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91877. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91878. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91879. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91880. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91881. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91882. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91883. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91884. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91885. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91886. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91887. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91888. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91889. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91890. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91891. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91892. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91893. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91894. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91895. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91896. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91897. static readonly STEP_AFTERRENDER_AUDIO: number;
  91898. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91899. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91900. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91901. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91902. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91903. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91904. static readonly STEP_POINTERMOVE_SPRITE: number;
  91905. static readonly STEP_POINTERDOWN_SPRITE: number;
  91906. static readonly STEP_POINTERUP_SPRITE: number;
  91907. }
  91908. /**
  91909. * This represents a scene component.
  91910. *
  91911. * This is used to decouple the dependency the scene is having on the different workloads like
  91912. * layers, post processes...
  91913. */
  91914. export interface ISceneComponent {
  91915. /**
  91916. * The name of the component. Each component must have a unique name.
  91917. */
  91918. name: string;
  91919. /**
  91920. * The scene the component belongs to.
  91921. */
  91922. scene: Scene;
  91923. /**
  91924. * Register the component to one instance of a scene.
  91925. */
  91926. register(): void;
  91927. /**
  91928. * Rebuilds the elements related to this component in case of
  91929. * context lost for instance.
  91930. */
  91931. rebuild(): void;
  91932. /**
  91933. * Disposes the component and the associated ressources.
  91934. */
  91935. dispose(): void;
  91936. }
  91937. /**
  91938. * This represents a SERIALIZABLE scene component.
  91939. *
  91940. * This extends Scene Component to add Serialization methods on top.
  91941. */
  91942. export interface ISceneSerializableComponent extends ISceneComponent {
  91943. /**
  91944. * Adds all the elements from the container to the scene
  91945. * @param container the container holding the elements
  91946. */
  91947. addFromContainer(container: AbstractScene): void;
  91948. /**
  91949. * Removes all the elements in the container from the scene
  91950. * @param container contains the elements to remove
  91951. * @param dispose if the removed element should be disposed (default: false)
  91952. */
  91953. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91954. /**
  91955. * Serializes the component data to the specified json object
  91956. * @param serializationObject The object to serialize to
  91957. */
  91958. serialize(serializationObject: any): void;
  91959. }
  91960. /**
  91961. * Strong typing of a Mesh related stage step action
  91962. */
  91963. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91964. /**
  91965. * Strong typing of a Evaluate Sub Mesh related stage step action
  91966. */
  91967. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91968. /**
  91969. * Strong typing of a pre active Mesh related stage step action
  91970. */
  91971. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  91972. /**
  91973. * Strong typing of a Camera related stage step action
  91974. */
  91975. export type CameraStageAction = (camera: Camera) => void;
  91976. /**
  91977. * Strong typing of a Camera Frame buffer related stage step action
  91978. */
  91979. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91980. /**
  91981. * Strong typing of a Render Target related stage step action
  91982. */
  91983. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91984. /**
  91985. * Strong typing of a RenderingGroup related stage step action
  91986. */
  91987. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91988. /**
  91989. * Strong typing of a Mesh Render related stage step action
  91990. */
  91991. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91992. /**
  91993. * Strong typing of a simple stage step action
  91994. */
  91995. export type SimpleStageAction = () => void;
  91996. /**
  91997. * Strong typing of a render target action.
  91998. */
  91999. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  92000. /**
  92001. * Strong typing of a pointer move action.
  92002. */
  92003. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  92004. /**
  92005. * Strong typing of a pointer up/down action.
  92006. */
  92007. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  92008. /**
  92009. * Representation of a stage in the scene (Basically a list of ordered steps)
  92010. * @hidden
  92011. */
  92012. export class Stage<T extends Function> extends Array<{
  92013. index: number;
  92014. component: ISceneComponent;
  92015. action: T;
  92016. }> {
  92017. /**
  92018. * Hide ctor from the rest of the world.
  92019. * @param items The items to add.
  92020. */
  92021. private constructor();
  92022. /**
  92023. * Creates a new Stage.
  92024. * @returns A new instance of a Stage
  92025. */
  92026. static Create<T extends Function>(): Stage<T>;
  92027. /**
  92028. * Registers a step in an ordered way in the targeted stage.
  92029. * @param index Defines the position to register the step in
  92030. * @param component Defines the component attached to the step
  92031. * @param action Defines the action to launch during the step
  92032. */
  92033. registerStep(index: number, component: ISceneComponent, action: T): void;
  92034. /**
  92035. * Clears all the steps from the stage.
  92036. */
  92037. clear(): void;
  92038. }
  92039. }
  92040. declare module BABYLON {
  92041. interface Scene {
  92042. /** @hidden */
  92043. _pointerOverSprite: Nullable<Sprite>;
  92044. /** @hidden */
  92045. _pickedDownSprite: Nullable<Sprite>;
  92046. /** @hidden */
  92047. _tempSpritePickingRay: Nullable<Ray>;
  92048. /**
  92049. * All of the sprite managers added to this scene
  92050. * @see https://doc.babylonjs.com/babylon101/sprites
  92051. */
  92052. spriteManagers: Array<ISpriteManager>;
  92053. /**
  92054. * An event triggered when sprites rendering is about to start
  92055. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92056. */
  92057. onBeforeSpritesRenderingObservable: Observable<Scene>;
  92058. /**
  92059. * An event triggered when sprites rendering is done
  92060. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92061. */
  92062. onAfterSpritesRenderingObservable: Observable<Scene>;
  92063. /** @hidden */
  92064. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92065. /** Launch a ray to try to pick a sprite in the scene
  92066. * @param x position on screen
  92067. * @param y position on screen
  92068. * @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
  92069. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92070. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92071. * @returns a PickingInfo
  92072. */
  92073. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92074. /** Use the given ray to pick a sprite in the scene
  92075. * @param ray The ray (in world space) to use to pick meshes
  92076. * @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
  92077. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92078. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92079. * @returns a PickingInfo
  92080. */
  92081. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92082. /** @hidden */
  92083. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92084. /** Launch a ray to try to pick sprites in the scene
  92085. * @param x position on screen
  92086. * @param y position on screen
  92087. * @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
  92088. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92089. * @returns a PickingInfo array
  92090. */
  92091. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92092. /** Use the given ray to pick sprites in the scene
  92093. * @param ray The ray (in world space) to use to pick meshes
  92094. * @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
  92095. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92096. * @returns a PickingInfo array
  92097. */
  92098. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92099. /**
  92100. * Force the sprite under the pointer
  92101. * @param sprite defines the sprite to use
  92102. */
  92103. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  92104. /**
  92105. * Gets the sprite under the pointer
  92106. * @returns a Sprite or null if no sprite is under the pointer
  92107. */
  92108. getPointerOverSprite(): Nullable<Sprite>;
  92109. }
  92110. /**
  92111. * Defines the sprite scene component responsible to manage sprites
  92112. * in a given scene.
  92113. */
  92114. export class SpriteSceneComponent implements ISceneComponent {
  92115. /**
  92116. * The component name helpfull to identify the component in the list of scene components.
  92117. */
  92118. readonly name: string;
  92119. /**
  92120. * The scene the component belongs to.
  92121. */
  92122. scene: Scene;
  92123. /** @hidden */
  92124. private _spritePredicate;
  92125. /**
  92126. * Creates a new instance of the component for the given scene
  92127. * @param scene Defines the scene to register the component in
  92128. */
  92129. constructor(scene: Scene);
  92130. /**
  92131. * Registers the component in a given scene
  92132. */
  92133. register(): void;
  92134. /**
  92135. * Rebuilds the elements related to this component in case of
  92136. * context lost for instance.
  92137. */
  92138. rebuild(): void;
  92139. /**
  92140. * Disposes the component and the associated ressources.
  92141. */
  92142. dispose(): void;
  92143. private _pickSpriteButKeepRay;
  92144. private _pointerMove;
  92145. private _pointerDown;
  92146. private _pointerUp;
  92147. }
  92148. }
  92149. declare module BABYLON {
  92150. /** @hidden */
  92151. export var fogFragmentDeclaration: {
  92152. name: string;
  92153. shader: string;
  92154. };
  92155. }
  92156. declare module BABYLON {
  92157. /** @hidden */
  92158. export var fogFragment: {
  92159. name: string;
  92160. shader: string;
  92161. };
  92162. }
  92163. declare module BABYLON {
  92164. /** @hidden */
  92165. export var imageProcessingCompatibility: {
  92166. name: string;
  92167. shader: string;
  92168. };
  92169. }
  92170. declare module BABYLON {
  92171. /** @hidden */
  92172. export var spritesPixelShader: {
  92173. name: string;
  92174. shader: string;
  92175. };
  92176. }
  92177. declare module BABYLON {
  92178. /** @hidden */
  92179. export var fogVertexDeclaration: {
  92180. name: string;
  92181. shader: string;
  92182. };
  92183. }
  92184. declare module BABYLON {
  92185. /** @hidden */
  92186. export var spritesVertexShader: {
  92187. name: string;
  92188. shader: string;
  92189. };
  92190. }
  92191. declare module BABYLON {
  92192. /**
  92193. * Defines the minimum interface to fullfil in order to be a sprite manager.
  92194. */
  92195. export interface ISpriteManager extends IDisposable {
  92196. /**
  92197. * Gets manager's name
  92198. */
  92199. name: string;
  92200. /**
  92201. * Restricts the camera to viewing objects with the same layerMask.
  92202. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  92203. */
  92204. layerMask: number;
  92205. /**
  92206. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92207. */
  92208. isPickable: boolean;
  92209. /**
  92210. * Gets the hosting scene
  92211. */
  92212. scene: Scene;
  92213. /**
  92214. * Specifies the rendering group id for this mesh (0 by default)
  92215. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92216. */
  92217. renderingGroupId: number;
  92218. /**
  92219. * Defines the list of sprites managed by the manager.
  92220. */
  92221. sprites: Array<Sprite>;
  92222. /**
  92223. * Gets or sets the spritesheet texture
  92224. */
  92225. texture: Texture;
  92226. /** Defines the default width of a cell in the spritesheet */
  92227. cellWidth: number;
  92228. /** Defines the default height of a cell in the spritesheet */
  92229. cellHeight: number;
  92230. /**
  92231. * Tests the intersection of a sprite with a specific ray.
  92232. * @param ray The ray we are sending to test the collision
  92233. * @param camera The camera space we are sending rays in
  92234. * @param predicate A predicate allowing excluding sprites from the list of object to test
  92235. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92236. * @returns picking info or null.
  92237. */
  92238. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  92239. /**
  92240. * Intersects the sprites with a ray
  92241. * @param ray defines the ray to intersect with
  92242. * @param camera defines the current active camera
  92243. * @param predicate defines a predicate used to select candidate sprites
  92244. * @returns null if no hit or a PickingInfo array
  92245. */
  92246. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  92247. /**
  92248. * Renders the list of sprites on screen.
  92249. */
  92250. render(): void;
  92251. }
  92252. /**
  92253. * Class used to manage multiple sprites on the same spritesheet
  92254. * @see https://doc.babylonjs.com/babylon101/sprites
  92255. */
  92256. export class SpriteManager implements ISpriteManager {
  92257. /** defines the manager's name */
  92258. name: string;
  92259. /** Define the Url to load snippets */
  92260. static SnippetUrl: string;
  92261. /** Snippet ID if the manager was created from the snippet server */
  92262. snippetId: string;
  92263. /** Gets the list of sprites */
  92264. sprites: Sprite[];
  92265. /** Gets or sets the rendering group id (0 by default) */
  92266. renderingGroupId: number;
  92267. /** Gets or sets camera layer mask */
  92268. layerMask: number;
  92269. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  92270. fogEnabled: boolean;
  92271. /** Gets or sets a boolean indicating if the sprites are pickable */
  92272. isPickable: boolean;
  92273. /** Defines the default width of a cell in the spritesheet */
  92274. cellWidth: number;
  92275. /** Defines the default height of a cell in the spritesheet */
  92276. cellHeight: number;
  92277. /** Associative array from JSON sprite data file */
  92278. private _cellData;
  92279. /** Array of sprite names from JSON sprite data file */
  92280. private _spriteMap;
  92281. /** True when packed cell data from JSON file is ready*/
  92282. private _packedAndReady;
  92283. private _textureContent;
  92284. private _useInstancing;
  92285. /**
  92286. * An event triggered when the manager is disposed.
  92287. */
  92288. onDisposeObservable: Observable<SpriteManager>;
  92289. private _onDisposeObserver;
  92290. /**
  92291. * Callback called when the manager is disposed
  92292. */
  92293. set onDispose(callback: () => void);
  92294. private _capacity;
  92295. private _fromPacked;
  92296. private _spriteTexture;
  92297. private _epsilon;
  92298. private _scene;
  92299. private _vertexData;
  92300. private _buffer;
  92301. private _vertexBuffers;
  92302. private _spriteBuffer;
  92303. private _indexBuffer;
  92304. private _effectBase;
  92305. private _effectFog;
  92306. private _vertexBufferSize;
  92307. /**
  92308. * Gets or sets the unique id of the sprite
  92309. */
  92310. uniqueId: number;
  92311. /**
  92312. * Gets the array of sprites
  92313. */
  92314. get children(): Sprite[];
  92315. /**
  92316. * Gets the hosting scene
  92317. */
  92318. get scene(): Scene;
  92319. /**
  92320. * Gets the capacity of the manager
  92321. */
  92322. get capacity(): number;
  92323. /**
  92324. * Gets or sets the spritesheet texture
  92325. */
  92326. get texture(): Texture;
  92327. set texture(value: Texture);
  92328. private _blendMode;
  92329. /**
  92330. * Blend mode use to render the particle, it can be any of
  92331. * the static Constants.ALPHA_x properties provided in this class.
  92332. * Default value is Constants.ALPHA_COMBINE
  92333. */
  92334. get blendMode(): number;
  92335. set blendMode(blendMode: number);
  92336. /** Disables writing to the depth buffer when rendering the sprites.
  92337. * It can be handy to disable depth writing when using textures without alpha channel
  92338. * and setting some specific blend modes.
  92339. */
  92340. disableDepthWrite: boolean;
  92341. /**
  92342. * Creates a new sprite manager
  92343. * @param name defines the manager's name
  92344. * @param imgUrl defines the sprite sheet url
  92345. * @param capacity defines the maximum allowed number of sprites
  92346. * @param cellSize defines the size of a sprite cell
  92347. * @param scene defines the hosting scene
  92348. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  92349. * @param samplingMode defines the smapling mode to use with spritesheet
  92350. * @param fromPacked set to false; do not alter
  92351. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  92352. */
  92353. constructor(
  92354. /** defines the manager's name */
  92355. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  92356. /**
  92357. * Returns the string "SpriteManager"
  92358. * @returns "SpriteManager"
  92359. */
  92360. getClassName(): string;
  92361. private _makePacked;
  92362. private _appendSpriteVertex;
  92363. private _checkTextureAlpha;
  92364. /**
  92365. * Intersects the sprites with a ray
  92366. * @param ray defines the ray to intersect with
  92367. * @param camera defines the current active camera
  92368. * @param predicate defines a predicate used to select candidate sprites
  92369. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  92370. * @returns null if no hit or a PickingInfo
  92371. */
  92372. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  92373. /**
  92374. * Intersects the sprites with a ray
  92375. * @param ray defines the ray to intersect with
  92376. * @param camera defines the current active camera
  92377. * @param predicate defines a predicate used to select candidate sprites
  92378. * @returns null if no hit or a PickingInfo array
  92379. */
  92380. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  92381. /**
  92382. * Render all child sprites
  92383. */
  92384. render(): void;
  92385. /**
  92386. * Release associated resources
  92387. */
  92388. dispose(): void;
  92389. /**
  92390. * Serializes the sprite manager to a JSON object
  92391. * @param serializeTexture defines if the texture must be serialized as well
  92392. * @returns the JSON object
  92393. */
  92394. serialize(serializeTexture?: boolean): any;
  92395. /**
  92396. * Parses a JSON object to create a new sprite manager.
  92397. * @param parsedManager The JSON object to parse
  92398. * @param scene The scene to create the sprite managerin
  92399. * @param rootUrl The root url to use to load external dependencies like texture
  92400. * @returns the new sprite manager
  92401. */
  92402. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  92403. /**
  92404. * Creates a sprite manager from a snippet saved in a remote file
  92405. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  92406. * @param url defines the url to load from
  92407. * @param scene defines the hosting scene
  92408. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92409. * @returns a promise that will resolve to the new sprite manager
  92410. */
  92411. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  92412. /**
  92413. * Creates a sprite manager from a snippet saved by the sprite editor
  92414. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  92415. * @param scene defines the hosting scene
  92416. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92417. * @returns a promise that will resolve to the new sprite manager
  92418. */
  92419. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  92420. }
  92421. }
  92422. declare module BABYLON {
  92423. /** Interface used by value gradients (color, factor, ...) */
  92424. export interface IValueGradient {
  92425. /**
  92426. * Gets or sets the gradient value (between 0 and 1)
  92427. */
  92428. gradient: number;
  92429. }
  92430. /** Class used to store color4 gradient */
  92431. export class ColorGradient implements IValueGradient {
  92432. /**
  92433. * Gets or sets the gradient value (between 0 and 1)
  92434. */
  92435. gradient: number;
  92436. /**
  92437. * Gets or sets first associated color
  92438. */
  92439. color1: Color4;
  92440. /**
  92441. * Gets or sets second associated color
  92442. */
  92443. color2?: Color4 | undefined;
  92444. /**
  92445. * Creates a new color4 gradient
  92446. * @param gradient gets or sets the gradient value (between 0 and 1)
  92447. * @param color1 gets or sets first associated color
  92448. * @param color2 gets or sets first second color
  92449. */
  92450. constructor(
  92451. /**
  92452. * Gets or sets the gradient value (between 0 and 1)
  92453. */
  92454. gradient: number,
  92455. /**
  92456. * Gets or sets first associated color
  92457. */
  92458. color1: Color4,
  92459. /**
  92460. * Gets or sets second associated color
  92461. */
  92462. color2?: Color4 | undefined);
  92463. /**
  92464. * Will get a color picked randomly between color1 and color2.
  92465. * If color2 is undefined then color1 will be used
  92466. * @param result defines the target Color4 to store the result in
  92467. */
  92468. getColorToRef(result: Color4): void;
  92469. }
  92470. /** Class used to store color 3 gradient */
  92471. export class Color3Gradient implements IValueGradient {
  92472. /**
  92473. * Gets or sets the gradient value (between 0 and 1)
  92474. */
  92475. gradient: number;
  92476. /**
  92477. * Gets or sets the associated color
  92478. */
  92479. color: Color3;
  92480. /**
  92481. * Creates a new color3 gradient
  92482. * @param gradient gets or sets the gradient value (between 0 and 1)
  92483. * @param color gets or sets associated color
  92484. */
  92485. constructor(
  92486. /**
  92487. * Gets or sets the gradient value (between 0 and 1)
  92488. */
  92489. gradient: number,
  92490. /**
  92491. * Gets or sets the associated color
  92492. */
  92493. color: Color3);
  92494. }
  92495. /** Class used to store factor gradient */
  92496. export class FactorGradient implements IValueGradient {
  92497. /**
  92498. * Gets or sets the gradient value (between 0 and 1)
  92499. */
  92500. gradient: number;
  92501. /**
  92502. * Gets or sets first associated factor
  92503. */
  92504. factor1: number;
  92505. /**
  92506. * Gets or sets second associated factor
  92507. */
  92508. factor2?: number | undefined;
  92509. /**
  92510. * Creates a new factor gradient
  92511. * @param gradient gets or sets the gradient value (between 0 and 1)
  92512. * @param factor1 gets or sets first associated factor
  92513. * @param factor2 gets or sets second associated factor
  92514. */
  92515. constructor(
  92516. /**
  92517. * Gets or sets the gradient value (between 0 and 1)
  92518. */
  92519. gradient: number,
  92520. /**
  92521. * Gets or sets first associated factor
  92522. */
  92523. factor1: number,
  92524. /**
  92525. * Gets or sets second associated factor
  92526. */
  92527. factor2?: number | undefined);
  92528. /**
  92529. * Will get a number picked randomly between factor1 and factor2.
  92530. * If factor2 is undefined then factor1 will be used
  92531. * @returns the picked number
  92532. */
  92533. getFactor(): number;
  92534. }
  92535. /**
  92536. * Helper used to simplify some generic gradient tasks
  92537. */
  92538. export class GradientHelper {
  92539. /**
  92540. * Gets the current gradient from an array of IValueGradient
  92541. * @param ratio defines the current ratio to get
  92542. * @param gradients defines the array of IValueGradient
  92543. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  92544. */
  92545. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  92546. }
  92547. }
  92548. declare module BABYLON {
  92549. interface ThinEngine {
  92550. /**
  92551. * Creates a raw texture
  92552. * @param data defines the data to store in the texture
  92553. * @param width defines the width of the texture
  92554. * @param height defines the height of the texture
  92555. * @param format defines the format of the data
  92556. * @param generateMipMaps defines if the engine should generate the mip levels
  92557. * @param invertY defines if data must be stored with Y axis inverted
  92558. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  92559. * @param compression defines the compression used (null by default)
  92560. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92561. * @returns the raw texture inside an InternalTexture
  92562. */
  92563. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  92564. /**
  92565. * Update a raw texture
  92566. * @param texture defines the texture to update
  92567. * @param data defines the data to store in the texture
  92568. * @param format defines the format of the data
  92569. * @param invertY defines if data must be stored with Y axis inverted
  92570. */
  92571. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92572. /**
  92573. * Update a raw texture
  92574. * @param texture defines the texture to update
  92575. * @param data defines the data to store in the texture
  92576. * @param format defines the format of the data
  92577. * @param invertY defines if data must be stored with Y axis inverted
  92578. * @param compression defines the compression used (null by default)
  92579. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92580. */
  92581. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  92582. /**
  92583. * Creates a new raw cube texture
  92584. * @param data defines the array of data to use to create each face
  92585. * @param size defines the size of the textures
  92586. * @param format defines the format of the data
  92587. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92588. * @param generateMipMaps defines if the engine should generate the mip levels
  92589. * @param invertY defines if data must be stored with Y axis inverted
  92590. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92591. * @param compression defines the compression used (null by default)
  92592. * @returns the cube texture as an InternalTexture
  92593. */
  92594. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  92595. /**
  92596. * Update a raw cube texture
  92597. * @param texture defines the texture to udpdate
  92598. * @param data defines the data to store
  92599. * @param format defines the data format
  92600. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92601. * @param invertY defines if data must be stored with Y axis inverted
  92602. */
  92603. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  92604. /**
  92605. * Update a raw cube texture
  92606. * @param texture defines the texture to udpdate
  92607. * @param data defines the data to store
  92608. * @param format defines the data format
  92609. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92610. * @param invertY defines if data must be stored with Y axis inverted
  92611. * @param compression defines the compression used (null by default)
  92612. */
  92613. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  92614. /**
  92615. * Update a raw cube texture
  92616. * @param texture defines the texture to udpdate
  92617. * @param data defines the data to store
  92618. * @param format defines the data format
  92619. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92620. * @param invertY defines if data must be stored with Y axis inverted
  92621. * @param compression defines the compression used (null by default)
  92622. * @param level defines which level of the texture to update
  92623. */
  92624. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  92625. /**
  92626. * Creates a new raw cube texture from a specified url
  92627. * @param url defines the url where the data is located
  92628. * @param scene defines the current scene
  92629. * @param size defines the size of the textures
  92630. * @param format defines the format of the data
  92631. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92632. * @param noMipmap defines if the engine should avoid generating the mip levels
  92633. * @param callback defines a callback used to extract texture data from loaded data
  92634. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92635. * @param onLoad defines a callback called when texture is loaded
  92636. * @param onError defines a callback called if there is an error
  92637. * @returns the cube texture as an InternalTexture
  92638. */
  92639. 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;
  92640. /**
  92641. * Creates a new raw cube texture from a specified url
  92642. * @param url defines the url where the data is located
  92643. * @param scene defines the current scene
  92644. * @param size defines the size of the textures
  92645. * @param format defines the format of the data
  92646. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92647. * @param noMipmap defines if the engine should avoid generating the mip levels
  92648. * @param callback defines a callback used to extract texture data from loaded data
  92649. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92650. * @param onLoad defines a callback called when texture is loaded
  92651. * @param onError defines a callback called if there is an error
  92652. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92653. * @param invertY defines if data must be stored with Y axis inverted
  92654. * @returns the cube texture as an InternalTexture
  92655. */
  92656. 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;
  92657. /**
  92658. * Creates a new raw 3D texture
  92659. * @param data defines the data used to create the texture
  92660. * @param width defines the width of the texture
  92661. * @param height defines the height of the texture
  92662. * @param depth defines the depth of the texture
  92663. * @param format defines the format of the texture
  92664. * @param generateMipMaps defines if the engine must generate mip levels
  92665. * @param invertY defines if data must be stored with Y axis inverted
  92666. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92667. * @param compression defines the compressed used (can be null)
  92668. * @param textureType defines the compressed used (can be null)
  92669. * @returns a new raw 3D texture (stored in an InternalTexture)
  92670. */
  92671. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92672. /**
  92673. * Update a raw 3D texture
  92674. * @param texture defines the texture to update
  92675. * @param data defines the data to store
  92676. * @param format defines the data format
  92677. * @param invertY defines if data must be stored with Y axis inverted
  92678. */
  92679. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92680. /**
  92681. * Update a raw 3D texture
  92682. * @param texture defines the texture to update
  92683. * @param data defines the data to store
  92684. * @param format defines the data format
  92685. * @param invertY defines if data must be stored with Y axis inverted
  92686. * @param compression defines the used compression (can be null)
  92687. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92688. */
  92689. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92690. /**
  92691. * Creates a new raw 2D array texture
  92692. * @param data defines the data used to create the texture
  92693. * @param width defines the width of the texture
  92694. * @param height defines the height of the texture
  92695. * @param depth defines the number of layers of the texture
  92696. * @param format defines the format of the texture
  92697. * @param generateMipMaps defines if the engine must generate mip levels
  92698. * @param invertY defines if data must be stored with Y axis inverted
  92699. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92700. * @param compression defines the compressed used (can be null)
  92701. * @param textureType defines the compressed used (can be null)
  92702. * @returns a new raw 2D array texture (stored in an InternalTexture)
  92703. */
  92704. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92705. /**
  92706. * Update a raw 2D array texture
  92707. * @param texture defines the texture to update
  92708. * @param data defines the data to store
  92709. * @param format defines the data format
  92710. * @param invertY defines if data must be stored with Y axis inverted
  92711. */
  92712. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92713. /**
  92714. * Update a raw 2D array texture
  92715. * @param texture defines the texture to update
  92716. * @param data defines the data to store
  92717. * @param format defines the data format
  92718. * @param invertY defines if data must be stored with Y axis inverted
  92719. * @param compression defines the used compression (can be null)
  92720. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92721. */
  92722. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92723. }
  92724. }
  92725. declare module BABYLON {
  92726. /**
  92727. * Raw texture can help creating a texture directly from an array of data.
  92728. * This can be super useful if you either get the data from an uncompressed source or
  92729. * if you wish to create your texture pixel by pixel.
  92730. */
  92731. export class RawTexture extends Texture {
  92732. /**
  92733. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92734. */
  92735. format: number;
  92736. /**
  92737. * Instantiates a new RawTexture.
  92738. * Raw texture can help creating a texture directly from an array of data.
  92739. * This can be super useful if you either get the data from an uncompressed source or
  92740. * if you wish to create your texture pixel by pixel.
  92741. * @param data define the array of data to use to create the texture
  92742. * @param width define the width of the texture
  92743. * @param height define the height of the texture
  92744. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92745. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92746. * @param generateMipMaps define whether mip maps should be generated or not
  92747. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92748. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92749. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92750. */
  92751. constructor(data: ArrayBufferView, width: number, height: number,
  92752. /**
  92753. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92754. */
  92755. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  92756. /**
  92757. * Updates the texture underlying data.
  92758. * @param data Define the new data of the texture
  92759. */
  92760. update(data: ArrayBufferView): void;
  92761. /**
  92762. * Creates a luminance texture from some data.
  92763. * @param data Define the texture data
  92764. * @param width Define the width of the texture
  92765. * @param height Define the height of the texture
  92766. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92767. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92768. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92769. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92770. * @returns the luminance texture
  92771. */
  92772. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92773. /**
  92774. * Creates a luminance alpha texture from some data.
  92775. * @param data Define the texture data
  92776. * @param width Define the width of the texture
  92777. * @param height Define the height of the texture
  92778. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92779. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92780. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92781. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92782. * @returns the luminance alpha texture
  92783. */
  92784. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92785. /**
  92786. * Creates an alpha texture from some data.
  92787. * @param data Define the texture data
  92788. * @param width Define the width of the texture
  92789. * @param height Define the height of the texture
  92790. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92791. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92792. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92793. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92794. * @returns the alpha texture
  92795. */
  92796. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92797. /**
  92798. * Creates a RGB texture from some data.
  92799. * @param data Define the texture data
  92800. * @param width Define the width of the texture
  92801. * @param height Define the height of the texture
  92802. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92803. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92804. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92805. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92806. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92807. * @returns the RGB alpha texture
  92808. */
  92809. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92810. /**
  92811. * Creates a RGBA texture from some data.
  92812. * @param data Define the texture data
  92813. * @param width Define the width of the texture
  92814. * @param height Define the height of the texture
  92815. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92816. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92817. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92818. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92819. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92820. * @returns the RGBA texture
  92821. */
  92822. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92823. /**
  92824. * Creates a R texture from some data.
  92825. * @param data Define the texture data
  92826. * @param width Define the width of the texture
  92827. * @param height Define the height of the texture
  92828. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92829. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92832. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92833. * @returns the R texture
  92834. */
  92835. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92836. }
  92837. }
  92838. declare module BABYLON {
  92839. interface ThinEngine {
  92840. /**
  92841. * Update a dynamic index buffer
  92842. * @param indexBuffer defines the target index buffer
  92843. * @param indices defines the data to update
  92844. * @param offset defines the offset in the target index buffer where update should start
  92845. */
  92846. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  92847. /**
  92848. * Updates a dynamic vertex buffer.
  92849. * @param vertexBuffer the vertex buffer to update
  92850. * @param data the data used to update the vertex buffer
  92851. * @param byteOffset the byte offset of the data
  92852. * @param byteLength the byte length of the data
  92853. */
  92854. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  92855. }
  92856. }
  92857. declare module BABYLON {
  92858. interface AbstractScene {
  92859. /**
  92860. * The list of procedural textures added to the scene
  92861. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92862. */
  92863. proceduralTextures: Array<ProceduralTexture>;
  92864. }
  92865. /**
  92866. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  92867. * in a given scene.
  92868. */
  92869. export class ProceduralTextureSceneComponent implements ISceneComponent {
  92870. /**
  92871. * The component name helpfull to identify the component in the list of scene components.
  92872. */
  92873. readonly name: string;
  92874. /**
  92875. * The scene the component belongs to.
  92876. */
  92877. scene: Scene;
  92878. /**
  92879. * Creates a new instance of the component for the given scene
  92880. * @param scene Defines the scene to register the component in
  92881. */
  92882. constructor(scene: Scene);
  92883. /**
  92884. * Registers the component in a given scene
  92885. */
  92886. register(): void;
  92887. /**
  92888. * Rebuilds the elements related to this component in case of
  92889. * context lost for instance.
  92890. */
  92891. rebuild(): void;
  92892. /**
  92893. * Disposes the component and the associated ressources.
  92894. */
  92895. dispose(): void;
  92896. private _beforeClear;
  92897. }
  92898. }
  92899. declare module BABYLON {
  92900. interface ThinEngine {
  92901. /**
  92902. * Creates a new render target cube texture
  92903. * @param size defines the size of the texture
  92904. * @param options defines the options used to create the texture
  92905. * @returns a new render target cube texture stored in an InternalTexture
  92906. */
  92907. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92908. }
  92909. }
  92910. declare module BABYLON {
  92911. /** @hidden */
  92912. export var proceduralVertexShader: {
  92913. name: string;
  92914. shader: string;
  92915. };
  92916. }
  92917. declare module BABYLON {
  92918. /**
  92919. * 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.
  92920. * This is the base class of any Procedural texture and contains most of the shareable code.
  92921. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92922. */
  92923. export class ProceduralTexture extends Texture {
  92924. /**
  92925. * Define if the texture is enabled or not (disabled texture will not render)
  92926. */
  92927. isEnabled: boolean;
  92928. /**
  92929. * Define if the texture must be cleared before rendering (default is true)
  92930. */
  92931. autoClear: boolean;
  92932. /**
  92933. * Callback called when the texture is generated
  92934. */
  92935. onGenerated: () => void;
  92936. /**
  92937. * Event raised when the texture is generated
  92938. */
  92939. onGeneratedObservable: Observable<ProceduralTexture>;
  92940. /**
  92941. * Event raised before the texture is generated
  92942. */
  92943. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92944. /**
  92945. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92946. */
  92947. nodeMaterialSource: Nullable<NodeMaterial>;
  92948. /** @hidden */
  92949. _generateMipMaps: boolean;
  92950. /** @hidden **/
  92951. _effect: Effect;
  92952. /** @hidden */
  92953. _textures: {
  92954. [key: string]: Texture;
  92955. };
  92956. /** @hidden */
  92957. protected _fallbackTexture: Nullable<Texture>;
  92958. private _size;
  92959. private _currentRefreshId;
  92960. private _frameId;
  92961. private _refreshRate;
  92962. private _vertexBuffers;
  92963. private _indexBuffer;
  92964. private _uniforms;
  92965. private _samplers;
  92966. private _fragment;
  92967. private _floats;
  92968. private _ints;
  92969. private _floatsArrays;
  92970. private _colors3;
  92971. private _colors4;
  92972. private _vectors2;
  92973. private _vectors3;
  92974. private _matrices;
  92975. private _fallbackTextureUsed;
  92976. private _fullEngine;
  92977. private _cachedDefines;
  92978. private _contentUpdateId;
  92979. private _contentData;
  92980. /**
  92981. * Instantiates a new procedural texture.
  92982. * 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.
  92983. * This is the base class of any Procedural texture and contains most of the shareable code.
  92984. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92985. * @param name Define the name of the texture
  92986. * @param size Define the size of the texture to create
  92987. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92988. * @param scene Define the scene the texture belongs to
  92989. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92990. * @param generateMipMaps Define if the texture should creates mip maps or not
  92991. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92992. * @param textureType The FBO internal texture type
  92993. */
  92994. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  92995. /**
  92996. * The effect that is created when initializing the post process.
  92997. * @returns The created effect corresponding the the postprocess.
  92998. */
  92999. getEffect(): Effect;
  93000. /**
  93001. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  93002. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  93003. */
  93004. getContent(): Nullable<ArrayBufferView>;
  93005. private _createIndexBuffer;
  93006. /** @hidden */
  93007. _rebuild(): void;
  93008. /**
  93009. * Resets the texture in order to recreate its associated resources.
  93010. * This can be called in case of context loss
  93011. */
  93012. reset(): void;
  93013. protected _getDefines(): string;
  93014. /**
  93015. * Is the texture ready to be used ? (rendered at least once)
  93016. * @returns true if ready, otherwise, false.
  93017. */
  93018. isReady(): boolean;
  93019. /**
  93020. * Resets the refresh counter of the texture and start bak from scratch.
  93021. * Could be useful to regenerate the texture if it is setup to render only once.
  93022. */
  93023. resetRefreshCounter(): void;
  93024. /**
  93025. * Set the fragment shader to use in order to render the texture.
  93026. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  93027. */
  93028. setFragment(fragment: any): void;
  93029. /**
  93030. * Define the refresh rate of the texture or the rendering frequency.
  93031. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93032. */
  93033. get refreshRate(): number;
  93034. set refreshRate(value: number);
  93035. /** @hidden */
  93036. _shouldRender(): boolean;
  93037. /**
  93038. * Get the size the texture is rendering at.
  93039. * @returns the size (on cube texture it is always squared)
  93040. */
  93041. getRenderSize(): RenderTargetTextureSize;
  93042. /**
  93043. * Resize the texture to new value.
  93044. * @param size Define the new size the texture should have
  93045. * @param generateMipMaps Define whether the new texture should create mip maps
  93046. */
  93047. resize(size: number, generateMipMaps: boolean): void;
  93048. private _checkUniform;
  93049. /**
  93050. * Set a texture in the shader program used to render.
  93051. * @param name Define the name of the uniform samplers as defined in the shader
  93052. * @param texture Define the texture to bind to this sampler
  93053. * @return the texture itself allowing "fluent" like uniform updates
  93054. */
  93055. setTexture(name: string, texture: Texture): ProceduralTexture;
  93056. /**
  93057. * Set a float in the shader.
  93058. * @param name Define the name of the uniform as defined in the shader
  93059. * @param value Define the value to give to the uniform
  93060. * @return the texture itself allowing "fluent" like uniform updates
  93061. */
  93062. setFloat(name: string, value: number): ProceduralTexture;
  93063. /**
  93064. * Set a int in the shader.
  93065. * @param name Define the name of the uniform as defined in the shader
  93066. * @param value Define the value to give to the uniform
  93067. * @return the texture itself allowing "fluent" like uniform updates
  93068. */
  93069. setInt(name: string, value: number): ProceduralTexture;
  93070. /**
  93071. * Set an array of floats in the shader.
  93072. * @param name Define the name of the uniform as defined in the shader
  93073. * @param value Define the value to give to the uniform
  93074. * @return the texture itself allowing "fluent" like uniform updates
  93075. */
  93076. setFloats(name: string, value: number[]): ProceduralTexture;
  93077. /**
  93078. * Set a vec3 in the shader from a Color3.
  93079. * @param name Define the name of the uniform as defined in the shader
  93080. * @param value Define the value to give to the uniform
  93081. * @return the texture itself allowing "fluent" like uniform updates
  93082. */
  93083. setColor3(name: string, value: Color3): ProceduralTexture;
  93084. /**
  93085. * Set a vec4 in the shader from a Color4.
  93086. * @param name Define the name of the uniform as defined in the shader
  93087. * @param value Define the value to give to the uniform
  93088. * @return the texture itself allowing "fluent" like uniform updates
  93089. */
  93090. setColor4(name: string, value: Color4): ProceduralTexture;
  93091. /**
  93092. * Set a vec2 in the shader from a Vector2.
  93093. * @param name Define the name of the uniform as defined in the shader
  93094. * @param value Define the value to give to the uniform
  93095. * @return the texture itself allowing "fluent" like uniform updates
  93096. */
  93097. setVector2(name: string, value: Vector2): ProceduralTexture;
  93098. /**
  93099. * Set a vec3 in the shader from a Vector3.
  93100. * @param name Define the name of the uniform as defined in the shader
  93101. * @param value Define the value to give to the uniform
  93102. * @return the texture itself allowing "fluent" like uniform updates
  93103. */
  93104. setVector3(name: string, value: Vector3): ProceduralTexture;
  93105. /**
  93106. * Set a mat4 in the shader from a MAtrix.
  93107. * @param name Define the name of the uniform as defined in the shader
  93108. * @param value Define the value to give to the uniform
  93109. * @return the texture itself allowing "fluent" like uniform updates
  93110. */
  93111. setMatrix(name: string, value: Matrix): ProceduralTexture;
  93112. /**
  93113. * Render the texture to its associated render target.
  93114. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  93115. */
  93116. render(useCameraPostProcess?: boolean): void;
  93117. /**
  93118. * Clone the texture.
  93119. * @returns the cloned texture
  93120. */
  93121. clone(): ProceduralTexture;
  93122. /**
  93123. * Dispose the texture and release its asoociated resources.
  93124. */
  93125. dispose(): void;
  93126. }
  93127. }
  93128. declare module BABYLON {
  93129. /**
  93130. * This represents the base class for particle system in Babylon.
  93131. * 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.
  93132. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93133. * @example https://doc.babylonjs.com/babylon101/particles
  93134. */
  93135. export class BaseParticleSystem {
  93136. /**
  93137. * Source color is added to the destination color without alpha affecting the result
  93138. */
  93139. static BLENDMODE_ONEONE: number;
  93140. /**
  93141. * Blend current color and particle color using particle’s alpha
  93142. */
  93143. static BLENDMODE_STANDARD: number;
  93144. /**
  93145. * Add current color and particle color multiplied by particle’s alpha
  93146. */
  93147. static BLENDMODE_ADD: number;
  93148. /**
  93149. * Multiply current color with particle color
  93150. */
  93151. static BLENDMODE_MULTIPLY: number;
  93152. /**
  93153. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  93154. */
  93155. static BLENDMODE_MULTIPLYADD: number;
  93156. /**
  93157. * List of animations used by the particle system.
  93158. */
  93159. animations: Animation[];
  93160. /**
  93161. * Gets or sets the unique id of the particle system
  93162. */
  93163. uniqueId: number;
  93164. /**
  93165. * The id of the Particle system.
  93166. */
  93167. id: string;
  93168. /**
  93169. * The friendly name of the Particle system.
  93170. */
  93171. name: string;
  93172. /**
  93173. * Snippet ID if the particle system was created from the snippet server
  93174. */
  93175. snippetId: string;
  93176. /**
  93177. * The rendering group used by the Particle system to chose when to render.
  93178. */
  93179. renderingGroupId: number;
  93180. /**
  93181. * The emitter represents the Mesh or position we are attaching the particle system to.
  93182. */
  93183. emitter: Nullable<AbstractMesh | Vector3>;
  93184. /**
  93185. * The maximum number of particles to emit per frame
  93186. */
  93187. emitRate: number;
  93188. /**
  93189. * If you want to launch only a few particles at once, that can be done, as well.
  93190. */
  93191. manualEmitCount: number;
  93192. /**
  93193. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  93194. */
  93195. updateSpeed: number;
  93196. /**
  93197. * The amount of time the particle system is running (depends of the overall update speed).
  93198. */
  93199. targetStopDuration: number;
  93200. /**
  93201. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  93202. */
  93203. disposeOnStop: boolean;
  93204. /**
  93205. * Minimum power of emitting particles.
  93206. */
  93207. minEmitPower: number;
  93208. /**
  93209. * Maximum power of emitting particles.
  93210. */
  93211. maxEmitPower: number;
  93212. /**
  93213. * Minimum life time of emitting particles.
  93214. */
  93215. minLifeTime: number;
  93216. /**
  93217. * Maximum life time of emitting particles.
  93218. */
  93219. maxLifeTime: number;
  93220. /**
  93221. * Minimum Size of emitting particles.
  93222. */
  93223. minSize: number;
  93224. /**
  93225. * Maximum Size of emitting particles.
  93226. */
  93227. maxSize: number;
  93228. /**
  93229. * Minimum scale of emitting particles on X axis.
  93230. */
  93231. minScaleX: number;
  93232. /**
  93233. * Maximum scale of emitting particles on X axis.
  93234. */
  93235. maxScaleX: number;
  93236. /**
  93237. * Minimum scale of emitting particles on Y axis.
  93238. */
  93239. minScaleY: number;
  93240. /**
  93241. * Maximum scale of emitting particles on Y axis.
  93242. */
  93243. maxScaleY: number;
  93244. /**
  93245. * Gets or sets the minimal initial rotation in radians.
  93246. */
  93247. minInitialRotation: number;
  93248. /**
  93249. * Gets or sets the maximal initial rotation in radians.
  93250. */
  93251. maxInitialRotation: number;
  93252. /**
  93253. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  93254. */
  93255. minAngularSpeed: number;
  93256. /**
  93257. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  93258. */
  93259. maxAngularSpeed: number;
  93260. /**
  93261. * The texture used to render each particle. (this can be a spritesheet)
  93262. */
  93263. particleTexture: Nullable<BaseTexture>;
  93264. /**
  93265. * The layer mask we are rendering the particles through.
  93266. */
  93267. layerMask: number;
  93268. /**
  93269. * This can help using your own shader to render the particle system.
  93270. * The according effect will be created
  93271. */
  93272. customShader: any;
  93273. /**
  93274. * By default particle system starts as soon as they are created. This prevents the
  93275. * automatic start to happen and let you decide when to start emitting particles.
  93276. */
  93277. preventAutoStart: boolean;
  93278. private _noiseTexture;
  93279. /**
  93280. * Gets or sets a texture used to add random noise to particle positions
  93281. */
  93282. get noiseTexture(): Nullable<ProceduralTexture>;
  93283. set noiseTexture(value: Nullable<ProceduralTexture>);
  93284. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  93285. noiseStrength: Vector3;
  93286. /**
  93287. * Callback triggered when the particle animation is ending.
  93288. */
  93289. onAnimationEnd: Nullable<() => void>;
  93290. /**
  93291. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  93292. */
  93293. blendMode: number;
  93294. /**
  93295. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  93296. * to override the particles.
  93297. */
  93298. forceDepthWrite: boolean;
  93299. /** 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 */
  93300. preWarmCycles: number;
  93301. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  93302. preWarmStepOffset: number;
  93303. /**
  93304. * 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)
  93305. */
  93306. spriteCellChangeSpeed: number;
  93307. /**
  93308. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  93309. */
  93310. startSpriteCellID: number;
  93311. /**
  93312. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  93313. */
  93314. endSpriteCellID: number;
  93315. /**
  93316. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  93317. */
  93318. spriteCellWidth: number;
  93319. /**
  93320. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  93321. */
  93322. spriteCellHeight: number;
  93323. /**
  93324. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  93325. */
  93326. spriteRandomStartCell: boolean;
  93327. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  93328. translationPivot: Vector2;
  93329. /** @hidden */
  93330. protected _isAnimationSheetEnabled: boolean;
  93331. /**
  93332. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  93333. */
  93334. beginAnimationOnStart: boolean;
  93335. /**
  93336. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  93337. */
  93338. beginAnimationFrom: number;
  93339. /**
  93340. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  93341. */
  93342. beginAnimationTo: number;
  93343. /**
  93344. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  93345. */
  93346. beginAnimationLoop: boolean;
  93347. /**
  93348. * Gets or sets a world offset applied to all particles
  93349. */
  93350. worldOffset: Vector3;
  93351. /**
  93352. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  93353. */
  93354. get isAnimationSheetEnabled(): boolean;
  93355. set isAnimationSheetEnabled(value: boolean);
  93356. /**
  93357. * Get hosting scene
  93358. * @returns the scene
  93359. */
  93360. getScene(): Nullable<Scene>;
  93361. /**
  93362. * You can use gravity if you want to give an orientation to your particles.
  93363. */
  93364. gravity: Vector3;
  93365. protected _colorGradients: Nullable<Array<ColorGradient>>;
  93366. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  93367. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  93368. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  93369. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  93370. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  93371. protected _dragGradients: Nullable<Array<FactorGradient>>;
  93372. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  93373. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  93374. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  93375. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  93376. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  93377. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  93378. /**
  93379. * Defines the delay in milliseconds before starting the system (0 by default)
  93380. */
  93381. startDelay: number;
  93382. /**
  93383. * Gets the current list of drag gradients.
  93384. * You must use addDragGradient and removeDragGradient to udpate this list
  93385. * @returns the list of drag gradients
  93386. */
  93387. getDragGradients(): Nullable<Array<FactorGradient>>;
  93388. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  93389. limitVelocityDamping: number;
  93390. /**
  93391. * Gets the current list of limit velocity gradients.
  93392. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  93393. * @returns the list of limit velocity gradients
  93394. */
  93395. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  93396. /**
  93397. * Gets the current list of color gradients.
  93398. * You must use addColorGradient and removeColorGradient to udpate this list
  93399. * @returns the list of color gradients
  93400. */
  93401. getColorGradients(): Nullable<Array<ColorGradient>>;
  93402. /**
  93403. * Gets the current list of size gradients.
  93404. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93405. * @returns the list of size gradients
  93406. */
  93407. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93408. /**
  93409. * Gets the current list of color remap gradients.
  93410. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93411. * @returns the list of color remap gradients
  93412. */
  93413. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93414. /**
  93415. * Gets the current list of alpha remap gradients.
  93416. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93417. * @returns the list of alpha remap gradients
  93418. */
  93419. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93420. /**
  93421. * Gets the current list of life time gradients.
  93422. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93423. * @returns the list of life time gradients
  93424. */
  93425. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93426. /**
  93427. * Gets the current list of angular speed gradients.
  93428. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93429. * @returns the list of angular speed gradients
  93430. */
  93431. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93432. /**
  93433. * Gets the current list of velocity gradients.
  93434. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93435. * @returns the list of velocity gradients
  93436. */
  93437. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93438. /**
  93439. * Gets the current list of start size gradients.
  93440. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93441. * @returns the list of start size gradients
  93442. */
  93443. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93444. /**
  93445. * Gets the current list of emit rate gradients.
  93446. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  93447. * @returns the list of emit rate gradients
  93448. */
  93449. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  93450. /**
  93451. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93452. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93453. */
  93454. get direction1(): Vector3;
  93455. set direction1(value: Vector3);
  93456. /**
  93457. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93458. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93459. */
  93460. get direction2(): Vector3;
  93461. set direction2(value: Vector3);
  93462. /**
  93463. * 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.
  93464. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93465. */
  93466. get minEmitBox(): Vector3;
  93467. set minEmitBox(value: Vector3);
  93468. /**
  93469. * 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.
  93470. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93471. */
  93472. get maxEmitBox(): Vector3;
  93473. set maxEmitBox(value: Vector3);
  93474. /**
  93475. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93476. */
  93477. color1: Color4;
  93478. /**
  93479. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93480. */
  93481. color2: Color4;
  93482. /**
  93483. * Color the particle will have at the end of its lifetime
  93484. */
  93485. colorDead: Color4;
  93486. /**
  93487. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  93488. */
  93489. textureMask: Color4;
  93490. /**
  93491. * The particle emitter type defines the emitter used by the particle system.
  93492. * It can be for example box, sphere, or cone...
  93493. */
  93494. particleEmitterType: IParticleEmitterType;
  93495. /** @hidden */
  93496. _isSubEmitter: boolean;
  93497. /**
  93498. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93499. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93500. */
  93501. billboardMode: number;
  93502. protected _isBillboardBased: boolean;
  93503. /**
  93504. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93505. */
  93506. get isBillboardBased(): boolean;
  93507. set isBillboardBased(value: boolean);
  93508. /**
  93509. * The scene the particle system belongs to.
  93510. */
  93511. protected _scene: Nullable<Scene>;
  93512. /**
  93513. * The engine the particle system belongs to.
  93514. */
  93515. protected _engine: ThinEngine;
  93516. /**
  93517. * Local cache of defines for image processing.
  93518. */
  93519. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  93520. /**
  93521. * Default configuration related to image processing available in the standard Material.
  93522. */
  93523. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  93524. /**
  93525. * Gets the image processing configuration used either in this material.
  93526. */
  93527. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  93528. /**
  93529. * Sets the Default image processing configuration used either in the this material.
  93530. *
  93531. * If sets to null, the scene one is in use.
  93532. */
  93533. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  93534. /**
  93535. * Attaches a new image processing configuration to the Standard Material.
  93536. * @param configuration
  93537. */
  93538. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  93539. /** @hidden */
  93540. protected _reset(): void;
  93541. /** @hidden */
  93542. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  93543. /**
  93544. * Instantiates a particle system.
  93545. * 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.
  93546. * @param name The name of the particle system
  93547. */
  93548. constructor(name: string);
  93549. /**
  93550. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93551. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93552. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93553. * @returns the emitter
  93554. */
  93555. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93556. /**
  93557. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93558. * @param radius The radius of the hemisphere to emit from
  93559. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93560. * @returns the emitter
  93561. */
  93562. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  93563. /**
  93564. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93565. * @param radius The radius of the sphere to emit from
  93566. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93567. * @returns the emitter
  93568. */
  93569. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  93570. /**
  93571. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93572. * @param radius The radius of the sphere to emit from
  93573. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93574. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93575. * @returns the emitter
  93576. */
  93577. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  93578. /**
  93579. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93580. * @param radius The radius of the emission cylinder
  93581. * @param height The height of the emission cylinder
  93582. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93583. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93584. * @returns the emitter
  93585. */
  93586. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  93587. /**
  93588. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93589. * @param radius The radius of the cylinder to emit from
  93590. * @param height The height of the emission cylinder
  93591. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93592. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93593. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93594. * @returns the emitter
  93595. */
  93596. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  93597. /**
  93598. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93599. * @param radius The radius of the cone to emit from
  93600. * @param angle The base angle of the cone
  93601. * @returns the emitter
  93602. */
  93603. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  93604. /**
  93605. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93606. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93607. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93608. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93609. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93610. * @returns the emitter
  93611. */
  93612. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93613. }
  93614. }
  93615. declare module BABYLON {
  93616. /**
  93617. * Type of sub emitter
  93618. */
  93619. export enum SubEmitterType {
  93620. /**
  93621. * Attached to the particle over it's lifetime
  93622. */
  93623. ATTACHED = 0,
  93624. /**
  93625. * Created when the particle dies
  93626. */
  93627. END = 1
  93628. }
  93629. /**
  93630. * Sub emitter class used to emit particles from an existing particle
  93631. */
  93632. export class SubEmitter {
  93633. /**
  93634. * the particle system to be used by the sub emitter
  93635. */
  93636. particleSystem: ParticleSystem;
  93637. /**
  93638. * Type of the submitter (Default: END)
  93639. */
  93640. type: SubEmitterType;
  93641. /**
  93642. * 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)
  93643. * Note: This only is supported when using an emitter of type Mesh
  93644. */
  93645. inheritDirection: boolean;
  93646. /**
  93647. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  93648. */
  93649. inheritedVelocityAmount: number;
  93650. /**
  93651. * Creates a sub emitter
  93652. * @param particleSystem the particle system to be used by the sub emitter
  93653. */
  93654. constructor(
  93655. /**
  93656. * the particle system to be used by the sub emitter
  93657. */
  93658. particleSystem: ParticleSystem);
  93659. /**
  93660. * Clones the sub emitter
  93661. * @returns the cloned sub emitter
  93662. */
  93663. clone(): SubEmitter;
  93664. /**
  93665. * Serialize current object to a JSON object
  93666. * @returns the serialized object
  93667. */
  93668. serialize(): any;
  93669. /** @hidden */
  93670. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  93671. /**
  93672. * Creates a new SubEmitter from a serialized JSON version
  93673. * @param serializationObject defines the JSON object to read from
  93674. * @param sceneOrEngine defines the hosting scene or the hosting engine
  93675. * @param rootUrl defines the rootUrl for data loading
  93676. * @returns a new SubEmitter
  93677. */
  93678. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  93679. /** Release associated resources */
  93680. dispose(): void;
  93681. }
  93682. }
  93683. declare module BABYLON {
  93684. /** @hidden */
  93685. export var imageProcessingDeclaration: {
  93686. name: string;
  93687. shader: string;
  93688. };
  93689. }
  93690. declare module BABYLON {
  93691. /** @hidden */
  93692. export var imageProcessingFunctions: {
  93693. name: string;
  93694. shader: string;
  93695. };
  93696. }
  93697. declare module BABYLON {
  93698. /** @hidden */
  93699. export var particlesPixelShader: {
  93700. name: string;
  93701. shader: string;
  93702. };
  93703. }
  93704. declare module BABYLON {
  93705. /** @hidden */
  93706. export var particlesVertexShader: {
  93707. name: string;
  93708. shader: string;
  93709. };
  93710. }
  93711. declare module BABYLON {
  93712. /**
  93713. * Interface used to define entities containing multiple clip planes
  93714. */
  93715. export interface IClipPlanesHolder {
  93716. /**
  93717. * Gets or sets the active clipplane 1
  93718. */
  93719. clipPlane: Nullable<Plane>;
  93720. /**
  93721. * Gets or sets the active clipplane 2
  93722. */
  93723. clipPlane2: Nullable<Plane>;
  93724. /**
  93725. * Gets or sets the active clipplane 3
  93726. */
  93727. clipPlane3: Nullable<Plane>;
  93728. /**
  93729. * Gets or sets the active clipplane 4
  93730. */
  93731. clipPlane4: Nullable<Plane>;
  93732. /**
  93733. * Gets or sets the active clipplane 5
  93734. */
  93735. clipPlane5: Nullable<Plane>;
  93736. /**
  93737. * Gets or sets the active clipplane 6
  93738. */
  93739. clipPlane6: Nullable<Plane>;
  93740. }
  93741. }
  93742. declare module BABYLON {
  93743. /**
  93744. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  93745. *
  93746. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  93747. *
  93748. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  93749. */
  93750. export class ThinMaterialHelper {
  93751. /**
  93752. * Binds the clip plane information from the holder to the effect.
  93753. * @param effect The effect we are binding the data to
  93754. * @param holder The entity containing the clip plane information
  93755. */
  93756. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  93757. }
  93758. }
  93759. declare module BABYLON {
  93760. interface ThinEngine {
  93761. /**
  93762. * Sets alpha constants used by some alpha blending modes
  93763. * @param r defines the red component
  93764. * @param g defines the green component
  93765. * @param b defines the blue component
  93766. * @param a defines the alpha component
  93767. */
  93768. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  93769. /**
  93770. * Sets the current alpha mode
  93771. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  93772. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  93773. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93774. */
  93775. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  93776. /**
  93777. * Gets the current alpha mode
  93778. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93779. * @returns the current alpha mode
  93780. */
  93781. getAlphaMode(): number;
  93782. /**
  93783. * Sets the current alpha equation
  93784. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  93785. */
  93786. setAlphaEquation(equation: number): void;
  93787. /**
  93788. * Gets the current alpha equation.
  93789. * @returns the current alpha equation
  93790. */
  93791. getAlphaEquation(): number;
  93792. }
  93793. }
  93794. declare module BABYLON {
  93795. /**
  93796. * This represents a particle system in Babylon.
  93797. * 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.
  93798. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93799. * @example https://doc.babylonjs.com/babylon101/particles
  93800. */
  93801. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  93802. /**
  93803. * Billboard mode will only apply to Y axis
  93804. */
  93805. static readonly BILLBOARDMODE_Y: number;
  93806. /**
  93807. * Billboard mode will apply to all axes
  93808. */
  93809. static readonly BILLBOARDMODE_ALL: number;
  93810. /**
  93811. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  93812. */
  93813. static readonly BILLBOARDMODE_STRETCHED: number;
  93814. /**
  93815. * This function can be defined to provide custom update for active particles.
  93816. * This function will be called instead of regular update (age, position, color, etc.).
  93817. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  93818. */
  93819. updateFunction: (particles: Particle[]) => void;
  93820. private _emitterWorldMatrix;
  93821. /**
  93822. * This function can be defined to specify initial direction for every new particle.
  93823. * It by default use the emitterType defined function
  93824. */
  93825. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93826. /**
  93827. * This function can be defined to specify initial position for every new particle.
  93828. * It by default use the emitterType defined function
  93829. */
  93830. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93831. /**
  93832. * @hidden
  93833. */
  93834. _inheritedVelocityOffset: Vector3;
  93835. /**
  93836. * An event triggered when the system is disposed
  93837. */
  93838. onDisposeObservable: Observable<IParticleSystem>;
  93839. /**
  93840. * An event triggered when the system is stopped
  93841. */
  93842. onStoppedObservable: Observable<IParticleSystem>;
  93843. private _onDisposeObserver;
  93844. /**
  93845. * Sets a callback that will be triggered when the system is disposed
  93846. */
  93847. set onDispose(callback: () => void);
  93848. private _particles;
  93849. private _epsilon;
  93850. private _capacity;
  93851. private _stockParticles;
  93852. private _newPartsExcess;
  93853. private _vertexData;
  93854. private _vertexBuffer;
  93855. private _vertexBuffers;
  93856. private _spriteBuffer;
  93857. private _indexBuffer;
  93858. private _effect;
  93859. private _customEffect;
  93860. private _cachedDefines;
  93861. private _scaledColorStep;
  93862. private _colorDiff;
  93863. private _scaledDirection;
  93864. private _scaledGravity;
  93865. private _currentRenderId;
  93866. private _alive;
  93867. private _useInstancing;
  93868. private _vertexArrayObject;
  93869. private _started;
  93870. private _stopped;
  93871. private _actualFrame;
  93872. private _scaledUpdateSpeed;
  93873. private _vertexBufferSize;
  93874. /** @hidden */
  93875. _currentEmitRateGradient: Nullable<FactorGradient>;
  93876. /** @hidden */
  93877. _currentEmitRate1: number;
  93878. /** @hidden */
  93879. _currentEmitRate2: number;
  93880. /** @hidden */
  93881. _currentStartSizeGradient: Nullable<FactorGradient>;
  93882. /** @hidden */
  93883. _currentStartSize1: number;
  93884. /** @hidden */
  93885. _currentStartSize2: number;
  93886. private readonly _rawTextureWidth;
  93887. private _rampGradientsTexture;
  93888. private _useRampGradients;
  93889. /** Gets or sets a matrix to use to compute projection */
  93890. defaultProjectionMatrix: Matrix;
  93891. /** Gets or sets a matrix to use to compute view */
  93892. defaultViewMatrix: Matrix;
  93893. /** Gets or sets a boolean indicating that ramp gradients must be used
  93894. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93895. */
  93896. get useRampGradients(): boolean;
  93897. set useRampGradients(value: boolean);
  93898. /**
  93899. * 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.
  93900. * 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: [])
  93901. */
  93902. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93903. private _subEmitters;
  93904. /**
  93905. * @hidden
  93906. * If the particle systems emitter should be disposed when the particle system is disposed
  93907. */
  93908. _disposeEmitterOnDispose: boolean;
  93909. /**
  93910. * The current active Sub-systems, this property is used by the root particle system only.
  93911. */
  93912. activeSubSystems: Array<ParticleSystem>;
  93913. /**
  93914. * Specifies if the particles are updated in emitter local space or world space
  93915. */
  93916. isLocal: boolean;
  93917. private _rootParticleSystem;
  93918. /**
  93919. * Gets the current list of active particles
  93920. */
  93921. get particles(): Particle[];
  93922. /**
  93923. * Gets the number of particles active at the same time.
  93924. * @returns The number of active particles.
  93925. */
  93926. getActiveCount(): number;
  93927. /**
  93928. * Returns the string "ParticleSystem"
  93929. * @returns a string containing the class name
  93930. */
  93931. getClassName(): string;
  93932. /**
  93933. * Gets a boolean indicating that the system is stopping
  93934. * @returns true if the system is currently stopping
  93935. */
  93936. isStopping(): boolean;
  93937. /**
  93938. * Gets the custom effect used to render the particles
  93939. * @param blendMode Blend mode for which the effect should be retrieved
  93940. * @returns The effect
  93941. */
  93942. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93943. /**
  93944. * Sets the custom effect used to render the particles
  93945. * @param effect The effect to set
  93946. * @param blendMode Blend mode for which the effect should be set
  93947. */
  93948. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93949. /** @hidden */
  93950. private _onBeforeDrawParticlesObservable;
  93951. /**
  93952. * Observable that will be called just before the particles are drawn
  93953. */
  93954. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93955. /**
  93956. * Gets the name of the particle vertex shader
  93957. */
  93958. get vertexShaderName(): string;
  93959. /**
  93960. * Instantiates a particle system.
  93961. * 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.
  93962. * @param name The name of the particle system
  93963. * @param capacity The max number of particles alive at the same time
  93964. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93965. * @param customEffect a custom effect used to change the way particles are rendered by default
  93966. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93967. * @param epsilon Offset used to render the particles
  93968. */
  93969. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93970. private _addFactorGradient;
  93971. private _removeFactorGradient;
  93972. /**
  93973. * Adds a new life time gradient
  93974. * @param gradient defines the gradient to use (between 0 and 1)
  93975. * @param factor defines the life time factor to affect to the specified gradient
  93976. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93977. * @returns the current particle system
  93978. */
  93979. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93980. /**
  93981. * Remove a specific life time gradient
  93982. * @param gradient defines the gradient to remove
  93983. * @returns the current particle system
  93984. */
  93985. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93986. /**
  93987. * Adds a new size gradient
  93988. * @param gradient defines the gradient to use (between 0 and 1)
  93989. * @param factor defines the size factor to affect to the specified gradient
  93990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93991. * @returns the current particle system
  93992. */
  93993. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93994. /**
  93995. * Remove a specific size gradient
  93996. * @param gradient defines the gradient to remove
  93997. * @returns the current particle system
  93998. */
  93999. removeSizeGradient(gradient: number): IParticleSystem;
  94000. /**
  94001. * Adds a new color remap gradient
  94002. * @param gradient defines the gradient to use (between 0 and 1)
  94003. * @param min defines the color remap minimal range
  94004. * @param max defines the color remap maximal range
  94005. * @returns the current particle system
  94006. */
  94007. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94008. /**
  94009. * Remove a specific color remap gradient
  94010. * @param gradient defines the gradient to remove
  94011. * @returns the current particle system
  94012. */
  94013. removeColorRemapGradient(gradient: number): IParticleSystem;
  94014. /**
  94015. * Adds a new alpha remap gradient
  94016. * @param gradient defines the gradient to use (between 0 and 1)
  94017. * @param min defines the alpha remap minimal range
  94018. * @param max defines the alpha remap maximal range
  94019. * @returns the current particle system
  94020. */
  94021. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94022. /**
  94023. * Remove a specific alpha remap gradient
  94024. * @param gradient defines the gradient to remove
  94025. * @returns the current particle system
  94026. */
  94027. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  94028. /**
  94029. * Adds a new angular speed gradient
  94030. * @param gradient defines the gradient to use (between 0 and 1)
  94031. * @param factor defines the angular speed to affect to the specified gradient
  94032. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94033. * @returns the current particle system
  94034. */
  94035. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94036. /**
  94037. * Remove a specific angular speed gradient
  94038. * @param gradient defines the gradient to remove
  94039. * @returns the current particle system
  94040. */
  94041. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94042. /**
  94043. * Adds a new velocity gradient
  94044. * @param gradient defines the gradient to use (between 0 and 1)
  94045. * @param factor defines the velocity to affect to the specified gradient
  94046. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94047. * @returns the current particle system
  94048. */
  94049. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94050. /**
  94051. * Remove a specific velocity gradient
  94052. * @param gradient defines the gradient to remove
  94053. * @returns the current particle system
  94054. */
  94055. removeVelocityGradient(gradient: number): IParticleSystem;
  94056. /**
  94057. * Adds a new limit velocity gradient
  94058. * @param gradient defines the gradient to use (between 0 and 1)
  94059. * @param factor defines the limit velocity value to affect to the specified gradient
  94060. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94061. * @returns the current particle system
  94062. */
  94063. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94064. /**
  94065. * Remove a specific limit velocity gradient
  94066. * @param gradient defines the gradient to remove
  94067. * @returns the current particle system
  94068. */
  94069. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94070. /**
  94071. * Adds a new drag gradient
  94072. * @param gradient defines the gradient to use (between 0 and 1)
  94073. * @param factor defines the drag value to affect to the specified gradient
  94074. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94075. * @returns the current particle system
  94076. */
  94077. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94078. /**
  94079. * Remove a specific drag gradient
  94080. * @param gradient defines the gradient to remove
  94081. * @returns the current particle system
  94082. */
  94083. removeDragGradient(gradient: number): IParticleSystem;
  94084. /**
  94085. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94086. * @param gradient defines the gradient to use (between 0 and 1)
  94087. * @param factor defines the emit rate value to affect to the specified gradient
  94088. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94089. * @returns the current particle system
  94090. */
  94091. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94092. /**
  94093. * Remove a specific emit rate gradient
  94094. * @param gradient defines the gradient to remove
  94095. * @returns the current particle system
  94096. */
  94097. removeEmitRateGradient(gradient: number): IParticleSystem;
  94098. /**
  94099. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94100. * @param gradient defines the gradient to use (between 0 and 1)
  94101. * @param factor defines the start size value to affect to the specified gradient
  94102. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94103. * @returns the current particle system
  94104. */
  94105. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94106. /**
  94107. * Remove a specific start size gradient
  94108. * @param gradient defines the gradient to remove
  94109. * @returns the current particle system
  94110. */
  94111. removeStartSizeGradient(gradient: number): IParticleSystem;
  94112. private _createRampGradientTexture;
  94113. /**
  94114. * Gets the current list of ramp gradients.
  94115. * You must use addRampGradient and removeRampGradient to udpate this list
  94116. * @returns the list of ramp gradients
  94117. */
  94118. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94119. /** Force the system to rebuild all gradients that need to be resync */
  94120. forceRefreshGradients(): void;
  94121. private _syncRampGradientTexture;
  94122. /**
  94123. * Adds a new ramp gradient used to remap particle colors
  94124. * @param gradient defines the gradient to use (between 0 and 1)
  94125. * @param color defines the color to affect to the specified gradient
  94126. * @returns the current particle system
  94127. */
  94128. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  94129. /**
  94130. * Remove a specific ramp gradient
  94131. * @param gradient defines the gradient to remove
  94132. * @returns the current particle system
  94133. */
  94134. removeRampGradient(gradient: number): ParticleSystem;
  94135. /**
  94136. * Adds a new color gradient
  94137. * @param gradient defines the gradient to use (between 0 and 1)
  94138. * @param color1 defines the color to affect to the specified gradient
  94139. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94140. * @returns this particle system
  94141. */
  94142. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94143. /**
  94144. * Remove a specific color gradient
  94145. * @param gradient defines the gradient to remove
  94146. * @returns this particle system
  94147. */
  94148. removeColorGradient(gradient: number): IParticleSystem;
  94149. private _fetchR;
  94150. protected _reset(): void;
  94151. private _resetEffect;
  94152. private _createVertexBuffers;
  94153. private _createIndexBuffer;
  94154. /**
  94155. * Gets the maximum number of particles active at the same time.
  94156. * @returns The max number of active particles.
  94157. */
  94158. getCapacity(): number;
  94159. /**
  94160. * Gets whether there are still active particles in the system.
  94161. * @returns True if it is alive, otherwise false.
  94162. */
  94163. isAlive(): boolean;
  94164. /**
  94165. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94166. * @returns True if it has been started, otherwise false.
  94167. */
  94168. isStarted(): boolean;
  94169. private _prepareSubEmitterInternalArray;
  94170. /**
  94171. * Starts the particle system and begins to emit
  94172. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  94173. */
  94174. start(delay?: number): void;
  94175. /**
  94176. * Stops the particle system.
  94177. * @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.
  94178. */
  94179. stop(stopSubEmitters?: boolean): void;
  94180. /**
  94181. * Remove all active particles
  94182. */
  94183. reset(): void;
  94184. /**
  94185. * @hidden (for internal use only)
  94186. */
  94187. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  94188. /**
  94189. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  94190. * Its lifetime will start back at 0.
  94191. */
  94192. recycleParticle: (particle: Particle) => void;
  94193. private _stopSubEmitters;
  94194. private _createParticle;
  94195. private _removeFromRoot;
  94196. private _emitFromParticle;
  94197. private _update;
  94198. /** @hidden */
  94199. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  94200. /** @hidden */
  94201. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  94202. /**
  94203. * Fill the defines array according to the current settings of the particle system
  94204. * @param defines Array to be updated
  94205. * @param blendMode blend mode to take into account when updating the array
  94206. */
  94207. fillDefines(defines: Array<string>, blendMode: number): void;
  94208. /**
  94209. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94210. * @param uniforms Uniforms array to fill
  94211. * @param attributes Attributes array to fill
  94212. * @param samplers Samplers array to fill
  94213. */
  94214. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94215. /** @hidden */
  94216. private _getEffect;
  94217. /**
  94218. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  94219. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  94220. */
  94221. animate(preWarmOnly?: boolean): void;
  94222. private _appendParticleVertices;
  94223. /**
  94224. * Rebuilds the particle system.
  94225. */
  94226. rebuild(): void;
  94227. /**
  94228. * Is this system ready to be used/rendered
  94229. * @return true if the system is ready
  94230. */
  94231. isReady(): boolean;
  94232. private _render;
  94233. /**
  94234. * Renders the particle system in its current state.
  94235. * @returns the current number of particles
  94236. */
  94237. render(): number;
  94238. /**
  94239. * Disposes the particle system and free the associated resources
  94240. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94241. */
  94242. dispose(disposeTexture?: boolean): void;
  94243. /**
  94244. * Clones the particle system.
  94245. * @param name The name of the cloned object
  94246. * @param newEmitter The new emitter to use
  94247. * @returns the cloned particle system
  94248. */
  94249. clone(name: string, newEmitter: any): ParticleSystem;
  94250. /**
  94251. * Serializes the particle system to a JSON object
  94252. * @param serializeTexture defines if the texture must be serialized as well
  94253. * @returns the JSON object
  94254. */
  94255. serialize(serializeTexture?: boolean): any;
  94256. /** @hidden */
  94257. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  94258. /** @hidden */
  94259. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  94260. /**
  94261. * Parses a JSON object to create a particle system.
  94262. * @param parsedParticleSystem The JSON object to parse
  94263. * @param sceneOrEngine The scene or the engine to create the particle system in
  94264. * @param rootUrl The root url to use to load external dependencies like texture
  94265. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  94266. * @returns the Parsed particle system
  94267. */
  94268. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  94269. }
  94270. }
  94271. declare module BABYLON {
  94272. /**
  94273. * A particle represents one of the element emitted by a particle system.
  94274. * This is mainly define by its coordinates, direction, velocity and age.
  94275. */
  94276. export class Particle {
  94277. /**
  94278. * The particle system the particle belongs to.
  94279. */
  94280. particleSystem: ParticleSystem;
  94281. private static _Count;
  94282. /**
  94283. * Unique ID of the particle
  94284. */
  94285. id: number;
  94286. /**
  94287. * The world position of the particle in the scene.
  94288. */
  94289. position: Vector3;
  94290. /**
  94291. * The world direction of the particle in the scene.
  94292. */
  94293. direction: Vector3;
  94294. /**
  94295. * The color of the particle.
  94296. */
  94297. color: Color4;
  94298. /**
  94299. * The color change of the particle per step.
  94300. */
  94301. colorStep: Color4;
  94302. /**
  94303. * Defines how long will the life of the particle be.
  94304. */
  94305. lifeTime: number;
  94306. /**
  94307. * The current age of the particle.
  94308. */
  94309. age: number;
  94310. /**
  94311. * The current size of the particle.
  94312. */
  94313. size: number;
  94314. /**
  94315. * The current scale of the particle.
  94316. */
  94317. scale: Vector2;
  94318. /**
  94319. * The current angle of the particle.
  94320. */
  94321. angle: number;
  94322. /**
  94323. * Defines how fast is the angle changing.
  94324. */
  94325. angularSpeed: number;
  94326. /**
  94327. * Defines the cell index used by the particle to be rendered from a sprite.
  94328. */
  94329. cellIndex: number;
  94330. /**
  94331. * The information required to support color remapping
  94332. */
  94333. remapData: Vector4;
  94334. /** @hidden */
  94335. _randomCellOffset?: number;
  94336. /** @hidden */
  94337. _initialDirection: Nullable<Vector3>;
  94338. /** @hidden */
  94339. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  94340. /** @hidden */
  94341. _initialStartSpriteCellID: number;
  94342. /** @hidden */
  94343. _initialEndSpriteCellID: number;
  94344. /** @hidden */
  94345. _currentColorGradient: Nullable<ColorGradient>;
  94346. /** @hidden */
  94347. _currentColor1: Color4;
  94348. /** @hidden */
  94349. _currentColor2: Color4;
  94350. /** @hidden */
  94351. _currentSizeGradient: Nullable<FactorGradient>;
  94352. /** @hidden */
  94353. _currentSize1: number;
  94354. /** @hidden */
  94355. _currentSize2: number;
  94356. /** @hidden */
  94357. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  94358. /** @hidden */
  94359. _currentAngularSpeed1: number;
  94360. /** @hidden */
  94361. _currentAngularSpeed2: number;
  94362. /** @hidden */
  94363. _currentVelocityGradient: Nullable<FactorGradient>;
  94364. /** @hidden */
  94365. _currentVelocity1: number;
  94366. /** @hidden */
  94367. _currentVelocity2: number;
  94368. /** @hidden */
  94369. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  94370. /** @hidden */
  94371. _currentLimitVelocity1: number;
  94372. /** @hidden */
  94373. _currentLimitVelocity2: number;
  94374. /** @hidden */
  94375. _currentDragGradient: Nullable<FactorGradient>;
  94376. /** @hidden */
  94377. _currentDrag1: number;
  94378. /** @hidden */
  94379. _currentDrag2: number;
  94380. /** @hidden */
  94381. _randomNoiseCoordinates1: Vector3;
  94382. /** @hidden */
  94383. _randomNoiseCoordinates2: Vector3;
  94384. /** @hidden */
  94385. _localPosition?: Vector3;
  94386. /**
  94387. * Creates a new instance Particle
  94388. * @param particleSystem the particle system the particle belongs to
  94389. */
  94390. constructor(
  94391. /**
  94392. * The particle system the particle belongs to.
  94393. */
  94394. particleSystem: ParticleSystem);
  94395. private updateCellInfoFromSystem;
  94396. /**
  94397. * Defines how the sprite cell index is updated for the particle
  94398. */
  94399. updateCellIndex(): void;
  94400. /** @hidden */
  94401. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  94402. /** @hidden */
  94403. _inheritParticleInfoToSubEmitters(): void;
  94404. /** @hidden */
  94405. _reset(): void;
  94406. /**
  94407. * Copy the properties of particle to another one.
  94408. * @param other the particle to copy the information to.
  94409. */
  94410. copyTo(other: Particle): void;
  94411. }
  94412. }
  94413. declare module BABYLON {
  94414. /**
  94415. * Particle emitter represents a volume emitting particles.
  94416. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  94417. */
  94418. export interface IParticleEmitterType {
  94419. /**
  94420. * Called by the particle System when the direction is computed for the created particle.
  94421. * @param worldMatrix is the world matrix of the particle system
  94422. * @param directionToUpdate is the direction vector to update with the result
  94423. * @param particle is the particle we are computed the direction for
  94424. * @param isLocal defines if the direction should be set in local space
  94425. */
  94426. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94427. /**
  94428. * Called by the particle System when the position is computed for the created particle.
  94429. * @param worldMatrix is the world matrix of the particle system
  94430. * @param positionToUpdate is the position vector to update with the result
  94431. * @param particle is the particle we are computed the position for
  94432. * @param isLocal defines if the position should be set in local space
  94433. */
  94434. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94435. /**
  94436. * Clones the current emitter and returns a copy of it
  94437. * @returns the new emitter
  94438. */
  94439. clone(): IParticleEmitterType;
  94440. /**
  94441. * Called by the GPUParticleSystem to setup the update shader
  94442. * @param effect defines the update shader
  94443. */
  94444. applyToShader(effect: Effect): void;
  94445. /**
  94446. * Returns a string to use to update the GPU particles update shader
  94447. * @returns the effect defines string
  94448. */
  94449. getEffectDefines(): string;
  94450. /**
  94451. * Returns a string representing the class name
  94452. * @returns a string containing the class name
  94453. */
  94454. getClassName(): string;
  94455. /**
  94456. * Serializes the particle system to a JSON object.
  94457. * @returns the JSON object
  94458. */
  94459. serialize(): any;
  94460. /**
  94461. * Parse properties from a JSON object
  94462. * @param serializationObject defines the JSON object
  94463. * @param scene defines the hosting scene
  94464. */
  94465. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94466. }
  94467. }
  94468. declare module BABYLON {
  94469. /**
  94470. * Particle emitter emitting particles from the inside of a box.
  94471. * It emits the particles randomly between 2 given directions.
  94472. */
  94473. export class BoxParticleEmitter implements IParticleEmitterType {
  94474. /**
  94475. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94476. */
  94477. direction1: Vector3;
  94478. /**
  94479. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94480. */
  94481. direction2: Vector3;
  94482. /**
  94483. * 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.
  94484. */
  94485. minEmitBox: Vector3;
  94486. /**
  94487. * 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.
  94488. */
  94489. maxEmitBox: Vector3;
  94490. /**
  94491. * Creates a new instance BoxParticleEmitter
  94492. */
  94493. constructor();
  94494. /**
  94495. * Called by the particle System when the direction is computed for the created particle.
  94496. * @param worldMatrix is the world matrix of the particle system
  94497. * @param directionToUpdate is the direction vector to update with the result
  94498. * @param particle is the particle we are computed the direction for
  94499. * @param isLocal defines if the direction should be set in local space
  94500. */
  94501. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94502. /**
  94503. * Called by the particle System when the position is computed for the created particle.
  94504. * @param worldMatrix is the world matrix of the particle system
  94505. * @param positionToUpdate is the position vector to update with the result
  94506. * @param particle is the particle we are computed the position for
  94507. * @param isLocal defines if the position should be set in local space
  94508. */
  94509. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94510. /**
  94511. * Clones the current emitter and returns a copy of it
  94512. * @returns the new emitter
  94513. */
  94514. clone(): BoxParticleEmitter;
  94515. /**
  94516. * Called by the GPUParticleSystem to setup the update shader
  94517. * @param effect defines the update shader
  94518. */
  94519. applyToShader(effect: Effect): void;
  94520. /**
  94521. * Returns a string to use to update the GPU particles update shader
  94522. * @returns a string containng the defines string
  94523. */
  94524. getEffectDefines(): string;
  94525. /**
  94526. * Returns the string "BoxParticleEmitter"
  94527. * @returns a string containing the class name
  94528. */
  94529. getClassName(): string;
  94530. /**
  94531. * Serializes the particle system to a JSON object.
  94532. * @returns the JSON object
  94533. */
  94534. serialize(): any;
  94535. /**
  94536. * Parse properties from a JSON object
  94537. * @param serializationObject defines the JSON object
  94538. */
  94539. parse(serializationObject: any): void;
  94540. }
  94541. }
  94542. declare module BABYLON {
  94543. /**
  94544. * Particle emitter emitting particles from the inside of a cone.
  94545. * It emits the particles alongside the cone volume from the base to the particle.
  94546. * The emission direction might be randomized.
  94547. */
  94548. export class ConeParticleEmitter implements IParticleEmitterType {
  94549. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94550. directionRandomizer: number;
  94551. private _radius;
  94552. private _angle;
  94553. private _height;
  94554. /**
  94555. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  94556. */
  94557. radiusRange: number;
  94558. /**
  94559. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  94560. */
  94561. heightRange: number;
  94562. /**
  94563. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  94564. */
  94565. emitFromSpawnPointOnly: boolean;
  94566. /**
  94567. * Gets or sets the radius of the emission cone
  94568. */
  94569. get radius(): number;
  94570. set radius(value: number);
  94571. /**
  94572. * Gets or sets the angle of the emission cone
  94573. */
  94574. get angle(): number;
  94575. set angle(value: number);
  94576. private _buildHeight;
  94577. /**
  94578. * Creates a new instance ConeParticleEmitter
  94579. * @param radius the radius of the emission cone (1 by default)
  94580. * @param angle the cone base angle (PI by default)
  94581. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  94582. */
  94583. constructor(radius?: number, angle?: number,
  94584. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94585. directionRandomizer?: number);
  94586. /**
  94587. * Called by the particle System when the direction is computed for the created particle.
  94588. * @param worldMatrix is the world matrix of the particle system
  94589. * @param directionToUpdate is the direction vector to update with the result
  94590. * @param particle is the particle we are computed the direction for
  94591. * @param isLocal defines if the direction should be set in local space
  94592. */
  94593. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94594. /**
  94595. * Called by the particle System when the position is computed for the created particle.
  94596. * @param worldMatrix is the world matrix of the particle system
  94597. * @param positionToUpdate is the position vector to update with the result
  94598. * @param particle is the particle we are computed the position for
  94599. * @param isLocal defines if the position should be set in local space
  94600. */
  94601. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94602. /**
  94603. * Clones the current emitter and returns a copy of it
  94604. * @returns the new emitter
  94605. */
  94606. clone(): ConeParticleEmitter;
  94607. /**
  94608. * Called by the GPUParticleSystem to setup the update shader
  94609. * @param effect defines the update shader
  94610. */
  94611. applyToShader(effect: Effect): void;
  94612. /**
  94613. * Returns a string to use to update the GPU particles update shader
  94614. * @returns a string containng the defines string
  94615. */
  94616. getEffectDefines(): string;
  94617. /**
  94618. * Returns the string "ConeParticleEmitter"
  94619. * @returns a string containing the class name
  94620. */
  94621. getClassName(): string;
  94622. /**
  94623. * Serializes the particle system to a JSON object.
  94624. * @returns the JSON object
  94625. */
  94626. serialize(): any;
  94627. /**
  94628. * Parse properties from a JSON object
  94629. * @param serializationObject defines the JSON object
  94630. */
  94631. parse(serializationObject: any): void;
  94632. }
  94633. }
  94634. declare module BABYLON {
  94635. /**
  94636. * Particle emitter emitting particles from the inside of a cylinder.
  94637. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  94638. */
  94639. export class CylinderParticleEmitter implements IParticleEmitterType {
  94640. /**
  94641. * The radius of the emission cylinder.
  94642. */
  94643. radius: number;
  94644. /**
  94645. * The height of the emission cylinder.
  94646. */
  94647. height: number;
  94648. /**
  94649. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94650. */
  94651. radiusRange: number;
  94652. /**
  94653. * How much to randomize the particle direction [0-1].
  94654. */
  94655. directionRandomizer: number;
  94656. /**
  94657. * Creates a new instance CylinderParticleEmitter
  94658. * @param radius the radius of the emission cylinder (1 by default)
  94659. * @param height the height of the emission cylinder (1 by default)
  94660. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94661. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94662. */
  94663. constructor(
  94664. /**
  94665. * The radius of the emission cylinder.
  94666. */
  94667. radius?: number,
  94668. /**
  94669. * The height of the emission cylinder.
  94670. */
  94671. height?: number,
  94672. /**
  94673. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94674. */
  94675. radiusRange?: number,
  94676. /**
  94677. * How much to randomize the particle direction [0-1].
  94678. */
  94679. directionRandomizer?: number);
  94680. /**
  94681. * Called by the particle System when the direction is computed for the created particle.
  94682. * @param worldMatrix is the world matrix of the particle system
  94683. * @param directionToUpdate is the direction vector to update with the result
  94684. * @param particle is the particle we are computed the direction for
  94685. * @param isLocal defines if the direction should be set in local space
  94686. */
  94687. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94688. /**
  94689. * Called by the particle System when the position is computed for the created particle.
  94690. * @param worldMatrix is the world matrix of the particle system
  94691. * @param positionToUpdate is the position vector to update with the result
  94692. * @param particle is the particle we are computed the position for
  94693. * @param isLocal defines if the position should be set in local space
  94694. */
  94695. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94696. /**
  94697. * Clones the current emitter and returns a copy of it
  94698. * @returns the new emitter
  94699. */
  94700. clone(): CylinderParticleEmitter;
  94701. /**
  94702. * Called by the GPUParticleSystem to setup the update shader
  94703. * @param effect defines the update shader
  94704. */
  94705. applyToShader(effect: Effect): void;
  94706. /**
  94707. * Returns a string to use to update the GPU particles update shader
  94708. * @returns a string containng the defines string
  94709. */
  94710. getEffectDefines(): string;
  94711. /**
  94712. * Returns the string "CylinderParticleEmitter"
  94713. * @returns a string containing the class name
  94714. */
  94715. getClassName(): string;
  94716. /**
  94717. * Serializes the particle system to a JSON object.
  94718. * @returns the JSON object
  94719. */
  94720. serialize(): any;
  94721. /**
  94722. * Parse properties from a JSON object
  94723. * @param serializationObject defines the JSON object
  94724. */
  94725. parse(serializationObject: any): void;
  94726. }
  94727. /**
  94728. * Particle emitter emitting particles from the inside of a cylinder.
  94729. * It emits the particles randomly between two vectors.
  94730. */
  94731. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  94732. /**
  94733. * The min limit of the emission direction.
  94734. */
  94735. direction1: Vector3;
  94736. /**
  94737. * The max limit of the emission direction.
  94738. */
  94739. direction2: Vector3;
  94740. /**
  94741. * Creates a new instance CylinderDirectedParticleEmitter
  94742. * @param radius the radius of the emission cylinder (1 by default)
  94743. * @param height the height of the emission cylinder (1 by default)
  94744. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94745. * @param direction1 the min limit of the emission direction (up vector by default)
  94746. * @param direction2 the max limit of the emission direction (up vector by default)
  94747. */
  94748. constructor(radius?: number, height?: number, radiusRange?: number,
  94749. /**
  94750. * The min limit of the emission direction.
  94751. */
  94752. direction1?: Vector3,
  94753. /**
  94754. * The max limit of the emission direction.
  94755. */
  94756. direction2?: Vector3);
  94757. /**
  94758. * Called by the particle System when the direction is computed for the created particle.
  94759. * @param worldMatrix is the world matrix of the particle system
  94760. * @param directionToUpdate is the direction vector to update with the result
  94761. * @param particle is the particle we are computed the direction for
  94762. */
  94763. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94764. /**
  94765. * Clones the current emitter and returns a copy of it
  94766. * @returns the new emitter
  94767. */
  94768. clone(): CylinderDirectedParticleEmitter;
  94769. /**
  94770. * Called by the GPUParticleSystem to setup the update shader
  94771. * @param effect defines the update shader
  94772. */
  94773. applyToShader(effect: Effect): void;
  94774. /**
  94775. * Returns a string to use to update the GPU particles update shader
  94776. * @returns a string containng the defines string
  94777. */
  94778. getEffectDefines(): string;
  94779. /**
  94780. * Returns the string "CylinderDirectedParticleEmitter"
  94781. * @returns a string containing the class name
  94782. */
  94783. getClassName(): string;
  94784. /**
  94785. * Serializes the particle system to a JSON object.
  94786. * @returns the JSON object
  94787. */
  94788. serialize(): any;
  94789. /**
  94790. * Parse properties from a JSON object
  94791. * @param serializationObject defines the JSON object
  94792. */
  94793. parse(serializationObject: any): void;
  94794. }
  94795. }
  94796. declare module BABYLON {
  94797. /**
  94798. * Particle emitter emitting particles from the inside of a hemisphere.
  94799. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  94800. */
  94801. export class HemisphericParticleEmitter implements IParticleEmitterType {
  94802. /**
  94803. * The radius of the emission hemisphere.
  94804. */
  94805. radius: number;
  94806. /**
  94807. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94808. */
  94809. radiusRange: number;
  94810. /**
  94811. * How much to randomize the particle direction [0-1].
  94812. */
  94813. directionRandomizer: number;
  94814. /**
  94815. * Creates a new instance HemisphericParticleEmitter
  94816. * @param radius the radius of the emission hemisphere (1 by default)
  94817. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94818. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94819. */
  94820. constructor(
  94821. /**
  94822. * The radius of the emission hemisphere.
  94823. */
  94824. radius?: number,
  94825. /**
  94826. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94827. */
  94828. radiusRange?: number,
  94829. /**
  94830. * How much to randomize the particle direction [0-1].
  94831. */
  94832. directionRandomizer?: number);
  94833. /**
  94834. * Called by the particle System when the direction is computed for the created particle.
  94835. * @param worldMatrix is the world matrix of the particle system
  94836. * @param directionToUpdate is the direction vector to update with the result
  94837. * @param particle is the particle we are computed the direction for
  94838. * @param isLocal defines if the direction should be set in local space
  94839. */
  94840. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94841. /**
  94842. * Called by the particle System when the position is computed for the created particle.
  94843. * @param worldMatrix is the world matrix of the particle system
  94844. * @param positionToUpdate is the position vector to update with the result
  94845. * @param particle is the particle we are computed the position for
  94846. * @param isLocal defines if the position should be set in local space
  94847. */
  94848. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94849. /**
  94850. * Clones the current emitter and returns a copy of it
  94851. * @returns the new emitter
  94852. */
  94853. clone(): HemisphericParticleEmitter;
  94854. /**
  94855. * Called by the GPUParticleSystem to setup the update shader
  94856. * @param effect defines the update shader
  94857. */
  94858. applyToShader(effect: Effect): void;
  94859. /**
  94860. * Returns a string to use to update the GPU particles update shader
  94861. * @returns a string containng the defines string
  94862. */
  94863. getEffectDefines(): string;
  94864. /**
  94865. * Returns the string "HemisphericParticleEmitter"
  94866. * @returns a string containing the class name
  94867. */
  94868. getClassName(): string;
  94869. /**
  94870. * Serializes the particle system to a JSON object.
  94871. * @returns the JSON object
  94872. */
  94873. serialize(): any;
  94874. /**
  94875. * Parse properties from a JSON object
  94876. * @param serializationObject defines the JSON object
  94877. */
  94878. parse(serializationObject: any): void;
  94879. }
  94880. }
  94881. declare module BABYLON {
  94882. /**
  94883. * Particle emitter emitting particles from a point.
  94884. * It emits the particles randomly between 2 given directions.
  94885. */
  94886. export class PointParticleEmitter implements IParticleEmitterType {
  94887. /**
  94888. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94889. */
  94890. direction1: Vector3;
  94891. /**
  94892. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94893. */
  94894. direction2: Vector3;
  94895. /**
  94896. * Creates a new instance PointParticleEmitter
  94897. */
  94898. constructor();
  94899. /**
  94900. * Called by the particle System when the direction is computed for the created particle.
  94901. * @param worldMatrix is the world matrix of the particle system
  94902. * @param directionToUpdate is the direction vector to update with the result
  94903. * @param particle is the particle we are computed the direction for
  94904. * @param isLocal defines if the direction should be set in local space
  94905. */
  94906. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94907. /**
  94908. * Called by the particle System when the position is computed for the created particle.
  94909. * @param worldMatrix is the world matrix of the particle system
  94910. * @param positionToUpdate is the position vector to update with the result
  94911. * @param particle is the particle we are computed the position for
  94912. * @param isLocal defines if the position should be set in local space
  94913. */
  94914. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94915. /**
  94916. * Clones the current emitter and returns a copy of it
  94917. * @returns the new emitter
  94918. */
  94919. clone(): PointParticleEmitter;
  94920. /**
  94921. * Called by the GPUParticleSystem to setup the update shader
  94922. * @param effect defines the update shader
  94923. */
  94924. applyToShader(effect: Effect): void;
  94925. /**
  94926. * Returns a string to use to update the GPU particles update shader
  94927. * @returns a string containng the defines string
  94928. */
  94929. getEffectDefines(): string;
  94930. /**
  94931. * Returns the string "PointParticleEmitter"
  94932. * @returns a string containing the class name
  94933. */
  94934. getClassName(): string;
  94935. /**
  94936. * Serializes the particle system to a JSON object.
  94937. * @returns the JSON object
  94938. */
  94939. serialize(): any;
  94940. /**
  94941. * Parse properties from a JSON object
  94942. * @param serializationObject defines the JSON object
  94943. */
  94944. parse(serializationObject: any): void;
  94945. }
  94946. }
  94947. declare module BABYLON {
  94948. /**
  94949. * Particle emitter emitting particles from the inside of a sphere.
  94950. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94951. */
  94952. export class SphereParticleEmitter implements IParticleEmitterType {
  94953. /**
  94954. * The radius of the emission sphere.
  94955. */
  94956. radius: number;
  94957. /**
  94958. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94959. */
  94960. radiusRange: number;
  94961. /**
  94962. * How much to randomize the particle direction [0-1].
  94963. */
  94964. directionRandomizer: number;
  94965. /**
  94966. * Creates a new instance SphereParticleEmitter
  94967. * @param radius the radius of the emission sphere (1 by default)
  94968. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94969. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94970. */
  94971. constructor(
  94972. /**
  94973. * The radius of the emission sphere.
  94974. */
  94975. radius?: number,
  94976. /**
  94977. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94978. */
  94979. radiusRange?: number,
  94980. /**
  94981. * How much to randomize the particle direction [0-1].
  94982. */
  94983. directionRandomizer?: number);
  94984. /**
  94985. * Called by the particle System when the direction is computed for the created particle.
  94986. * @param worldMatrix is the world matrix of the particle system
  94987. * @param directionToUpdate is the direction vector to update with the result
  94988. * @param particle is the particle we are computed the direction for
  94989. * @param isLocal defines if the direction should be set in local space
  94990. */
  94991. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94992. /**
  94993. * Called by the particle System when the position is computed for the created particle.
  94994. * @param worldMatrix is the world matrix of the particle system
  94995. * @param positionToUpdate is the position vector to update with the result
  94996. * @param particle is the particle we are computed the position for
  94997. * @param isLocal defines if the position should be set in local space
  94998. */
  94999. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95000. /**
  95001. * Clones the current emitter and returns a copy of it
  95002. * @returns the new emitter
  95003. */
  95004. clone(): SphereParticleEmitter;
  95005. /**
  95006. * Called by the GPUParticleSystem to setup the update shader
  95007. * @param effect defines the update shader
  95008. */
  95009. applyToShader(effect: Effect): void;
  95010. /**
  95011. * Returns a string to use to update the GPU particles update shader
  95012. * @returns a string containng the defines string
  95013. */
  95014. getEffectDefines(): string;
  95015. /**
  95016. * Returns the string "SphereParticleEmitter"
  95017. * @returns a string containing the class name
  95018. */
  95019. getClassName(): string;
  95020. /**
  95021. * Serializes the particle system to a JSON object.
  95022. * @returns the JSON object
  95023. */
  95024. serialize(): any;
  95025. /**
  95026. * Parse properties from a JSON object
  95027. * @param serializationObject defines the JSON object
  95028. */
  95029. parse(serializationObject: any): void;
  95030. }
  95031. /**
  95032. * Particle emitter emitting particles from the inside of a sphere.
  95033. * It emits the particles randomly between two vectors.
  95034. */
  95035. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  95036. /**
  95037. * The min limit of the emission direction.
  95038. */
  95039. direction1: Vector3;
  95040. /**
  95041. * The max limit of the emission direction.
  95042. */
  95043. direction2: Vector3;
  95044. /**
  95045. * Creates a new instance SphereDirectedParticleEmitter
  95046. * @param radius the radius of the emission sphere (1 by default)
  95047. * @param direction1 the min limit of the emission direction (up vector by default)
  95048. * @param direction2 the max limit of the emission direction (up vector by default)
  95049. */
  95050. constructor(radius?: number,
  95051. /**
  95052. * The min limit of the emission direction.
  95053. */
  95054. direction1?: Vector3,
  95055. /**
  95056. * The max limit of the emission direction.
  95057. */
  95058. direction2?: Vector3);
  95059. /**
  95060. * Called by the particle System when the direction is computed for the created particle.
  95061. * @param worldMatrix is the world matrix of the particle system
  95062. * @param directionToUpdate is the direction vector to update with the result
  95063. * @param particle is the particle we are computed the direction for
  95064. */
  95065. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  95066. /**
  95067. * Clones the current emitter and returns a copy of it
  95068. * @returns the new emitter
  95069. */
  95070. clone(): SphereDirectedParticleEmitter;
  95071. /**
  95072. * Called by the GPUParticleSystem to setup the update shader
  95073. * @param effect defines the update shader
  95074. */
  95075. applyToShader(effect: Effect): void;
  95076. /**
  95077. * Returns a string to use to update the GPU particles update shader
  95078. * @returns a string containng the defines string
  95079. */
  95080. getEffectDefines(): string;
  95081. /**
  95082. * Returns the string "SphereDirectedParticleEmitter"
  95083. * @returns a string containing the class name
  95084. */
  95085. getClassName(): string;
  95086. /**
  95087. * Serializes the particle system to a JSON object.
  95088. * @returns the JSON object
  95089. */
  95090. serialize(): any;
  95091. /**
  95092. * Parse properties from a JSON object
  95093. * @param serializationObject defines the JSON object
  95094. */
  95095. parse(serializationObject: any): void;
  95096. }
  95097. }
  95098. declare module BABYLON {
  95099. /**
  95100. * Particle emitter emitting particles from a custom list of positions.
  95101. */
  95102. export class CustomParticleEmitter implements IParticleEmitterType {
  95103. /**
  95104. * Gets or sets the position generator that will create the inital position of each particle.
  95105. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  95106. */
  95107. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  95108. /**
  95109. * Gets or sets the destination generator that will create the final destination of each particle.
  95110. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  95111. */
  95112. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  95113. /**
  95114. * Creates a new instance CustomParticleEmitter
  95115. */
  95116. constructor();
  95117. /**
  95118. * Called by the particle System when the direction is computed for the created particle.
  95119. * @param worldMatrix is the world matrix of the particle system
  95120. * @param directionToUpdate is the direction vector to update with the result
  95121. * @param particle is the particle we are computed the direction for
  95122. * @param isLocal defines if the direction should be set in local space
  95123. */
  95124. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95125. /**
  95126. * Called by the particle System when the position is computed for the created particle.
  95127. * @param worldMatrix is the world matrix of the particle system
  95128. * @param positionToUpdate is the position vector to update with the result
  95129. * @param particle is the particle we are computed the position for
  95130. * @param isLocal defines if the position should be set in local space
  95131. */
  95132. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95133. /**
  95134. * Clones the current emitter and returns a copy of it
  95135. * @returns the new emitter
  95136. */
  95137. clone(): CustomParticleEmitter;
  95138. /**
  95139. * Called by the GPUParticleSystem to setup the update shader
  95140. * @param effect defines the update shader
  95141. */
  95142. applyToShader(effect: Effect): void;
  95143. /**
  95144. * Returns a string to use to update the GPU particles update shader
  95145. * @returns a string containng the defines string
  95146. */
  95147. getEffectDefines(): string;
  95148. /**
  95149. * Returns the string "PointParticleEmitter"
  95150. * @returns a string containing the class name
  95151. */
  95152. getClassName(): string;
  95153. /**
  95154. * Serializes the particle system to a JSON object.
  95155. * @returns the JSON object
  95156. */
  95157. serialize(): any;
  95158. /**
  95159. * Parse properties from a JSON object
  95160. * @param serializationObject defines the JSON object
  95161. */
  95162. parse(serializationObject: any): void;
  95163. }
  95164. }
  95165. declare module BABYLON {
  95166. /**
  95167. * Particle emitter emitting particles from the inside of a box.
  95168. * It emits the particles randomly between 2 given directions.
  95169. */
  95170. export class MeshParticleEmitter implements IParticleEmitterType {
  95171. private _indices;
  95172. private _positions;
  95173. private _normals;
  95174. private _storedNormal;
  95175. private _mesh;
  95176. /**
  95177. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  95178. */
  95179. direction1: Vector3;
  95180. /**
  95181. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  95182. */
  95183. direction2: Vector3;
  95184. /**
  95185. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  95186. */
  95187. useMeshNormalsForDirection: boolean;
  95188. /** Defines the mesh to use as source */
  95189. get mesh(): Nullable<AbstractMesh>;
  95190. set mesh(value: Nullable<AbstractMesh>);
  95191. /**
  95192. * Creates a new instance MeshParticleEmitter
  95193. * @param mesh defines the mesh to use as source
  95194. */
  95195. constructor(mesh?: Nullable<AbstractMesh>);
  95196. /**
  95197. * Called by the particle System when the direction is computed for the created particle.
  95198. * @param worldMatrix is the world matrix of the particle system
  95199. * @param directionToUpdate is the direction vector to update with the result
  95200. * @param particle is the particle we are computed the direction for
  95201. * @param isLocal defines if the direction should be set in local space
  95202. */
  95203. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95204. /**
  95205. * Called by the particle System when the position is computed for the created particle.
  95206. * @param worldMatrix is the world matrix of the particle system
  95207. * @param positionToUpdate is the position vector to update with the result
  95208. * @param particle is the particle we are computed the position for
  95209. * @param isLocal defines if the position should be set in local space
  95210. */
  95211. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95212. /**
  95213. * Clones the current emitter and returns a copy of it
  95214. * @returns the new emitter
  95215. */
  95216. clone(): MeshParticleEmitter;
  95217. /**
  95218. * Called by the GPUParticleSystem to setup the update shader
  95219. * @param effect defines the update shader
  95220. */
  95221. applyToShader(effect: Effect): void;
  95222. /**
  95223. * Returns a string to use to update the GPU particles update shader
  95224. * @returns a string containng the defines string
  95225. */
  95226. getEffectDefines(): string;
  95227. /**
  95228. * Returns the string "BoxParticleEmitter"
  95229. * @returns a string containing the class name
  95230. */
  95231. getClassName(): string;
  95232. /**
  95233. * Serializes the particle system to a JSON object.
  95234. * @returns the JSON object
  95235. */
  95236. serialize(): any;
  95237. /**
  95238. * Parse properties from a JSON object
  95239. * @param serializationObject defines the JSON object
  95240. * @param scene defines the hosting scene
  95241. */
  95242. parse(serializationObject: any, scene: Nullable<Scene>): void;
  95243. }
  95244. }
  95245. declare module BABYLON {
  95246. /**
  95247. * Interface representing a particle system in Babylon.js.
  95248. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  95249. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  95250. */
  95251. export interface IParticleSystem {
  95252. /**
  95253. * List of animations used by the particle system.
  95254. */
  95255. animations: Animation[];
  95256. /**
  95257. * The id of the Particle system.
  95258. */
  95259. id: string;
  95260. /**
  95261. * The name of the Particle system.
  95262. */
  95263. name: string;
  95264. /**
  95265. * The emitter represents the Mesh or position we are attaching the particle system to.
  95266. */
  95267. emitter: Nullable<AbstractMesh | Vector3>;
  95268. /**
  95269. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  95270. */
  95271. isBillboardBased: boolean;
  95272. /**
  95273. * The rendering group used by the Particle system to chose when to render.
  95274. */
  95275. renderingGroupId: number;
  95276. /**
  95277. * The layer mask we are rendering the particles through.
  95278. */
  95279. layerMask: number;
  95280. /**
  95281. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  95282. */
  95283. updateSpeed: number;
  95284. /**
  95285. * The amount of time the particle system is running (depends of the overall update speed).
  95286. */
  95287. targetStopDuration: number;
  95288. /**
  95289. * The texture used to render each particle. (this can be a spritesheet)
  95290. */
  95291. particleTexture: Nullable<BaseTexture>;
  95292. /**
  95293. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  95294. */
  95295. blendMode: number;
  95296. /**
  95297. * Minimum life time of emitting particles.
  95298. */
  95299. minLifeTime: number;
  95300. /**
  95301. * Maximum life time of emitting particles.
  95302. */
  95303. maxLifeTime: number;
  95304. /**
  95305. * Minimum Size of emitting particles.
  95306. */
  95307. minSize: number;
  95308. /**
  95309. * Maximum Size of emitting particles.
  95310. */
  95311. maxSize: number;
  95312. /**
  95313. * Minimum scale of emitting particles on X axis.
  95314. */
  95315. minScaleX: number;
  95316. /**
  95317. * Maximum scale of emitting particles on X axis.
  95318. */
  95319. maxScaleX: number;
  95320. /**
  95321. * Minimum scale of emitting particles on Y axis.
  95322. */
  95323. minScaleY: number;
  95324. /**
  95325. * Maximum scale of emitting particles on Y axis.
  95326. */
  95327. maxScaleY: number;
  95328. /**
  95329. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  95330. */
  95331. color1: Color4;
  95332. /**
  95333. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  95334. */
  95335. color2: Color4;
  95336. /**
  95337. * Color the particle will have at the end of its lifetime.
  95338. */
  95339. colorDead: Color4;
  95340. /**
  95341. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  95342. */
  95343. emitRate: number;
  95344. /**
  95345. * You can use gravity if you want to give an orientation to your particles.
  95346. */
  95347. gravity: Vector3;
  95348. /**
  95349. * Minimum power of emitting particles.
  95350. */
  95351. minEmitPower: number;
  95352. /**
  95353. * Maximum power of emitting particles.
  95354. */
  95355. maxEmitPower: number;
  95356. /**
  95357. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  95358. */
  95359. minAngularSpeed: number;
  95360. /**
  95361. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  95362. */
  95363. maxAngularSpeed: number;
  95364. /**
  95365. * Gets or sets the minimal initial rotation in radians.
  95366. */
  95367. minInitialRotation: number;
  95368. /**
  95369. * Gets or sets the maximal initial rotation in radians.
  95370. */
  95371. maxInitialRotation: number;
  95372. /**
  95373. * The particle emitter type defines the emitter used by the particle system.
  95374. * It can be for example box, sphere, or cone...
  95375. */
  95376. particleEmitterType: Nullable<IParticleEmitterType>;
  95377. /**
  95378. * Defines the delay in milliseconds before starting the system (0 by default)
  95379. */
  95380. startDelay: number;
  95381. /**
  95382. * 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
  95383. */
  95384. preWarmCycles: number;
  95385. /**
  95386. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  95387. */
  95388. preWarmStepOffset: number;
  95389. /**
  95390. * 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)
  95391. */
  95392. spriteCellChangeSpeed: number;
  95393. /**
  95394. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  95395. */
  95396. startSpriteCellID: number;
  95397. /**
  95398. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  95399. */
  95400. endSpriteCellID: number;
  95401. /**
  95402. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  95403. */
  95404. spriteCellWidth: number;
  95405. /**
  95406. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  95407. */
  95408. spriteCellHeight: number;
  95409. /**
  95410. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  95411. */
  95412. spriteRandomStartCell: boolean;
  95413. /**
  95414. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  95415. */
  95416. isAnimationSheetEnabled: boolean;
  95417. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  95418. translationPivot: Vector2;
  95419. /**
  95420. * Gets or sets a texture used to add random noise to particle positions
  95421. */
  95422. noiseTexture: Nullable<BaseTexture>;
  95423. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  95424. noiseStrength: Vector3;
  95425. /**
  95426. * Gets or sets the billboard mode to use when isBillboardBased = true.
  95427. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  95428. */
  95429. billboardMode: number;
  95430. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  95431. limitVelocityDamping: number;
  95432. /**
  95433. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  95434. */
  95435. beginAnimationOnStart: boolean;
  95436. /**
  95437. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  95438. */
  95439. beginAnimationFrom: number;
  95440. /**
  95441. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  95442. */
  95443. beginAnimationTo: number;
  95444. /**
  95445. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  95446. */
  95447. beginAnimationLoop: boolean;
  95448. /**
  95449. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  95450. */
  95451. disposeOnStop: boolean;
  95452. /**
  95453. * Specifies if the particles are updated in emitter local space or world space
  95454. */
  95455. isLocal: boolean;
  95456. /** Snippet ID if the particle system was created from the snippet server */
  95457. snippetId: string;
  95458. /** Gets or sets a matrix to use to compute projection */
  95459. defaultProjectionMatrix: Matrix;
  95460. /**
  95461. * Gets the maximum number of particles active at the same time.
  95462. * @returns The max number of active particles.
  95463. */
  95464. getCapacity(): number;
  95465. /**
  95466. * Gets the number of particles active at the same time.
  95467. * @returns The number of active particles.
  95468. */
  95469. getActiveCount(): number;
  95470. /**
  95471. * Gets if the system has been started. (Note: this will still be true after stop is called)
  95472. * @returns True if it has been started, otherwise false.
  95473. */
  95474. isStarted(): boolean;
  95475. /**
  95476. * Animates the particle system for this frame.
  95477. */
  95478. animate(): void;
  95479. /**
  95480. * Renders the particle system in its current state.
  95481. * @returns the current number of particles
  95482. */
  95483. render(): number;
  95484. /**
  95485. * Dispose the particle system and frees its associated resources.
  95486. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  95487. */
  95488. dispose(disposeTexture?: boolean): void;
  95489. /**
  95490. * An event triggered when the system is disposed
  95491. */
  95492. onDisposeObservable: Observable<IParticleSystem>;
  95493. /**
  95494. * An event triggered when the system is stopped
  95495. */
  95496. onStoppedObservable: Observable<IParticleSystem>;
  95497. /**
  95498. * Clones the particle system.
  95499. * @param name The name of the cloned object
  95500. * @param newEmitter The new emitter to use
  95501. * @returns the cloned particle system
  95502. */
  95503. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  95504. /**
  95505. * Serializes the particle system to a JSON object
  95506. * @param serializeTexture defines if the texture must be serialized as well
  95507. * @returns the JSON object
  95508. */
  95509. serialize(serializeTexture: boolean): any;
  95510. /**
  95511. * Rebuild the particle system
  95512. */
  95513. rebuild(): void;
  95514. /** Force the system to rebuild all gradients that need to be resync */
  95515. forceRefreshGradients(): void;
  95516. /**
  95517. * Starts the particle system and begins to emit
  95518. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  95519. */
  95520. start(delay?: number): void;
  95521. /**
  95522. * Stops the particle system.
  95523. */
  95524. stop(): void;
  95525. /**
  95526. * Remove all active particles
  95527. */
  95528. reset(): void;
  95529. /**
  95530. * Gets a boolean indicating that the system is stopping
  95531. * @returns true if the system is currently stopping
  95532. */
  95533. isStopping(): boolean;
  95534. /**
  95535. * Is this system ready to be used/rendered
  95536. * @return true if the system is ready
  95537. */
  95538. isReady(): boolean;
  95539. /**
  95540. * Returns the string "ParticleSystem"
  95541. * @returns a string containing the class name
  95542. */
  95543. getClassName(): string;
  95544. /**
  95545. * Gets the custom effect used to render the particles
  95546. * @param blendMode Blend mode for which the effect should be retrieved
  95547. * @returns The effect
  95548. */
  95549. getCustomEffect(blendMode: number): Nullable<Effect>;
  95550. /**
  95551. * Sets the custom effect used to render the particles
  95552. * @param effect The effect to set
  95553. * @param blendMode Blend mode for which the effect should be set
  95554. */
  95555. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  95556. /**
  95557. * Fill the defines array according to the current settings of the particle system
  95558. * @param defines Array to be updated
  95559. * @param blendMode blend mode to take into account when updating the array
  95560. */
  95561. fillDefines(defines: Array<string>, blendMode: number): void;
  95562. /**
  95563. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  95564. * @param uniforms Uniforms array to fill
  95565. * @param attributes Attributes array to fill
  95566. * @param samplers Samplers array to fill
  95567. */
  95568. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  95569. /**
  95570. * Observable that will be called just before the particles are drawn
  95571. */
  95572. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  95573. /**
  95574. * Gets the name of the particle vertex shader
  95575. */
  95576. vertexShaderName: string;
  95577. /**
  95578. * Adds a new color gradient
  95579. * @param gradient defines the gradient to use (between 0 and 1)
  95580. * @param color1 defines the color to affect to the specified gradient
  95581. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  95582. * @returns the current particle system
  95583. */
  95584. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  95585. /**
  95586. * Remove a specific color gradient
  95587. * @param gradient defines the gradient to remove
  95588. * @returns the current particle system
  95589. */
  95590. removeColorGradient(gradient: number): IParticleSystem;
  95591. /**
  95592. * Adds a new size gradient
  95593. * @param gradient defines the gradient to use (between 0 and 1)
  95594. * @param factor defines the size factor to affect to the specified gradient
  95595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95596. * @returns the current particle system
  95597. */
  95598. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95599. /**
  95600. * Remove a specific size gradient
  95601. * @param gradient defines the gradient to remove
  95602. * @returns the current particle system
  95603. */
  95604. removeSizeGradient(gradient: number): IParticleSystem;
  95605. /**
  95606. * Gets the current list of color gradients.
  95607. * You must use addColorGradient and removeColorGradient to udpate this list
  95608. * @returns the list of color gradients
  95609. */
  95610. getColorGradients(): Nullable<Array<ColorGradient>>;
  95611. /**
  95612. * Gets the current list of size gradients.
  95613. * You must use addSizeGradient and removeSizeGradient to udpate this list
  95614. * @returns the list of size gradients
  95615. */
  95616. getSizeGradients(): Nullable<Array<FactorGradient>>;
  95617. /**
  95618. * Gets the current list of angular speed gradients.
  95619. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  95620. * @returns the list of angular speed gradients
  95621. */
  95622. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  95623. /**
  95624. * Adds a new angular speed gradient
  95625. * @param gradient defines the gradient to use (between 0 and 1)
  95626. * @param factor defines the angular speed to affect to the specified gradient
  95627. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95628. * @returns the current particle system
  95629. */
  95630. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95631. /**
  95632. * Remove a specific angular speed gradient
  95633. * @param gradient defines the gradient to remove
  95634. * @returns the current particle system
  95635. */
  95636. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  95637. /**
  95638. * Gets the current list of velocity gradients.
  95639. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  95640. * @returns the list of velocity gradients
  95641. */
  95642. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  95643. /**
  95644. * Adds a new velocity gradient
  95645. * @param gradient defines the gradient to use (between 0 and 1)
  95646. * @param factor defines the velocity to affect to the specified gradient
  95647. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95648. * @returns the current particle system
  95649. */
  95650. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95651. /**
  95652. * Remove a specific velocity gradient
  95653. * @param gradient defines the gradient to remove
  95654. * @returns the current particle system
  95655. */
  95656. removeVelocityGradient(gradient: number): IParticleSystem;
  95657. /**
  95658. * Gets the current list of limit velocity gradients.
  95659. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  95660. * @returns the list of limit velocity gradients
  95661. */
  95662. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  95663. /**
  95664. * Adds a new limit velocity gradient
  95665. * @param gradient defines the gradient to use (between 0 and 1)
  95666. * @param factor defines the limit velocity to affect to the specified gradient
  95667. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95668. * @returns the current particle system
  95669. */
  95670. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95671. /**
  95672. * Remove a specific limit velocity gradient
  95673. * @param gradient defines the gradient to remove
  95674. * @returns the current particle system
  95675. */
  95676. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  95677. /**
  95678. * Adds a new drag gradient
  95679. * @param gradient defines the gradient to use (between 0 and 1)
  95680. * @param factor defines the drag to affect to the specified gradient
  95681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95682. * @returns the current particle system
  95683. */
  95684. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95685. /**
  95686. * Remove a specific drag gradient
  95687. * @param gradient defines the gradient to remove
  95688. * @returns the current particle system
  95689. */
  95690. removeDragGradient(gradient: number): IParticleSystem;
  95691. /**
  95692. * Gets the current list of drag gradients.
  95693. * You must use addDragGradient and removeDragGradient to udpate this list
  95694. * @returns the list of drag gradients
  95695. */
  95696. getDragGradients(): Nullable<Array<FactorGradient>>;
  95697. /**
  95698. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  95699. * @param gradient defines the gradient to use (between 0 and 1)
  95700. * @param factor defines the emit rate to affect to the specified gradient
  95701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95702. * @returns the current particle system
  95703. */
  95704. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95705. /**
  95706. * Remove a specific emit rate gradient
  95707. * @param gradient defines the gradient to remove
  95708. * @returns the current particle system
  95709. */
  95710. removeEmitRateGradient(gradient: number): IParticleSystem;
  95711. /**
  95712. * Gets the current list of emit rate gradients.
  95713. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  95714. * @returns the list of emit rate gradients
  95715. */
  95716. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  95717. /**
  95718. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  95719. * @param gradient defines the gradient to use (between 0 and 1)
  95720. * @param factor defines the start size to affect to the specified gradient
  95721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95722. * @returns the current particle system
  95723. */
  95724. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95725. /**
  95726. * Remove a specific start size gradient
  95727. * @param gradient defines the gradient to remove
  95728. * @returns the current particle system
  95729. */
  95730. removeStartSizeGradient(gradient: number): IParticleSystem;
  95731. /**
  95732. * Gets the current list of start size gradients.
  95733. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95734. * @returns the list of start size gradients
  95735. */
  95736. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95737. /**
  95738. * Adds a new life time gradient
  95739. * @param gradient defines the gradient to use (between 0 and 1)
  95740. * @param factor defines the life time factor to affect to the specified gradient
  95741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95742. * @returns the current particle system
  95743. */
  95744. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95745. /**
  95746. * Remove a specific life time gradient
  95747. * @param gradient defines the gradient to remove
  95748. * @returns the current particle system
  95749. */
  95750. removeLifeTimeGradient(gradient: number): IParticleSystem;
  95751. /**
  95752. * Gets the current list of life time gradients.
  95753. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95754. * @returns the list of life time gradients
  95755. */
  95756. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95757. /**
  95758. * Gets the current list of color gradients.
  95759. * You must use addColorGradient and removeColorGradient to udpate this list
  95760. * @returns the list of color gradients
  95761. */
  95762. getColorGradients(): Nullable<Array<ColorGradient>>;
  95763. /**
  95764. * Adds a new ramp gradient used to remap particle colors
  95765. * @param gradient defines the gradient to use (between 0 and 1)
  95766. * @param color defines the color to affect to the specified gradient
  95767. * @returns the current particle system
  95768. */
  95769. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  95770. /**
  95771. * Gets the current list of ramp gradients.
  95772. * You must use addRampGradient and removeRampGradient to udpate this list
  95773. * @returns the list of ramp gradients
  95774. */
  95775. getRampGradients(): Nullable<Array<Color3Gradient>>;
  95776. /** Gets or sets a boolean indicating that ramp gradients must be used
  95777. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  95778. */
  95779. useRampGradients: boolean;
  95780. /**
  95781. * Adds a new color remap gradient
  95782. * @param gradient defines the gradient to use (between 0 and 1)
  95783. * @param min defines the color remap minimal range
  95784. * @param max defines the color remap maximal range
  95785. * @returns the current particle system
  95786. */
  95787. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95788. /**
  95789. * Gets the current list of color remap gradients.
  95790. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95791. * @returns the list of color remap gradients
  95792. */
  95793. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95794. /**
  95795. * Adds a new alpha remap gradient
  95796. * @param gradient defines the gradient to use (between 0 and 1)
  95797. * @param min defines the alpha remap minimal range
  95798. * @param max defines the alpha remap maximal range
  95799. * @returns the current particle system
  95800. */
  95801. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95802. /**
  95803. * Gets the current list of alpha remap gradients.
  95804. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95805. * @returns the list of alpha remap gradients
  95806. */
  95807. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95808. /**
  95809. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  95810. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95811. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95812. * @returns the emitter
  95813. */
  95814. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  95815. /**
  95816. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  95817. * @param radius The radius of the hemisphere to emit from
  95818. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95819. * @returns the emitter
  95820. */
  95821. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  95822. /**
  95823. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  95824. * @param radius The radius of the sphere to emit from
  95825. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95826. * @returns the emitter
  95827. */
  95828. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  95829. /**
  95830. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  95831. * @param radius The radius of the sphere to emit from
  95832. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  95833. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  95834. * @returns the emitter
  95835. */
  95836. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95837. /**
  95838. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  95839. * @param radius The radius of the emission cylinder
  95840. * @param height The height of the emission cylinder
  95841. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  95842. * @param directionRandomizer How much to randomize the particle direction [0-1]
  95843. * @returns the emitter
  95844. */
  95845. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  95846. /**
  95847. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  95848. * @param radius The radius of the cylinder to emit from
  95849. * @param height The height of the emission cylinder
  95850. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95851. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  95852. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  95853. * @returns the emitter
  95854. */
  95855. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95856. /**
  95857. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  95858. * @param radius The radius of the cone to emit from
  95859. * @param angle The base angle of the cone
  95860. * @returns the emitter
  95861. */
  95862. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  95863. /**
  95864. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  95865. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95866. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95867. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95868. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95869. * @returns the emitter
  95870. */
  95871. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  95872. /**
  95873. * Get hosting scene
  95874. * @returns the scene
  95875. */
  95876. getScene(): Nullable<Scene>;
  95877. }
  95878. }
  95879. declare module BABYLON {
  95880. /**
  95881. * 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.
  95882. * @see https://doc.babylonjs.com/how_to/transformnode
  95883. */
  95884. export class TransformNode extends Node {
  95885. /**
  95886. * Object will not rotate to face the camera
  95887. */
  95888. static BILLBOARDMODE_NONE: number;
  95889. /**
  95890. * Object will rotate to face the camera but only on the x axis
  95891. */
  95892. static BILLBOARDMODE_X: number;
  95893. /**
  95894. * Object will rotate to face the camera but only on the y axis
  95895. */
  95896. static BILLBOARDMODE_Y: number;
  95897. /**
  95898. * Object will rotate to face the camera but only on the z axis
  95899. */
  95900. static BILLBOARDMODE_Z: number;
  95901. /**
  95902. * Object will rotate to face the camera
  95903. */
  95904. static BILLBOARDMODE_ALL: number;
  95905. /**
  95906. * Object will rotate to face the camera's position instead of orientation
  95907. */
  95908. static BILLBOARDMODE_USE_POSITION: number;
  95909. private static _TmpRotation;
  95910. private static _TmpScaling;
  95911. private static _TmpTranslation;
  95912. private _forward;
  95913. private _forwardInverted;
  95914. private _up;
  95915. private _right;
  95916. private _rightInverted;
  95917. private _position;
  95918. private _rotation;
  95919. private _rotationQuaternion;
  95920. protected _scaling: Vector3;
  95921. protected _isDirty: boolean;
  95922. private _transformToBoneReferal;
  95923. private _isAbsoluteSynced;
  95924. private _billboardMode;
  95925. /**
  95926. * Gets or sets the billboard mode. Default is 0.
  95927. *
  95928. * | Value | Type | Description |
  95929. * | --- | --- | --- |
  95930. * | 0 | BILLBOARDMODE_NONE | |
  95931. * | 1 | BILLBOARDMODE_X | |
  95932. * | 2 | BILLBOARDMODE_Y | |
  95933. * | 4 | BILLBOARDMODE_Z | |
  95934. * | 7 | BILLBOARDMODE_ALL | |
  95935. *
  95936. */
  95937. get billboardMode(): number;
  95938. set billboardMode(value: number);
  95939. private _preserveParentRotationForBillboard;
  95940. /**
  95941. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95942. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95943. */
  95944. get preserveParentRotationForBillboard(): boolean;
  95945. set preserveParentRotationForBillboard(value: boolean);
  95946. /**
  95947. * 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
  95948. */
  95949. scalingDeterminant: number;
  95950. private _infiniteDistance;
  95951. /**
  95952. * Gets or sets the distance of the object to max, often used by skybox
  95953. */
  95954. get infiniteDistance(): boolean;
  95955. set infiniteDistance(value: boolean);
  95956. /**
  95957. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95958. * By default the system will update normals to compensate
  95959. */
  95960. ignoreNonUniformScaling: boolean;
  95961. /**
  95962. * 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
  95963. */
  95964. reIntegrateRotationIntoRotationQuaternion: boolean;
  95965. /** @hidden */
  95966. _poseMatrix: Nullable<Matrix>;
  95967. /** @hidden */
  95968. _localMatrix: Matrix;
  95969. private _usePivotMatrix;
  95970. private _absolutePosition;
  95971. private _absoluteScaling;
  95972. private _absoluteRotationQuaternion;
  95973. private _pivotMatrix;
  95974. private _pivotMatrixInverse;
  95975. /** @hidden */
  95976. _postMultiplyPivotMatrix: boolean;
  95977. protected _isWorldMatrixFrozen: boolean;
  95978. /** @hidden */
  95979. _indexInSceneTransformNodesArray: number;
  95980. /**
  95981. * An event triggered after the world matrix is updated
  95982. */
  95983. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95984. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95985. /**
  95986. * Gets a string identifying the name of the class
  95987. * @returns "TransformNode" string
  95988. */
  95989. getClassName(): string;
  95990. /**
  95991. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95992. */
  95993. get position(): Vector3;
  95994. set position(newPosition: Vector3);
  95995. /**
  95996. * 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)).
  95997. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95998. */
  95999. get rotation(): Vector3;
  96000. set rotation(newRotation: Vector3);
  96001. /**
  96002. * 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)).
  96003. */
  96004. get scaling(): Vector3;
  96005. set scaling(newScaling: Vector3);
  96006. /**
  96007. * 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).
  96008. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  96009. */
  96010. get rotationQuaternion(): Nullable<Quaternion>;
  96011. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  96012. /**
  96013. * The forward direction of that transform in world space.
  96014. */
  96015. get forward(): Vector3;
  96016. /**
  96017. * The up direction of that transform in world space.
  96018. */
  96019. get up(): Vector3;
  96020. /**
  96021. * The right direction of that transform in world space.
  96022. */
  96023. get right(): Vector3;
  96024. /**
  96025. * Copies the parameter passed Matrix into the mesh Pose matrix.
  96026. * @param matrix the matrix to copy the pose from
  96027. * @returns this TransformNode.
  96028. */
  96029. updatePoseMatrix(matrix: Matrix): TransformNode;
  96030. /**
  96031. * Returns the mesh Pose matrix.
  96032. * @returns the pose matrix
  96033. */
  96034. getPoseMatrix(): Matrix;
  96035. /** @hidden */
  96036. _isSynchronized(): boolean;
  96037. /** @hidden */
  96038. _initCache(): void;
  96039. /**
  96040. * Flag the transform node as dirty (Forcing it to update everything)
  96041. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  96042. * @returns this transform node
  96043. */
  96044. markAsDirty(property: string): TransformNode;
  96045. /**
  96046. * Returns the current mesh absolute position.
  96047. * Returns a Vector3.
  96048. */
  96049. get absolutePosition(): Vector3;
  96050. /**
  96051. * Returns the current mesh absolute scaling.
  96052. * Returns a Vector3.
  96053. */
  96054. get absoluteScaling(): Vector3;
  96055. /**
  96056. * Returns the current mesh absolute rotation.
  96057. * Returns a Quaternion.
  96058. */
  96059. get absoluteRotationQuaternion(): Quaternion;
  96060. /**
  96061. * Sets a new matrix to apply before all other transformation
  96062. * @param matrix defines the transform matrix
  96063. * @returns the current TransformNode
  96064. */
  96065. setPreTransformMatrix(matrix: Matrix): TransformNode;
  96066. /**
  96067. * Sets a new pivot matrix to the current node
  96068. * @param matrix defines the new pivot matrix to use
  96069. * @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
  96070. * @returns the current TransformNode
  96071. */
  96072. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  96073. /**
  96074. * Returns the mesh pivot matrix.
  96075. * Default : Identity.
  96076. * @returns the matrix
  96077. */
  96078. getPivotMatrix(): Matrix;
  96079. /**
  96080. * Instantiate (when possible) or clone that node with its hierarchy
  96081. * @param newParent defines the new parent to use for the instance (or clone)
  96082. * @param options defines options to configure how copy is done
  96083. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  96084. * @returns an instance (or a clone) of the current node with its hiearchy
  96085. */
  96086. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  96087. doNotInstantiate: boolean;
  96088. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  96089. /**
  96090. * Prevents the World matrix to be computed any longer
  96091. * @param newWorldMatrix defines an optional matrix to use as world matrix
  96092. * @returns the TransformNode.
  96093. */
  96094. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  96095. /**
  96096. * Allows back the World matrix computation.
  96097. * @returns the TransformNode.
  96098. */
  96099. unfreezeWorldMatrix(): this;
  96100. /**
  96101. * True if the World matrix has been frozen.
  96102. */
  96103. get isWorldMatrixFrozen(): boolean;
  96104. /**
  96105. * Retuns the mesh absolute position in the World.
  96106. * @returns a Vector3.
  96107. */
  96108. getAbsolutePosition(): Vector3;
  96109. /**
  96110. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  96111. * @param absolutePosition the absolute position to set
  96112. * @returns the TransformNode.
  96113. */
  96114. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96115. /**
  96116. * Sets the mesh position in its local space.
  96117. * @param vector3 the position to set in localspace
  96118. * @returns the TransformNode.
  96119. */
  96120. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  96121. /**
  96122. * Returns the mesh position in the local space from the current World matrix values.
  96123. * @returns a new Vector3.
  96124. */
  96125. getPositionExpressedInLocalSpace(): Vector3;
  96126. /**
  96127. * Translates the mesh along the passed Vector3 in its local space.
  96128. * @param vector3 the distance to translate in localspace
  96129. * @returns the TransformNode.
  96130. */
  96131. locallyTranslate(vector3: Vector3): TransformNode;
  96132. private static _lookAtVectorCache;
  96133. /**
  96134. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  96135. * @param targetPoint the position (must be in same space as current mesh) to look at
  96136. * @param yawCor optional yaw (y-axis) correction in radians
  96137. * @param pitchCor optional pitch (x-axis) correction in radians
  96138. * @param rollCor optional roll (z-axis) correction in radians
  96139. * @param space the choosen space of the target
  96140. * @returns the TransformNode.
  96141. */
  96142. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  96143. /**
  96144. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  96145. * This Vector3 is expressed in the World space.
  96146. * @param localAxis axis to rotate
  96147. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  96148. */
  96149. getDirection(localAxis: Vector3): Vector3;
  96150. /**
  96151. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  96152. * localAxis is expressed in the mesh local space.
  96153. * result is computed in the Wordl space from the mesh World matrix.
  96154. * @param localAxis axis to rotate
  96155. * @param result the resulting transformnode
  96156. * @returns this TransformNode.
  96157. */
  96158. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  96159. /**
  96160. * Sets this transform node rotation to the given local axis.
  96161. * @param localAxis the axis in local space
  96162. * @param yawCor optional yaw (y-axis) correction in radians
  96163. * @param pitchCor optional pitch (x-axis) correction in radians
  96164. * @param rollCor optional roll (z-axis) correction in radians
  96165. * @returns this TransformNode
  96166. */
  96167. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  96168. /**
  96169. * Sets a new pivot point to the current node
  96170. * @param point defines the new pivot point to use
  96171. * @param space defines if the point is in world or local space (local by default)
  96172. * @returns the current TransformNode
  96173. */
  96174. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  96175. /**
  96176. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  96177. * @returns the pivot point
  96178. */
  96179. getPivotPoint(): Vector3;
  96180. /**
  96181. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  96182. * @param result the vector3 to store the result
  96183. * @returns this TransformNode.
  96184. */
  96185. getPivotPointToRef(result: Vector3): TransformNode;
  96186. /**
  96187. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  96188. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  96189. */
  96190. getAbsolutePivotPoint(): Vector3;
  96191. /**
  96192. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  96193. * @param result vector3 to store the result
  96194. * @returns this TransformNode.
  96195. */
  96196. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  96197. /**
  96198. * Defines the passed node as the parent of the current node.
  96199. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  96200. * @see https://doc.babylonjs.com/how_to/parenting
  96201. * @param node the node ot set as the parent
  96202. * @returns this TransformNode.
  96203. */
  96204. setParent(node: Nullable<Node>): TransformNode;
  96205. private _nonUniformScaling;
  96206. /**
  96207. * True if the scaling property of this object is non uniform eg. (1,2,1)
  96208. */
  96209. get nonUniformScaling(): boolean;
  96210. /** @hidden */
  96211. _updateNonUniformScalingState(value: boolean): boolean;
  96212. /**
  96213. * Attach the current TransformNode to another TransformNode associated with a bone
  96214. * @param bone Bone affecting the TransformNode
  96215. * @param affectedTransformNode TransformNode associated with the bone
  96216. * @returns this object
  96217. */
  96218. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  96219. /**
  96220. * Detach the transform node if its associated with a bone
  96221. * @returns this object
  96222. */
  96223. detachFromBone(): TransformNode;
  96224. private static _rotationAxisCache;
  96225. /**
  96226. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  96227. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  96228. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  96229. * The passed axis is also normalized.
  96230. * @param axis the axis to rotate around
  96231. * @param amount the amount to rotate in radians
  96232. * @param space Space to rotate in (Default: local)
  96233. * @returns the TransformNode.
  96234. */
  96235. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96236. /**
  96237. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  96238. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  96239. * The passed axis is also normalized. .
  96240. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  96241. * @param point the point to rotate around
  96242. * @param axis the axis to rotate around
  96243. * @param amount the amount to rotate in radians
  96244. * @returns the TransformNode
  96245. */
  96246. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  96247. /**
  96248. * Translates the mesh along the axis vector for the passed distance in the given space.
  96249. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  96250. * @param axis the axis to translate in
  96251. * @param distance the distance to translate
  96252. * @param space Space to rotate in (Default: local)
  96253. * @returns the TransformNode.
  96254. */
  96255. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96256. /**
  96257. * Adds a rotation step to the mesh current rotation.
  96258. * x, y, z are Euler angles expressed in radians.
  96259. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  96260. * This means this rotation is made in the mesh local space only.
  96261. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  96262. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  96263. * ```javascript
  96264. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  96265. * ```
  96266. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  96267. * 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.
  96268. * @param x Rotation to add
  96269. * @param y Rotation to add
  96270. * @param z Rotation to add
  96271. * @returns the TransformNode.
  96272. */
  96273. addRotation(x: number, y: number, z: number): TransformNode;
  96274. /**
  96275. * @hidden
  96276. */
  96277. protected _getEffectiveParent(): Nullable<Node>;
  96278. /**
  96279. * Computes the world matrix of the node
  96280. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  96281. * @returns the world matrix
  96282. */
  96283. computeWorldMatrix(force?: boolean): Matrix;
  96284. /**
  96285. * Resets this nodeTransform's local matrix to Matrix.Identity().
  96286. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  96287. */
  96288. resetLocalMatrix(independentOfChildren?: boolean): void;
  96289. protected _afterComputeWorldMatrix(): void;
  96290. /**
  96291. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  96292. * @param func callback function to add
  96293. *
  96294. * @returns the TransformNode.
  96295. */
  96296. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  96297. /**
  96298. * Removes a registered callback function.
  96299. * @param func callback function to remove
  96300. * @returns the TransformNode.
  96301. */
  96302. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  96303. /**
  96304. * Gets the position of the current mesh in camera space
  96305. * @param camera defines the camera to use
  96306. * @returns a position
  96307. */
  96308. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  96309. /**
  96310. * Returns the distance from the mesh to the active camera
  96311. * @param camera defines the camera to use
  96312. * @returns the distance
  96313. */
  96314. getDistanceToCamera(camera?: Nullable<Camera>): number;
  96315. /**
  96316. * Clone the current transform node
  96317. * @param name Name of the new clone
  96318. * @param newParent New parent for the clone
  96319. * @param doNotCloneChildren Do not clone children hierarchy
  96320. * @returns the new transform node
  96321. */
  96322. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  96323. /**
  96324. * Serializes the objects information.
  96325. * @param currentSerializationObject defines the object to serialize in
  96326. * @returns the serialized object
  96327. */
  96328. serialize(currentSerializationObject?: any): any;
  96329. /**
  96330. * Returns a new TransformNode object parsed from the source provided.
  96331. * @param parsedTransformNode is the source.
  96332. * @param scene the scne the object belongs to
  96333. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  96334. * @returns a new TransformNode object parsed from the source provided.
  96335. */
  96336. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  96337. /**
  96338. * Get all child-transformNodes of this node
  96339. * @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
  96340. * @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
  96341. * @returns an array of TransformNode
  96342. */
  96343. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  96344. /**
  96345. * Releases resources associated with this transform node.
  96346. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96347. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96348. */
  96349. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96350. /**
  96351. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  96352. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  96353. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  96354. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  96355. * @returns the current mesh
  96356. */
  96357. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  96358. private _syncAbsoluteScalingAndRotation;
  96359. }
  96360. }
  96361. declare module BABYLON {
  96362. /**
  96363. * Class used to override all child animations of a given target
  96364. */
  96365. export class AnimationPropertiesOverride {
  96366. /**
  96367. * Gets or sets a value indicating if animation blending must be used
  96368. */
  96369. enableBlending: boolean;
  96370. /**
  96371. * Gets or sets the blending speed to use when enableBlending is true
  96372. */
  96373. blendingSpeed: number;
  96374. /**
  96375. * Gets or sets the default loop mode to use
  96376. */
  96377. loopMode: number;
  96378. }
  96379. }
  96380. declare module BABYLON {
  96381. /**
  96382. * Class used to store bone information
  96383. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96384. */
  96385. export class Bone extends Node {
  96386. /**
  96387. * defines the bone name
  96388. */
  96389. name: string;
  96390. private static _tmpVecs;
  96391. private static _tmpQuat;
  96392. private static _tmpMats;
  96393. /**
  96394. * Gets the list of child bones
  96395. */
  96396. children: Bone[];
  96397. /** Gets the animations associated with this bone */
  96398. animations: Animation[];
  96399. /**
  96400. * Gets or sets bone length
  96401. */
  96402. length: number;
  96403. /**
  96404. * @hidden Internal only
  96405. * Set this value to map this bone to a different index in the transform matrices
  96406. * Set this value to -1 to exclude the bone from the transform matrices
  96407. */
  96408. _index: Nullable<number>;
  96409. private _skeleton;
  96410. private _localMatrix;
  96411. private _restPose;
  96412. private _bindPose;
  96413. private _baseMatrix;
  96414. private _absoluteTransform;
  96415. private _invertedAbsoluteTransform;
  96416. private _parent;
  96417. private _scalingDeterminant;
  96418. private _worldTransform;
  96419. private _localScaling;
  96420. private _localRotation;
  96421. private _localPosition;
  96422. private _needToDecompose;
  96423. private _needToCompose;
  96424. /** @hidden */
  96425. _linkedTransformNode: Nullable<TransformNode>;
  96426. /** @hidden */
  96427. _waitingTransformNodeId: Nullable<string>;
  96428. /** @hidden */
  96429. get _matrix(): Matrix;
  96430. /** @hidden */
  96431. set _matrix(value: Matrix);
  96432. /**
  96433. * Create a new bone
  96434. * @param name defines the bone name
  96435. * @param skeleton defines the parent skeleton
  96436. * @param parentBone defines the parent (can be null if the bone is the root)
  96437. * @param localMatrix defines the local matrix
  96438. * @param restPose defines the rest pose matrix
  96439. * @param baseMatrix defines the base matrix
  96440. * @param index defines index of the bone in the hiearchy
  96441. */
  96442. constructor(
  96443. /**
  96444. * defines the bone name
  96445. */
  96446. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  96447. /**
  96448. * Gets the current object class name.
  96449. * @return the class name
  96450. */
  96451. getClassName(): string;
  96452. /**
  96453. * Gets the parent skeleton
  96454. * @returns a skeleton
  96455. */
  96456. getSkeleton(): Skeleton;
  96457. /**
  96458. * Gets parent bone
  96459. * @returns a bone or null if the bone is the root of the bone hierarchy
  96460. */
  96461. getParent(): Nullable<Bone>;
  96462. /**
  96463. * Returns an array containing the root bones
  96464. * @returns an array containing the root bones
  96465. */
  96466. getChildren(): Array<Bone>;
  96467. /**
  96468. * Gets the node index in matrix array generated for rendering
  96469. * @returns the node index
  96470. */
  96471. getIndex(): number;
  96472. /**
  96473. * Sets the parent bone
  96474. * @param parent defines the parent (can be null if the bone is the root)
  96475. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96476. */
  96477. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  96478. /**
  96479. * Gets the local matrix
  96480. * @returns a matrix
  96481. */
  96482. getLocalMatrix(): Matrix;
  96483. /**
  96484. * Gets the base matrix (initial matrix which remains unchanged)
  96485. * @returns a matrix
  96486. */
  96487. getBaseMatrix(): Matrix;
  96488. /**
  96489. * Gets the rest pose matrix
  96490. * @returns a matrix
  96491. */
  96492. getRestPose(): Matrix;
  96493. /**
  96494. * Sets the rest pose matrix
  96495. * @param matrix the local-space rest pose to set for this bone
  96496. */
  96497. setRestPose(matrix: Matrix): void;
  96498. /**
  96499. * Gets the bind pose matrix
  96500. * @returns the bind pose matrix
  96501. */
  96502. getBindPose(): Matrix;
  96503. /**
  96504. * Sets the bind pose matrix
  96505. * @param matrix the local-space bind pose to set for this bone
  96506. */
  96507. setBindPose(matrix: Matrix): void;
  96508. /**
  96509. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  96510. */
  96511. getWorldMatrix(): Matrix;
  96512. /**
  96513. * Sets the local matrix to rest pose matrix
  96514. */
  96515. returnToRest(): void;
  96516. /**
  96517. * Gets the inverse of the absolute transform matrix.
  96518. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  96519. * @returns a matrix
  96520. */
  96521. getInvertedAbsoluteTransform(): Matrix;
  96522. /**
  96523. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  96524. * @returns a matrix
  96525. */
  96526. getAbsoluteTransform(): Matrix;
  96527. /**
  96528. * Links with the given transform node.
  96529. * The local matrix of this bone is copied from the transform node every frame.
  96530. * @param transformNode defines the transform node to link to
  96531. */
  96532. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  96533. /**
  96534. * Gets the node used to drive the bone's transformation
  96535. * @returns a transform node or null
  96536. */
  96537. getTransformNode(): Nullable<TransformNode>;
  96538. /** Gets or sets current position (in local space) */
  96539. get position(): Vector3;
  96540. set position(newPosition: Vector3);
  96541. /** Gets or sets current rotation (in local space) */
  96542. get rotation(): Vector3;
  96543. set rotation(newRotation: Vector3);
  96544. /** Gets or sets current rotation quaternion (in local space) */
  96545. get rotationQuaternion(): Quaternion;
  96546. set rotationQuaternion(newRotation: Quaternion);
  96547. /** Gets or sets current scaling (in local space) */
  96548. get scaling(): Vector3;
  96549. set scaling(newScaling: Vector3);
  96550. /**
  96551. * Gets the animation properties override
  96552. */
  96553. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96554. private _decompose;
  96555. private _compose;
  96556. /**
  96557. * Update the base and local matrices
  96558. * @param matrix defines the new base or local matrix
  96559. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96560. * @param updateLocalMatrix defines if the local matrix should be updated
  96561. */
  96562. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  96563. /** @hidden */
  96564. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  96565. /**
  96566. * Flag the bone as dirty (Forcing it to update everything)
  96567. */
  96568. markAsDirty(): void;
  96569. /** @hidden */
  96570. _markAsDirtyAndCompose(): void;
  96571. private _markAsDirtyAndDecompose;
  96572. /**
  96573. * Translate the bone in local or world space
  96574. * @param vec The amount to translate the bone
  96575. * @param space The space that the translation is in
  96576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96577. */
  96578. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96579. /**
  96580. * Set the postion of the bone in local or world space
  96581. * @param position The position to set the bone
  96582. * @param space The space that the position is in
  96583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96584. */
  96585. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96586. /**
  96587. * Set the absolute position of the bone (world space)
  96588. * @param position The position to set the bone
  96589. * @param mesh The mesh that this bone is attached to
  96590. */
  96591. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  96592. /**
  96593. * Scale the bone on the x, y and z axes (in local space)
  96594. * @param x The amount to scale the bone on the x axis
  96595. * @param y The amount to scale the bone on the y axis
  96596. * @param z The amount to scale the bone on the z axis
  96597. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  96598. */
  96599. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  96600. /**
  96601. * Set the bone scaling in local space
  96602. * @param scale defines the scaling vector
  96603. */
  96604. setScale(scale: Vector3): void;
  96605. /**
  96606. * Gets the current scaling in local space
  96607. * @returns the current scaling vector
  96608. */
  96609. getScale(): Vector3;
  96610. /**
  96611. * Gets the current scaling in local space and stores it in a target vector
  96612. * @param result defines the target vector
  96613. */
  96614. getScaleToRef(result: Vector3): void;
  96615. /**
  96616. * Set the yaw, pitch, and roll of the bone in local or world space
  96617. * @param yaw The rotation of the bone on the y axis
  96618. * @param pitch The rotation of the bone on the x axis
  96619. * @param roll The rotation of the bone on the z axis
  96620. * @param space The space that the axes of rotation are in
  96621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96622. */
  96623. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  96624. /**
  96625. * Add a rotation to the bone on an axis in local or world space
  96626. * @param axis The axis to rotate the bone on
  96627. * @param amount The amount to rotate the bone
  96628. * @param space The space that the axis is in
  96629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96630. */
  96631. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  96632. /**
  96633. * Set the rotation of the bone to a particular axis angle in local or world space
  96634. * @param axis The axis to rotate the bone on
  96635. * @param angle The angle that the bone should be rotated to
  96636. * @param space The space that the axis is in
  96637. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96638. */
  96639. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  96640. /**
  96641. * Set the euler rotation of the bone in local or world space
  96642. * @param rotation The euler rotation that the bone should be set to
  96643. * @param space The space that the rotation is in
  96644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96645. */
  96646. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96647. /**
  96648. * Set the quaternion rotation of the bone in local or world space
  96649. * @param quat The quaternion rotation that the bone should be set to
  96650. * @param space The space that the rotation is in
  96651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96652. */
  96653. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  96654. /**
  96655. * Set the rotation matrix of the bone in local or world space
  96656. * @param rotMat The rotation matrix that the bone should be set to
  96657. * @param space The space that the rotation is in
  96658. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96659. */
  96660. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  96661. private _rotateWithMatrix;
  96662. private _getNegativeRotationToRef;
  96663. /**
  96664. * Get the position of the bone in local or world space
  96665. * @param space The space that the returned position is in
  96666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96667. * @returns The position of the bone
  96668. */
  96669. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96670. /**
  96671. * Copy the position of the bone to a vector3 in local or world space
  96672. * @param space The space that the returned position is in
  96673. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96674. * @param result The vector3 to copy the position to
  96675. */
  96676. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  96677. /**
  96678. * Get the absolute position of the bone (world space)
  96679. * @param mesh The mesh that this bone is attached to
  96680. * @returns The absolute position of the bone
  96681. */
  96682. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  96683. /**
  96684. * Copy the absolute position of the bone (world space) to the result param
  96685. * @param mesh The mesh that this bone is attached to
  96686. * @param result The vector3 to copy the absolute position to
  96687. */
  96688. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  96689. /**
  96690. * Compute the absolute transforms of this bone and its children
  96691. */
  96692. computeAbsoluteTransforms(): void;
  96693. /**
  96694. * Get the world direction from an axis that is in the local space of the bone
  96695. * @param localAxis The local direction that is used to compute the world direction
  96696. * @param mesh The mesh that this bone is attached to
  96697. * @returns The world direction
  96698. */
  96699. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96700. /**
  96701. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  96702. * @param localAxis The local direction that is used to compute the world direction
  96703. * @param mesh The mesh that this bone is attached to
  96704. * @param result The vector3 that the world direction will be copied to
  96705. */
  96706. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96707. /**
  96708. * Get the euler rotation of the bone in local or world space
  96709. * @param space The space that the rotation should be in
  96710. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96711. * @returns The euler rotation
  96712. */
  96713. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96714. /**
  96715. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  96716. * @param space The space that the rotation should be in
  96717. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96718. * @param result The vector3 that the rotation should be copied to
  96719. */
  96720. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96721. /**
  96722. * Get the quaternion rotation of the bone in either local or world space
  96723. * @param space The space that the rotation should be in
  96724. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96725. * @returns The quaternion rotation
  96726. */
  96727. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  96728. /**
  96729. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  96730. * @param space The space that the rotation should be in
  96731. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96732. * @param result The quaternion that the rotation should be copied to
  96733. */
  96734. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  96735. /**
  96736. * Get the rotation matrix of the bone in local or world space
  96737. * @param space The space that the rotation should be in
  96738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96739. * @returns The rotation matrix
  96740. */
  96741. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  96742. /**
  96743. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  96744. * @param space The space that the rotation should be in
  96745. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96746. * @param result The quaternion that the rotation should be copied to
  96747. */
  96748. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  96749. /**
  96750. * Get the world position of a point that is in the local space of the bone
  96751. * @param position The local position
  96752. * @param mesh The mesh that this bone is attached to
  96753. * @returns The world position
  96754. */
  96755. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96756. /**
  96757. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  96758. * @param position The local position
  96759. * @param mesh The mesh that this bone is attached to
  96760. * @param result The vector3 that the world position should be copied to
  96761. */
  96762. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96763. /**
  96764. * Get the local position of a point that is in world space
  96765. * @param position The world position
  96766. * @param mesh The mesh that this bone is attached to
  96767. * @returns The local position
  96768. */
  96769. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96770. /**
  96771. * Get the local position of a point that is in world space and copy it to the result param
  96772. * @param position The world position
  96773. * @param mesh The mesh that this bone is attached to
  96774. * @param result The vector3 that the local position should be copied to
  96775. */
  96776. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96777. /**
  96778. * Set the current local matrix as the restPose for this bone.
  96779. */
  96780. setCurrentPoseAsRest(): void;
  96781. }
  96782. }
  96783. declare module BABYLON {
  96784. /**
  96785. * Defines a runtime animation
  96786. */
  96787. export class RuntimeAnimation {
  96788. private _events;
  96789. /**
  96790. * The current frame of the runtime animation
  96791. */
  96792. private _currentFrame;
  96793. /**
  96794. * The animation used by the runtime animation
  96795. */
  96796. private _animation;
  96797. /**
  96798. * The target of the runtime animation
  96799. */
  96800. private _target;
  96801. /**
  96802. * The initiating animatable
  96803. */
  96804. private _host;
  96805. /**
  96806. * The original value of the runtime animation
  96807. */
  96808. private _originalValue;
  96809. /**
  96810. * The original blend value of the runtime animation
  96811. */
  96812. private _originalBlendValue;
  96813. /**
  96814. * The offsets cache of the runtime animation
  96815. */
  96816. private _offsetsCache;
  96817. /**
  96818. * The high limits cache of the runtime animation
  96819. */
  96820. private _highLimitsCache;
  96821. /**
  96822. * Specifies if the runtime animation has been stopped
  96823. */
  96824. private _stopped;
  96825. /**
  96826. * The blending factor of the runtime animation
  96827. */
  96828. private _blendingFactor;
  96829. /**
  96830. * The BabylonJS scene
  96831. */
  96832. private _scene;
  96833. /**
  96834. * The current value of the runtime animation
  96835. */
  96836. private _currentValue;
  96837. /** @hidden */
  96838. _animationState: _IAnimationState;
  96839. /**
  96840. * The active target of the runtime animation
  96841. */
  96842. private _activeTargets;
  96843. private _currentActiveTarget;
  96844. private _directTarget;
  96845. /**
  96846. * The target path of the runtime animation
  96847. */
  96848. private _targetPath;
  96849. /**
  96850. * The weight of the runtime animation
  96851. */
  96852. private _weight;
  96853. /**
  96854. * The ratio offset of the runtime animation
  96855. */
  96856. private _ratioOffset;
  96857. /**
  96858. * The previous delay of the runtime animation
  96859. */
  96860. private _previousDelay;
  96861. /**
  96862. * The previous ratio of the runtime animation
  96863. */
  96864. private _previousRatio;
  96865. private _enableBlending;
  96866. private _keys;
  96867. private _minFrame;
  96868. private _maxFrame;
  96869. private _minValue;
  96870. private _maxValue;
  96871. private _targetIsArray;
  96872. /**
  96873. * Gets the current frame of the runtime animation
  96874. */
  96875. get currentFrame(): number;
  96876. /**
  96877. * Gets the weight of the runtime animation
  96878. */
  96879. get weight(): number;
  96880. /**
  96881. * Gets the current value of the runtime animation
  96882. */
  96883. get currentValue(): any;
  96884. /**
  96885. * Gets the target path of the runtime animation
  96886. */
  96887. get targetPath(): string;
  96888. /**
  96889. * Gets the actual target of the runtime animation
  96890. */
  96891. get target(): any;
  96892. /**
  96893. * Gets the additive state of the runtime animation
  96894. */
  96895. get isAdditive(): boolean;
  96896. /** @hidden */
  96897. _onLoop: () => void;
  96898. /**
  96899. * Create a new RuntimeAnimation object
  96900. * @param target defines the target of the animation
  96901. * @param animation defines the source animation object
  96902. * @param scene defines the hosting scene
  96903. * @param host defines the initiating Animatable
  96904. */
  96905. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96906. private _preparePath;
  96907. /**
  96908. * Gets the animation from the runtime animation
  96909. */
  96910. get animation(): Animation;
  96911. /**
  96912. * Resets the runtime animation to the beginning
  96913. * @param restoreOriginal defines whether to restore the target property to the original value
  96914. */
  96915. reset(restoreOriginal?: boolean): void;
  96916. /**
  96917. * Specifies if the runtime animation is stopped
  96918. * @returns Boolean specifying if the runtime animation is stopped
  96919. */
  96920. isStopped(): boolean;
  96921. /**
  96922. * Disposes of the runtime animation
  96923. */
  96924. dispose(): void;
  96925. /**
  96926. * Apply the interpolated value to the target
  96927. * @param currentValue defines the value computed by the animation
  96928. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  96929. */
  96930. setValue(currentValue: any, weight: number): void;
  96931. private _getOriginalValues;
  96932. private _setValue;
  96933. /**
  96934. * Gets the loop pmode of the runtime animation
  96935. * @returns Loop Mode
  96936. */
  96937. private _getCorrectLoopMode;
  96938. /**
  96939. * Move the current animation to a given frame
  96940. * @param frame defines the frame to move to
  96941. */
  96942. goToFrame(frame: number): void;
  96943. /**
  96944. * @hidden Internal use only
  96945. */
  96946. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96947. /**
  96948. * Execute the current animation
  96949. * @param delay defines the delay to add to the current frame
  96950. * @param from defines the lower bound of the animation range
  96951. * @param to defines the upper bound of the animation range
  96952. * @param loop defines if the current animation must loop
  96953. * @param speedRatio defines the current speed ratio
  96954. * @param weight defines the weight of the animation (default is -1 so no weight)
  96955. * @param onLoop optional callback called when animation loops
  96956. * @returns a boolean indicating if the animation is running
  96957. */
  96958. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96959. }
  96960. }
  96961. declare module BABYLON {
  96962. /**
  96963. * Class used to store an actual running animation
  96964. */
  96965. export class Animatable {
  96966. /** defines the target object */
  96967. target: any;
  96968. /** defines the starting frame number (default is 0) */
  96969. fromFrame: number;
  96970. /** defines the ending frame number (default is 100) */
  96971. toFrame: number;
  96972. /** defines if the animation must loop (default is false) */
  96973. loopAnimation: boolean;
  96974. /** defines a callback to call when animation ends if it is not looping */
  96975. onAnimationEnd?: (() => void) | null | undefined;
  96976. /** defines a callback to call when animation loops */
  96977. onAnimationLoop?: (() => void) | null | undefined;
  96978. /** defines whether the animation should be evaluated additively */
  96979. isAdditive: boolean;
  96980. private _localDelayOffset;
  96981. private _pausedDelay;
  96982. private _runtimeAnimations;
  96983. private _paused;
  96984. private _scene;
  96985. private _speedRatio;
  96986. private _weight;
  96987. private _syncRoot;
  96988. /**
  96989. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96990. * This will only apply for non looping animation (default is true)
  96991. */
  96992. disposeOnEnd: boolean;
  96993. /**
  96994. * Gets a boolean indicating if the animation has started
  96995. */
  96996. animationStarted: boolean;
  96997. /**
  96998. * Observer raised when the animation ends
  96999. */
  97000. onAnimationEndObservable: Observable<Animatable>;
  97001. /**
  97002. * Observer raised when the animation loops
  97003. */
  97004. onAnimationLoopObservable: Observable<Animatable>;
  97005. /**
  97006. * Gets the root Animatable used to synchronize and normalize animations
  97007. */
  97008. get syncRoot(): Nullable<Animatable>;
  97009. /**
  97010. * Gets the current frame of the first RuntimeAnimation
  97011. * Used to synchronize Animatables
  97012. */
  97013. get masterFrame(): number;
  97014. /**
  97015. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  97016. */
  97017. get weight(): number;
  97018. set weight(value: number);
  97019. /**
  97020. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  97021. */
  97022. get speedRatio(): number;
  97023. set speedRatio(value: number);
  97024. /**
  97025. * Creates a new Animatable
  97026. * @param scene defines the hosting scene
  97027. * @param target defines the target object
  97028. * @param fromFrame defines the starting frame number (default is 0)
  97029. * @param toFrame defines the ending frame number (default is 100)
  97030. * @param loopAnimation defines if the animation must loop (default is false)
  97031. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  97032. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  97033. * @param animations defines a group of animation to add to the new Animatable
  97034. * @param onAnimationLoop defines a callback to call when animation loops
  97035. * @param isAdditive defines whether the animation should be evaluated additively
  97036. */
  97037. constructor(scene: Scene,
  97038. /** defines the target object */
  97039. target: any,
  97040. /** defines the starting frame number (default is 0) */
  97041. fromFrame?: number,
  97042. /** defines the ending frame number (default is 100) */
  97043. toFrame?: number,
  97044. /** defines if the animation must loop (default is false) */
  97045. loopAnimation?: boolean, speedRatio?: number,
  97046. /** defines a callback to call when animation ends if it is not looping */
  97047. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  97048. /** defines a callback to call when animation loops */
  97049. onAnimationLoop?: (() => void) | null | undefined,
  97050. /** defines whether the animation should be evaluated additively */
  97051. isAdditive?: boolean);
  97052. /**
  97053. * Synchronize and normalize current Animatable with a source Animatable
  97054. * This is useful when using animation weights and when animations are not of the same length
  97055. * @param root defines the root Animatable to synchronize with
  97056. * @returns the current Animatable
  97057. */
  97058. syncWith(root: Animatable): Animatable;
  97059. /**
  97060. * Gets the list of runtime animations
  97061. * @returns an array of RuntimeAnimation
  97062. */
  97063. getAnimations(): RuntimeAnimation[];
  97064. /**
  97065. * Adds more animations to the current animatable
  97066. * @param target defines the target of the animations
  97067. * @param animations defines the new animations to add
  97068. */
  97069. appendAnimations(target: any, animations: Animation[]): void;
  97070. /**
  97071. * Gets the source animation for a specific property
  97072. * @param property defines the propertyu to look for
  97073. * @returns null or the source animation for the given property
  97074. */
  97075. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  97076. /**
  97077. * Gets the runtime animation for a specific property
  97078. * @param property defines the propertyu to look for
  97079. * @returns null or the runtime animation for the given property
  97080. */
  97081. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  97082. /**
  97083. * Resets the animatable to its original state
  97084. */
  97085. reset(): void;
  97086. /**
  97087. * Allows the animatable to blend with current running animations
  97088. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  97089. * @param blendingSpeed defines the blending speed to use
  97090. */
  97091. enableBlending(blendingSpeed: number): void;
  97092. /**
  97093. * Disable animation blending
  97094. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  97095. */
  97096. disableBlending(): void;
  97097. /**
  97098. * Jump directly to a given frame
  97099. * @param frame defines the frame to jump to
  97100. */
  97101. goToFrame(frame: number): void;
  97102. /**
  97103. * Pause the animation
  97104. */
  97105. pause(): void;
  97106. /**
  97107. * Restart the animation
  97108. */
  97109. restart(): void;
  97110. private _raiseOnAnimationEnd;
  97111. /**
  97112. * Stop and delete the current animation
  97113. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  97114. * @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)
  97115. */
  97116. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  97117. /**
  97118. * Wait asynchronously for the animation to end
  97119. * @returns a promise which will be fullfilled when the animation ends
  97120. */
  97121. waitAsync(): Promise<Animatable>;
  97122. /** @hidden */
  97123. _animate(delay: number): boolean;
  97124. }
  97125. interface Scene {
  97126. /** @hidden */
  97127. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  97128. /** @hidden */
  97129. _processLateAnimationBindingsForMatrices(holder: {
  97130. totalWeight: number;
  97131. totalAdditiveWeight: number;
  97132. animations: RuntimeAnimation[];
  97133. additiveAnimations: RuntimeAnimation[];
  97134. originalValue: Matrix;
  97135. }): any;
  97136. /** @hidden */
  97137. _processLateAnimationBindingsForQuaternions(holder: {
  97138. totalWeight: number;
  97139. totalAdditiveWeight: number;
  97140. animations: RuntimeAnimation[];
  97141. additiveAnimations: RuntimeAnimation[];
  97142. originalValue: Quaternion;
  97143. }, refQuaternion: Quaternion): Quaternion;
  97144. /** @hidden */
  97145. _processLateAnimationBindings(): void;
  97146. /**
  97147. * Will start the animation sequence of a given target
  97148. * @param target defines the target
  97149. * @param from defines from which frame should animation start
  97150. * @param to defines until which frame should animation run.
  97151. * @param weight defines the weight to apply to the animation (1.0 by default)
  97152. * @param loop defines if the animation loops
  97153. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  97154. * @param onAnimationEnd defines the function to be executed when the animation ends
  97155. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  97156. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  97157. * @param onAnimationLoop defines the callback to call when an animation loops
  97158. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97159. * @returns the animatable object created for this animation
  97160. */
  97161. 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;
  97162. /**
  97163. * Will start the animation sequence of a given target
  97164. * @param target defines the target
  97165. * @param from defines from which frame should animation start
  97166. * @param to defines until which frame should animation run.
  97167. * @param loop defines if the animation loops
  97168. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  97169. * @param onAnimationEnd defines the function to be executed when the animation ends
  97170. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  97171. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  97172. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  97173. * @param onAnimationLoop defines the callback to call when an animation loops
  97174. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97175. * @returns the animatable object created for this animation
  97176. */
  97177. 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;
  97178. /**
  97179. * Will start the animation sequence of a given target and its hierarchy
  97180. * @param target defines the target
  97181. * @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.
  97182. * @param from defines from which frame should animation start
  97183. * @param to defines until which frame should animation run.
  97184. * @param loop defines if the animation loops
  97185. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  97186. * @param onAnimationEnd defines the function to be executed when the animation ends
  97187. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  97188. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  97189. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  97190. * @param onAnimationLoop defines the callback to call when an animation loops
  97191. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97192. * @returns the list of created animatables
  97193. */
  97194. 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[];
  97195. /**
  97196. * Begin a new animation on a given node
  97197. * @param target defines the target where the animation will take place
  97198. * @param animations defines the list of animations to start
  97199. * @param from defines the initial value
  97200. * @param to defines the final value
  97201. * @param loop defines if you want animation to loop (off by default)
  97202. * @param speedRatio defines the speed ratio to apply to all animations
  97203. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  97204. * @param onAnimationLoop defines the callback to call when an animation loops
  97205. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97206. * @returns the list of created animatables
  97207. */
  97208. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  97209. /**
  97210. * Begin a new animation on a given node and its hierarchy
  97211. * @param target defines the root node where the animation will take place
  97212. * @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.
  97213. * @param animations defines the list of animations to start
  97214. * @param from defines the initial value
  97215. * @param to defines the final value
  97216. * @param loop defines if you want animation to loop (off by default)
  97217. * @param speedRatio defines the speed ratio to apply to all animations
  97218. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  97219. * @param onAnimationLoop defines the callback to call when an animation loops
  97220. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97221. * @returns the list of animatables created for all nodes
  97222. */
  97223. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  97224. /**
  97225. * Gets the animatable associated with a specific target
  97226. * @param target defines the target of the animatable
  97227. * @returns the required animatable if found
  97228. */
  97229. getAnimatableByTarget(target: any): Nullable<Animatable>;
  97230. /**
  97231. * Gets all animatables associated with a given target
  97232. * @param target defines the target to look animatables for
  97233. * @returns an array of Animatables
  97234. */
  97235. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  97236. /**
  97237. * Stops and removes all animations that have been applied to the scene
  97238. */
  97239. stopAllAnimations(): void;
  97240. /**
  97241. * Gets the current delta time used by animation engine
  97242. */
  97243. deltaTime: number;
  97244. }
  97245. interface Bone {
  97246. /**
  97247. * Copy an animation range from another bone
  97248. * @param source defines the source bone
  97249. * @param rangeName defines the range name to copy
  97250. * @param frameOffset defines the frame offset
  97251. * @param rescaleAsRequired defines if rescaling must be applied if required
  97252. * @param skelDimensionsRatio defines the scaling ratio
  97253. * @returns true if operation was successful
  97254. */
  97255. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  97256. }
  97257. }
  97258. declare module BABYLON {
  97259. /**
  97260. * Class used to handle skinning animations
  97261. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  97262. */
  97263. export class Skeleton implements IAnimatable {
  97264. /** defines the skeleton name */
  97265. name: string;
  97266. /** defines the skeleton Id */
  97267. id: string;
  97268. /**
  97269. * Defines the list of child bones
  97270. */
  97271. bones: Bone[];
  97272. /**
  97273. * Defines an estimate of the dimension of the skeleton at rest
  97274. */
  97275. dimensionsAtRest: Vector3;
  97276. /**
  97277. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  97278. */
  97279. needInitialSkinMatrix: boolean;
  97280. /**
  97281. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  97282. */
  97283. overrideMesh: Nullable<AbstractMesh>;
  97284. /**
  97285. * Gets the list of animations attached to this skeleton
  97286. */
  97287. animations: Array<Animation>;
  97288. private _scene;
  97289. private _isDirty;
  97290. private _transformMatrices;
  97291. private _transformMatrixTexture;
  97292. private _meshesWithPoseMatrix;
  97293. private _animatables;
  97294. private _identity;
  97295. private _synchronizedWithMesh;
  97296. private _ranges;
  97297. private _lastAbsoluteTransformsUpdateId;
  97298. private _canUseTextureForBones;
  97299. private _uniqueId;
  97300. /** @hidden */
  97301. _numBonesWithLinkedTransformNode: number;
  97302. /** @hidden */
  97303. _hasWaitingData: Nullable<boolean>;
  97304. /** @hidden */
  97305. _waitingOverrideMeshId: Nullable<string>;
  97306. /**
  97307. * Specifies if the skeleton should be serialized
  97308. */
  97309. doNotSerialize: boolean;
  97310. private _useTextureToStoreBoneMatrices;
  97311. /**
  97312. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  97313. * Please note that this option is not available if the hardware does not support it
  97314. */
  97315. get useTextureToStoreBoneMatrices(): boolean;
  97316. set useTextureToStoreBoneMatrices(value: boolean);
  97317. private _animationPropertiesOverride;
  97318. /**
  97319. * Gets or sets the animation properties override
  97320. */
  97321. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  97322. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  97323. /**
  97324. * List of inspectable custom properties (used by the Inspector)
  97325. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97326. */
  97327. inspectableCustomProperties: IInspectable[];
  97328. /**
  97329. * An observable triggered before computing the skeleton's matrices
  97330. */
  97331. onBeforeComputeObservable: Observable<Skeleton>;
  97332. /**
  97333. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  97334. */
  97335. get isUsingTextureForMatrices(): boolean;
  97336. /**
  97337. * Gets the unique ID of this skeleton
  97338. */
  97339. get uniqueId(): number;
  97340. /**
  97341. * Creates a new skeleton
  97342. * @param name defines the skeleton name
  97343. * @param id defines the skeleton Id
  97344. * @param scene defines the hosting scene
  97345. */
  97346. constructor(
  97347. /** defines the skeleton name */
  97348. name: string,
  97349. /** defines the skeleton Id */
  97350. id: string, scene: Scene);
  97351. /**
  97352. * Gets the current object class name.
  97353. * @return the class name
  97354. */
  97355. getClassName(): string;
  97356. /**
  97357. * Returns an array containing the root bones
  97358. * @returns an array containing the root bones
  97359. */
  97360. getChildren(): Array<Bone>;
  97361. /**
  97362. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  97363. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  97364. * @returns a Float32Array containing matrices data
  97365. */
  97366. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  97367. /**
  97368. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  97369. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  97370. * @returns a raw texture containing the data
  97371. */
  97372. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  97373. /**
  97374. * Gets the current hosting scene
  97375. * @returns a scene object
  97376. */
  97377. getScene(): Scene;
  97378. /**
  97379. * Gets a string representing the current skeleton data
  97380. * @param fullDetails defines a boolean indicating if we want a verbose version
  97381. * @returns a string representing the current skeleton data
  97382. */
  97383. toString(fullDetails?: boolean): string;
  97384. /**
  97385. * Get bone's index searching by name
  97386. * @param name defines bone's name to search for
  97387. * @return the indice of the bone. Returns -1 if not found
  97388. */
  97389. getBoneIndexByName(name: string): number;
  97390. /**
  97391. * Creater a new animation range
  97392. * @param name defines the name of the range
  97393. * @param from defines the start key
  97394. * @param to defines the end key
  97395. */
  97396. createAnimationRange(name: string, from: number, to: number): void;
  97397. /**
  97398. * Delete a specific animation range
  97399. * @param name defines the name of the range
  97400. * @param deleteFrames defines if frames must be removed as well
  97401. */
  97402. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  97403. /**
  97404. * Gets a specific animation range
  97405. * @param name defines the name of the range to look for
  97406. * @returns the requested animation range or null if not found
  97407. */
  97408. getAnimationRange(name: string): Nullable<AnimationRange>;
  97409. /**
  97410. * Gets the list of all animation ranges defined on this skeleton
  97411. * @returns an array
  97412. */
  97413. getAnimationRanges(): Nullable<AnimationRange>[];
  97414. /**
  97415. * Copy animation range from a source skeleton.
  97416. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  97417. * @param source defines the source skeleton
  97418. * @param name defines the name of the range to copy
  97419. * @param rescaleAsRequired defines if rescaling must be applied if required
  97420. * @returns true if operation was successful
  97421. */
  97422. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  97423. /**
  97424. * Forces the skeleton to go to rest pose
  97425. */
  97426. returnToRest(): void;
  97427. private _getHighestAnimationFrame;
  97428. /**
  97429. * Begin a specific animation range
  97430. * @param name defines the name of the range to start
  97431. * @param loop defines if looping must be turned on (false by default)
  97432. * @param speedRatio defines the speed ratio to apply (1 by default)
  97433. * @param onAnimationEnd defines a callback which will be called when animation will end
  97434. * @returns a new animatable
  97435. */
  97436. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  97437. /**
  97438. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  97439. * @param skeleton defines the Skeleton containing the animation range to convert
  97440. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  97441. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  97442. * @returns the original skeleton
  97443. */
  97444. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  97445. /** @hidden */
  97446. _markAsDirty(): void;
  97447. /** @hidden */
  97448. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  97449. /** @hidden */
  97450. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  97451. private _computeTransformMatrices;
  97452. /**
  97453. * Build all resources required to render a skeleton
  97454. */
  97455. prepare(): void;
  97456. /**
  97457. * Gets the list of animatables currently running for this skeleton
  97458. * @returns an array of animatables
  97459. */
  97460. getAnimatables(): IAnimatable[];
  97461. /**
  97462. * Clone the current skeleton
  97463. * @param name defines the name of the new skeleton
  97464. * @param id defines the id of the new skeleton
  97465. * @returns the new skeleton
  97466. */
  97467. clone(name: string, id?: string): Skeleton;
  97468. /**
  97469. * Enable animation blending for this skeleton
  97470. * @param blendingSpeed defines the blending speed to apply
  97471. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  97472. */
  97473. enableBlending(blendingSpeed?: number): void;
  97474. /**
  97475. * Releases all resources associated with the current skeleton
  97476. */
  97477. dispose(): void;
  97478. /**
  97479. * Serialize the skeleton in a JSON object
  97480. * @returns a JSON object
  97481. */
  97482. serialize(): any;
  97483. /**
  97484. * Creates a new skeleton from serialized data
  97485. * @param parsedSkeleton defines the serialized data
  97486. * @param scene defines the hosting scene
  97487. * @returns a new skeleton
  97488. */
  97489. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  97490. /**
  97491. * Compute all node absolute transforms
  97492. * @param forceUpdate defines if computation must be done even if cache is up to date
  97493. */
  97494. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  97495. /**
  97496. * Gets the root pose matrix
  97497. * @returns a matrix
  97498. */
  97499. getPoseMatrix(): Nullable<Matrix>;
  97500. /**
  97501. * Sorts bones per internal index
  97502. */
  97503. sortBones(): void;
  97504. private _sortBones;
  97505. /**
  97506. * Set the current local matrix as the restPose for all bones in the skeleton.
  97507. */
  97508. setCurrentPoseAsRest(): void;
  97509. }
  97510. }
  97511. declare module BABYLON {
  97512. /**
  97513. * Creates an instance based on a source mesh.
  97514. */
  97515. export class InstancedMesh extends AbstractMesh {
  97516. private _sourceMesh;
  97517. private _currentLOD;
  97518. /** @hidden */
  97519. _indexInSourceMeshInstanceArray: number;
  97520. constructor(name: string, source: Mesh);
  97521. /**
  97522. * Returns the string "InstancedMesh".
  97523. */
  97524. getClassName(): string;
  97525. /** Gets the list of lights affecting that mesh */
  97526. get lightSources(): Light[];
  97527. _resyncLightSources(): void;
  97528. _resyncLightSource(light: Light): void;
  97529. _removeLightSource(light: Light, dispose: boolean): void;
  97530. /**
  97531. * If the source mesh receives shadows
  97532. */
  97533. get receiveShadows(): boolean;
  97534. /**
  97535. * The material of the source mesh
  97536. */
  97537. get material(): Nullable<Material>;
  97538. /**
  97539. * Visibility of the source mesh
  97540. */
  97541. get visibility(): number;
  97542. /**
  97543. * Skeleton of the source mesh
  97544. */
  97545. get skeleton(): Nullable<Skeleton>;
  97546. /**
  97547. * Rendering ground id of the source mesh
  97548. */
  97549. get renderingGroupId(): number;
  97550. set renderingGroupId(value: number);
  97551. /**
  97552. * Returns the total number of vertices (integer).
  97553. */
  97554. getTotalVertices(): number;
  97555. /**
  97556. * Returns a positive integer : the total number of indices in this mesh geometry.
  97557. * @returns the numner of indices or zero if the mesh has no geometry.
  97558. */
  97559. getTotalIndices(): number;
  97560. /**
  97561. * The source mesh of the instance
  97562. */
  97563. get sourceMesh(): Mesh;
  97564. /**
  97565. * Creates a new InstancedMesh object from the mesh model.
  97566. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97567. * @param name defines the name of the new instance
  97568. * @returns a new InstancedMesh
  97569. */
  97570. createInstance(name: string): InstancedMesh;
  97571. /**
  97572. * Is this node ready to be used/rendered
  97573. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97574. * @return {boolean} is it ready
  97575. */
  97576. isReady(completeCheck?: boolean): boolean;
  97577. /**
  97578. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97579. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  97580. * @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.
  97581. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  97582. */
  97583. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  97584. /**
  97585. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97586. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97587. * The `data` are either a numeric array either a Float32Array.
  97588. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  97589. * 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).
  97590. * Note that a new underlying VertexBuffer object is created each call.
  97591. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97592. *
  97593. * Possible `kind` values :
  97594. * - VertexBuffer.PositionKind
  97595. * - VertexBuffer.UVKind
  97596. * - VertexBuffer.UV2Kind
  97597. * - VertexBuffer.UV3Kind
  97598. * - VertexBuffer.UV4Kind
  97599. * - VertexBuffer.UV5Kind
  97600. * - VertexBuffer.UV6Kind
  97601. * - VertexBuffer.ColorKind
  97602. * - VertexBuffer.MatricesIndicesKind
  97603. * - VertexBuffer.MatricesIndicesExtraKind
  97604. * - VertexBuffer.MatricesWeightsKind
  97605. * - VertexBuffer.MatricesWeightsExtraKind
  97606. *
  97607. * Returns the Mesh.
  97608. */
  97609. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97610. /**
  97611. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97612. * If the mesh has no geometry, it is simply returned as it is.
  97613. * The `data` are either a numeric array either a Float32Array.
  97614. * No new underlying VertexBuffer object is created.
  97615. * 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.
  97616. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  97617. *
  97618. * Possible `kind` values :
  97619. * - VertexBuffer.PositionKind
  97620. * - VertexBuffer.UVKind
  97621. * - VertexBuffer.UV2Kind
  97622. * - VertexBuffer.UV3Kind
  97623. * - VertexBuffer.UV4Kind
  97624. * - VertexBuffer.UV5Kind
  97625. * - VertexBuffer.UV6Kind
  97626. * - VertexBuffer.ColorKind
  97627. * - VertexBuffer.MatricesIndicesKind
  97628. * - VertexBuffer.MatricesIndicesExtraKind
  97629. * - VertexBuffer.MatricesWeightsKind
  97630. * - VertexBuffer.MatricesWeightsExtraKind
  97631. *
  97632. * Returns the Mesh.
  97633. */
  97634. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  97635. /**
  97636. * Sets the mesh indices.
  97637. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  97638. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97639. * This method creates a new index buffer each call.
  97640. * Returns the Mesh.
  97641. */
  97642. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  97643. /**
  97644. * Boolean : True if the mesh owns the requested kind of data.
  97645. */
  97646. isVerticesDataPresent(kind: string): boolean;
  97647. /**
  97648. * Returns an array of indices (IndicesArray).
  97649. */
  97650. getIndices(): Nullable<IndicesArray>;
  97651. get _positions(): Nullable<Vector3[]>;
  97652. /**
  97653. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97654. * This means the mesh underlying bounding box and sphere are recomputed.
  97655. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97656. * @returns the current mesh
  97657. */
  97658. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  97659. /** @hidden */
  97660. _preActivate(): InstancedMesh;
  97661. /** @hidden */
  97662. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97663. /** @hidden */
  97664. _postActivate(): void;
  97665. getWorldMatrix(): Matrix;
  97666. get isAnInstance(): boolean;
  97667. /**
  97668. * Returns the current associated LOD AbstractMesh.
  97669. */
  97670. getLOD(camera: Camera): AbstractMesh;
  97671. /** @hidden */
  97672. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97673. /** @hidden */
  97674. _syncSubMeshes(): InstancedMesh;
  97675. /** @hidden */
  97676. _generatePointsArray(): boolean;
  97677. /** @hidden */
  97678. _updateBoundingInfo(): AbstractMesh;
  97679. /**
  97680. * Creates a new InstancedMesh from the current mesh.
  97681. * - name (string) : the cloned mesh name
  97682. * - newParent (optional Node) : the optional Node to parent the clone to.
  97683. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  97684. *
  97685. * Returns the clone.
  97686. */
  97687. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  97688. /**
  97689. * Disposes the InstancedMesh.
  97690. * Returns nothing.
  97691. */
  97692. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97693. }
  97694. interface Mesh {
  97695. /**
  97696. * Register a custom buffer that will be instanced
  97697. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97698. * @param kind defines the buffer kind
  97699. * @param stride defines the stride in floats
  97700. */
  97701. registerInstancedBuffer(kind: string, stride: number): void;
  97702. /**
  97703. * true to use the edge renderer for all instances of this mesh
  97704. */
  97705. edgesShareWithInstances: boolean;
  97706. /** @hidden */
  97707. _userInstancedBuffersStorage: {
  97708. data: {
  97709. [key: string]: Float32Array;
  97710. };
  97711. sizes: {
  97712. [key: string]: number;
  97713. };
  97714. vertexBuffers: {
  97715. [key: string]: Nullable<VertexBuffer>;
  97716. };
  97717. strides: {
  97718. [key: string]: number;
  97719. };
  97720. };
  97721. }
  97722. interface AbstractMesh {
  97723. /**
  97724. * Object used to store instanced buffers defined by user
  97725. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97726. */
  97727. instancedBuffers: {
  97728. [key: string]: any;
  97729. };
  97730. }
  97731. }
  97732. declare module BABYLON {
  97733. /**
  97734. * Defines the options associated with the creation of a shader material.
  97735. */
  97736. export interface IShaderMaterialOptions {
  97737. /**
  97738. * Does the material work in alpha blend mode
  97739. */
  97740. needAlphaBlending: boolean;
  97741. /**
  97742. * Does the material work in alpha test mode
  97743. */
  97744. needAlphaTesting: boolean;
  97745. /**
  97746. * The list of attribute names used in the shader
  97747. */
  97748. attributes: string[];
  97749. /**
  97750. * The list of unifrom names used in the shader
  97751. */
  97752. uniforms: string[];
  97753. /**
  97754. * The list of UBO names used in the shader
  97755. */
  97756. uniformBuffers: string[];
  97757. /**
  97758. * The list of sampler names used in the shader
  97759. */
  97760. samplers: string[];
  97761. /**
  97762. * The list of defines used in the shader
  97763. */
  97764. defines: string[];
  97765. }
  97766. /**
  97767. * 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.
  97768. *
  97769. * This returned material effects how the mesh will look based on the code in the shaders.
  97770. *
  97771. * @see https://doc.babylonjs.com/how_to/shader_material
  97772. */
  97773. export class ShaderMaterial extends Material {
  97774. private _shaderPath;
  97775. private _options;
  97776. private _textures;
  97777. private _textureArrays;
  97778. private _floats;
  97779. private _ints;
  97780. private _floatsArrays;
  97781. private _colors3;
  97782. private _colors3Arrays;
  97783. private _colors4;
  97784. private _colors4Arrays;
  97785. private _vectors2;
  97786. private _vectors3;
  97787. private _vectors4;
  97788. private _matrices;
  97789. private _matrixArrays;
  97790. private _matrices3x3;
  97791. private _matrices2x2;
  97792. private _vectors2Arrays;
  97793. private _vectors3Arrays;
  97794. private _vectors4Arrays;
  97795. private _cachedWorldViewMatrix;
  97796. private _cachedWorldViewProjectionMatrix;
  97797. private _renderId;
  97798. private _multiview;
  97799. private _cachedDefines;
  97800. /** Define the Url to load snippets */
  97801. static SnippetUrl: string;
  97802. /** Snippet ID if the material was created from the snippet server */
  97803. snippetId: string;
  97804. /**
  97805. * Instantiate a new shader material.
  97806. * 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.
  97807. * This returned material effects how the mesh will look based on the code in the shaders.
  97808. * @see https://doc.babylonjs.com/how_to/shader_material
  97809. * @param name Define the name of the material in the scene
  97810. * @param scene Define the scene the material belongs to
  97811. * @param shaderPath Defines the route to the shader code in one of three ways:
  97812. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  97813. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  97814. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  97815. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  97816. * @param options Define the options used to create the shader
  97817. */
  97818. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  97819. /**
  97820. * Gets the shader path used to define the shader code
  97821. * It can be modified to trigger a new compilation
  97822. */
  97823. get shaderPath(): any;
  97824. /**
  97825. * Sets the shader path used to define the shader code
  97826. * It can be modified to trigger a new compilation
  97827. */
  97828. set shaderPath(shaderPath: any);
  97829. /**
  97830. * Gets the options used to compile the shader.
  97831. * They can be modified to trigger a new compilation
  97832. */
  97833. get options(): IShaderMaterialOptions;
  97834. /**
  97835. * Gets the current class name of the material e.g. "ShaderMaterial"
  97836. * Mainly use in serialization.
  97837. * @returns the class name
  97838. */
  97839. getClassName(): string;
  97840. /**
  97841. * Specifies if the material will require alpha blending
  97842. * @returns a boolean specifying if alpha blending is needed
  97843. */
  97844. needAlphaBlending(): boolean;
  97845. /**
  97846. * Specifies if this material should be rendered in alpha test mode
  97847. * @returns a boolean specifying if an alpha test is needed.
  97848. */
  97849. needAlphaTesting(): boolean;
  97850. private _checkUniform;
  97851. /**
  97852. * Set a texture in the shader.
  97853. * @param name Define the name of the uniform samplers as defined in the shader
  97854. * @param texture Define the texture to bind to this sampler
  97855. * @return the material itself allowing "fluent" like uniform updates
  97856. */
  97857. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  97858. /**
  97859. * Set a texture array in the shader.
  97860. * @param name Define the name of the uniform sampler array as defined in the shader
  97861. * @param textures Define the list of textures to bind to this sampler
  97862. * @return the material itself allowing "fluent" like uniform updates
  97863. */
  97864. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  97865. /**
  97866. * Set a float in the shader.
  97867. * @param name Define the name of the uniform as defined in the shader
  97868. * @param value Define the value to give to the uniform
  97869. * @return the material itself allowing "fluent" like uniform updates
  97870. */
  97871. setFloat(name: string, value: number): ShaderMaterial;
  97872. /**
  97873. * Set a int in the shader.
  97874. * @param name Define the name of the uniform as defined in the shader
  97875. * @param value Define the value to give to the uniform
  97876. * @return the material itself allowing "fluent" like uniform updates
  97877. */
  97878. setInt(name: string, value: number): ShaderMaterial;
  97879. /**
  97880. * Set an array of floats in the shader.
  97881. * @param name Define the name of the uniform as defined in the shader
  97882. * @param value Define the value to give to the uniform
  97883. * @return the material itself allowing "fluent" like uniform updates
  97884. */
  97885. setFloats(name: string, value: number[]): ShaderMaterial;
  97886. /**
  97887. * Set a vec3 in the shader from a Color3.
  97888. * @param name Define the name of the uniform as defined in the shader
  97889. * @param value Define the value to give to the uniform
  97890. * @return the material itself allowing "fluent" like uniform updates
  97891. */
  97892. setColor3(name: string, value: Color3): ShaderMaterial;
  97893. /**
  97894. * Set a vec3 array in the shader from a Color3 array.
  97895. * @param name Define the name of the uniform as defined in the shader
  97896. * @param value Define the value to give to the uniform
  97897. * @return the material itself allowing "fluent" like uniform updates
  97898. */
  97899. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97900. /**
  97901. * Set a vec4 in the shader from a Color4.
  97902. * @param name Define the name of the uniform as defined in the shader
  97903. * @param value Define the value to give to the uniform
  97904. * @return the material itself allowing "fluent" like uniform updates
  97905. */
  97906. setColor4(name: string, value: Color4): ShaderMaterial;
  97907. /**
  97908. * Set a vec4 array in the shader from a Color4 array.
  97909. * @param name Define the name of the uniform as defined in the shader
  97910. * @param value Define the value to give to the uniform
  97911. * @return the material itself allowing "fluent" like uniform updates
  97912. */
  97913. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97914. /**
  97915. * Set a vec2 in the shader from a Vector2.
  97916. * @param name Define the name of the uniform as defined in the shader
  97917. * @param value Define the value to give to the uniform
  97918. * @return the material itself allowing "fluent" like uniform updates
  97919. */
  97920. setVector2(name: string, value: Vector2): ShaderMaterial;
  97921. /**
  97922. * Set a vec3 in the shader from a Vector3.
  97923. * @param name Define the name of the uniform as defined in the shader
  97924. * @param value Define the value to give to the uniform
  97925. * @return the material itself allowing "fluent" like uniform updates
  97926. */
  97927. setVector3(name: string, value: Vector3): ShaderMaterial;
  97928. /**
  97929. * Set a vec4 in the shader from a Vector4.
  97930. * @param name Define the name of the uniform as defined in the shader
  97931. * @param value Define the value to give to the uniform
  97932. * @return the material itself allowing "fluent" like uniform updates
  97933. */
  97934. setVector4(name: string, value: Vector4): ShaderMaterial;
  97935. /**
  97936. * Set a mat4 in the shader from a Matrix.
  97937. * @param name Define the name of the uniform as defined in the shader
  97938. * @param value Define the value to give to the uniform
  97939. * @return the material itself allowing "fluent" like uniform updates
  97940. */
  97941. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97942. /**
  97943. * Set a float32Array in the shader from a matrix array.
  97944. * @param name Define the name of the uniform as defined in the shader
  97945. * @param value Define the value to give to the uniform
  97946. * @return the material itself allowing "fluent" like uniform updates
  97947. */
  97948. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97949. /**
  97950. * Set a mat3 in the shader from a Float32Array.
  97951. * @param name Define the name of the uniform as defined in the shader
  97952. * @param value Define the value to give to the uniform
  97953. * @return the material itself allowing "fluent" like uniform updates
  97954. */
  97955. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97956. /**
  97957. * Set a mat2 in the shader from a Float32Array.
  97958. * @param name Define the name of the uniform as defined in the shader
  97959. * @param value Define the value to give to the uniform
  97960. * @return the material itself allowing "fluent" like uniform updates
  97961. */
  97962. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97963. /**
  97964. * Set a vec2 array in the shader from a number array.
  97965. * @param name Define the name of the uniform as defined in the shader
  97966. * @param value Define the value to give to the uniform
  97967. * @return the material itself allowing "fluent" like uniform updates
  97968. */
  97969. setArray2(name: string, value: number[]): ShaderMaterial;
  97970. /**
  97971. * Set a vec3 array in the shader from a number array.
  97972. * @param name Define the name of the uniform as defined in the shader
  97973. * @param value Define the value to give to the uniform
  97974. * @return the material itself allowing "fluent" like uniform updates
  97975. */
  97976. setArray3(name: string, value: number[]): ShaderMaterial;
  97977. /**
  97978. * Set a vec4 array in the shader from a number array.
  97979. * @param name Define the name of the uniform as defined in the shader
  97980. * @param value Define the value to give to the uniform
  97981. * @return the material itself allowing "fluent" like uniform updates
  97982. */
  97983. setArray4(name: string, value: number[]): ShaderMaterial;
  97984. private _checkCache;
  97985. /**
  97986. * Specifies that the submesh is ready to be used
  97987. * @param mesh defines the mesh to check
  97988. * @param subMesh defines which submesh to check
  97989. * @param useInstances specifies that instances should be used
  97990. * @returns a boolean indicating that the submesh is ready or not
  97991. */
  97992. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97993. /**
  97994. * Checks if the material is ready to render the requested mesh
  97995. * @param mesh Define the mesh to render
  97996. * @param useInstances Define whether or not the material is used with instances
  97997. * @returns true if ready, otherwise false
  97998. */
  97999. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98000. /**
  98001. * Binds the world matrix to the material
  98002. * @param world defines the world transformation matrix
  98003. * @param effectOverride - If provided, use this effect instead of internal effect
  98004. */
  98005. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  98006. /**
  98007. * Binds the submesh to this material by preparing the effect and shader to draw
  98008. * @param world defines the world transformation matrix
  98009. * @param mesh defines the mesh containing the submesh
  98010. * @param subMesh defines the submesh to bind the material to
  98011. */
  98012. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98013. /**
  98014. * Binds the material to the mesh
  98015. * @param world defines the world transformation matrix
  98016. * @param mesh defines the mesh to bind the material to
  98017. * @param effectOverride - If provided, use this effect instead of internal effect
  98018. */
  98019. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  98020. protected _afterBind(mesh?: Mesh): void;
  98021. /**
  98022. * Gets the active textures from the material
  98023. * @returns an array of textures
  98024. */
  98025. getActiveTextures(): BaseTexture[];
  98026. /**
  98027. * Specifies if the material uses a texture
  98028. * @param texture defines the texture to check against the material
  98029. * @returns a boolean specifying if the material uses the texture
  98030. */
  98031. hasTexture(texture: BaseTexture): boolean;
  98032. /**
  98033. * Makes a duplicate of the material, and gives it a new name
  98034. * @param name defines the new name for the duplicated material
  98035. * @returns the cloned material
  98036. */
  98037. clone(name: string): ShaderMaterial;
  98038. /**
  98039. * Disposes the material
  98040. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98041. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98042. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  98043. */
  98044. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  98045. /**
  98046. * Serializes this material in a JSON representation
  98047. * @returns the serialized material object
  98048. */
  98049. serialize(): any;
  98050. /**
  98051. * Creates a shader material from parsed shader material data
  98052. * @param source defines the JSON represnetation of the material
  98053. * @param scene defines the hosting scene
  98054. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98055. * @returns a new material
  98056. */
  98057. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  98058. /**
  98059. * Creates a new ShaderMaterial from a snippet saved in a remote file
  98060. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  98061. * @param url defines the url to load from
  98062. * @param scene defines the hosting scene
  98063. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98064. * @returns a promise that will resolve to the new ShaderMaterial
  98065. */
  98066. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  98067. /**
  98068. * Creates a ShaderMaterial from a snippet saved by the Inspector
  98069. * @param snippetId defines the snippet to load
  98070. * @param scene defines the hosting scene
  98071. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98072. * @returns a promise that will resolve to the new ShaderMaterial
  98073. */
  98074. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  98075. }
  98076. }
  98077. declare module BABYLON {
  98078. /** @hidden */
  98079. export var colorPixelShader: {
  98080. name: string;
  98081. shader: string;
  98082. };
  98083. }
  98084. declare module BABYLON {
  98085. /** @hidden */
  98086. export var colorVertexShader: {
  98087. name: string;
  98088. shader: string;
  98089. };
  98090. }
  98091. declare module BABYLON {
  98092. /**
  98093. * Line mesh
  98094. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  98095. */
  98096. export class LinesMesh extends Mesh {
  98097. /**
  98098. * If vertex color should be applied to the mesh
  98099. */
  98100. readonly useVertexColor?: boolean | undefined;
  98101. /**
  98102. * If vertex alpha should be applied to the mesh
  98103. */
  98104. readonly useVertexAlpha?: boolean | undefined;
  98105. /**
  98106. * Color of the line (Default: White)
  98107. */
  98108. color: Color3;
  98109. /**
  98110. * Alpha of the line (Default: 1)
  98111. */
  98112. alpha: number;
  98113. /**
  98114. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  98115. * This margin is expressed in world space coordinates, so its value may vary.
  98116. * Default value is 0.1
  98117. */
  98118. intersectionThreshold: number;
  98119. private _colorShader;
  98120. private color4;
  98121. /**
  98122. * Creates a new LinesMesh
  98123. * @param name defines the name
  98124. * @param scene defines the hosting scene
  98125. * @param parent defines the parent mesh if any
  98126. * @param source defines the optional source LinesMesh used to clone data from
  98127. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  98128. * When false, achieved by calling a clone(), also passing False.
  98129. * This will make creation of children, recursive.
  98130. * @param useVertexColor defines if this LinesMesh supports vertex color
  98131. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  98132. */
  98133. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  98134. /**
  98135. * If vertex color should be applied to the mesh
  98136. */
  98137. useVertexColor?: boolean | undefined,
  98138. /**
  98139. * If vertex alpha should be applied to the mesh
  98140. */
  98141. useVertexAlpha?: boolean | undefined);
  98142. private _addClipPlaneDefine;
  98143. private _removeClipPlaneDefine;
  98144. isReady(): boolean;
  98145. /**
  98146. * Returns the string "LineMesh"
  98147. */
  98148. getClassName(): string;
  98149. /**
  98150. * @hidden
  98151. */
  98152. get material(): Material;
  98153. /**
  98154. * @hidden
  98155. */
  98156. set material(value: Material);
  98157. /**
  98158. * @hidden
  98159. */
  98160. get checkCollisions(): boolean;
  98161. /** @hidden */
  98162. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98163. /** @hidden */
  98164. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98165. /**
  98166. * Disposes of the line mesh
  98167. * @param doNotRecurse If children should be disposed
  98168. */
  98169. dispose(doNotRecurse?: boolean): void;
  98170. /**
  98171. * Returns a new LineMesh object cloned from the current one.
  98172. */
  98173. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  98174. /**
  98175. * Creates a new InstancedLinesMesh object from the mesh model.
  98176. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  98177. * @param name defines the name of the new instance
  98178. * @returns a new InstancedLinesMesh
  98179. */
  98180. createInstance(name: string): InstancedLinesMesh;
  98181. }
  98182. /**
  98183. * Creates an instance based on a source LinesMesh
  98184. */
  98185. export class InstancedLinesMesh extends InstancedMesh {
  98186. /**
  98187. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  98188. * This margin is expressed in world space coordinates, so its value may vary.
  98189. * Initilized with the intersectionThreshold value of the source LinesMesh
  98190. */
  98191. intersectionThreshold: number;
  98192. constructor(name: string, source: LinesMesh);
  98193. /**
  98194. * Returns the string "InstancedLinesMesh".
  98195. */
  98196. getClassName(): string;
  98197. }
  98198. }
  98199. declare module BABYLON {
  98200. /** @hidden */
  98201. export var linePixelShader: {
  98202. name: string;
  98203. shader: string;
  98204. };
  98205. }
  98206. declare module BABYLON {
  98207. /** @hidden */
  98208. export var lineVertexShader: {
  98209. name: string;
  98210. shader: string;
  98211. };
  98212. }
  98213. declare module BABYLON {
  98214. interface Scene {
  98215. /** @hidden */
  98216. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  98217. }
  98218. interface AbstractMesh {
  98219. /**
  98220. * Gets the edgesRenderer associated with the mesh
  98221. */
  98222. edgesRenderer: Nullable<EdgesRenderer>;
  98223. }
  98224. interface LinesMesh {
  98225. /**
  98226. * Enables the edge rendering mode on the mesh.
  98227. * This mode makes the mesh edges visible
  98228. * @param epsilon defines the maximal distance between two angles to detect a face
  98229. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  98230. * @returns the currentAbstractMesh
  98231. * @see https://www.babylonjs-playground.com/#19O9TU#0
  98232. */
  98233. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  98234. }
  98235. interface InstancedLinesMesh {
  98236. /**
  98237. * Enables the edge rendering mode on the mesh.
  98238. * This mode makes the mesh edges visible
  98239. * @param epsilon defines the maximal distance between two angles to detect a face
  98240. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  98241. * @returns the current InstancedLinesMesh
  98242. * @see https://www.babylonjs-playground.com/#19O9TU#0
  98243. */
  98244. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  98245. }
  98246. /**
  98247. * Defines the minimum contract an Edges renderer should follow.
  98248. */
  98249. export interface IEdgesRenderer extends IDisposable {
  98250. /**
  98251. * Gets or sets a boolean indicating if the edgesRenderer is active
  98252. */
  98253. isEnabled: boolean;
  98254. /**
  98255. * Renders the edges of the attached mesh,
  98256. */
  98257. render(): void;
  98258. /**
  98259. * Checks wether or not the edges renderer is ready to render.
  98260. * @return true if ready, otherwise false.
  98261. */
  98262. isReady(): boolean;
  98263. /**
  98264. * List of instances to render in case the source mesh has instances
  98265. */
  98266. customInstances: SmartArray<Matrix>;
  98267. }
  98268. /**
  98269. * Defines the additional options of the edges renderer
  98270. */
  98271. export interface IEdgesRendererOptions {
  98272. /**
  98273. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  98274. * If not defined, the default value is true
  98275. */
  98276. useAlternateEdgeFinder?: boolean;
  98277. /**
  98278. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  98279. * If not defined, the default value is true.
  98280. * 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)
  98281. * This option is used only if useAlternateEdgeFinder = true
  98282. */
  98283. useFastVertexMerger?: boolean;
  98284. /**
  98285. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  98286. * The default value is 1e-6
  98287. * This option is used only if useAlternateEdgeFinder = true
  98288. */
  98289. epsilonVertexMerge?: number;
  98290. /**
  98291. * 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
  98292. * 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.
  98293. * This option is used only if useAlternateEdgeFinder = true
  98294. */
  98295. applyTessellation?: boolean;
  98296. /**
  98297. * 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
  98298. * The default value is 1e-6
  98299. * This option is used only if useAlternateEdgeFinder = true
  98300. */
  98301. epsilonVertexAligned?: number;
  98302. }
  98303. /**
  98304. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  98305. */
  98306. export class EdgesRenderer implements IEdgesRenderer {
  98307. /**
  98308. * Define the size of the edges with an orthographic camera
  98309. */
  98310. edgesWidthScalerForOrthographic: number;
  98311. /**
  98312. * Define the size of the edges with a perspective camera
  98313. */
  98314. edgesWidthScalerForPerspective: number;
  98315. protected _source: AbstractMesh;
  98316. protected _linesPositions: number[];
  98317. protected _linesNormals: number[];
  98318. protected _linesIndices: number[];
  98319. protected _epsilon: number;
  98320. protected _indicesCount: number;
  98321. protected _lineShader: ShaderMaterial;
  98322. protected _ib: DataBuffer;
  98323. protected _buffers: {
  98324. [key: string]: Nullable<VertexBuffer>;
  98325. };
  98326. protected _buffersForInstances: {
  98327. [key: string]: Nullable<VertexBuffer>;
  98328. };
  98329. protected _checkVerticesInsteadOfIndices: boolean;
  98330. protected _options: Nullable<IEdgesRendererOptions>;
  98331. private _meshRebuildObserver;
  98332. private _meshDisposeObserver;
  98333. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  98334. isEnabled: boolean;
  98335. /**
  98336. * List of instances to render in case the source mesh has instances
  98337. */
  98338. customInstances: SmartArray<Matrix>;
  98339. private static GetShader;
  98340. /**
  98341. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  98342. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  98343. * @param source Mesh used to create edges
  98344. * @param epsilon sum of angles in adjacency to check for edge
  98345. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  98346. * @param generateEdgesLines - should generate Lines or only prepare resources.
  98347. * @param options The options to apply when generating the edges
  98348. */
  98349. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  98350. protected _prepareRessources(): void;
  98351. /** @hidden */
  98352. _rebuild(): void;
  98353. /**
  98354. * Releases the required resources for the edges renderer
  98355. */
  98356. dispose(): void;
  98357. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  98358. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  98359. /**
  98360. * Checks if the pair of p0 and p1 is en edge
  98361. * @param faceIndex
  98362. * @param edge
  98363. * @param faceNormals
  98364. * @param p0
  98365. * @param p1
  98366. * @private
  98367. */
  98368. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  98369. /**
  98370. * push line into the position, normal and index buffer
  98371. * @protected
  98372. */
  98373. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  98374. /**
  98375. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  98376. */
  98377. private _tessellateTriangle;
  98378. private _generateEdgesLinesAlternate;
  98379. /**
  98380. * Generates lines edges from adjacencjes
  98381. * @private
  98382. */
  98383. _generateEdgesLines(): void;
  98384. /**
  98385. * Checks wether or not the edges renderer is ready to render.
  98386. * @return true if ready, otherwise false.
  98387. */
  98388. isReady(): boolean;
  98389. /**
  98390. * Renders the edges of the attached mesh,
  98391. */
  98392. render(): void;
  98393. }
  98394. /**
  98395. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  98396. */
  98397. export class LineEdgesRenderer extends EdgesRenderer {
  98398. /**
  98399. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  98400. * @param source LineMesh used to generate edges
  98401. * @param epsilon not important (specified angle for edge detection)
  98402. * @param checkVerticesInsteadOfIndices not important for LineMesh
  98403. */
  98404. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  98405. /**
  98406. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  98407. */
  98408. _generateEdgesLines(): void;
  98409. }
  98410. }
  98411. declare module BABYLON {
  98412. /**
  98413. * This represents the object necessary to create a rendering group.
  98414. * This is exclusively used and created by the rendering manager.
  98415. * To modify the behavior, you use the available helpers in your scene or meshes.
  98416. * @hidden
  98417. */
  98418. export class RenderingGroup {
  98419. index: number;
  98420. private static _zeroVector;
  98421. private _scene;
  98422. private _opaqueSubMeshes;
  98423. private _transparentSubMeshes;
  98424. private _alphaTestSubMeshes;
  98425. private _depthOnlySubMeshes;
  98426. private _particleSystems;
  98427. private _spriteManagers;
  98428. private _opaqueSortCompareFn;
  98429. private _alphaTestSortCompareFn;
  98430. private _transparentSortCompareFn;
  98431. private _renderOpaque;
  98432. private _renderAlphaTest;
  98433. private _renderTransparent;
  98434. /** @hidden */
  98435. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  98436. onBeforeTransparentRendering: () => void;
  98437. /**
  98438. * Set the opaque sort comparison function.
  98439. * If null the sub meshes will be render in the order they were created
  98440. */
  98441. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98442. /**
  98443. * Set the alpha test sort comparison function.
  98444. * If null the sub meshes will be render in the order they were created
  98445. */
  98446. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98447. /**
  98448. * Set the transparent sort comparison function.
  98449. * If null the sub meshes will be render in the order they were created
  98450. */
  98451. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98452. /**
  98453. * Creates a new rendering group.
  98454. * @param index The rendering group index
  98455. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  98456. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  98457. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  98458. */
  98459. 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>);
  98460. /**
  98461. * Render all the sub meshes contained in the group.
  98462. * @param customRenderFunction Used to override the default render behaviour of the group.
  98463. * @returns true if rendered some submeshes.
  98464. */
  98465. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  98466. /**
  98467. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  98468. * @param subMeshes The submeshes to render
  98469. */
  98470. private renderOpaqueSorted;
  98471. /**
  98472. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  98473. * @param subMeshes The submeshes to render
  98474. */
  98475. private renderAlphaTestSorted;
  98476. /**
  98477. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  98478. * @param subMeshes The submeshes to render
  98479. */
  98480. private renderTransparentSorted;
  98481. /**
  98482. * Renders the submeshes in a specified order.
  98483. * @param subMeshes The submeshes to sort before render
  98484. * @param sortCompareFn The comparison function use to sort
  98485. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  98486. * @param transparent Specifies to activate blending if true
  98487. */
  98488. private static renderSorted;
  98489. /**
  98490. * Renders the submeshes in the order they were dispatched (no sort applied).
  98491. * @param subMeshes The submeshes to render
  98492. */
  98493. private static renderUnsorted;
  98494. /**
  98495. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98496. * are rendered back to front if in the same alpha index.
  98497. *
  98498. * @param a The first submesh
  98499. * @param b The second submesh
  98500. * @returns The result of the comparison
  98501. */
  98502. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  98503. /**
  98504. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98505. * are rendered back to front.
  98506. *
  98507. * @param a The first submesh
  98508. * @param b The second submesh
  98509. * @returns The result of the comparison
  98510. */
  98511. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  98512. /**
  98513. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98514. * are rendered front to back (prevent overdraw).
  98515. *
  98516. * @param a The first submesh
  98517. * @param b The second submesh
  98518. * @returns The result of the comparison
  98519. */
  98520. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  98521. /**
  98522. * Resets the different lists of submeshes to prepare a new frame.
  98523. */
  98524. prepare(): void;
  98525. dispose(): void;
  98526. /**
  98527. * Inserts the submesh in its correct queue depending on its material.
  98528. * @param subMesh The submesh to dispatch
  98529. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98530. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98531. */
  98532. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98533. dispatchSprites(spriteManager: ISpriteManager): void;
  98534. dispatchParticles(particleSystem: IParticleSystem): void;
  98535. private _renderParticles;
  98536. private _renderSprites;
  98537. }
  98538. }
  98539. declare module BABYLON {
  98540. /**
  98541. * Interface describing the different options available in the rendering manager
  98542. * regarding Auto Clear between groups.
  98543. */
  98544. export interface IRenderingManagerAutoClearSetup {
  98545. /**
  98546. * Defines whether or not autoclear is enable.
  98547. */
  98548. autoClear: boolean;
  98549. /**
  98550. * Defines whether or not to autoclear the depth buffer.
  98551. */
  98552. depth: boolean;
  98553. /**
  98554. * Defines whether or not to autoclear the stencil buffer.
  98555. */
  98556. stencil: boolean;
  98557. }
  98558. /**
  98559. * This class is used by the onRenderingGroupObservable
  98560. */
  98561. export class RenderingGroupInfo {
  98562. /**
  98563. * The Scene that being rendered
  98564. */
  98565. scene: Scene;
  98566. /**
  98567. * The camera currently used for the rendering pass
  98568. */
  98569. camera: Nullable<Camera>;
  98570. /**
  98571. * The ID of the renderingGroup being processed
  98572. */
  98573. renderingGroupId: number;
  98574. }
  98575. /**
  98576. * This is the manager responsible of all the rendering for meshes sprites and particles.
  98577. * It is enable to manage the different groups as well as the different necessary sort functions.
  98578. * This should not be used directly aside of the few static configurations
  98579. */
  98580. export class RenderingManager {
  98581. /**
  98582. * The max id used for rendering groups (not included)
  98583. */
  98584. static MAX_RENDERINGGROUPS: number;
  98585. /**
  98586. * The min id used for rendering groups (included)
  98587. */
  98588. static MIN_RENDERINGGROUPS: number;
  98589. /**
  98590. * Used to globally prevent autoclearing scenes.
  98591. */
  98592. static AUTOCLEAR: boolean;
  98593. /**
  98594. * @hidden
  98595. */
  98596. _useSceneAutoClearSetup: boolean;
  98597. private _scene;
  98598. private _renderingGroups;
  98599. private _depthStencilBufferAlreadyCleaned;
  98600. private _autoClearDepthStencil;
  98601. private _customOpaqueSortCompareFn;
  98602. private _customAlphaTestSortCompareFn;
  98603. private _customTransparentSortCompareFn;
  98604. private _renderingGroupInfo;
  98605. /**
  98606. * Instantiates a new rendering group for a particular scene
  98607. * @param scene Defines the scene the groups belongs to
  98608. */
  98609. constructor(scene: Scene);
  98610. private _clearDepthStencilBuffer;
  98611. /**
  98612. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  98613. * @hidden
  98614. */
  98615. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  98616. /**
  98617. * Resets the different information of the group to prepare a new frame
  98618. * @hidden
  98619. */
  98620. reset(): void;
  98621. /**
  98622. * Dispose and release the group and its associated resources.
  98623. * @hidden
  98624. */
  98625. dispose(): void;
  98626. /**
  98627. * Clear the info related to rendering groups preventing retention points during dispose.
  98628. */
  98629. freeRenderingGroups(): void;
  98630. private _prepareRenderingGroup;
  98631. /**
  98632. * Add a sprite manager to the rendering manager in order to render it this frame.
  98633. * @param spriteManager Define the sprite manager to render
  98634. */
  98635. dispatchSprites(spriteManager: ISpriteManager): void;
  98636. /**
  98637. * Add a particle system to the rendering manager in order to render it this frame.
  98638. * @param particleSystem Define the particle system to render
  98639. */
  98640. dispatchParticles(particleSystem: IParticleSystem): void;
  98641. /**
  98642. * Add a submesh to the manager in order to render it this frame
  98643. * @param subMesh The submesh to dispatch
  98644. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98645. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98646. */
  98647. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98648. /**
  98649. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98650. * This allowed control for front to back rendering or reversly depending of the special needs.
  98651. *
  98652. * @param renderingGroupId The rendering group id corresponding to its index
  98653. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98654. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98655. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98656. */
  98657. 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;
  98658. /**
  98659. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98660. *
  98661. * @param renderingGroupId The rendering group id corresponding to its index
  98662. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98663. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98664. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98665. */
  98666. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98667. /**
  98668. * Gets the current auto clear configuration for one rendering group of the rendering
  98669. * manager.
  98670. * @param index the rendering group index to get the information for
  98671. * @returns The auto clear setup for the requested rendering group
  98672. */
  98673. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98674. }
  98675. }
  98676. declare module BABYLON {
  98677. /**
  98678. * Defines the options associated with the creation of a custom shader for a shadow generator.
  98679. */
  98680. export interface ICustomShaderOptions {
  98681. /**
  98682. * Gets or sets the custom shader name to use
  98683. */
  98684. shaderName: string;
  98685. /**
  98686. * The list of attribute names used in the shader
  98687. */
  98688. attributes?: string[];
  98689. /**
  98690. * The list of unifrom names used in the shader
  98691. */
  98692. uniforms?: string[];
  98693. /**
  98694. * The list of sampler names used in the shader
  98695. */
  98696. samplers?: string[];
  98697. /**
  98698. * The list of defines used in the shader
  98699. */
  98700. defines?: string[];
  98701. }
  98702. /**
  98703. * Interface to implement to create a shadow generator compatible with BJS.
  98704. */
  98705. export interface IShadowGenerator {
  98706. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98707. id: string;
  98708. /**
  98709. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98710. * @returns The render target texture if present otherwise, null
  98711. */
  98712. getShadowMap(): Nullable<RenderTargetTexture>;
  98713. /**
  98714. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98715. * @param subMesh The submesh we want to render in the shadow map
  98716. * @param useInstances Defines wether will draw in the map using instances
  98717. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98718. * @returns true if ready otherwise, false
  98719. */
  98720. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98721. /**
  98722. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98723. * @param defines Defines of the material we want to update
  98724. * @param lightIndex Index of the light in the enabled light list of the material
  98725. */
  98726. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  98727. /**
  98728. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98729. * defined in the generator but impacting the effect).
  98730. * It implies the unifroms available on the materials are the standard BJS ones.
  98731. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98732. * @param effect The effect we are binfing the information for
  98733. */
  98734. bindShadowLight(lightIndex: string, effect: Effect): void;
  98735. /**
  98736. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98737. * (eq to shadow prjection matrix * light transform matrix)
  98738. * @returns The transform matrix used to create the shadow map
  98739. */
  98740. getTransformMatrix(): Matrix;
  98741. /**
  98742. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98743. * Cube and 2D textures for instance.
  98744. */
  98745. recreateShadowMap(): void;
  98746. /**
  98747. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98748. * @param onCompiled Callback triggered at the and of the effects compilation
  98749. * @param options Sets of optional options forcing the compilation with different modes
  98750. */
  98751. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98752. useInstances: boolean;
  98753. }>): void;
  98754. /**
  98755. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98756. * @param options Sets of optional options forcing the compilation with different modes
  98757. * @returns A promise that resolves when the compilation completes
  98758. */
  98759. forceCompilationAsync(options?: Partial<{
  98760. useInstances: boolean;
  98761. }>): Promise<void>;
  98762. /**
  98763. * Serializes the shadow generator setup to a json object.
  98764. * @returns The serialized JSON object
  98765. */
  98766. serialize(): any;
  98767. /**
  98768. * Disposes the Shadow map and related Textures and effects.
  98769. */
  98770. dispose(): void;
  98771. }
  98772. /**
  98773. * Default implementation IShadowGenerator.
  98774. * This is the main object responsible of generating shadows in the framework.
  98775. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  98776. */
  98777. export class ShadowGenerator implements IShadowGenerator {
  98778. /**
  98779. * Name of the shadow generator class
  98780. */
  98781. static CLASSNAME: string;
  98782. /**
  98783. * Shadow generator mode None: no filtering applied.
  98784. */
  98785. static readonly FILTER_NONE: number;
  98786. /**
  98787. * Shadow generator mode ESM: Exponential Shadow Mapping.
  98788. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98789. */
  98790. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  98791. /**
  98792. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  98793. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  98794. */
  98795. static readonly FILTER_POISSONSAMPLING: number;
  98796. /**
  98797. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  98798. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98799. */
  98800. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  98801. /**
  98802. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  98803. * edge artifacts on steep falloff.
  98804. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98805. */
  98806. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  98807. /**
  98808. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  98809. * edge artifacts on steep falloff.
  98810. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98811. */
  98812. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  98813. /**
  98814. * Shadow generator mode PCF: Percentage Closer Filtering
  98815. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98816. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  98817. */
  98818. static readonly FILTER_PCF: number;
  98819. /**
  98820. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  98821. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98822. * Contact Hardening
  98823. */
  98824. static readonly FILTER_PCSS: number;
  98825. /**
  98826. * Reserved for PCF and PCSS
  98827. * Highest Quality.
  98828. *
  98829. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  98830. *
  98831. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  98832. */
  98833. static readonly QUALITY_HIGH: number;
  98834. /**
  98835. * Reserved for PCF and PCSS
  98836. * Good tradeoff for quality/perf cross devices
  98837. *
  98838. * Execute PCF on a 3*3 kernel.
  98839. *
  98840. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  98841. */
  98842. static readonly QUALITY_MEDIUM: number;
  98843. /**
  98844. * Reserved for PCF and PCSS
  98845. * The lowest quality but the fastest.
  98846. *
  98847. * Execute PCF on a 1*1 kernel.
  98848. *
  98849. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  98850. */
  98851. static readonly QUALITY_LOW: number;
  98852. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98853. id: string;
  98854. /** Gets or sets the custom shader name to use */
  98855. customShaderOptions: ICustomShaderOptions;
  98856. /**
  98857. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  98858. */
  98859. onBeforeShadowMapRenderObservable: Observable<Effect>;
  98860. /**
  98861. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  98862. */
  98863. onAfterShadowMapRenderObservable: Observable<Effect>;
  98864. /**
  98865. * Observable triggered before a mesh is rendered in the shadow map.
  98866. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  98867. */
  98868. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  98869. /**
  98870. * Observable triggered after a mesh is rendered in the shadow map.
  98871. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  98872. */
  98873. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  98874. protected _bias: number;
  98875. /**
  98876. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  98877. */
  98878. get bias(): number;
  98879. /**
  98880. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  98881. */
  98882. set bias(bias: number);
  98883. protected _normalBias: number;
  98884. /**
  98885. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98886. */
  98887. get normalBias(): number;
  98888. /**
  98889. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98890. */
  98891. set normalBias(normalBias: number);
  98892. protected _blurBoxOffset: number;
  98893. /**
  98894. * Gets the blur box offset: offset applied during the blur pass.
  98895. * Only useful if useKernelBlur = false
  98896. */
  98897. get blurBoxOffset(): number;
  98898. /**
  98899. * Sets the blur box offset: offset applied during the blur pass.
  98900. * Only useful if useKernelBlur = false
  98901. */
  98902. set blurBoxOffset(value: number);
  98903. protected _blurScale: number;
  98904. /**
  98905. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98906. * 2 means half of the size.
  98907. */
  98908. get blurScale(): number;
  98909. /**
  98910. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98911. * 2 means half of the size.
  98912. */
  98913. set blurScale(value: number);
  98914. protected _blurKernel: number;
  98915. /**
  98916. * Gets the blur kernel: kernel size of the blur pass.
  98917. * Only useful if useKernelBlur = true
  98918. */
  98919. get blurKernel(): number;
  98920. /**
  98921. * Sets the blur kernel: kernel size of the blur pass.
  98922. * Only useful if useKernelBlur = true
  98923. */
  98924. set blurKernel(value: number);
  98925. protected _useKernelBlur: boolean;
  98926. /**
  98927. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  98928. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98929. */
  98930. get useKernelBlur(): boolean;
  98931. /**
  98932. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98933. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98934. */
  98935. set useKernelBlur(value: boolean);
  98936. protected _depthScale: number;
  98937. /**
  98938. * Gets the depth scale used in ESM mode.
  98939. */
  98940. get depthScale(): number;
  98941. /**
  98942. * Sets the depth scale used in ESM mode.
  98943. * This can override the scale stored on the light.
  98944. */
  98945. set depthScale(value: number);
  98946. protected _validateFilter(filter: number): number;
  98947. protected _filter: number;
  98948. /**
  98949. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98950. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98951. */
  98952. get filter(): number;
  98953. /**
  98954. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98955. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98956. */
  98957. set filter(value: number);
  98958. /**
  98959. * Gets if the current filter is set to Poisson Sampling.
  98960. */
  98961. get usePoissonSampling(): boolean;
  98962. /**
  98963. * Sets the current filter to Poisson Sampling.
  98964. */
  98965. set usePoissonSampling(value: boolean);
  98966. /**
  98967. * Gets if the current filter is set to ESM.
  98968. */
  98969. get useExponentialShadowMap(): boolean;
  98970. /**
  98971. * Sets the current filter is to ESM.
  98972. */
  98973. set useExponentialShadowMap(value: boolean);
  98974. /**
  98975. * Gets if the current filter is set to filtered ESM.
  98976. */
  98977. get useBlurExponentialShadowMap(): boolean;
  98978. /**
  98979. * Gets if the current filter is set to filtered ESM.
  98980. */
  98981. set useBlurExponentialShadowMap(value: boolean);
  98982. /**
  98983. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98984. * exponential to prevent steep falloff artifacts).
  98985. */
  98986. get useCloseExponentialShadowMap(): boolean;
  98987. /**
  98988. * Sets the current filter to "close ESM" (using the inverse of the
  98989. * exponential to prevent steep falloff artifacts).
  98990. */
  98991. set useCloseExponentialShadowMap(value: boolean);
  98992. /**
  98993. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98994. * exponential to prevent steep falloff artifacts).
  98995. */
  98996. get useBlurCloseExponentialShadowMap(): boolean;
  98997. /**
  98998. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98999. * exponential to prevent steep falloff artifacts).
  99000. */
  99001. set useBlurCloseExponentialShadowMap(value: boolean);
  99002. /**
  99003. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  99004. */
  99005. get usePercentageCloserFiltering(): boolean;
  99006. /**
  99007. * Sets the current filter to "PCF" (percentage closer filtering).
  99008. */
  99009. set usePercentageCloserFiltering(value: boolean);
  99010. protected _filteringQuality: number;
  99011. /**
  99012. * Gets the PCF or PCSS Quality.
  99013. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  99014. */
  99015. get filteringQuality(): number;
  99016. /**
  99017. * Sets the PCF or PCSS Quality.
  99018. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  99019. */
  99020. set filteringQuality(filteringQuality: number);
  99021. /**
  99022. * Gets if the current filter is set to "PCSS" (contact hardening).
  99023. */
  99024. get useContactHardeningShadow(): boolean;
  99025. /**
  99026. * Sets the current filter to "PCSS" (contact hardening).
  99027. */
  99028. set useContactHardeningShadow(value: boolean);
  99029. protected _contactHardeningLightSizeUVRatio: number;
  99030. /**
  99031. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  99032. * Using a ratio helps keeping shape stability independently of the map size.
  99033. *
  99034. * It does not account for the light projection as it was having too much
  99035. * instability during the light setup or during light position changes.
  99036. *
  99037. * Only valid if useContactHardeningShadow is true.
  99038. */
  99039. get contactHardeningLightSizeUVRatio(): number;
  99040. /**
  99041. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  99042. * Using a ratio helps keeping shape stability independently of the map size.
  99043. *
  99044. * It does not account for the light projection as it was having too much
  99045. * instability during the light setup or during light position changes.
  99046. *
  99047. * Only valid if useContactHardeningShadow is true.
  99048. */
  99049. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  99050. protected _darkness: number;
  99051. /** Gets or sets the actual darkness of a shadow */
  99052. get darkness(): number;
  99053. set darkness(value: number);
  99054. /**
  99055. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  99056. * 0 means strongest and 1 would means no shadow.
  99057. * @returns the darkness.
  99058. */
  99059. getDarkness(): number;
  99060. /**
  99061. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  99062. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  99063. * @returns the shadow generator allowing fluent coding.
  99064. */
  99065. setDarkness(darkness: number): ShadowGenerator;
  99066. protected _transparencyShadow: boolean;
  99067. /** Gets or sets the ability to have transparent shadow */
  99068. get transparencyShadow(): boolean;
  99069. set transparencyShadow(value: boolean);
  99070. /**
  99071. * Sets the ability to have transparent shadow (boolean).
  99072. * @param transparent True if transparent else False
  99073. * @returns the shadow generator allowing fluent coding
  99074. */
  99075. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  99076. /**
  99077. * Enables or disables shadows with varying strength based on the transparency
  99078. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  99079. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  99080. * mesh.visibility * alphaTexture.a
  99081. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  99082. */
  99083. enableSoftTransparentShadow: boolean;
  99084. protected _shadowMap: Nullable<RenderTargetTexture>;
  99085. protected _shadowMap2: Nullable<RenderTargetTexture>;
  99086. /**
  99087. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  99088. * @returns The render target texture if present otherwise, null
  99089. */
  99090. getShadowMap(): Nullable<RenderTargetTexture>;
  99091. /**
  99092. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  99093. * @returns The render target texture if the shadow map is present otherwise, null
  99094. */
  99095. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  99096. /**
  99097. * Gets the class name of that object
  99098. * @returns "ShadowGenerator"
  99099. */
  99100. getClassName(): string;
  99101. /**
  99102. * Helper function to add a mesh and its descendants to the list of shadow casters.
  99103. * @param mesh Mesh to add
  99104. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  99105. * @returns the Shadow Generator itself
  99106. */
  99107. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  99108. /**
  99109. * Helper function to remove a mesh and its descendants from the list of shadow casters
  99110. * @param mesh Mesh to remove
  99111. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  99112. * @returns the Shadow Generator itself
  99113. */
  99114. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  99115. /**
  99116. * Controls the extent to which the shadows fade out at the edge of the frustum
  99117. */
  99118. frustumEdgeFalloff: number;
  99119. protected _light: IShadowLight;
  99120. /**
  99121. * Returns the associated light object.
  99122. * @returns the light generating the shadow
  99123. */
  99124. getLight(): IShadowLight;
  99125. /**
  99126. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  99127. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  99128. * It might on the other hand introduce peter panning.
  99129. */
  99130. forceBackFacesOnly: boolean;
  99131. protected _scene: Scene;
  99132. protected _lightDirection: Vector3;
  99133. protected _effect: Effect;
  99134. protected _viewMatrix: Matrix;
  99135. protected _projectionMatrix: Matrix;
  99136. protected _transformMatrix: Matrix;
  99137. protected _cachedPosition: Vector3;
  99138. protected _cachedDirection: Vector3;
  99139. protected _cachedDefines: string;
  99140. protected _currentRenderID: number;
  99141. protected _boxBlurPostprocess: Nullable<PostProcess>;
  99142. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  99143. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  99144. protected _blurPostProcesses: PostProcess[];
  99145. protected _mapSize: number;
  99146. protected _currentFaceIndex: number;
  99147. protected _currentFaceIndexCache: number;
  99148. protected _textureType: number;
  99149. protected _defaultTextureMatrix: Matrix;
  99150. protected _storedUniqueId: Nullable<number>;
  99151. /** @hidden */
  99152. static _SceneComponentInitialization: (scene: Scene) => void;
  99153. /**
  99154. * Gets or sets the size of the texture what stores the shadows
  99155. */
  99156. get mapSize(): number;
  99157. set mapSize(size: number);
  99158. /**
  99159. * Creates a ShadowGenerator object.
  99160. * A ShadowGenerator is the required tool to use the shadows.
  99161. * Each light casting shadows needs to use its own ShadowGenerator.
  99162. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  99163. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  99164. * @param light The light object generating the shadows.
  99165. * @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.
  99166. */
  99167. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  99168. protected _initializeGenerator(): void;
  99169. protected _createTargetRenderTexture(): void;
  99170. protected _initializeShadowMap(): void;
  99171. protected _initializeBlurRTTAndPostProcesses(): void;
  99172. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  99173. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  99174. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  99175. protected _applyFilterValues(): void;
  99176. /**
  99177. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  99178. * @param onCompiled Callback triggered at the and of the effects compilation
  99179. * @param options Sets of optional options forcing the compilation with different modes
  99180. */
  99181. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  99182. useInstances: boolean;
  99183. }>): void;
  99184. /**
  99185. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  99186. * @param options Sets of optional options forcing the compilation with different modes
  99187. * @returns A promise that resolves when the compilation completes
  99188. */
  99189. forceCompilationAsync(options?: Partial<{
  99190. useInstances: boolean;
  99191. }>): Promise<void>;
  99192. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  99193. private _prepareShadowDefines;
  99194. /**
  99195. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  99196. * @param subMesh The submesh we want to render in the shadow map
  99197. * @param useInstances Defines wether will draw in the map using instances
  99198. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  99199. * @returns true if ready otherwise, false
  99200. */
  99201. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  99202. /**
  99203. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  99204. * @param defines Defines of the material we want to update
  99205. * @param lightIndex Index of the light in the enabled light list of the material
  99206. */
  99207. prepareDefines(defines: any, lightIndex: number): void;
  99208. /**
  99209. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  99210. * defined in the generator but impacting the effect).
  99211. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  99212. * @param effect The effect we are binfing the information for
  99213. */
  99214. bindShadowLight(lightIndex: string, effect: Effect): void;
  99215. /**
  99216. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  99217. * (eq to shadow prjection matrix * light transform matrix)
  99218. * @returns The transform matrix used to create the shadow map
  99219. */
  99220. getTransformMatrix(): Matrix;
  99221. /**
  99222. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  99223. * Cube and 2D textures for instance.
  99224. */
  99225. recreateShadowMap(): void;
  99226. protected _disposeBlurPostProcesses(): void;
  99227. protected _disposeRTTandPostProcesses(): void;
  99228. /**
  99229. * Disposes the ShadowGenerator.
  99230. * Returns nothing.
  99231. */
  99232. dispose(): void;
  99233. /**
  99234. * Serializes the shadow generator setup to a json object.
  99235. * @returns The serialized JSON object
  99236. */
  99237. serialize(): any;
  99238. /**
  99239. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  99240. * @param parsedShadowGenerator The JSON object to parse
  99241. * @param scene The scene to create the shadow map for
  99242. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  99243. * @returns The parsed shadow generator
  99244. */
  99245. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  99246. }
  99247. }
  99248. declare module BABYLON {
  99249. /**
  99250. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  99251. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  99252. * 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.
  99253. */
  99254. export abstract class Light extends Node {
  99255. /**
  99256. * Falloff Default: light is falling off following the material specification:
  99257. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  99258. */
  99259. static readonly FALLOFF_DEFAULT: number;
  99260. /**
  99261. * Falloff Physical: light is falling off following the inverse squared distance law.
  99262. */
  99263. static readonly FALLOFF_PHYSICAL: number;
  99264. /**
  99265. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  99266. * to enhance interoperability with other engines.
  99267. */
  99268. static readonly FALLOFF_GLTF: number;
  99269. /**
  99270. * Falloff Standard: light is falling off like in the standard material
  99271. * to enhance interoperability with other materials.
  99272. */
  99273. static readonly FALLOFF_STANDARD: number;
  99274. /**
  99275. * If every light affecting the material is in this lightmapMode,
  99276. * material.lightmapTexture adds or multiplies
  99277. * (depends on material.useLightmapAsShadowmap)
  99278. * after every other light calculations.
  99279. */
  99280. static readonly LIGHTMAP_DEFAULT: number;
  99281. /**
  99282. * material.lightmapTexture as only diffuse lighting from this light
  99283. * adds only specular lighting from this light
  99284. * adds dynamic shadows
  99285. */
  99286. static readonly LIGHTMAP_SPECULAR: number;
  99287. /**
  99288. * material.lightmapTexture as only lighting
  99289. * no light calculation from this light
  99290. * only adds dynamic shadows from this light
  99291. */
  99292. static readonly LIGHTMAP_SHADOWSONLY: number;
  99293. /**
  99294. * Each light type uses the default quantity according to its type:
  99295. * point/spot lights use luminous intensity
  99296. * directional lights use illuminance
  99297. */
  99298. static readonly INTENSITYMODE_AUTOMATIC: number;
  99299. /**
  99300. * lumen (lm)
  99301. */
  99302. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  99303. /**
  99304. * candela (lm/sr)
  99305. */
  99306. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  99307. /**
  99308. * lux (lm/m^2)
  99309. */
  99310. static readonly INTENSITYMODE_ILLUMINANCE: number;
  99311. /**
  99312. * nit (cd/m^2)
  99313. */
  99314. static readonly INTENSITYMODE_LUMINANCE: number;
  99315. /**
  99316. * Light type const id of the point light.
  99317. */
  99318. static readonly LIGHTTYPEID_POINTLIGHT: number;
  99319. /**
  99320. * Light type const id of the directional light.
  99321. */
  99322. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  99323. /**
  99324. * Light type const id of the spot light.
  99325. */
  99326. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  99327. /**
  99328. * Light type const id of the hemispheric light.
  99329. */
  99330. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  99331. /**
  99332. * Diffuse gives the basic color to an object.
  99333. */
  99334. diffuse: Color3;
  99335. /**
  99336. * Specular produces a highlight color on an object.
  99337. * Note: This is note affecting PBR materials.
  99338. */
  99339. specular: Color3;
  99340. /**
  99341. * Defines the falloff type for this light. This lets overrriding how punctual light are
  99342. * falling off base on range or angle.
  99343. * This can be set to any values in Light.FALLOFF_x.
  99344. *
  99345. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  99346. * other types of materials.
  99347. */
  99348. falloffType: number;
  99349. /**
  99350. * Strength of the light.
  99351. * Note: By default it is define in the framework own unit.
  99352. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  99353. */
  99354. intensity: number;
  99355. private _range;
  99356. protected _inverseSquaredRange: number;
  99357. /**
  99358. * Defines how far from the source the light is impacting in scene units.
  99359. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  99360. */
  99361. get range(): number;
  99362. /**
  99363. * Defines how far from the source the light is impacting in scene units.
  99364. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  99365. */
  99366. set range(value: number);
  99367. /**
  99368. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  99369. * of light.
  99370. */
  99371. private _photometricScale;
  99372. private _intensityMode;
  99373. /**
  99374. * Gets the photometric scale used to interpret the intensity.
  99375. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  99376. */
  99377. get intensityMode(): number;
  99378. /**
  99379. * Sets the photometric scale used to interpret the intensity.
  99380. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  99381. */
  99382. set intensityMode(value: number);
  99383. private _radius;
  99384. /**
  99385. * Gets the light radius used by PBR Materials to simulate soft area lights.
  99386. */
  99387. get radius(): number;
  99388. /**
  99389. * sets the light radius used by PBR Materials to simulate soft area lights.
  99390. */
  99391. set radius(value: number);
  99392. private _renderPriority;
  99393. /**
  99394. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  99395. * exceeding the number allowed of the materials.
  99396. */
  99397. renderPriority: number;
  99398. private _shadowEnabled;
  99399. /**
  99400. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  99401. * the current shadow generator.
  99402. */
  99403. get shadowEnabled(): boolean;
  99404. /**
  99405. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  99406. * the current shadow generator.
  99407. */
  99408. set shadowEnabled(value: boolean);
  99409. private _includedOnlyMeshes;
  99410. /**
  99411. * Gets the only meshes impacted by this light.
  99412. */
  99413. get includedOnlyMeshes(): AbstractMesh[];
  99414. /**
  99415. * Sets the only meshes impacted by this light.
  99416. */
  99417. set includedOnlyMeshes(value: AbstractMesh[]);
  99418. private _excludedMeshes;
  99419. /**
  99420. * Gets the meshes not impacted by this light.
  99421. */
  99422. get excludedMeshes(): AbstractMesh[];
  99423. /**
  99424. * Sets the meshes not impacted by this light.
  99425. */
  99426. set excludedMeshes(value: AbstractMesh[]);
  99427. private _excludeWithLayerMask;
  99428. /**
  99429. * Gets the layer id use to find what meshes are not impacted by the light.
  99430. * Inactive if 0
  99431. */
  99432. get excludeWithLayerMask(): number;
  99433. /**
  99434. * Sets the layer id use to find what meshes are not impacted by the light.
  99435. * Inactive if 0
  99436. */
  99437. set excludeWithLayerMask(value: number);
  99438. private _includeOnlyWithLayerMask;
  99439. /**
  99440. * Gets the layer id use to find what meshes are impacted by the light.
  99441. * Inactive if 0
  99442. */
  99443. get includeOnlyWithLayerMask(): number;
  99444. /**
  99445. * Sets the layer id use to find what meshes are impacted by the light.
  99446. * Inactive if 0
  99447. */
  99448. set includeOnlyWithLayerMask(value: number);
  99449. private _lightmapMode;
  99450. /**
  99451. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  99452. */
  99453. get lightmapMode(): number;
  99454. /**
  99455. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  99456. */
  99457. set lightmapMode(value: number);
  99458. /**
  99459. * Shadow generator associted to the light.
  99460. * @hidden Internal use only.
  99461. */
  99462. _shadowGenerator: Nullable<IShadowGenerator>;
  99463. /**
  99464. * @hidden Internal use only.
  99465. */
  99466. _excludedMeshesIds: string[];
  99467. /**
  99468. * @hidden Internal use only.
  99469. */
  99470. _includedOnlyMeshesIds: string[];
  99471. /**
  99472. * The current light unifom buffer.
  99473. * @hidden Internal use only.
  99474. */
  99475. _uniformBuffer: UniformBuffer;
  99476. /** @hidden */
  99477. _renderId: number;
  99478. /**
  99479. * Creates a Light object in the scene.
  99480. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99481. * @param name The firendly name of the light
  99482. * @param scene The scene the light belongs too
  99483. */
  99484. constructor(name: string, scene: Scene);
  99485. protected abstract _buildUniformLayout(): void;
  99486. /**
  99487. * Sets the passed Effect "effect" with the Light information.
  99488. * @param effect The effect to update
  99489. * @param lightIndex The index of the light in the effect to update
  99490. * @returns The light
  99491. */
  99492. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  99493. /**
  99494. * Sets the passed Effect "effect" with the Light textures.
  99495. * @param effect The effect to update
  99496. * @param lightIndex The index of the light in the effect to update
  99497. * @returns The light
  99498. */
  99499. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  99500. /**
  99501. * Binds the lights information from the scene to the effect for the given mesh.
  99502. * @param lightIndex Light index
  99503. * @param scene The scene where the light belongs to
  99504. * @param effect The effect we are binding the data to
  99505. * @param useSpecular Defines if specular is supported
  99506. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99507. */
  99508. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99509. /**
  99510. * Sets the passed Effect "effect" with the Light information.
  99511. * @param effect The effect to update
  99512. * @param lightDataUniformName The uniform used to store light data (position or direction)
  99513. * @returns The light
  99514. */
  99515. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  99516. /**
  99517. * Returns the string "Light".
  99518. * @returns the class name
  99519. */
  99520. getClassName(): string;
  99521. /** @hidden */
  99522. readonly _isLight: boolean;
  99523. /**
  99524. * Converts the light information to a readable string for debug purpose.
  99525. * @param fullDetails Supports for multiple levels of logging within scene loading
  99526. * @returns the human readable light info
  99527. */
  99528. toString(fullDetails?: boolean): string;
  99529. /** @hidden */
  99530. protected _syncParentEnabledState(): void;
  99531. /**
  99532. * Set the enabled state of this node.
  99533. * @param value - the new enabled state
  99534. */
  99535. setEnabled(value: boolean): void;
  99536. /**
  99537. * Returns the Light associated shadow generator if any.
  99538. * @return the associated shadow generator.
  99539. */
  99540. getShadowGenerator(): Nullable<IShadowGenerator>;
  99541. /**
  99542. * Returns a Vector3, the absolute light position in the World.
  99543. * @returns the world space position of the light
  99544. */
  99545. getAbsolutePosition(): Vector3;
  99546. /**
  99547. * Specifies if the light will affect the passed mesh.
  99548. * @param mesh The mesh to test against the light
  99549. * @return true the mesh is affected otherwise, false.
  99550. */
  99551. canAffectMesh(mesh: AbstractMesh): boolean;
  99552. /**
  99553. * Sort function to order lights for rendering.
  99554. * @param a First Light object to compare to second.
  99555. * @param b Second Light object to compare first.
  99556. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  99557. */
  99558. static CompareLightsPriority(a: Light, b: Light): number;
  99559. /**
  99560. * Releases resources associated with this node.
  99561. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99562. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99563. */
  99564. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99565. /**
  99566. * Returns the light type ID (integer).
  99567. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99568. */
  99569. getTypeID(): number;
  99570. /**
  99571. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  99572. * @returns the scaled intensity in intensity mode unit
  99573. */
  99574. getScaledIntensity(): number;
  99575. /**
  99576. * Returns a new Light object, named "name", from the current one.
  99577. * @param name The name of the cloned light
  99578. * @param newParent The parent of this light, if it has one
  99579. * @returns the new created light
  99580. */
  99581. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  99582. /**
  99583. * Serializes the current light into a Serialization object.
  99584. * @returns the serialized object.
  99585. */
  99586. serialize(): any;
  99587. /**
  99588. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  99589. * This new light is named "name" and added to the passed scene.
  99590. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  99591. * @param name The friendly name of the light
  99592. * @param scene The scene the new light will belong to
  99593. * @returns the constructor function
  99594. */
  99595. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  99596. /**
  99597. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  99598. * @param parsedLight The JSON representation of the light
  99599. * @param scene The scene to create the parsed light in
  99600. * @returns the created light after parsing
  99601. */
  99602. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  99603. private _hookArrayForExcluded;
  99604. private _hookArrayForIncludedOnly;
  99605. private _resyncMeshes;
  99606. /**
  99607. * Forces the meshes to update their light related information in their rendering used effects
  99608. * @hidden Internal Use Only
  99609. */
  99610. _markMeshesAsLightDirty(): void;
  99611. /**
  99612. * Recomputes the cached photometric scale if needed.
  99613. */
  99614. private _computePhotometricScale;
  99615. /**
  99616. * Returns the Photometric Scale according to the light type and intensity mode.
  99617. */
  99618. private _getPhotometricScale;
  99619. /**
  99620. * Reorder the light in the scene according to their defined priority.
  99621. * @hidden Internal Use Only
  99622. */
  99623. _reorderLightsInScene(): void;
  99624. /**
  99625. * Prepares the list of defines specific to the light type.
  99626. * @param defines the list of defines
  99627. * @param lightIndex defines the index of the light for the effect
  99628. */
  99629. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99630. }
  99631. }
  99632. declare module BABYLON {
  99633. /**
  99634. * Configuration needed for prepass-capable materials
  99635. */
  99636. export class PrePassConfiguration {
  99637. /**
  99638. * Previous world matrices of meshes carrying this material
  99639. * Used for computing velocity
  99640. */
  99641. previousWorldMatrices: {
  99642. [index: number]: Matrix;
  99643. };
  99644. /**
  99645. * Previous view project matrix
  99646. * Used for computing velocity
  99647. */
  99648. previousViewProjection: Matrix;
  99649. /**
  99650. * Previous bones of meshes carrying this material
  99651. * Used for computing velocity
  99652. */
  99653. previousBones: {
  99654. [index: number]: Float32Array;
  99655. };
  99656. /**
  99657. * Add the required uniforms to the current list.
  99658. * @param uniforms defines the current uniform list.
  99659. */
  99660. static AddUniforms(uniforms: string[]): void;
  99661. /**
  99662. * Add the required samplers to the current list.
  99663. * @param samplers defines the current sampler list.
  99664. */
  99665. static AddSamplers(samplers: string[]): void;
  99666. /**
  99667. * Binds the material data.
  99668. * @param effect defines the effect to update
  99669. * @param scene defines the scene the material belongs to.
  99670. * @param mesh The mesh
  99671. * @param world World matrix of this mesh
  99672. * @param isFrozen Is the material frozen
  99673. */
  99674. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  99675. }
  99676. }
  99677. declare module BABYLON {
  99678. /**
  99679. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  99680. * This is the base of the follow, arc rotate cameras and Free camera
  99681. * @see https://doc.babylonjs.com/features/cameras
  99682. */
  99683. export class TargetCamera extends Camera {
  99684. private static _RigCamTransformMatrix;
  99685. private static _TargetTransformMatrix;
  99686. private static _TargetFocalPoint;
  99687. private _tmpUpVector;
  99688. private _tmpTargetVector;
  99689. /**
  99690. * Define the current direction the camera is moving to
  99691. */
  99692. cameraDirection: Vector3;
  99693. /**
  99694. * Define the current rotation the camera is rotating to
  99695. */
  99696. cameraRotation: Vector2;
  99697. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  99698. ignoreParentScaling: boolean;
  99699. /**
  99700. * When set, the up vector of the camera will be updated by the rotation of the camera
  99701. */
  99702. updateUpVectorFromRotation: boolean;
  99703. private _tmpQuaternion;
  99704. /**
  99705. * Define the current rotation of the camera
  99706. */
  99707. rotation: Vector3;
  99708. /**
  99709. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  99710. */
  99711. rotationQuaternion: Quaternion;
  99712. /**
  99713. * Define the current speed of the camera
  99714. */
  99715. speed: number;
  99716. /**
  99717. * Add constraint to the camera to prevent it to move freely in all directions and
  99718. * around all axis.
  99719. */
  99720. noRotationConstraint: boolean;
  99721. /**
  99722. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  99723. * panning
  99724. */
  99725. invertRotation: boolean;
  99726. /**
  99727. * Speed multiplier for inverse camera panning
  99728. */
  99729. inverseRotationSpeed: number;
  99730. /**
  99731. * Define the current target of the camera as an object or a position.
  99732. */
  99733. lockedTarget: any;
  99734. /** @hidden */
  99735. _currentTarget: Vector3;
  99736. /** @hidden */
  99737. _initialFocalDistance: number;
  99738. /** @hidden */
  99739. _viewMatrix: Matrix;
  99740. /** @hidden */
  99741. _camMatrix: Matrix;
  99742. /** @hidden */
  99743. _cameraTransformMatrix: Matrix;
  99744. /** @hidden */
  99745. _cameraRotationMatrix: Matrix;
  99746. /** @hidden */
  99747. _referencePoint: Vector3;
  99748. /** @hidden */
  99749. _transformedReferencePoint: Vector3;
  99750. /** @hidden */
  99751. _reset: () => void;
  99752. private _defaultUp;
  99753. /**
  99754. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  99755. * This is the base of the follow, arc rotate cameras and Free camera
  99756. * @see https://doc.babylonjs.com/features/cameras
  99757. * @param name Defines the name of the camera in the scene
  99758. * @param position Defines the start position of the camera in the scene
  99759. * @param scene Defines the scene the camera belongs to
  99760. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99761. */
  99762. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99763. /**
  99764. * Gets the position in front of the camera at a given distance.
  99765. * @param distance The distance from the camera we want the position to be
  99766. * @returns the position
  99767. */
  99768. getFrontPosition(distance: number): Vector3;
  99769. /** @hidden */
  99770. _getLockedTargetPosition(): Nullable<Vector3>;
  99771. private _storedPosition;
  99772. private _storedRotation;
  99773. private _storedRotationQuaternion;
  99774. /**
  99775. * Store current camera state of the camera (fov, position, rotation, etc..)
  99776. * @returns the camera
  99777. */
  99778. storeState(): Camera;
  99779. /**
  99780. * Restored camera state. You must call storeState() first
  99781. * @returns whether it was successful or not
  99782. * @hidden
  99783. */
  99784. _restoreStateValues(): boolean;
  99785. /** @hidden */
  99786. _initCache(): void;
  99787. /** @hidden */
  99788. _updateCache(ignoreParentClass?: boolean): void;
  99789. /** @hidden */
  99790. _isSynchronizedViewMatrix(): boolean;
  99791. /** @hidden */
  99792. _computeLocalCameraSpeed(): number;
  99793. /**
  99794. * Defines the target the camera should look at.
  99795. * @param target Defines the new target as a Vector or a mesh
  99796. */
  99797. setTarget(target: Vector3): void;
  99798. /**
  99799. * Defines the target point of the camera.
  99800. * The camera looks towards it form the radius distance.
  99801. */
  99802. get target(): Vector3;
  99803. set target(value: Vector3);
  99804. /**
  99805. * Return the current target position of the camera. This value is expressed in local space.
  99806. * @returns the target position
  99807. */
  99808. getTarget(): Vector3;
  99809. /** @hidden */
  99810. _decideIfNeedsToMove(): boolean;
  99811. /** @hidden */
  99812. _updatePosition(): void;
  99813. /** @hidden */
  99814. _checkInputs(): void;
  99815. protected _updateCameraRotationMatrix(): void;
  99816. /**
  99817. * 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)
  99818. * @returns the current camera
  99819. */
  99820. private _rotateUpVectorWithCameraRotationMatrix;
  99821. private _cachedRotationZ;
  99822. private _cachedQuaternionRotationZ;
  99823. /** @hidden */
  99824. _getViewMatrix(): Matrix;
  99825. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  99826. /**
  99827. * @hidden
  99828. */
  99829. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99830. /**
  99831. * @hidden
  99832. */
  99833. _updateRigCameras(): void;
  99834. private _getRigCamPositionAndTarget;
  99835. /**
  99836. * Gets the current object class name.
  99837. * @return the class name
  99838. */
  99839. getClassName(): string;
  99840. }
  99841. }
  99842. declare module BABYLON {
  99843. /**
  99844. * Gather the list of keyboard event types as constants.
  99845. */
  99846. export class KeyboardEventTypes {
  99847. /**
  99848. * The keydown event is fired when a key becomes active (pressed).
  99849. */
  99850. static readonly KEYDOWN: number;
  99851. /**
  99852. * The keyup event is fired when a key has been released.
  99853. */
  99854. static readonly KEYUP: number;
  99855. }
  99856. /**
  99857. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99858. */
  99859. export class KeyboardInfo {
  99860. /**
  99861. * Defines the type of event (KeyboardEventTypes)
  99862. */
  99863. type: number;
  99864. /**
  99865. * Defines the related dom event
  99866. */
  99867. event: KeyboardEvent;
  99868. /**
  99869. * Instantiates a new keyboard info.
  99870. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99871. * @param type Defines the type of event (KeyboardEventTypes)
  99872. * @param event Defines the related dom event
  99873. */
  99874. constructor(
  99875. /**
  99876. * Defines the type of event (KeyboardEventTypes)
  99877. */
  99878. type: number,
  99879. /**
  99880. * Defines the related dom event
  99881. */
  99882. event: KeyboardEvent);
  99883. }
  99884. /**
  99885. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99886. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  99887. */
  99888. export class KeyboardInfoPre extends KeyboardInfo {
  99889. /**
  99890. * Defines the type of event (KeyboardEventTypes)
  99891. */
  99892. type: number;
  99893. /**
  99894. * Defines the related dom event
  99895. */
  99896. event: KeyboardEvent;
  99897. /**
  99898. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  99899. */
  99900. skipOnPointerObservable: boolean;
  99901. /**
  99902. * Instantiates a new keyboard pre info.
  99903. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99904. * @param type Defines the type of event (KeyboardEventTypes)
  99905. * @param event Defines the related dom event
  99906. */
  99907. constructor(
  99908. /**
  99909. * Defines the type of event (KeyboardEventTypes)
  99910. */
  99911. type: number,
  99912. /**
  99913. * Defines the related dom event
  99914. */
  99915. event: KeyboardEvent);
  99916. }
  99917. }
  99918. declare module BABYLON {
  99919. /**
  99920. * Manage the keyboard inputs to control the movement of a free camera.
  99921. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99922. */
  99923. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  99924. /**
  99925. * Defines the camera the input is attached to.
  99926. */
  99927. camera: FreeCamera;
  99928. /**
  99929. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99930. */
  99931. keysUp: number[];
  99932. /**
  99933. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99934. */
  99935. keysUpward: number[];
  99936. /**
  99937. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99938. */
  99939. keysDown: number[];
  99940. /**
  99941. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99942. */
  99943. keysDownward: number[];
  99944. /**
  99945. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99946. */
  99947. keysLeft: number[];
  99948. /**
  99949. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99950. */
  99951. keysRight: number[];
  99952. private _keys;
  99953. private _onCanvasBlurObserver;
  99954. private _onKeyboardObserver;
  99955. private _engine;
  99956. private _scene;
  99957. /**
  99958. * Attach the input controls to a specific dom element to get the input from.
  99959. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99960. */
  99961. attachControl(noPreventDefault?: boolean): void;
  99962. /**
  99963. * Detach the current controls from the specified dom element.
  99964. */
  99965. detachControl(): void;
  99966. /**
  99967. * Update the current camera state depending on the inputs that have been used this frame.
  99968. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99969. */
  99970. checkInputs(): void;
  99971. /**
  99972. * Gets the class name of the current intput.
  99973. * @returns the class name
  99974. */
  99975. getClassName(): string;
  99976. /** @hidden */
  99977. _onLostFocus(): void;
  99978. /**
  99979. * Get the friendly name associated with the input class.
  99980. * @returns the input friendly name
  99981. */
  99982. getSimpleName(): string;
  99983. }
  99984. }
  99985. declare module BABYLON {
  99986. /**
  99987. * Gather the list of pointer event types as constants.
  99988. */
  99989. export class PointerEventTypes {
  99990. /**
  99991. * 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.
  99992. */
  99993. static readonly POINTERDOWN: number;
  99994. /**
  99995. * The pointerup event is fired when a pointer is no longer active.
  99996. */
  99997. static readonly POINTERUP: number;
  99998. /**
  99999. * The pointermove event is fired when a pointer changes coordinates.
  100000. */
  100001. static readonly POINTERMOVE: number;
  100002. /**
  100003. * The pointerwheel event is fired when a mouse wheel has been rotated.
  100004. */
  100005. static readonly POINTERWHEEL: number;
  100006. /**
  100007. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  100008. */
  100009. static readonly POINTERPICK: number;
  100010. /**
  100011. * The pointertap event is fired when a the object has been touched and released without drag.
  100012. */
  100013. static readonly POINTERTAP: number;
  100014. /**
  100015. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  100016. */
  100017. static readonly POINTERDOUBLETAP: number;
  100018. }
  100019. /**
  100020. * Base class of pointer info types.
  100021. */
  100022. export class PointerInfoBase {
  100023. /**
  100024. * Defines the type of event (PointerEventTypes)
  100025. */
  100026. type: number;
  100027. /**
  100028. * Defines the related dom event
  100029. */
  100030. event: PointerEvent | MouseWheelEvent;
  100031. /**
  100032. * Instantiates the base class of pointers info.
  100033. * @param type Defines the type of event (PointerEventTypes)
  100034. * @param event Defines the related dom event
  100035. */
  100036. constructor(
  100037. /**
  100038. * Defines the type of event (PointerEventTypes)
  100039. */
  100040. type: number,
  100041. /**
  100042. * Defines the related dom event
  100043. */
  100044. event: PointerEvent | MouseWheelEvent);
  100045. }
  100046. /**
  100047. * This class is used to store pointer related info for the onPrePointerObservable event.
  100048. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  100049. */
  100050. export class PointerInfoPre extends PointerInfoBase {
  100051. /**
  100052. * Ray from a pointer if availible (eg. 6dof controller)
  100053. */
  100054. ray: Nullable<Ray>;
  100055. /**
  100056. * Defines the local position of the pointer on the canvas.
  100057. */
  100058. localPosition: Vector2;
  100059. /**
  100060. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  100061. */
  100062. skipOnPointerObservable: boolean;
  100063. /**
  100064. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  100065. * @param type Defines the type of event (PointerEventTypes)
  100066. * @param event Defines the related dom event
  100067. * @param localX Defines the local x coordinates of the pointer when the event occured
  100068. * @param localY Defines the local y coordinates of the pointer when the event occured
  100069. */
  100070. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  100071. }
  100072. /**
  100073. * This type contains all the data related to a pointer event in Babylon.js.
  100074. * 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.
  100075. */
  100076. export class PointerInfo extends PointerInfoBase {
  100077. /**
  100078. * Defines the picking info associated to the info (if any)\
  100079. */
  100080. pickInfo: Nullable<PickingInfo>;
  100081. /**
  100082. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  100083. * @param type Defines the type of event (PointerEventTypes)
  100084. * @param event Defines the related dom event
  100085. * @param pickInfo Defines the picking info associated to the info (if any)\
  100086. */
  100087. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  100088. /**
  100089. * Defines the picking info associated to the info (if any)\
  100090. */
  100091. pickInfo: Nullable<PickingInfo>);
  100092. }
  100093. /**
  100094. * Data relating to a touch event on the screen.
  100095. */
  100096. export interface PointerTouch {
  100097. /**
  100098. * X coordinate of touch.
  100099. */
  100100. x: number;
  100101. /**
  100102. * Y coordinate of touch.
  100103. */
  100104. y: number;
  100105. /**
  100106. * Id of touch. Unique for each finger.
  100107. */
  100108. pointerId: number;
  100109. /**
  100110. * Event type passed from DOM.
  100111. */
  100112. type: any;
  100113. }
  100114. }
  100115. declare module BABYLON {
  100116. /**
  100117. * Manage the mouse inputs to control the movement of a free camera.
  100118. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100119. */
  100120. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  100121. /**
  100122. * Define if touch is enabled in the mouse input
  100123. */
  100124. touchEnabled: boolean;
  100125. /**
  100126. * Defines the camera the input is attached to.
  100127. */
  100128. camera: FreeCamera;
  100129. /**
  100130. * Defines the buttons associated with the input to handle camera move.
  100131. */
  100132. buttons: number[];
  100133. /**
  100134. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  100135. */
  100136. angularSensibility: number;
  100137. private _pointerInput;
  100138. private _onMouseMove;
  100139. private _observer;
  100140. private previousPosition;
  100141. /**
  100142. * Observable for when a pointer move event occurs containing the move offset
  100143. */
  100144. onPointerMovedObservable: Observable<{
  100145. offsetX: number;
  100146. offsetY: number;
  100147. }>;
  100148. /**
  100149. * @hidden
  100150. * If the camera should be rotated automatically based on pointer movement
  100151. */
  100152. _allowCameraRotation: boolean;
  100153. /**
  100154. * Manage the mouse inputs to control the movement of a free camera.
  100155. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100156. * @param touchEnabled Defines if touch is enabled or not
  100157. */
  100158. constructor(
  100159. /**
  100160. * Define if touch is enabled in the mouse input
  100161. */
  100162. touchEnabled?: boolean);
  100163. /**
  100164. * Attach the input controls to a specific dom element to get the input from.
  100165. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100166. */
  100167. attachControl(noPreventDefault?: boolean): void;
  100168. /**
  100169. * Called on JS contextmenu event.
  100170. * Override this method to provide functionality.
  100171. */
  100172. protected onContextMenu(evt: PointerEvent): void;
  100173. /**
  100174. * Detach the current controls from the specified dom element.
  100175. */
  100176. detachControl(): void;
  100177. /**
  100178. * Gets the class name of the current intput.
  100179. * @returns the class name
  100180. */
  100181. getClassName(): string;
  100182. /**
  100183. * Get the friendly name associated with the input class.
  100184. * @returns the input friendly name
  100185. */
  100186. getSimpleName(): string;
  100187. }
  100188. }
  100189. declare module BABYLON {
  100190. /**
  100191. * Base class for mouse wheel input..
  100192. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  100193. * for example usage.
  100194. */
  100195. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  100196. /**
  100197. * Defines the camera the input is attached to.
  100198. */
  100199. abstract camera: Camera;
  100200. /**
  100201. * How fast is the camera moves in relation to X axis mouseWheel events.
  100202. * Use negative value to reverse direction.
  100203. */
  100204. wheelPrecisionX: number;
  100205. /**
  100206. * How fast is the camera moves in relation to Y axis mouseWheel events.
  100207. * Use negative value to reverse direction.
  100208. */
  100209. wheelPrecisionY: number;
  100210. /**
  100211. * How fast is the camera moves in relation to Z axis mouseWheel events.
  100212. * Use negative value to reverse direction.
  100213. */
  100214. wheelPrecisionZ: number;
  100215. /**
  100216. * Observable for when a mouse wheel move event occurs.
  100217. */
  100218. onChangedObservable: Observable<{
  100219. wheelDeltaX: number;
  100220. wheelDeltaY: number;
  100221. wheelDeltaZ: number;
  100222. }>;
  100223. private _wheel;
  100224. private _observer;
  100225. /**
  100226. * Attach the input controls to a specific dom element to get the input from.
  100227. * @param noPreventDefault Defines whether event caught by the controls
  100228. * should call preventdefault().
  100229. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100230. */
  100231. attachControl(noPreventDefault?: boolean): void;
  100232. /**
  100233. * Detach the current controls from the specified dom element.
  100234. */
  100235. detachControl(): void;
  100236. /**
  100237. * Called for each rendered frame.
  100238. */
  100239. checkInputs(): void;
  100240. /**
  100241. * Gets the class name of the current intput.
  100242. * @returns the class name
  100243. */
  100244. getClassName(): string;
  100245. /**
  100246. * Get the friendly name associated with the input class.
  100247. * @returns the input friendly name
  100248. */
  100249. getSimpleName(): string;
  100250. /**
  100251. * Incremental value of multiple mouse wheel movements of the X axis.
  100252. * Should be zero-ed when read.
  100253. */
  100254. protected _wheelDeltaX: number;
  100255. /**
  100256. * Incremental value of multiple mouse wheel movements of the Y axis.
  100257. * Should be zero-ed when read.
  100258. */
  100259. protected _wheelDeltaY: number;
  100260. /**
  100261. * Incremental value of multiple mouse wheel movements of the Z axis.
  100262. * Should be zero-ed when read.
  100263. */
  100264. protected _wheelDeltaZ: number;
  100265. /**
  100266. * Firefox uses a different scheme to report scroll distances to other
  100267. * browsers. Rather than use complicated methods to calculate the exact
  100268. * multiple we need to apply, let's just cheat and use a constant.
  100269. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  100270. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  100271. */
  100272. private readonly _ffMultiplier;
  100273. /**
  100274. * Different event attributes for wheel data fall into a few set ranges.
  100275. * Some relevant but dated date here:
  100276. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  100277. */
  100278. private readonly _normalize;
  100279. }
  100280. }
  100281. declare module BABYLON {
  100282. /**
  100283. * Manage the mouse wheel inputs to control a free camera.
  100284. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100285. */
  100286. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  100287. /**
  100288. * Defines the camera the input is attached to.
  100289. */
  100290. camera: FreeCamera;
  100291. /**
  100292. * Gets the class name of the current input.
  100293. * @returns the class name
  100294. */
  100295. getClassName(): string;
  100296. /**
  100297. * Set which movement axis (relative to camera's orientation) the mouse
  100298. * wheel's X axis controls.
  100299. * @param axis The axis to be moved. Set null to clear.
  100300. */
  100301. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  100302. /**
  100303. * Get the configured movement axis (relative to camera's orientation) the
  100304. * mouse wheel's X axis controls.
  100305. * @returns The configured axis or null if none.
  100306. */
  100307. get wheelXMoveRelative(): Nullable<Coordinate>;
  100308. /**
  100309. * Set which movement axis (relative to camera's orientation) the mouse
  100310. * wheel's Y axis controls.
  100311. * @param axis The axis to be moved. Set null to clear.
  100312. */
  100313. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  100314. /**
  100315. * Get the configured movement axis (relative to camera's orientation) the
  100316. * mouse wheel's Y axis controls.
  100317. * @returns The configured axis or null if none.
  100318. */
  100319. get wheelYMoveRelative(): Nullable<Coordinate>;
  100320. /**
  100321. * Set which movement axis (relative to camera's orientation) the mouse
  100322. * wheel's Z axis controls.
  100323. * @param axis The axis to be moved. Set null to clear.
  100324. */
  100325. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  100326. /**
  100327. * Get the configured movement axis (relative to camera's orientation) the
  100328. * mouse wheel's Z axis controls.
  100329. * @returns The configured axis or null if none.
  100330. */
  100331. get wheelZMoveRelative(): Nullable<Coordinate>;
  100332. /**
  100333. * Set which rotation axis (relative to camera's orientation) the mouse
  100334. * wheel's X axis controls.
  100335. * @param axis The axis to be moved. Set null to clear.
  100336. */
  100337. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  100338. /**
  100339. * Get the configured rotation axis (relative to camera's orientation) the
  100340. * mouse wheel's X axis controls.
  100341. * @returns The configured axis or null if none.
  100342. */
  100343. get wheelXRotateRelative(): Nullable<Coordinate>;
  100344. /**
  100345. * Set which rotation axis (relative to camera's orientation) the mouse
  100346. * wheel's Y axis controls.
  100347. * @param axis The axis to be moved. Set null to clear.
  100348. */
  100349. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  100350. /**
  100351. * Get the configured rotation axis (relative to camera's orientation) the
  100352. * mouse wheel's Y axis controls.
  100353. * @returns The configured axis or null if none.
  100354. */
  100355. get wheelYRotateRelative(): Nullable<Coordinate>;
  100356. /**
  100357. * Set which rotation axis (relative to camera's orientation) the mouse
  100358. * wheel's Z axis controls.
  100359. * @param axis The axis to be moved. Set null to clear.
  100360. */
  100361. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  100362. /**
  100363. * Get the configured rotation axis (relative to camera's orientation) the
  100364. * mouse wheel's Z axis controls.
  100365. * @returns The configured axis or null if none.
  100366. */
  100367. get wheelZRotateRelative(): Nullable<Coordinate>;
  100368. /**
  100369. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  100370. * controls.
  100371. * @param axis The axis to be moved. Set null to clear.
  100372. */
  100373. set wheelXMoveScene(axis: Nullable<Coordinate>);
  100374. /**
  100375. * Get the configured movement axis (relative to the scene) the mouse wheel's
  100376. * X axis controls.
  100377. * @returns The configured axis or null if none.
  100378. */
  100379. get wheelXMoveScene(): Nullable<Coordinate>;
  100380. /**
  100381. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  100382. * controls.
  100383. * @param axis The axis to be moved. Set null to clear.
  100384. */
  100385. set wheelYMoveScene(axis: Nullable<Coordinate>);
  100386. /**
  100387. * Get the configured movement axis (relative to the scene) the mouse wheel's
  100388. * Y axis controls.
  100389. * @returns The configured axis or null if none.
  100390. */
  100391. get wheelYMoveScene(): Nullable<Coordinate>;
  100392. /**
  100393. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  100394. * controls.
  100395. * @param axis The axis to be moved. Set null to clear.
  100396. */
  100397. set wheelZMoveScene(axis: Nullable<Coordinate>);
  100398. /**
  100399. * Get the configured movement axis (relative to the scene) the mouse wheel's
  100400. * Z axis controls.
  100401. * @returns The configured axis or null if none.
  100402. */
  100403. get wheelZMoveScene(): Nullable<Coordinate>;
  100404. /**
  100405. * Called for each rendered frame.
  100406. */
  100407. checkInputs(): void;
  100408. private _moveRelative;
  100409. private _rotateRelative;
  100410. private _moveScene;
  100411. /**
  100412. * These are set to the desired default behaviour.
  100413. */
  100414. private _wheelXAction;
  100415. private _wheelXActionCoordinate;
  100416. private _wheelYAction;
  100417. private _wheelYActionCoordinate;
  100418. private _wheelZAction;
  100419. private _wheelZActionCoordinate;
  100420. /**
  100421. * Update the camera according to any configured properties for the 3
  100422. * mouse-wheel axis.
  100423. */
  100424. private _updateCamera;
  100425. }
  100426. }
  100427. declare module BABYLON {
  100428. /**
  100429. * Manage the touch inputs to control the movement of a free camera.
  100430. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100431. */
  100432. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  100433. /**
  100434. * Define if mouse events can be treated as touch events
  100435. */
  100436. allowMouse: boolean;
  100437. /**
  100438. * Defines the camera the input is attached to.
  100439. */
  100440. camera: FreeCamera;
  100441. /**
  100442. * Defines the touch sensibility for rotation.
  100443. * The higher the faster.
  100444. */
  100445. touchAngularSensibility: number;
  100446. /**
  100447. * Defines the touch sensibility for move.
  100448. * The higher the faster.
  100449. */
  100450. touchMoveSensibility: number;
  100451. private _offsetX;
  100452. private _offsetY;
  100453. private _pointerPressed;
  100454. private _pointerInput?;
  100455. private _observer;
  100456. private _onLostFocus;
  100457. /**
  100458. * Manage the touch inputs to control the movement of a free camera.
  100459. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100460. * @param allowMouse Defines if mouse events can be treated as touch events
  100461. */
  100462. constructor(
  100463. /**
  100464. * Define if mouse events can be treated as touch events
  100465. */
  100466. allowMouse?: boolean);
  100467. /**
  100468. * Attach the input controls to a specific dom element to get the input from.
  100469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100470. */
  100471. attachControl(noPreventDefault?: boolean): void;
  100472. /**
  100473. * Detach the current controls from the specified dom element.
  100474. * @param element Defines the element to stop listening the inputs from
  100475. */
  100476. detachControl(): void;
  100477. /**
  100478. * Update the current camera state depending on the inputs that have been used this frame.
  100479. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100480. */
  100481. checkInputs(): void;
  100482. /**
  100483. * Gets the class name of the current intput.
  100484. * @returns the class name
  100485. */
  100486. getClassName(): string;
  100487. /**
  100488. * Get the friendly name associated with the input class.
  100489. * @returns the input friendly name
  100490. */
  100491. getSimpleName(): string;
  100492. }
  100493. }
  100494. declare module BABYLON {
  100495. /**
  100496. * Default Inputs manager for the FreeCamera.
  100497. * It groups all the default supported inputs for ease of use.
  100498. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100499. */
  100500. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  100501. /**
  100502. * @hidden
  100503. */
  100504. _mouseInput: Nullable<FreeCameraMouseInput>;
  100505. /**
  100506. * @hidden
  100507. */
  100508. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  100509. /**
  100510. * Instantiates a new FreeCameraInputsManager.
  100511. * @param camera Defines the camera the inputs belong to
  100512. */
  100513. constructor(camera: FreeCamera);
  100514. /**
  100515. * Add keyboard input support to the input manager.
  100516. * @returns the current input manager
  100517. */
  100518. addKeyboard(): FreeCameraInputsManager;
  100519. /**
  100520. * Add mouse input support to the input manager.
  100521. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  100522. * @returns the current input manager
  100523. */
  100524. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  100525. /**
  100526. * Removes the mouse input support from the manager
  100527. * @returns the current input manager
  100528. */
  100529. removeMouse(): FreeCameraInputsManager;
  100530. /**
  100531. * Add mouse wheel input support to the input manager.
  100532. * @returns the current input manager
  100533. */
  100534. addMouseWheel(): FreeCameraInputsManager;
  100535. /**
  100536. * Removes the mouse wheel input support from the manager
  100537. * @returns the current input manager
  100538. */
  100539. removeMouseWheel(): FreeCameraInputsManager;
  100540. /**
  100541. * Add touch input support to the input manager.
  100542. * @returns the current input manager
  100543. */
  100544. addTouch(): FreeCameraInputsManager;
  100545. /**
  100546. * Remove all attached input methods from a camera
  100547. */
  100548. clear(): void;
  100549. }
  100550. }
  100551. declare module BABYLON {
  100552. /**
  100553. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100554. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  100555. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  100556. */
  100557. export class FreeCamera extends TargetCamera {
  100558. /**
  100559. * Define the collision ellipsoid of the camera.
  100560. * This is helpful to simulate a camera body like the player body around the camera
  100561. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100562. */
  100563. ellipsoid: Vector3;
  100564. /**
  100565. * Define an offset for the position of the ellipsoid around the camera.
  100566. * This can be helpful to determine the center of the body near the gravity center of the body
  100567. * instead of its head.
  100568. */
  100569. ellipsoidOffset: Vector3;
  100570. /**
  100571. * Enable or disable collisions of the camera with the rest of the scene objects.
  100572. */
  100573. checkCollisions: boolean;
  100574. /**
  100575. * Enable or disable gravity on the camera.
  100576. */
  100577. applyGravity: boolean;
  100578. /**
  100579. * Define the input manager associated to the camera.
  100580. */
  100581. inputs: FreeCameraInputsManager;
  100582. /**
  100583. * Gets the input sensibility for a mouse input. (default is 2000.0)
  100584. * Higher values reduce sensitivity.
  100585. */
  100586. get angularSensibility(): number;
  100587. /**
  100588. * Sets the input sensibility for a mouse input. (default is 2000.0)
  100589. * Higher values reduce sensitivity.
  100590. */
  100591. set angularSensibility(value: number);
  100592. /**
  100593. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  100594. */
  100595. get keysUp(): number[];
  100596. set keysUp(value: number[]);
  100597. /**
  100598. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  100599. */
  100600. get keysUpward(): number[];
  100601. set keysUpward(value: number[]);
  100602. /**
  100603. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  100604. */
  100605. get keysDown(): number[];
  100606. set keysDown(value: number[]);
  100607. /**
  100608. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  100609. */
  100610. get keysDownward(): number[];
  100611. set keysDownward(value: number[]);
  100612. /**
  100613. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  100614. */
  100615. get keysLeft(): number[];
  100616. set keysLeft(value: number[]);
  100617. /**
  100618. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  100619. */
  100620. get keysRight(): number[];
  100621. set keysRight(value: number[]);
  100622. /**
  100623. * Event raised when the camera collide with a mesh in the scene.
  100624. */
  100625. onCollide: (collidedMesh: AbstractMesh) => void;
  100626. private _collider;
  100627. private _needMoveForGravity;
  100628. private _oldPosition;
  100629. private _diffPosition;
  100630. private _newPosition;
  100631. /** @hidden */
  100632. _localDirection: Vector3;
  100633. /** @hidden */
  100634. _transformedDirection: Vector3;
  100635. /**
  100636. * Instantiates a Free Camera.
  100637. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100638. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  100639. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  100640. * @param name Define the name of the camera in the scene
  100641. * @param position Define the start position of the camera in the scene
  100642. * @param scene Define the scene the camera belongs to
  100643. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  100644. */
  100645. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100646. /**
  100647. * Attached controls to the current camera.
  100648. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100649. */
  100650. attachControl(noPreventDefault?: boolean): void;
  100651. /**
  100652. * Detach the current controls from the camera.
  100653. * The camera will stop reacting to inputs.
  100654. */
  100655. detachControl(): void;
  100656. private _collisionMask;
  100657. /**
  100658. * Define a collision mask to limit the list of object the camera can collide with
  100659. */
  100660. get collisionMask(): number;
  100661. set collisionMask(mask: number);
  100662. /** @hidden */
  100663. _collideWithWorld(displacement: Vector3): void;
  100664. private _onCollisionPositionChange;
  100665. /** @hidden */
  100666. _checkInputs(): void;
  100667. /** @hidden */
  100668. _decideIfNeedsToMove(): boolean;
  100669. /** @hidden */
  100670. _updatePosition(): void;
  100671. /**
  100672. * Destroy the camera and release the current resources hold by it.
  100673. */
  100674. dispose(): void;
  100675. /**
  100676. * Gets the current object class name.
  100677. * @return the class name
  100678. */
  100679. getClassName(): string;
  100680. }
  100681. }
  100682. declare module BABYLON {
  100683. /**
  100684. * Represents a gamepad control stick position
  100685. */
  100686. export class StickValues {
  100687. /**
  100688. * The x component of the control stick
  100689. */
  100690. x: number;
  100691. /**
  100692. * The y component of the control stick
  100693. */
  100694. y: number;
  100695. /**
  100696. * Initializes the gamepad x and y control stick values
  100697. * @param x The x component of the gamepad control stick value
  100698. * @param y The y component of the gamepad control stick value
  100699. */
  100700. constructor(
  100701. /**
  100702. * The x component of the control stick
  100703. */
  100704. x: number,
  100705. /**
  100706. * The y component of the control stick
  100707. */
  100708. y: number);
  100709. }
  100710. /**
  100711. * An interface which manages callbacks for gamepad button changes
  100712. */
  100713. export interface GamepadButtonChanges {
  100714. /**
  100715. * Called when a gamepad has been changed
  100716. */
  100717. changed: boolean;
  100718. /**
  100719. * Called when a gamepad press event has been triggered
  100720. */
  100721. pressChanged: boolean;
  100722. /**
  100723. * Called when a touch event has been triggered
  100724. */
  100725. touchChanged: boolean;
  100726. /**
  100727. * Called when a value has changed
  100728. */
  100729. valueChanged: boolean;
  100730. }
  100731. /**
  100732. * Represents a gamepad
  100733. */
  100734. export class Gamepad {
  100735. /**
  100736. * The id of the gamepad
  100737. */
  100738. id: string;
  100739. /**
  100740. * The index of the gamepad
  100741. */
  100742. index: number;
  100743. /**
  100744. * The browser gamepad
  100745. */
  100746. browserGamepad: any;
  100747. /**
  100748. * Specifies what type of gamepad this represents
  100749. */
  100750. type: number;
  100751. private _leftStick;
  100752. private _rightStick;
  100753. /** @hidden */
  100754. _isConnected: boolean;
  100755. private _leftStickAxisX;
  100756. private _leftStickAxisY;
  100757. private _rightStickAxisX;
  100758. private _rightStickAxisY;
  100759. /**
  100760. * Triggered when the left control stick has been changed
  100761. */
  100762. private _onleftstickchanged;
  100763. /**
  100764. * Triggered when the right control stick has been changed
  100765. */
  100766. private _onrightstickchanged;
  100767. /**
  100768. * Represents a gamepad controller
  100769. */
  100770. static GAMEPAD: number;
  100771. /**
  100772. * Represents a generic controller
  100773. */
  100774. static GENERIC: number;
  100775. /**
  100776. * Represents an XBox controller
  100777. */
  100778. static XBOX: number;
  100779. /**
  100780. * Represents a pose-enabled controller
  100781. */
  100782. static POSE_ENABLED: number;
  100783. /**
  100784. * Represents an Dual Shock controller
  100785. */
  100786. static DUALSHOCK: number;
  100787. /**
  100788. * Specifies whether the left control stick should be Y-inverted
  100789. */
  100790. protected _invertLeftStickY: boolean;
  100791. /**
  100792. * Specifies if the gamepad has been connected
  100793. */
  100794. get isConnected(): boolean;
  100795. /**
  100796. * Initializes the gamepad
  100797. * @param id The id of the gamepad
  100798. * @param index The index of the gamepad
  100799. * @param browserGamepad The browser gamepad
  100800. * @param leftStickX The x component of the left joystick
  100801. * @param leftStickY The y component of the left joystick
  100802. * @param rightStickX The x component of the right joystick
  100803. * @param rightStickY The y component of the right joystick
  100804. */
  100805. constructor(
  100806. /**
  100807. * The id of the gamepad
  100808. */
  100809. id: string,
  100810. /**
  100811. * The index of the gamepad
  100812. */
  100813. index: number,
  100814. /**
  100815. * The browser gamepad
  100816. */
  100817. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  100818. /**
  100819. * Callback triggered when the left joystick has changed
  100820. * @param callback
  100821. */
  100822. onleftstickchanged(callback: (values: StickValues) => void): void;
  100823. /**
  100824. * Callback triggered when the right joystick has changed
  100825. * @param callback
  100826. */
  100827. onrightstickchanged(callback: (values: StickValues) => void): void;
  100828. /**
  100829. * Gets the left joystick
  100830. */
  100831. get leftStick(): StickValues;
  100832. /**
  100833. * Sets the left joystick values
  100834. */
  100835. set leftStick(newValues: StickValues);
  100836. /**
  100837. * Gets the right joystick
  100838. */
  100839. get rightStick(): StickValues;
  100840. /**
  100841. * Sets the right joystick value
  100842. */
  100843. set rightStick(newValues: StickValues);
  100844. /**
  100845. * Updates the gamepad joystick positions
  100846. */
  100847. update(): void;
  100848. /**
  100849. * Disposes the gamepad
  100850. */
  100851. dispose(): void;
  100852. }
  100853. /**
  100854. * Represents a generic gamepad
  100855. */
  100856. export class GenericPad extends Gamepad {
  100857. private _buttons;
  100858. private _onbuttondown;
  100859. private _onbuttonup;
  100860. /**
  100861. * Observable triggered when a button has been pressed
  100862. */
  100863. onButtonDownObservable: Observable<number>;
  100864. /**
  100865. * Observable triggered when a button has been released
  100866. */
  100867. onButtonUpObservable: Observable<number>;
  100868. /**
  100869. * Callback triggered when a button has been pressed
  100870. * @param callback Called when a button has been pressed
  100871. */
  100872. onbuttondown(callback: (buttonPressed: number) => void): void;
  100873. /**
  100874. * Callback triggered when a button has been released
  100875. * @param callback Called when a button has been released
  100876. */
  100877. onbuttonup(callback: (buttonReleased: number) => void): void;
  100878. /**
  100879. * Initializes the generic gamepad
  100880. * @param id The id of the generic gamepad
  100881. * @param index The index of the generic gamepad
  100882. * @param browserGamepad The browser gamepad
  100883. */
  100884. constructor(id: string, index: number, browserGamepad: any);
  100885. private _setButtonValue;
  100886. /**
  100887. * Updates the generic gamepad
  100888. */
  100889. update(): void;
  100890. /**
  100891. * Disposes the generic gamepad
  100892. */
  100893. dispose(): void;
  100894. }
  100895. }
  100896. declare module BABYLON {
  100897. /**
  100898. * Defines the types of pose enabled controllers that are supported
  100899. */
  100900. export enum PoseEnabledControllerType {
  100901. /**
  100902. * HTC Vive
  100903. */
  100904. VIVE = 0,
  100905. /**
  100906. * Oculus Rift
  100907. */
  100908. OCULUS = 1,
  100909. /**
  100910. * Windows mixed reality
  100911. */
  100912. WINDOWS = 2,
  100913. /**
  100914. * Samsung gear VR
  100915. */
  100916. GEAR_VR = 3,
  100917. /**
  100918. * Google Daydream
  100919. */
  100920. DAYDREAM = 4,
  100921. /**
  100922. * Generic
  100923. */
  100924. GENERIC = 5
  100925. }
  100926. /**
  100927. * Defines the MutableGamepadButton interface for the state of a gamepad button
  100928. */
  100929. export interface MutableGamepadButton {
  100930. /**
  100931. * Value of the button/trigger
  100932. */
  100933. value: number;
  100934. /**
  100935. * If the button/trigger is currently touched
  100936. */
  100937. touched: boolean;
  100938. /**
  100939. * If the button/trigger is currently pressed
  100940. */
  100941. pressed: boolean;
  100942. }
  100943. /**
  100944. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  100945. * @hidden
  100946. */
  100947. export interface ExtendedGamepadButton extends GamepadButton {
  100948. /**
  100949. * If the button/trigger is currently pressed
  100950. */
  100951. readonly pressed: boolean;
  100952. /**
  100953. * If the button/trigger is currently touched
  100954. */
  100955. readonly touched: boolean;
  100956. /**
  100957. * Value of the button/trigger
  100958. */
  100959. readonly value: number;
  100960. }
  100961. /** @hidden */
  100962. export interface _GamePadFactory {
  100963. /**
  100964. * Returns whether or not the current gamepad can be created for this type of controller.
  100965. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100966. * @returns true if it can be created, otherwise false
  100967. */
  100968. canCreate(gamepadInfo: any): boolean;
  100969. /**
  100970. * Creates a new instance of the Gamepad.
  100971. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100972. * @returns the new gamepad instance
  100973. */
  100974. create(gamepadInfo: any): Gamepad;
  100975. }
  100976. /**
  100977. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100978. */
  100979. export class PoseEnabledControllerHelper {
  100980. /** @hidden */
  100981. static _ControllerFactories: _GamePadFactory[];
  100982. /** @hidden */
  100983. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  100984. /**
  100985. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100986. * @param vrGamepad the gamepad to initialized
  100987. * @returns a vr controller of the type the gamepad identified as
  100988. */
  100989. static InitiateController(vrGamepad: any): Gamepad;
  100990. }
  100991. /**
  100992. * Defines the PoseEnabledController object that contains state of a vr capable controller
  100993. */
  100994. export class PoseEnabledController extends Gamepad implements PoseControlled {
  100995. /**
  100996. * If the controller is used in a webXR session
  100997. */
  100998. isXR: boolean;
  100999. private _deviceRoomPosition;
  101000. private _deviceRoomRotationQuaternion;
  101001. /**
  101002. * The device position in babylon space
  101003. */
  101004. devicePosition: Vector3;
  101005. /**
  101006. * The device rotation in babylon space
  101007. */
  101008. deviceRotationQuaternion: Quaternion;
  101009. /**
  101010. * The scale factor of the device in babylon space
  101011. */
  101012. deviceScaleFactor: number;
  101013. /**
  101014. * (Likely devicePosition should be used instead) The device position in its room space
  101015. */
  101016. position: Vector3;
  101017. /**
  101018. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  101019. */
  101020. rotationQuaternion: Quaternion;
  101021. /**
  101022. * The type of controller (Eg. Windows mixed reality)
  101023. */
  101024. controllerType: PoseEnabledControllerType;
  101025. protected _calculatedPosition: Vector3;
  101026. private _calculatedRotation;
  101027. /**
  101028. * The raw pose from the device
  101029. */
  101030. rawPose: DevicePose;
  101031. private _trackPosition;
  101032. private _maxRotationDistFromHeadset;
  101033. private _draggedRoomRotation;
  101034. /**
  101035. * @hidden
  101036. */
  101037. _disableTrackPosition(fixedPosition: Vector3): void;
  101038. /**
  101039. * Internal, the mesh attached to the controller
  101040. * @hidden
  101041. */
  101042. _mesh: Nullable<AbstractMesh>;
  101043. private _poseControlledCamera;
  101044. private _leftHandSystemQuaternion;
  101045. /**
  101046. * Internal, matrix used to convert room space to babylon space
  101047. * @hidden
  101048. */
  101049. _deviceToWorld: Matrix;
  101050. /**
  101051. * Node to be used when casting a ray from the controller
  101052. * @hidden
  101053. */
  101054. _pointingPoseNode: Nullable<TransformNode>;
  101055. /**
  101056. * Name of the child mesh that can be used to cast a ray from the controller
  101057. */
  101058. static readonly POINTING_POSE: string;
  101059. /**
  101060. * Creates a new PoseEnabledController from a gamepad
  101061. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  101062. */
  101063. constructor(browserGamepad: any);
  101064. private _workingMatrix;
  101065. /**
  101066. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  101067. */
  101068. update(): void;
  101069. /**
  101070. * Updates only the pose device and mesh without doing any button event checking
  101071. */
  101072. protected _updatePoseAndMesh(): void;
  101073. /**
  101074. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  101075. * @param poseData raw pose fromthe device
  101076. */
  101077. updateFromDevice(poseData: DevicePose): void;
  101078. /**
  101079. * @hidden
  101080. */
  101081. _meshAttachedObservable: Observable<AbstractMesh>;
  101082. /**
  101083. * Attaches a mesh to the controller
  101084. * @param mesh the mesh to be attached
  101085. */
  101086. attachToMesh(mesh: AbstractMesh): void;
  101087. /**
  101088. * Attaches the controllers mesh to a camera
  101089. * @param camera the camera the mesh should be attached to
  101090. */
  101091. attachToPoseControlledCamera(camera: TargetCamera): void;
  101092. /**
  101093. * Disposes of the controller
  101094. */
  101095. dispose(): void;
  101096. /**
  101097. * The mesh that is attached to the controller
  101098. */
  101099. get mesh(): Nullable<AbstractMesh>;
  101100. /**
  101101. * Gets the ray of the controller in the direction the controller is pointing
  101102. * @param length the length the resulting ray should be
  101103. * @returns a ray in the direction the controller is pointing
  101104. */
  101105. getForwardRay(length?: number): Ray;
  101106. }
  101107. }
  101108. declare module BABYLON {
  101109. /**
  101110. * Defines the WebVRController object that represents controllers tracked in 3D space
  101111. */
  101112. export abstract class WebVRController extends PoseEnabledController {
  101113. /**
  101114. * Internal, the default controller model for the controller
  101115. */
  101116. protected _defaultModel: Nullable<AbstractMesh>;
  101117. /**
  101118. * Fired when the trigger state has changed
  101119. */
  101120. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  101121. /**
  101122. * Fired when the main button state has changed
  101123. */
  101124. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101125. /**
  101126. * Fired when the secondary button state has changed
  101127. */
  101128. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101129. /**
  101130. * Fired when the pad state has changed
  101131. */
  101132. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  101133. /**
  101134. * Fired when controllers stick values have changed
  101135. */
  101136. onPadValuesChangedObservable: Observable<StickValues>;
  101137. /**
  101138. * Array of button availible on the controller
  101139. */
  101140. protected _buttons: Array<MutableGamepadButton>;
  101141. private _onButtonStateChange;
  101142. /**
  101143. * Fired when a controller button's state has changed
  101144. * @param callback the callback containing the button that was modified
  101145. */
  101146. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  101147. /**
  101148. * X and Y axis corresponding to the controllers joystick
  101149. */
  101150. pad: StickValues;
  101151. /**
  101152. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  101153. */
  101154. hand: string;
  101155. /**
  101156. * The default controller model for the controller
  101157. */
  101158. get defaultModel(): Nullable<AbstractMesh>;
  101159. /**
  101160. * Creates a new WebVRController from a gamepad
  101161. * @param vrGamepad the gamepad that the WebVRController should be created from
  101162. */
  101163. constructor(vrGamepad: any);
  101164. /**
  101165. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  101166. */
  101167. update(): void;
  101168. /**
  101169. * Function to be called when a button is modified
  101170. */
  101171. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101172. /**
  101173. * Loads a mesh and attaches it to the controller
  101174. * @param scene the scene the mesh should be added to
  101175. * @param meshLoaded callback for when the mesh has been loaded
  101176. */
  101177. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101178. private _setButtonValue;
  101179. private _changes;
  101180. private _checkChanges;
  101181. /**
  101182. * Disposes of th webVRCOntroller
  101183. */
  101184. dispose(): void;
  101185. }
  101186. }
  101187. declare module BABYLON {
  101188. /**
  101189. * The HemisphericLight simulates the ambient environment light,
  101190. * so the passed direction is the light reflection direction, not the incoming direction.
  101191. */
  101192. export class HemisphericLight extends Light {
  101193. /**
  101194. * The groundColor is the light in the opposite direction to the one specified during creation.
  101195. * 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.
  101196. */
  101197. groundColor: Color3;
  101198. /**
  101199. * The light reflection direction, not the incoming direction.
  101200. */
  101201. direction: Vector3;
  101202. /**
  101203. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  101204. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  101205. * The HemisphericLight can't cast shadows.
  101206. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101207. * @param name The friendly name of the light
  101208. * @param direction The direction of the light reflection
  101209. * @param scene The scene the light belongs to
  101210. */
  101211. constructor(name: string, direction: Vector3, scene: Scene);
  101212. protected _buildUniformLayout(): void;
  101213. /**
  101214. * Returns the string "HemisphericLight".
  101215. * @return The class name
  101216. */
  101217. getClassName(): string;
  101218. /**
  101219. * Sets the HemisphericLight direction towards the passed target (Vector3).
  101220. * Returns the updated direction.
  101221. * @param target The target the direction should point to
  101222. * @return The computed direction
  101223. */
  101224. setDirectionToTarget(target: Vector3): Vector3;
  101225. /**
  101226. * Returns the shadow generator associated to the light.
  101227. * @returns Always null for hemispheric lights because it does not support shadows.
  101228. */
  101229. getShadowGenerator(): Nullable<IShadowGenerator>;
  101230. /**
  101231. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  101232. * @param effect The effect to update
  101233. * @param lightIndex The index of the light in the effect to update
  101234. * @returns The hemispheric light
  101235. */
  101236. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  101237. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  101238. /**
  101239. * Computes the world matrix of the node
  101240. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  101241. * @param useWasUpdatedFlag defines a reserved property
  101242. * @returns the world matrix
  101243. */
  101244. computeWorldMatrix(): Matrix;
  101245. /**
  101246. * Returns the integer 3.
  101247. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101248. */
  101249. getTypeID(): number;
  101250. /**
  101251. * Prepares the list of defines specific to the light type.
  101252. * @param defines the list of defines
  101253. * @param lightIndex defines the index of the light for the effect
  101254. */
  101255. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101256. }
  101257. }
  101258. declare module BABYLON {
  101259. /** @hidden */
  101260. export var vrMultiviewToSingleviewPixelShader: {
  101261. name: string;
  101262. shader: string;
  101263. };
  101264. }
  101265. declare module BABYLON {
  101266. /**
  101267. * Renders to multiple views with a single draw call
  101268. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  101269. */
  101270. export class MultiviewRenderTarget extends RenderTargetTexture {
  101271. /**
  101272. * Creates a multiview render target
  101273. * @param scene scene used with the render target
  101274. * @param size the size of the render target (used for each view)
  101275. */
  101276. constructor(scene: Scene, size?: number | {
  101277. width: number;
  101278. height: number;
  101279. } | {
  101280. ratio: number;
  101281. });
  101282. /**
  101283. * @hidden
  101284. * @param faceIndex the face index, if its a cube texture
  101285. */
  101286. _bindFrameBuffer(faceIndex?: number): void;
  101287. /**
  101288. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  101289. * @returns the view count
  101290. */
  101291. getViewCount(): number;
  101292. }
  101293. }
  101294. declare module BABYLON {
  101295. interface Engine {
  101296. /**
  101297. * Creates a new multiview render target
  101298. * @param width defines the width of the texture
  101299. * @param height defines the height of the texture
  101300. * @returns the created multiview texture
  101301. */
  101302. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  101303. /**
  101304. * Binds a multiview framebuffer to be drawn to
  101305. * @param multiviewTexture texture to bind
  101306. */
  101307. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  101308. }
  101309. interface Camera {
  101310. /**
  101311. * @hidden
  101312. * 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)
  101313. */
  101314. _useMultiviewToSingleView: boolean;
  101315. /**
  101316. * @hidden
  101317. * 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)
  101318. */
  101319. _multiviewTexture: Nullable<RenderTargetTexture>;
  101320. /**
  101321. * @hidden
  101322. * ensures the multiview texture of the camera exists and has the specified width/height
  101323. * @param width height to set on the multiview texture
  101324. * @param height width to set on the multiview texture
  101325. */
  101326. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  101327. }
  101328. interface Scene {
  101329. /** @hidden */
  101330. _transformMatrixR: Matrix;
  101331. /** @hidden */
  101332. _multiviewSceneUbo: Nullable<UniformBuffer>;
  101333. /** @hidden */
  101334. _createMultiviewUbo(): void;
  101335. /** @hidden */
  101336. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  101337. /** @hidden */
  101338. _renderMultiviewToSingleView(camera: Camera): void;
  101339. }
  101340. }
  101341. declare module BABYLON {
  101342. /**
  101343. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  101344. * This will not be used for webXR as it supports displaying texture arrays directly
  101345. */
  101346. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  101347. /**
  101348. * Gets a string identifying the name of the class
  101349. * @returns "VRMultiviewToSingleviewPostProcess" string
  101350. */
  101351. getClassName(): string;
  101352. /**
  101353. * Initializes a VRMultiviewToSingleview
  101354. * @param name name of the post process
  101355. * @param camera camera to be applied to
  101356. * @param scaleFactor scaling factor to the size of the output texture
  101357. */
  101358. constructor(name: string, camera: Camera, scaleFactor: number);
  101359. }
  101360. }
  101361. declare module BABYLON {
  101362. /**
  101363. * Interface used to define additional presentation attributes
  101364. */
  101365. export interface IVRPresentationAttributes {
  101366. /**
  101367. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  101368. */
  101369. highRefreshRate: boolean;
  101370. /**
  101371. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  101372. */
  101373. foveationLevel: number;
  101374. }
  101375. interface Engine {
  101376. /** @hidden */
  101377. _vrDisplay: any;
  101378. /** @hidden */
  101379. _vrSupported: boolean;
  101380. /** @hidden */
  101381. _oldSize: Size;
  101382. /** @hidden */
  101383. _oldHardwareScaleFactor: number;
  101384. /** @hidden */
  101385. _vrExclusivePointerMode: boolean;
  101386. /** @hidden */
  101387. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  101388. /** @hidden */
  101389. _onVRDisplayPointerRestricted: () => void;
  101390. /** @hidden */
  101391. _onVRDisplayPointerUnrestricted: () => void;
  101392. /** @hidden */
  101393. _onVrDisplayConnect: Nullable<(display: any) => void>;
  101394. /** @hidden */
  101395. _onVrDisplayDisconnect: Nullable<() => void>;
  101396. /** @hidden */
  101397. _onVrDisplayPresentChange: Nullable<() => void>;
  101398. /**
  101399. * Observable signaled when VR display mode changes
  101400. */
  101401. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  101402. /**
  101403. * Observable signaled when VR request present is complete
  101404. */
  101405. onVRRequestPresentComplete: Observable<boolean>;
  101406. /**
  101407. * Observable signaled when VR request present starts
  101408. */
  101409. onVRRequestPresentStart: Observable<Engine>;
  101410. /**
  101411. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  101412. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  101413. */
  101414. isInVRExclusivePointerMode: boolean;
  101415. /**
  101416. * Gets a boolean indicating if a webVR device was detected
  101417. * @returns true if a webVR device was detected
  101418. */
  101419. isVRDevicePresent(): boolean;
  101420. /**
  101421. * Gets the current webVR device
  101422. * @returns the current webVR device (or null)
  101423. */
  101424. getVRDevice(): any;
  101425. /**
  101426. * Initializes a webVR display and starts listening to display change events
  101427. * The onVRDisplayChangedObservable will be notified upon these changes
  101428. * @returns A promise containing a VRDisplay and if vr is supported
  101429. */
  101430. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  101431. /** @hidden */
  101432. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  101433. /**
  101434. * Gets or sets the presentation attributes used to configure VR rendering
  101435. */
  101436. vrPresentationAttributes?: IVRPresentationAttributes;
  101437. /**
  101438. * Call this function to switch to webVR mode
  101439. * Will do nothing if webVR is not supported or if there is no webVR device
  101440. * @param options the webvr options provided to the camera. mainly used for multiview
  101441. * @see https://doc.babylonjs.com/how_to/webvr_camera
  101442. */
  101443. enableVR(options: WebVROptions): void;
  101444. /** @hidden */
  101445. _onVRFullScreenTriggered(): void;
  101446. }
  101447. }
  101448. declare module BABYLON {
  101449. /**
  101450. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  101451. * IMPORTANT!! The data is right-hand data.
  101452. * @export
  101453. * @interface DevicePose
  101454. */
  101455. export interface DevicePose {
  101456. /**
  101457. * The position of the device, values in array are [x,y,z].
  101458. */
  101459. readonly position: Nullable<Float32Array>;
  101460. /**
  101461. * The linearVelocity of the device, values in array are [x,y,z].
  101462. */
  101463. readonly linearVelocity: Nullable<Float32Array>;
  101464. /**
  101465. * The linearAcceleration of the device, values in array are [x,y,z].
  101466. */
  101467. readonly linearAcceleration: Nullable<Float32Array>;
  101468. /**
  101469. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  101470. */
  101471. readonly orientation: Nullable<Float32Array>;
  101472. /**
  101473. * The angularVelocity of the device, values in array are [x,y,z].
  101474. */
  101475. readonly angularVelocity: Nullable<Float32Array>;
  101476. /**
  101477. * The angularAcceleration of the device, values in array are [x,y,z].
  101478. */
  101479. readonly angularAcceleration: Nullable<Float32Array>;
  101480. }
  101481. /**
  101482. * Interface representing a pose controlled object in Babylon.
  101483. * A pose controlled object has both regular pose values as well as pose values
  101484. * from an external device such as a VR head mounted display
  101485. */
  101486. export interface PoseControlled {
  101487. /**
  101488. * The position of the object in babylon space.
  101489. */
  101490. position: Vector3;
  101491. /**
  101492. * The rotation quaternion of the object in babylon space.
  101493. */
  101494. rotationQuaternion: Quaternion;
  101495. /**
  101496. * The position of the device in babylon space.
  101497. */
  101498. devicePosition?: Vector3;
  101499. /**
  101500. * The rotation quaternion of the device in babylon space.
  101501. */
  101502. deviceRotationQuaternion: Quaternion;
  101503. /**
  101504. * The raw pose coming from the device.
  101505. */
  101506. rawPose: Nullable<DevicePose>;
  101507. /**
  101508. * The scale of the device to be used when translating from device space to babylon space.
  101509. */
  101510. deviceScaleFactor: number;
  101511. /**
  101512. * Updates the poseControlled values based on the input device pose.
  101513. * @param poseData the pose data to update the object with
  101514. */
  101515. updateFromDevice(poseData: DevicePose): void;
  101516. }
  101517. /**
  101518. * Set of options to customize the webVRCamera
  101519. */
  101520. export interface WebVROptions {
  101521. /**
  101522. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  101523. */
  101524. trackPosition?: boolean;
  101525. /**
  101526. * Sets the scale of the vrDevice in babylon space. (default: 1)
  101527. */
  101528. positionScale?: number;
  101529. /**
  101530. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  101531. */
  101532. displayName?: string;
  101533. /**
  101534. * Should the native controller meshes be initialized. (default: true)
  101535. */
  101536. controllerMeshes?: boolean;
  101537. /**
  101538. * Creating a default HemiLight only on controllers. (default: true)
  101539. */
  101540. defaultLightingOnControllers?: boolean;
  101541. /**
  101542. * If you don't want to use the default VR button of the helper. (default: false)
  101543. */
  101544. useCustomVRButton?: boolean;
  101545. /**
  101546. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  101547. */
  101548. customVRButton?: HTMLButtonElement;
  101549. /**
  101550. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  101551. */
  101552. rayLength?: number;
  101553. /**
  101554. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  101555. */
  101556. defaultHeight?: number;
  101557. /**
  101558. * If multiview should be used if availible (default: false)
  101559. */
  101560. useMultiview?: boolean;
  101561. }
  101562. /**
  101563. * This represents a WebVR camera.
  101564. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  101565. * @example https://doc.babylonjs.com/how_to/webvr_camera
  101566. */
  101567. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  101568. private webVROptions;
  101569. /**
  101570. * @hidden
  101571. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  101572. */
  101573. _vrDevice: any;
  101574. /**
  101575. * The rawPose of the vrDevice.
  101576. */
  101577. rawPose: Nullable<DevicePose>;
  101578. private _onVREnabled;
  101579. private _specsVersion;
  101580. private _attached;
  101581. private _frameData;
  101582. protected _descendants: Array<Node>;
  101583. private _deviceRoomPosition;
  101584. /** @hidden */
  101585. _deviceRoomRotationQuaternion: Quaternion;
  101586. private _standingMatrix;
  101587. /**
  101588. * Represents device position in babylon space.
  101589. */
  101590. devicePosition: Vector3;
  101591. /**
  101592. * Represents device rotation in babylon space.
  101593. */
  101594. deviceRotationQuaternion: Quaternion;
  101595. /**
  101596. * The scale of the device to be used when translating from device space to babylon space.
  101597. */
  101598. deviceScaleFactor: number;
  101599. private _deviceToWorld;
  101600. private _worldToDevice;
  101601. /**
  101602. * References to the webVR controllers for the vrDevice.
  101603. */
  101604. controllers: Array<WebVRController>;
  101605. /**
  101606. * Emits an event when a controller is attached.
  101607. */
  101608. onControllersAttachedObservable: Observable<WebVRController[]>;
  101609. /**
  101610. * Emits an event when a controller's mesh has been loaded;
  101611. */
  101612. onControllerMeshLoadedObservable: Observable<WebVRController>;
  101613. /**
  101614. * Emits an event when the HMD's pose has been updated.
  101615. */
  101616. onPoseUpdatedFromDeviceObservable: Observable<any>;
  101617. private _poseSet;
  101618. /**
  101619. * If the rig cameras be used as parent instead of this camera.
  101620. */
  101621. rigParenting: boolean;
  101622. private _lightOnControllers;
  101623. private _defaultHeight?;
  101624. /**
  101625. * Instantiates a WebVRFreeCamera.
  101626. * @param name The name of the WebVRFreeCamera
  101627. * @param position The starting anchor position for the camera
  101628. * @param scene The scene the camera belongs to
  101629. * @param webVROptions a set of customizable options for the webVRCamera
  101630. */
  101631. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  101632. /**
  101633. * Gets the device distance from the ground in meters.
  101634. * @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.
  101635. */
  101636. deviceDistanceToRoomGround(): number;
  101637. /**
  101638. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  101639. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  101640. */
  101641. useStandingMatrix(callback?: (bool: boolean) => void): void;
  101642. /**
  101643. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  101644. * @returns A promise with a boolean set to if the standing matrix is supported.
  101645. */
  101646. useStandingMatrixAsync(): Promise<boolean>;
  101647. /**
  101648. * Disposes the camera
  101649. */
  101650. dispose(): void;
  101651. /**
  101652. * Gets a vrController by name.
  101653. * @param name The name of the controller to retreive
  101654. * @returns the controller matching the name specified or null if not found
  101655. */
  101656. getControllerByName(name: string): Nullable<WebVRController>;
  101657. private _leftController;
  101658. /**
  101659. * The controller corresponding to the users left hand.
  101660. */
  101661. get leftController(): Nullable<WebVRController>;
  101662. private _rightController;
  101663. /**
  101664. * The controller corresponding to the users right hand.
  101665. */
  101666. get rightController(): Nullable<WebVRController>;
  101667. /**
  101668. * Casts a ray forward from the vrCamera's gaze.
  101669. * @param length Length of the ray (default: 100)
  101670. * @returns the ray corresponding to the gaze
  101671. */
  101672. getForwardRay(length?: number): Ray;
  101673. /**
  101674. * @hidden
  101675. * Updates the camera based on device's frame data
  101676. */
  101677. _checkInputs(): void;
  101678. /**
  101679. * Updates the poseControlled values based on the input device pose.
  101680. * @param poseData Pose coming from the device
  101681. */
  101682. updateFromDevice(poseData: DevicePose): void;
  101683. private _detachIfAttached;
  101684. /**
  101685. * WebVR's attach control will start broadcasting frames to the device.
  101686. * Note that in certain browsers (chrome for example) this function must be called
  101687. * within a user-interaction callback. Example:
  101688. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  101689. *
  101690. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  101691. */
  101692. attachControl(noPreventDefault?: boolean): void;
  101693. /**
  101694. * Detaches the camera from the html element and disables VR
  101695. */
  101696. detachControl(): void;
  101697. /**
  101698. * @returns the name of this class
  101699. */
  101700. getClassName(): string;
  101701. /**
  101702. * Calls resetPose on the vrDisplay
  101703. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  101704. */
  101705. resetToCurrentRotation(): void;
  101706. /**
  101707. * @hidden
  101708. * Updates the rig cameras (left and right eye)
  101709. */
  101710. _updateRigCameras(): void;
  101711. private _workingVector;
  101712. private _oneVector;
  101713. private _workingMatrix;
  101714. private updateCacheCalled;
  101715. private _correctPositionIfNotTrackPosition;
  101716. /**
  101717. * @hidden
  101718. * Updates the cached values of the camera
  101719. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  101720. */
  101721. _updateCache(ignoreParentClass?: boolean): void;
  101722. /**
  101723. * @hidden
  101724. * Get current device position in babylon world
  101725. */
  101726. _computeDevicePosition(): void;
  101727. /**
  101728. * Updates the current device position and rotation in the babylon world
  101729. */
  101730. update(): void;
  101731. /**
  101732. * @hidden
  101733. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  101734. * @returns an identity matrix
  101735. */
  101736. _getViewMatrix(): Matrix;
  101737. private _tmpMatrix;
  101738. /**
  101739. * This function is called by the two RIG cameras.
  101740. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  101741. * @hidden
  101742. */
  101743. _getWebVRViewMatrix(): Matrix;
  101744. /** @hidden */
  101745. _getWebVRProjectionMatrix(): Matrix;
  101746. private _onGamepadConnectedObserver;
  101747. private _onGamepadDisconnectedObserver;
  101748. private _updateCacheWhenTrackingDisabledObserver;
  101749. /**
  101750. * Initializes the controllers and their meshes
  101751. */
  101752. initControllers(): void;
  101753. }
  101754. }
  101755. declare module BABYLON {
  101756. /**
  101757. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  101758. *
  101759. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  101760. *
  101761. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  101762. */
  101763. export class MaterialHelper {
  101764. /**
  101765. * Bind the current view position to an effect.
  101766. * @param effect The effect to be bound
  101767. * @param scene The scene the eyes position is used from
  101768. * @param variableName name of the shader variable that will hold the eye position
  101769. */
  101770. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  101771. /**
  101772. * Helps preparing the defines values about the UVs in used in the effect.
  101773. * UVs are shared as much as we can accross channels in the shaders.
  101774. * @param texture The texture we are preparing the UVs for
  101775. * @param defines The defines to update
  101776. * @param key The channel key "diffuse", "specular"... used in the shader
  101777. */
  101778. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  101779. /**
  101780. * Binds a texture matrix value to its corrsponding uniform
  101781. * @param texture The texture to bind the matrix for
  101782. * @param uniformBuffer The uniform buffer receivin the data
  101783. * @param key The channel key "diffuse", "specular"... used in the shader
  101784. */
  101785. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  101786. /**
  101787. * Gets the current status of the fog (should it be enabled?)
  101788. * @param mesh defines the mesh to evaluate for fog support
  101789. * @param scene defines the hosting scene
  101790. * @returns true if fog must be enabled
  101791. */
  101792. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  101793. /**
  101794. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  101795. * @param mesh defines the current mesh
  101796. * @param scene defines the current scene
  101797. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  101798. * @param pointsCloud defines if point cloud rendering has to be turned on
  101799. * @param fogEnabled defines if fog has to be turned on
  101800. * @param alphaTest defines if alpha testing has to be turned on
  101801. * @param defines defines the current list of defines
  101802. */
  101803. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  101804. /**
  101805. * Helper used to prepare the list of defines associated with frame values for shader compilation
  101806. * @param scene defines the current scene
  101807. * @param engine defines the current engine
  101808. * @param defines specifies the list of active defines
  101809. * @param useInstances defines if instances have to be turned on
  101810. * @param useClipPlane defines if clip plane have to be turned on
  101811. * @param useInstances defines if instances have to be turned on
  101812. * @param useThinInstances defines if thin instances have to be turned on
  101813. */
  101814. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  101815. /**
  101816. * Prepares the defines for bones
  101817. * @param mesh The mesh containing the geometry data we will draw
  101818. * @param defines The defines to update
  101819. */
  101820. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  101821. /**
  101822. * Prepares the defines for morph targets
  101823. * @param mesh The mesh containing the geometry data we will draw
  101824. * @param defines The defines to update
  101825. */
  101826. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  101827. /**
  101828. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  101829. * @param mesh The mesh containing the geometry data we will draw
  101830. * @param defines The defines to update
  101831. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  101832. * @param useBones Precise whether bones should be used or not (override mesh info)
  101833. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  101834. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  101835. * @returns false if defines are considered not dirty and have not been checked
  101836. */
  101837. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  101838. /**
  101839. * Prepares the defines related to multiview
  101840. * @param scene The scene we are intending to draw
  101841. * @param defines The defines to update
  101842. */
  101843. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  101844. /**
  101845. * Prepares the defines related to the prepass
  101846. * @param scene The scene we are intending to draw
  101847. * @param defines The defines to update
  101848. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  101849. */
  101850. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  101851. /**
  101852. * Prepares the defines related to the light information passed in parameter
  101853. * @param scene The scene we are intending to draw
  101854. * @param mesh The mesh the effect is compiling for
  101855. * @param light The light the effect is compiling for
  101856. * @param lightIndex The index of the light
  101857. * @param defines The defines to update
  101858. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101859. * @param state Defines the current state regarding what is needed (normals, etc...)
  101860. */
  101861. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  101862. needNormals: boolean;
  101863. needRebuild: boolean;
  101864. shadowEnabled: boolean;
  101865. specularEnabled: boolean;
  101866. lightmapMode: boolean;
  101867. }): void;
  101868. /**
  101869. * Prepares the defines related to the light information passed in parameter
  101870. * @param scene The scene we are intending to draw
  101871. * @param mesh The mesh the effect is compiling for
  101872. * @param defines The defines to update
  101873. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101874. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  101875. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  101876. * @returns true if normals will be required for the rest of the effect
  101877. */
  101878. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  101879. /**
  101880. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  101881. * @param lightIndex defines the light index
  101882. * @param uniformsList The uniform list
  101883. * @param samplersList The sampler list
  101884. * @param projectedLightTexture defines if projected texture must be used
  101885. * @param uniformBuffersList defines an optional list of uniform buffers
  101886. */
  101887. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  101888. /**
  101889. * Prepares the uniforms and samplers list to be used in the effect
  101890. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  101891. * @param samplersList The sampler list
  101892. * @param defines The defines helping in the list generation
  101893. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  101894. */
  101895. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  101896. /**
  101897. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  101898. * @param defines The defines to update while falling back
  101899. * @param fallbacks The authorized effect fallbacks
  101900. * @param maxSimultaneousLights The maximum number of lights allowed
  101901. * @param rank the current rank of the Effect
  101902. * @returns The newly affected rank
  101903. */
  101904. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  101905. private static _TmpMorphInfluencers;
  101906. /**
  101907. * Prepares the list of attributes required for morph targets according to the effect defines.
  101908. * @param attribs The current list of supported attribs
  101909. * @param mesh The mesh to prepare the morph targets attributes for
  101910. * @param influencers The number of influencers
  101911. */
  101912. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  101913. /**
  101914. * Prepares the list of attributes required for morph targets according to the effect defines.
  101915. * @param attribs The current list of supported attribs
  101916. * @param mesh The mesh to prepare the morph targets attributes for
  101917. * @param defines The current Defines of the effect
  101918. */
  101919. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  101920. /**
  101921. * Prepares the list of attributes required for bones according to the effect defines.
  101922. * @param attribs The current list of supported attribs
  101923. * @param mesh The mesh to prepare the bones attributes for
  101924. * @param defines The current Defines of the effect
  101925. * @param fallbacks The current efffect fallback strategy
  101926. */
  101927. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  101928. /**
  101929. * Check and prepare the list of attributes required for instances according to the effect defines.
  101930. * @param attribs The current list of supported attribs
  101931. * @param defines The current MaterialDefines of the effect
  101932. */
  101933. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  101934. /**
  101935. * Add the list of attributes required for instances to the attribs array.
  101936. * @param attribs The current list of supported attribs
  101937. */
  101938. static PushAttributesForInstances(attribs: string[]): void;
  101939. /**
  101940. * Binds the light information to the effect.
  101941. * @param light The light containing the generator
  101942. * @param effect The effect we are binding the data to
  101943. * @param lightIndex The light index in the effect used to render
  101944. */
  101945. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  101946. /**
  101947. * Binds the lights information from the scene to the effect for the given mesh.
  101948. * @param light Light to bind
  101949. * @param lightIndex Light index
  101950. * @param scene The scene where the light belongs to
  101951. * @param effect The effect we are binding the data to
  101952. * @param useSpecular Defines if specular is supported
  101953. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101954. */
  101955. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  101956. /**
  101957. * Binds the lights information from the scene to the effect for the given mesh.
  101958. * @param scene The scene the lights belongs to
  101959. * @param mesh The mesh we are binding the information to render
  101960. * @param effect The effect we are binding the data to
  101961. * @param defines The generated defines for the effect
  101962. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  101963. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101964. */
  101965. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  101966. private static _tempFogColor;
  101967. /**
  101968. * Binds the fog information from the scene to the effect for the given mesh.
  101969. * @param scene The scene the lights belongs to
  101970. * @param mesh The mesh we are binding the information to render
  101971. * @param effect The effect we are binding the data to
  101972. * @param linearSpace Defines if the fog effect is applied in linear space
  101973. */
  101974. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  101975. /**
  101976. * Binds the bones information from the mesh to the effect.
  101977. * @param mesh The mesh we are binding the information to render
  101978. * @param effect The effect we are binding the data to
  101979. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  101980. */
  101981. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  101982. private static _CopyBonesTransformationMatrices;
  101983. /**
  101984. * Binds the morph targets information from the mesh to the effect.
  101985. * @param abstractMesh The mesh we are binding the information to render
  101986. * @param effect The effect we are binding the data to
  101987. */
  101988. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  101989. /**
  101990. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  101991. * @param defines The generated defines used in the effect
  101992. * @param effect The effect we are binding the data to
  101993. * @param scene The scene we are willing to render with logarithmic scale for
  101994. */
  101995. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  101996. /**
  101997. * Binds the clip plane information from the scene to the effect.
  101998. * @param scene The scene the clip plane information are extracted from
  101999. * @param effect The effect we are binding the data to
  102000. */
  102001. static BindClipPlane(effect: Effect, scene: Scene): void;
  102002. }
  102003. }
  102004. declare module BABYLON {
  102005. /**
  102006. * Block used to expose an input value
  102007. */
  102008. export class InputBlock extends NodeMaterialBlock {
  102009. private _mode;
  102010. private _associatedVariableName;
  102011. private _storedValue;
  102012. private _valueCallback;
  102013. private _type;
  102014. private _animationType;
  102015. /** Gets or set a value used to limit the range of float values */
  102016. min: number;
  102017. /** Gets or set a value used to limit the range of float values */
  102018. max: number;
  102019. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  102020. isBoolean: boolean;
  102021. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  102022. matrixMode: number;
  102023. /** @hidden */
  102024. _systemValue: Nullable<NodeMaterialSystemValues>;
  102025. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  102026. isConstant: boolean;
  102027. /** Gets or sets the group to use to display this block in the Inspector */
  102028. groupInInspector: string;
  102029. /** Gets an observable raised when the value is changed */
  102030. onValueChangedObservable: Observable<InputBlock>;
  102031. /**
  102032. * Gets or sets the connection point type (default is float)
  102033. */
  102034. get type(): NodeMaterialBlockConnectionPointTypes;
  102035. /**
  102036. * Creates a new InputBlock
  102037. * @param name defines the block name
  102038. * @param target defines the target of that block (Vertex by default)
  102039. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  102040. */
  102041. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  102042. /**
  102043. * Validates if a name is a reserve word.
  102044. * @param newName the new name to be given to the node.
  102045. * @returns false if the name is a reserve word, else true.
  102046. */
  102047. validateBlockName(newName: string): boolean;
  102048. /**
  102049. * Gets the output component
  102050. */
  102051. get output(): NodeMaterialConnectionPoint;
  102052. /**
  102053. * Set the source of this connection point to a vertex attribute
  102054. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  102055. * @returns the current connection point
  102056. */
  102057. setAsAttribute(attributeName?: string): InputBlock;
  102058. /**
  102059. * Set the source of this connection point to a system value
  102060. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  102061. * @returns the current connection point
  102062. */
  102063. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  102064. /**
  102065. * Gets or sets the value of that point.
  102066. * Please note that this value will be ignored if valueCallback is defined
  102067. */
  102068. get value(): any;
  102069. set value(value: any);
  102070. /**
  102071. * Gets or sets a callback used to get the value of that point.
  102072. * Please note that setting this value will force the connection point to ignore the value property
  102073. */
  102074. get valueCallback(): () => any;
  102075. set valueCallback(value: () => any);
  102076. /**
  102077. * Gets or sets the associated variable name in the shader
  102078. */
  102079. get associatedVariableName(): string;
  102080. set associatedVariableName(value: string);
  102081. /** Gets or sets the type of animation applied to the input */
  102082. get animationType(): AnimatedInputBlockTypes;
  102083. set animationType(value: AnimatedInputBlockTypes);
  102084. /**
  102085. * Gets a boolean indicating that this connection point not defined yet
  102086. */
  102087. get isUndefined(): boolean;
  102088. /**
  102089. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  102090. * In this case the connection point name must be the name of the uniform to use.
  102091. * Can only be set on inputs
  102092. */
  102093. get isUniform(): boolean;
  102094. set isUniform(value: boolean);
  102095. /**
  102096. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  102097. * In this case the connection point name must be the name of the attribute to use
  102098. * Can only be set on inputs
  102099. */
  102100. get isAttribute(): boolean;
  102101. set isAttribute(value: boolean);
  102102. /**
  102103. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  102104. * Can only be set on exit points
  102105. */
  102106. get isVarying(): boolean;
  102107. set isVarying(value: boolean);
  102108. /**
  102109. * Gets a boolean indicating that the current connection point is a system value
  102110. */
  102111. get isSystemValue(): boolean;
  102112. /**
  102113. * Gets or sets the current well known value or null if not defined as a system value
  102114. */
  102115. get systemValue(): Nullable<NodeMaterialSystemValues>;
  102116. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  102117. /**
  102118. * Gets the current class name
  102119. * @returns the class name
  102120. */
  102121. getClassName(): string;
  102122. /**
  102123. * Animate the input if animationType !== None
  102124. * @param scene defines the rendering scene
  102125. */
  102126. animate(scene: Scene): void;
  102127. private _emitDefine;
  102128. initialize(state: NodeMaterialBuildState): void;
  102129. /**
  102130. * Set the input block to its default value (based on its type)
  102131. */
  102132. setDefaultValue(): void;
  102133. private _emitConstant;
  102134. /** @hidden */
  102135. get _noContextSwitch(): boolean;
  102136. private _emit;
  102137. /** @hidden */
  102138. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  102139. /** @hidden */
  102140. _transmit(effect: Effect, scene: Scene): void;
  102141. protected _buildBlock(state: NodeMaterialBuildState): void;
  102142. protected _dumpPropertiesCode(): string;
  102143. dispose(): void;
  102144. serialize(): any;
  102145. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102146. }
  102147. }
  102148. declare module BABYLON {
  102149. /**
  102150. * Enum used to define the compatibility state between two connection points
  102151. */
  102152. export enum NodeMaterialConnectionPointCompatibilityStates {
  102153. /** Points are compatibles */
  102154. Compatible = 0,
  102155. /** Points are incompatible because of their types */
  102156. TypeIncompatible = 1,
  102157. /** Points are incompatible because of their targets (vertex vs fragment) */
  102158. TargetIncompatible = 2
  102159. }
  102160. /**
  102161. * Defines the direction of a connection point
  102162. */
  102163. export enum NodeMaterialConnectionPointDirection {
  102164. /** Input */
  102165. Input = 0,
  102166. /** Output */
  102167. Output = 1
  102168. }
  102169. /**
  102170. * Defines a connection point for a block
  102171. */
  102172. export class NodeMaterialConnectionPoint {
  102173. /** @hidden */
  102174. _ownerBlock: NodeMaterialBlock;
  102175. /** @hidden */
  102176. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  102177. private _endpoints;
  102178. private _associatedVariableName;
  102179. private _direction;
  102180. /** @hidden */
  102181. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  102182. /** @hidden */
  102183. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  102184. private _type;
  102185. /** @hidden */
  102186. _enforceAssociatedVariableName: boolean;
  102187. /** Gets the direction of the point */
  102188. get direction(): NodeMaterialConnectionPointDirection;
  102189. /** Indicates that this connection point needs dual validation before being connected to another point */
  102190. needDualDirectionValidation: boolean;
  102191. /**
  102192. * Gets or sets the additional types supported by this connection point
  102193. */
  102194. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  102195. /**
  102196. * Gets or sets the additional types excluded by this connection point
  102197. */
  102198. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  102199. /**
  102200. * Observable triggered when this point is connected
  102201. */
  102202. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  102203. /**
  102204. * Gets or sets the associated variable name in the shader
  102205. */
  102206. get associatedVariableName(): string;
  102207. set associatedVariableName(value: string);
  102208. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  102209. get innerType(): NodeMaterialBlockConnectionPointTypes;
  102210. /**
  102211. * Gets or sets the connection point type (default is float)
  102212. */
  102213. get type(): NodeMaterialBlockConnectionPointTypes;
  102214. set type(value: NodeMaterialBlockConnectionPointTypes);
  102215. /**
  102216. * Gets or sets the connection point name
  102217. */
  102218. name: string;
  102219. /**
  102220. * Gets or sets the connection point name
  102221. */
  102222. displayName: string;
  102223. /**
  102224. * Gets or sets a boolean indicating that this connection point can be omitted
  102225. */
  102226. isOptional: boolean;
  102227. /**
  102228. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  102229. */
  102230. isExposedOnFrame: boolean;
  102231. /**
  102232. * Gets or sets number indicating the position that the port is exposed to on a frame
  102233. */
  102234. exposedPortPosition: number;
  102235. /**
  102236. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  102237. */
  102238. define: string;
  102239. /** @hidden */
  102240. _prioritizeVertex: boolean;
  102241. private _target;
  102242. /** Gets or sets the target of that connection point */
  102243. get target(): NodeMaterialBlockTargets;
  102244. set target(value: NodeMaterialBlockTargets);
  102245. /**
  102246. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  102247. */
  102248. get isConnected(): boolean;
  102249. /**
  102250. * Gets a boolean indicating that the current point is connected to an input block
  102251. */
  102252. get isConnectedToInputBlock(): boolean;
  102253. /**
  102254. * Gets a the connected input block (if any)
  102255. */
  102256. get connectInputBlock(): Nullable<InputBlock>;
  102257. /** Get the other side of the connection (if any) */
  102258. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  102259. /** Get the block that owns this connection point */
  102260. get ownerBlock(): NodeMaterialBlock;
  102261. /** Get the block connected on the other side of this connection (if any) */
  102262. get sourceBlock(): Nullable<NodeMaterialBlock>;
  102263. /** Get the block connected on the endpoints of this connection (if any) */
  102264. get connectedBlocks(): Array<NodeMaterialBlock>;
  102265. /** Gets the list of connected endpoints */
  102266. get endpoints(): NodeMaterialConnectionPoint[];
  102267. /** Gets a boolean indicating if that output point is connected to at least one input */
  102268. get hasEndpoints(): boolean;
  102269. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  102270. get isConnectedInVertexShader(): boolean;
  102271. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  102272. get isConnectedInFragmentShader(): boolean;
  102273. /**
  102274. * Creates a block suitable to be used as an input for this input point.
  102275. * If null is returned, a block based on the point type will be created.
  102276. * @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
  102277. */
  102278. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  102279. /**
  102280. * Creates a new connection point
  102281. * @param name defines the connection point name
  102282. * @param ownerBlock defines the block hosting this connection point
  102283. * @param direction defines the direction of the connection point
  102284. */
  102285. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  102286. /**
  102287. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  102288. * @returns the class name
  102289. */
  102290. getClassName(): string;
  102291. /**
  102292. * Gets a boolean indicating if the current point can be connected to another point
  102293. * @param connectionPoint defines the other connection point
  102294. * @returns a boolean
  102295. */
  102296. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  102297. /**
  102298. * Gets a number indicating if the current point can be connected to another point
  102299. * @param connectionPoint defines the other connection point
  102300. * @returns a number defining the compatibility state
  102301. */
  102302. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  102303. /**
  102304. * Connect this point to another connection point
  102305. * @param connectionPoint defines the other connection point
  102306. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  102307. * @returns the current connection point
  102308. */
  102309. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  102310. /**
  102311. * Disconnect this point from one of his endpoint
  102312. * @param endpoint defines the other connection point
  102313. * @returns the current connection point
  102314. */
  102315. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  102316. /**
  102317. * Serializes this point in a JSON representation
  102318. * @param isInput defines if the connection point is an input (default is true)
  102319. * @returns the serialized point object
  102320. */
  102321. serialize(isInput?: boolean): any;
  102322. /**
  102323. * Release resources
  102324. */
  102325. dispose(): void;
  102326. }
  102327. }
  102328. declare module BABYLON {
  102329. /**
  102330. * Enum used to define the material modes
  102331. */
  102332. export enum NodeMaterialModes {
  102333. /** Regular material */
  102334. Material = 0,
  102335. /** For post process */
  102336. PostProcess = 1,
  102337. /** For particle system */
  102338. Particle = 2,
  102339. /** For procedural texture */
  102340. ProceduralTexture = 3
  102341. }
  102342. }
  102343. declare module BABYLON {
  102344. /**
  102345. * Block used to read a texture from a sampler
  102346. */
  102347. export class TextureBlock extends NodeMaterialBlock {
  102348. private _defineName;
  102349. private _linearDefineName;
  102350. private _gammaDefineName;
  102351. private _tempTextureRead;
  102352. private _samplerName;
  102353. private _transformedUVName;
  102354. private _textureTransformName;
  102355. private _textureInfoName;
  102356. private _mainUVName;
  102357. private _mainUVDefineName;
  102358. private _fragmentOnly;
  102359. /**
  102360. * Gets or sets the texture associated with the node
  102361. */
  102362. texture: Nullable<Texture>;
  102363. /**
  102364. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102365. */
  102366. convertToGammaSpace: boolean;
  102367. /**
  102368. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102369. */
  102370. convertToLinearSpace: boolean;
  102371. /**
  102372. * Create a new TextureBlock
  102373. * @param name defines the block name
  102374. */
  102375. constructor(name: string, fragmentOnly?: boolean);
  102376. /**
  102377. * Gets the current class name
  102378. * @returns the class name
  102379. */
  102380. getClassName(): string;
  102381. /**
  102382. * Gets the uv input component
  102383. */
  102384. get uv(): NodeMaterialConnectionPoint;
  102385. /**
  102386. * Gets the rgba output component
  102387. */
  102388. get rgba(): NodeMaterialConnectionPoint;
  102389. /**
  102390. * Gets the rgb output component
  102391. */
  102392. get rgb(): NodeMaterialConnectionPoint;
  102393. /**
  102394. * Gets the r output component
  102395. */
  102396. get r(): NodeMaterialConnectionPoint;
  102397. /**
  102398. * Gets the g output component
  102399. */
  102400. get g(): NodeMaterialConnectionPoint;
  102401. /**
  102402. * Gets the b output component
  102403. */
  102404. get b(): NodeMaterialConnectionPoint;
  102405. /**
  102406. * Gets the a output component
  102407. */
  102408. get a(): NodeMaterialConnectionPoint;
  102409. get target(): NodeMaterialBlockTargets;
  102410. autoConfigure(material: NodeMaterial): void;
  102411. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102412. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102413. isReady(): boolean;
  102414. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  102415. private get _isMixed();
  102416. private _injectVertexCode;
  102417. private _writeTextureRead;
  102418. private _writeOutput;
  102419. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102420. protected _dumpPropertiesCode(): string;
  102421. serialize(): any;
  102422. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102423. }
  102424. }
  102425. declare module BABYLON {
  102426. /** @hidden */
  102427. export var reflectionFunction: {
  102428. name: string;
  102429. shader: string;
  102430. };
  102431. }
  102432. declare module BABYLON {
  102433. /**
  102434. * Base block used to read a reflection texture from a sampler
  102435. */
  102436. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  102437. /** @hidden */
  102438. _define3DName: string;
  102439. /** @hidden */
  102440. _defineCubicName: string;
  102441. /** @hidden */
  102442. _defineExplicitName: string;
  102443. /** @hidden */
  102444. _defineProjectionName: string;
  102445. /** @hidden */
  102446. _defineLocalCubicName: string;
  102447. /** @hidden */
  102448. _defineSphericalName: string;
  102449. /** @hidden */
  102450. _definePlanarName: string;
  102451. /** @hidden */
  102452. _defineEquirectangularName: string;
  102453. /** @hidden */
  102454. _defineMirroredEquirectangularFixedName: string;
  102455. /** @hidden */
  102456. _defineEquirectangularFixedName: string;
  102457. /** @hidden */
  102458. _defineSkyboxName: string;
  102459. /** @hidden */
  102460. _defineOppositeZ: string;
  102461. /** @hidden */
  102462. _cubeSamplerName: string;
  102463. /** @hidden */
  102464. _2DSamplerName: string;
  102465. protected _positionUVWName: string;
  102466. protected _directionWName: string;
  102467. protected _reflectionVectorName: string;
  102468. /** @hidden */
  102469. _reflectionCoordsName: string;
  102470. /** @hidden */
  102471. _reflectionMatrixName: string;
  102472. protected _reflectionColorName: string;
  102473. /**
  102474. * Gets or sets the texture associated with the node
  102475. */
  102476. texture: Nullable<BaseTexture>;
  102477. /**
  102478. * Create a new ReflectionTextureBaseBlock
  102479. * @param name defines the block name
  102480. */
  102481. constructor(name: string);
  102482. /**
  102483. * Gets the current class name
  102484. * @returns the class name
  102485. */
  102486. getClassName(): string;
  102487. /**
  102488. * Gets the world position input component
  102489. */
  102490. abstract get position(): NodeMaterialConnectionPoint;
  102491. /**
  102492. * Gets the world position input component
  102493. */
  102494. abstract get worldPosition(): NodeMaterialConnectionPoint;
  102495. /**
  102496. * Gets the world normal input component
  102497. */
  102498. abstract get worldNormal(): NodeMaterialConnectionPoint;
  102499. /**
  102500. * Gets the world input component
  102501. */
  102502. abstract get world(): NodeMaterialConnectionPoint;
  102503. /**
  102504. * Gets the camera (or eye) position component
  102505. */
  102506. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  102507. /**
  102508. * Gets the view input component
  102509. */
  102510. abstract get view(): NodeMaterialConnectionPoint;
  102511. protected _getTexture(): Nullable<BaseTexture>;
  102512. autoConfigure(material: NodeMaterial): void;
  102513. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102514. isReady(): boolean;
  102515. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  102516. /**
  102517. * Gets the code to inject in the vertex shader
  102518. * @param state current state of the node material building
  102519. * @returns the shader code
  102520. */
  102521. handleVertexSide(state: NodeMaterialBuildState): string;
  102522. /**
  102523. * Handles the inits for the fragment code path
  102524. * @param state node material build state
  102525. */
  102526. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  102527. /**
  102528. * Generates the reflection coords code for the fragment code path
  102529. * @param worldNormalVarName name of the world normal variable
  102530. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  102531. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  102532. * @returns the shader code
  102533. */
  102534. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  102535. /**
  102536. * Generates the reflection color code for the fragment code path
  102537. * @param lodVarName name of the lod variable
  102538. * @param swizzleLookupTexture swizzle to use for the final color variable
  102539. * @returns the shader code
  102540. */
  102541. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  102542. /**
  102543. * Generates the code corresponding to the connected output points
  102544. * @param state node material build state
  102545. * @param varName name of the variable to output
  102546. * @returns the shader code
  102547. */
  102548. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  102549. protected _buildBlock(state: NodeMaterialBuildState): this;
  102550. protected _dumpPropertiesCode(): string;
  102551. serialize(): any;
  102552. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102553. }
  102554. }
  102555. declare module BABYLON {
  102556. /**
  102557. * Defines a connection point to be used for points with a custom object type
  102558. */
  102559. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  102560. private _blockType;
  102561. private _blockName;
  102562. private _nameForCheking?;
  102563. /**
  102564. * Creates a new connection point
  102565. * @param name defines the connection point name
  102566. * @param ownerBlock defines the block hosting this connection point
  102567. * @param direction defines the direction of the connection point
  102568. */
  102569. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  102570. /**
  102571. * Gets a number indicating if the current point can be connected to another point
  102572. * @param connectionPoint defines the other connection point
  102573. * @returns a number defining the compatibility state
  102574. */
  102575. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  102576. /**
  102577. * Creates a block suitable to be used as an input for this input point.
  102578. * If null is returned, a block based on the point type will be created.
  102579. * @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
  102580. */
  102581. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  102582. }
  102583. }
  102584. declare module BABYLON {
  102585. /**
  102586. * Enum defining the type of properties that can be edited in the property pages in the NME
  102587. */
  102588. export enum PropertyTypeForEdition {
  102589. /** property is a boolean */
  102590. Boolean = 0,
  102591. /** property is a float */
  102592. Float = 1,
  102593. /** property is a Vector2 */
  102594. Vector2 = 2,
  102595. /** property is a list of values */
  102596. List = 3
  102597. }
  102598. /**
  102599. * Interface that defines an option in a variable of type list
  102600. */
  102601. export interface IEditablePropertyListOption {
  102602. /** label of the option */
  102603. "label": string;
  102604. /** value of the option */
  102605. "value": number;
  102606. }
  102607. /**
  102608. * Interface that defines the options available for an editable property
  102609. */
  102610. export interface IEditablePropertyOption {
  102611. /** min value */
  102612. "min"?: number;
  102613. /** max value */
  102614. "max"?: number;
  102615. /** notifiers: indicates which actions to take when the property is changed */
  102616. "notifiers"?: {
  102617. /** the material should be rebuilt */
  102618. "rebuild"?: boolean;
  102619. /** the preview should be updated */
  102620. "update"?: boolean;
  102621. };
  102622. /** list of the options for a variable of type list */
  102623. "options"?: IEditablePropertyListOption[];
  102624. }
  102625. /**
  102626. * Interface that describes an editable property
  102627. */
  102628. export interface IPropertyDescriptionForEdition {
  102629. /** name of the property */
  102630. "propertyName": string;
  102631. /** display name of the property */
  102632. "displayName": string;
  102633. /** type of the property */
  102634. "type": PropertyTypeForEdition;
  102635. /** group of the property - all properties with the same group value will be displayed in a specific section */
  102636. "groupName": string;
  102637. /** options for the property */
  102638. "options": IEditablePropertyOption;
  102639. }
  102640. /**
  102641. * Decorator that flags a property in a node material block as being editable
  102642. */
  102643. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  102644. }
  102645. declare module BABYLON {
  102646. /**
  102647. * Block used to implement the refraction part of the sub surface module of the PBR material
  102648. */
  102649. export class RefractionBlock extends NodeMaterialBlock {
  102650. /** @hidden */
  102651. _define3DName: string;
  102652. /** @hidden */
  102653. _refractionMatrixName: string;
  102654. /** @hidden */
  102655. _defineLODRefractionAlpha: string;
  102656. /** @hidden */
  102657. _defineLinearSpecularRefraction: string;
  102658. /** @hidden */
  102659. _defineOppositeZ: string;
  102660. /** @hidden */
  102661. _cubeSamplerName: string;
  102662. /** @hidden */
  102663. _2DSamplerName: string;
  102664. /** @hidden */
  102665. _vRefractionMicrosurfaceInfosName: string;
  102666. /** @hidden */
  102667. _vRefractionInfosName: string;
  102668. private _scene;
  102669. /**
  102670. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102671. * Materials half opaque for instance using refraction could benefit from this control.
  102672. */
  102673. linkRefractionWithTransparency: boolean;
  102674. /**
  102675. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102676. */
  102677. invertRefractionY: boolean;
  102678. /**
  102679. * Gets or sets the texture associated with the node
  102680. */
  102681. texture: Nullable<BaseTexture>;
  102682. /**
  102683. * Create a new RefractionBlock
  102684. * @param name defines the block name
  102685. */
  102686. constructor(name: string);
  102687. /**
  102688. * Gets the current class name
  102689. * @returns the class name
  102690. */
  102691. getClassName(): string;
  102692. /**
  102693. * Gets the intensity input component
  102694. */
  102695. get intensity(): NodeMaterialConnectionPoint;
  102696. /**
  102697. * Gets the index of refraction input component
  102698. */
  102699. get indexOfRefraction(): NodeMaterialConnectionPoint;
  102700. /**
  102701. * Gets the tint at distance input component
  102702. */
  102703. get tintAtDistance(): NodeMaterialConnectionPoint;
  102704. /**
  102705. * Gets the view input component
  102706. */
  102707. get view(): NodeMaterialConnectionPoint;
  102708. /**
  102709. * Gets the refraction object output component
  102710. */
  102711. get refraction(): NodeMaterialConnectionPoint;
  102712. /**
  102713. * Returns true if the block has a texture
  102714. */
  102715. get hasTexture(): boolean;
  102716. protected _getTexture(): Nullable<BaseTexture>;
  102717. autoConfigure(material: NodeMaterial): void;
  102718. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102719. isReady(): boolean;
  102720. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102721. /**
  102722. * Gets the main code of the block (fragment side)
  102723. * @param state current state of the node material building
  102724. * @returns the shader code
  102725. */
  102726. getCode(state: NodeMaterialBuildState): string;
  102727. protected _buildBlock(state: NodeMaterialBuildState): this;
  102728. protected _dumpPropertiesCode(): string;
  102729. serialize(): any;
  102730. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102731. }
  102732. }
  102733. declare module BABYLON {
  102734. /**
  102735. * Base block used as input for post process
  102736. */
  102737. export class CurrentScreenBlock extends NodeMaterialBlock {
  102738. private _samplerName;
  102739. private _linearDefineName;
  102740. private _gammaDefineName;
  102741. private _mainUVName;
  102742. private _tempTextureRead;
  102743. /**
  102744. * Gets or sets the texture associated with the node
  102745. */
  102746. texture: Nullable<BaseTexture>;
  102747. /**
  102748. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102749. */
  102750. convertToGammaSpace: boolean;
  102751. /**
  102752. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102753. */
  102754. convertToLinearSpace: boolean;
  102755. /**
  102756. * Create a new CurrentScreenBlock
  102757. * @param name defines the block name
  102758. */
  102759. constructor(name: string);
  102760. /**
  102761. * Gets the current class name
  102762. * @returns the class name
  102763. */
  102764. getClassName(): string;
  102765. /**
  102766. * Gets the uv input component
  102767. */
  102768. get uv(): NodeMaterialConnectionPoint;
  102769. /**
  102770. * Gets the rgba output component
  102771. */
  102772. get rgba(): NodeMaterialConnectionPoint;
  102773. /**
  102774. * Gets the rgb output component
  102775. */
  102776. get rgb(): NodeMaterialConnectionPoint;
  102777. /**
  102778. * Gets the r output component
  102779. */
  102780. get r(): NodeMaterialConnectionPoint;
  102781. /**
  102782. * Gets the g output component
  102783. */
  102784. get g(): NodeMaterialConnectionPoint;
  102785. /**
  102786. * Gets the b output component
  102787. */
  102788. get b(): NodeMaterialConnectionPoint;
  102789. /**
  102790. * Gets the a output component
  102791. */
  102792. get a(): NodeMaterialConnectionPoint;
  102793. /**
  102794. * Initialize the block and prepare the context for build
  102795. * @param state defines the state that will be used for the build
  102796. */
  102797. initialize(state: NodeMaterialBuildState): void;
  102798. get target(): NodeMaterialBlockTargets;
  102799. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102800. isReady(): boolean;
  102801. private _injectVertexCode;
  102802. private _writeTextureRead;
  102803. private _writeOutput;
  102804. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102805. serialize(): any;
  102806. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102807. }
  102808. }
  102809. declare module BABYLON {
  102810. /**
  102811. * Base block used for the particle texture
  102812. */
  102813. export class ParticleTextureBlock extends NodeMaterialBlock {
  102814. private _samplerName;
  102815. private _linearDefineName;
  102816. private _gammaDefineName;
  102817. private _tempTextureRead;
  102818. /**
  102819. * Gets or sets the texture associated with the node
  102820. */
  102821. texture: Nullable<BaseTexture>;
  102822. /**
  102823. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102824. */
  102825. convertToGammaSpace: boolean;
  102826. /**
  102827. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102828. */
  102829. convertToLinearSpace: boolean;
  102830. /**
  102831. * Create a new ParticleTextureBlock
  102832. * @param name defines the block name
  102833. */
  102834. constructor(name: string);
  102835. /**
  102836. * Gets the current class name
  102837. * @returns the class name
  102838. */
  102839. getClassName(): string;
  102840. /**
  102841. * Gets the uv input component
  102842. */
  102843. get uv(): NodeMaterialConnectionPoint;
  102844. /**
  102845. * Gets the rgba output component
  102846. */
  102847. get rgba(): NodeMaterialConnectionPoint;
  102848. /**
  102849. * Gets the rgb output component
  102850. */
  102851. get rgb(): NodeMaterialConnectionPoint;
  102852. /**
  102853. * Gets the r output component
  102854. */
  102855. get r(): NodeMaterialConnectionPoint;
  102856. /**
  102857. * Gets the g output component
  102858. */
  102859. get g(): NodeMaterialConnectionPoint;
  102860. /**
  102861. * Gets the b output component
  102862. */
  102863. get b(): NodeMaterialConnectionPoint;
  102864. /**
  102865. * Gets the a output component
  102866. */
  102867. get a(): NodeMaterialConnectionPoint;
  102868. /**
  102869. * Initialize the block and prepare the context for build
  102870. * @param state defines the state that will be used for the build
  102871. */
  102872. initialize(state: NodeMaterialBuildState): void;
  102873. autoConfigure(material: NodeMaterial): void;
  102874. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102875. isReady(): boolean;
  102876. private _writeOutput;
  102877. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102878. serialize(): any;
  102879. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102880. }
  102881. }
  102882. declare module BABYLON {
  102883. /**
  102884. * Class used to store shared data between 2 NodeMaterialBuildState
  102885. */
  102886. export class NodeMaterialBuildStateSharedData {
  102887. /**
  102888. * Gets the list of emitted varyings
  102889. */
  102890. temps: string[];
  102891. /**
  102892. * Gets the list of emitted varyings
  102893. */
  102894. varyings: string[];
  102895. /**
  102896. * Gets the varying declaration string
  102897. */
  102898. varyingDeclaration: string;
  102899. /**
  102900. * Input blocks
  102901. */
  102902. inputBlocks: InputBlock[];
  102903. /**
  102904. * Input blocks
  102905. */
  102906. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102907. /**
  102908. * Bindable blocks (Blocks that need to set data to the effect)
  102909. */
  102910. bindableBlocks: NodeMaterialBlock[];
  102911. /**
  102912. * List of blocks that can provide a compilation fallback
  102913. */
  102914. blocksWithFallbacks: NodeMaterialBlock[];
  102915. /**
  102916. * List of blocks that can provide a define update
  102917. */
  102918. blocksWithDefines: NodeMaterialBlock[];
  102919. /**
  102920. * List of blocks that can provide a repeatable content
  102921. */
  102922. repeatableContentBlocks: NodeMaterialBlock[];
  102923. /**
  102924. * List of blocks that can provide a dynamic list of uniforms
  102925. */
  102926. dynamicUniformBlocks: NodeMaterialBlock[];
  102927. /**
  102928. * List of blocks that can block the isReady function for the material
  102929. */
  102930. blockingBlocks: NodeMaterialBlock[];
  102931. /**
  102932. * Gets the list of animated inputs
  102933. */
  102934. animatedInputs: InputBlock[];
  102935. /**
  102936. * Build Id used to avoid multiple recompilations
  102937. */
  102938. buildId: number;
  102939. /** List of emitted variables */
  102940. variableNames: {
  102941. [key: string]: number;
  102942. };
  102943. /** List of emitted defines */
  102944. defineNames: {
  102945. [key: string]: number;
  102946. };
  102947. /** Should emit comments? */
  102948. emitComments: boolean;
  102949. /** Emit build activity */
  102950. verbose: boolean;
  102951. /** Gets or sets the hosting scene */
  102952. scene: Scene;
  102953. /**
  102954. * Gets the compilation hints emitted at compilation time
  102955. */
  102956. hints: {
  102957. needWorldViewMatrix: boolean;
  102958. needWorldViewProjectionMatrix: boolean;
  102959. needAlphaBlending: boolean;
  102960. needAlphaTesting: boolean;
  102961. };
  102962. /**
  102963. * List of compilation checks
  102964. */
  102965. checks: {
  102966. emitVertex: boolean;
  102967. emitFragment: boolean;
  102968. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  102969. };
  102970. /**
  102971. * Is vertex program allowed to be empty?
  102972. */
  102973. allowEmptyVertexProgram: boolean;
  102974. /** Creates a new shared data */
  102975. constructor();
  102976. /**
  102977. * Emits console errors and exceptions if there is a failing check
  102978. */
  102979. emitErrors(): void;
  102980. }
  102981. }
  102982. declare module BABYLON {
  102983. /**
  102984. * Class used to store node based material build state
  102985. */
  102986. export class NodeMaterialBuildState {
  102987. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  102988. supportUniformBuffers: boolean;
  102989. /**
  102990. * Gets the list of emitted attributes
  102991. */
  102992. attributes: string[];
  102993. /**
  102994. * Gets the list of emitted uniforms
  102995. */
  102996. uniforms: string[];
  102997. /**
  102998. * Gets the list of emitted constants
  102999. */
  103000. constants: string[];
  103001. /**
  103002. * Gets the list of emitted samplers
  103003. */
  103004. samplers: string[];
  103005. /**
  103006. * Gets the list of emitted functions
  103007. */
  103008. functions: {
  103009. [key: string]: string;
  103010. };
  103011. /**
  103012. * Gets the list of emitted extensions
  103013. */
  103014. extensions: {
  103015. [key: string]: string;
  103016. };
  103017. /**
  103018. * Gets the target of the compilation state
  103019. */
  103020. target: NodeMaterialBlockTargets;
  103021. /**
  103022. * Gets the list of emitted counters
  103023. */
  103024. counters: {
  103025. [key: string]: number;
  103026. };
  103027. /**
  103028. * Shared data between multiple NodeMaterialBuildState instances
  103029. */
  103030. sharedData: NodeMaterialBuildStateSharedData;
  103031. /** @hidden */
  103032. _vertexState: NodeMaterialBuildState;
  103033. /** @hidden */
  103034. _attributeDeclaration: string;
  103035. /** @hidden */
  103036. _uniformDeclaration: string;
  103037. /** @hidden */
  103038. _constantDeclaration: string;
  103039. /** @hidden */
  103040. _samplerDeclaration: string;
  103041. /** @hidden */
  103042. _varyingTransfer: string;
  103043. /** @hidden */
  103044. _injectAtEnd: string;
  103045. private _repeatableContentAnchorIndex;
  103046. /** @hidden */
  103047. _builtCompilationString: string;
  103048. /**
  103049. * Gets the emitted compilation strings
  103050. */
  103051. compilationString: string;
  103052. /**
  103053. * Finalize the compilation strings
  103054. * @param state defines the current compilation state
  103055. */
  103056. finalize(state: NodeMaterialBuildState): void;
  103057. /** @hidden */
  103058. get _repeatableContentAnchor(): string;
  103059. /** @hidden */
  103060. _getFreeVariableName(prefix: string): string;
  103061. /** @hidden */
  103062. _getFreeDefineName(prefix: string): string;
  103063. /** @hidden */
  103064. _excludeVariableName(name: string): void;
  103065. /** @hidden */
  103066. _emit2DSampler(name: string): void;
  103067. /** @hidden */
  103068. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  103069. /** @hidden */
  103070. _emitExtension(name: string, extension: string, define?: string): void;
  103071. /** @hidden */
  103072. _emitFunction(name: string, code: string, comments: string): void;
  103073. /** @hidden */
  103074. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  103075. replaceStrings?: {
  103076. search: RegExp;
  103077. replace: string;
  103078. }[];
  103079. repeatKey?: string;
  103080. }): string;
  103081. /** @hidden */
  103082. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  103083. repeatKey?: string;
  103084. removeAttributes?: boolean;
  103085. removeUniforms?: boolean;
  103086. removeVaryings?: boolean;
  103087. removeIfDef?: boolean;
  103088. replaceStrings?: {
  103089. search: RegExp;
  103090. replace: string;
  103091. }[];
  103092. }, storeKey?: string): void;
  103093. /** @hidden */
  103094. _registerTempVariable(name: string): boolean;
  103095. /** @hidden */
  103096. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  103097. /** @hidden */
  103098. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  103099. /** @hidden */
  103100. _emitFloat(value: number): string;
  103101. }
  103102. }
  103103. declare module BABYLON {
  103104. /**
  103105. * Helper class used to generate session unique ID
  103106. */
  103107. export class UniqueIdGenerator {
  103108. private static _UniqueIdCounter;
  103109. /**
  103110. * Gets an unique (relatively to the current scene) Id
  103111. */
  103112. static get UniqueId(): number;
  103113. }
  103114. }
  103115. declare module BABYLON {
  103116. /**
  103117. * Defines a block that can be used inside a node based material
  103118. */
  103119. export class NodeMaterialBlock {
  103120. private _buildId;
  103121. private _buildTarget;
  103122. private _target;
  103123. private _isFinalMerger;
  103124. private _isInput;
  103125. private _name;
  103126. protected _isUnique: boolean;
  103127. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  103128. inputsAreExclusive: boolean;
  103129. /** @hidden */
  103130. _codeVariableName: string;
  103131. /** @hidden */
  103132. _inputs: NodeMaterialConnectionPoint[];
  103133. /** @hidden */
  103134. _outputs: NodeMaterialConnectionPoint[];
  103135. /** @hidden */
  103136. _preparationId: number;
  103137. /**
  103138. * Gets the name of the block
  103139. */
  103140. get name(): string;
  103141. /**
  103142. * Sets the name of the block. Will check if the name is valid.
  103143. */
  103144. set name(newName: string);
  103145. /**
  103146. * Gets or sets the unique id of the node
  103147. */
  103148. uniqueId: number;
  103149. /**
  103150. * Gets or sets the comments associated with this block
  103151. */
  103152. comments: string;
  103153. /**
  103154. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  103155. */
  103156. get isUnique(): boolean;
  103157. /**
  103158. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  103159. */
  103160. get isFinalMerger(): boolean;
  103161. /**
  103162. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  103163. */
  103164. get isInput(): boolean;
  103165. /**
  103166. * Gets or sets the build Id
  103167. */
  103168. get buildId(): number;
  103169. set buildId(value: number);
  103170. /**
  103171. * Gets or sets the target of the block
  103172. */
  103173. get target(): NodeMaterialBlockTargets;
  103174. set target(value: NodeMaterialBlockTargets);
  103175. /**
  103176. * Gets the list of input points
  103177. */
  103178. get inputs(): NodeMaterialConnectionPoint[];
  103179. /** Gets the list of output points */
  103180. get outputs(): NodeMaterialConnectionPoint[];
  103181. /**
  103182. * Find an input by its name
  103183. * @param name defines the name of the input to look for
  103184. * @returns the input or null if not found
  103185. */
  103186. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  103187. /**
  103188. * Find an output by its name
  103189. * @param name defines the name of the outputto look for
  103190. * @returns the output or null if not found
  103191. */
  103192. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  103193. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  103194. visibleInInspector: boolean;
  103195. /**
  103196. * Creates a new NodeMaterialBlock
  103197. * @param name defines the block name
  103198. * @param target defines the target of that block (Vertex by default)
  103199. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  103200. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  103201. */
  103202. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  103203. /**
  103204. * Initialize the block and prepare the context for build
  103205. * @param state defines the state that will be used for the build
  103206. */
  103207. initialize(state: NodeMaterialBuildState): void;
  103208. /**
  103209. * Bind data to effect. Will only be called for blocks with isBindable === true
  103210. * @param effect defines the effect to bind data to
  103211. * @param nodeMaterial defines the hosting NodeMaterial
  103212. * @param mesh defines the mesh that will be rendered
  103213. * @param subMesh defines the submesh that will be rendered
  103214. */
  103215. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  103216. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  103217. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  103218. protected _writeFloat(value: number): string;
  103219. /**
  103220. * Gets the current class name e.g. "NodeMaterialBlock"
  103221. * @returns the class name
  103222. */
  103223. getClassName(): string;
  103224. /**
  103225. * Register a new input. Must be called inside a block constructor
  103226. * @param name defines the connection point name
  103227. * @param type defines the connection point type
  103228. * @param isOptional defines a boolean indicating that this input can be omitted
  103229. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  103230. * @param point an already created connection point. If not provided, create a new one
  103231. * @returns the current block
  103232. */
  103233. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  103234. /**
  103235. * Register a new output. Must be called inside a block constructor
  103236. * @param name defines the connection point name
  103237. * @param type defines the connection point type
  103238. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  103239. * @param point an already created connection point. If not provided, create a new one
  103240. * @returns the current block
  103241. */
  103242. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  103243. /**
  103244. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  103245. * @param forOutput defines an optional connection point to check compatibility with
  103246. * @returns the first available input or null
  103247. */
  103248. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  103249. /**
  103250. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  103251. * @param forBlock defines an optional block to check compatibility with
  103252. * @returns the first available input or null
  103253. */
  103254. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  103255. /**
  103256. * Gets the sibling of the given output
  103257. * @param current defines the current output
  103258. * @returns the next output in the list or null
  103259. */
  103260. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  103261. /**
  103262. * Connect current block with another block
  103263. * @param other defines the block to connect with
  103264. * @param options define the various options to help pick the right connections
  103265. * @returns the current block
  103266. */
  103267. connectTo(other: NodeMaterialBlock, options?: {
  103268. input?: string;
  103269. output?: string;
  103270. outputSwizzle?: string;
  103271. }): this | undefined;
  103272. protected _buildBlock(state: NodeMaterialBuildState): void;
  103273. /**
  103274. * Add uniforms, samplers and uniform buffers at compilation time
  103275. * @param state defines the state to update
  103276. * @param nodeMaterial defines the node material requesting the update
  103277. * @param defines defines the material defines to update
  103278. * @param uniformBuffers defines the list of uniform buffer names
  103279. */
  103280. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  103281. /**
  103282. * Add potential fallbacks if shader compilation fails
  103283. * @param mesh defines the mesh to be rendered
  103284. * @param fallbacks defines the current prioritized list of fallbacks
  103285. */
  103286. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  103287. /**
  103288. * Initialize defines for shader compilation
  103289. * @param mesh defines the mesh to be rendered
  103290. * @param nodeMaterial defines the node material requesting the update
  103291. * @param defines defines the material defines to update
  103292. * @param useInstances specifies that instances should be used
  103293. */
  103294. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  103295. /**
  103296. * Update defines for shader compilation
  103297. * @param mesh defines the mesh to be rendered
  103298. * @param nodeMaterial defines the node material requesting the update
  103299. * @param defines defines the material defines to update
  103300. * @param useInstances specifies that instances should be used
  103301. * @param subMesh defines which submesh to render
  103302. */
  103303. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  103304. /**
  103305. * Lets the block try to connect some inputs automatically
  103306. * @param material defines the hosting NodeMaterial
  103307. */
  103308. autoConfigure(material: NodeMaterial): void;
  103309. /**
  103310. * Function called when a block is declared as repeatable content generator
  103311. * @param vertexShaderState defines the current compilation state for the vertex shader
  103312. * @param fragmentShaderState defines the current compilation state for the fragment shader
  103313. * @param mesh defines the mesh to be rendered
  103314. * @param defines defines the material defines to update
  103315. */
  103316. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  103317. /**
  103318. * Checks if the block is ready
  103319. * @param mesh defines the mesh to be rendered
  103320. * @param nodeMaterial defines the node material requesting the update
  103321. * @param defines defines the material defines to update
  103322. * @param useInstances specifies that instances should be used
  103323. * @returns true if the block is ready
  103324. */
  103325. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  103326. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  103327. private _processBuild;
  103328. /**
  103329. * Validates the new name for the block node.
  103330. * @param newName the new name to be given to the node.
  103331. * @returns false if the name is a reserve word, else true.
  103332. */
  103333. validateBlockName(newName: string): boolean;
  103334. /**
  103335. * Compile the current node and generate the shader code
  103336. * @param state defines the current compilation state (uniforms, samplers, current string)
  103337. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  103338. * @returns true if already built
  103339. */
  103340. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  103341. protected _inputRename(name: string): string;
  103342. protected _outputRename(name: string): string;
  103343. protected _dumpPropertiesCode(): string;
  103344. /** @hidden */
  103345. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  103346. /** @hidden */
  103347. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  103348. /**
  103349. * Clone the current block to a new identical block
  103350. * @param scene defines the hosting scene
  103351. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103352. * @returns a copy of the current block
  103353. */
  103354. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  103355. /**
  103356. * Serializes this block in a JSON representation
  103357. * @returns the serialized block object
  103358. */
  103359. serialize(): any;
  103360. /** @hidden */
  103361. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103362. private _deserializePortDisplayNamesAndExposedOnFrame;
  103363. /**
  103364. * Release resources
  103365. */
  103366. dispose(): void;
  103367. }
  103368. }
  103369. declare module BABYLON {
  103370. /**
  103371. * Base class of materials working in push mode in babylon JS
  103372. * @hidden
  103373. */
  103374. export class PushMaterial extends Material {
  103375. protected _activeEffect: Effect;
  103376. protected _normalMatrix: Matrix;
  103377. constructor(name: string, scene: Scene);
  103378. getEffect(): Effect;
  103379. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103380. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  103381. /**
  103382. * Binds the given world matrix to the active effect
  103383. *
  103384. * @param world the matrix to bind
  103385. */
  103386. bindOnlyWorldMatrix(world: Matrix): void;
  103387. /**
  103388. * Binds the given normal matrix to the active effect
  103389. *
  103390. * @param normalMatrix the matrix to bind
  103391. */
  103392. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  103393. bind(world: Matrix, mesh?: Mesh): void;
  103394. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  103395. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  103396. }
  103397. }
  103398. declare module BABYLON {
  103399. /**
  103400. * Root class for all node material optimizers
  103401. */
  103402. export class NodeMaterialOptimizer {
  103403. /**
  103404. * Function used to optimize a NodeMaterial graph
  103405. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  103406. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  103407. */
  103408. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  103409. }
  103410. }
  103411. declare module BABYLON {
  103412. /**
  103413. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  103414. */
  103415. export class TransformBlock extends NodeMaterialBlock {
  103416. /**
  103417. * Defines the value to use to complement W value to transform it to a Vector4
  103418. */
  103419. complementW: number;
  103420. /**
  103421. * Defines the value to use to complement z value to transform it to a Vector4
  103422. */
  103423. complementZ: number;
  103424. /**
  103425. * Creates a new TransformBlock
  103426. * @param name defines the block name
  103427. */
  103428. constructor(name: string);
  103429. /**
  103430. * Gets the current class name
  103431. * @returns the class name
  103432. */
  103433. getClassName(): string;
  103434. /**
  103435. * Gets the vector input
  103436. */
  103437. get vector(): NodeMaterialConnectionPoint;
  103438. /**
  103439. * Gets the output component
  103440. */
  103441. get output(): NodeMaterialConnectionPoint;
  103442. /**
  103443. * Gets the xyz output component
  103444. */
  103445. get xyz(): NodeMaterialConnectionPoint;
  103446. /**
  103447. * Gets the matrix transform input
  103448. */
  103449. get transform(): NodeMaterialConnectionPoint;
  103450. protected _buildBlock(state: NodeMaterialBuildState): this;
  103451. /**
  103452. * Update defines for shader compilation
  103453. * @param mesh defines the mesh to be rendered
  103454. * @param nodeMaterial defines the node material requesting the update
  103455. * @param defines defines the material defines to update
  103456. * @param useInstances specifies that instances should be used
  103457. * @param subMesh defines which submesh to render
  103458. */
  103459. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  103460. serialize(): any;
  103461. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103462. protected _dumpPropertiesCode(): string;
  103463. }
  103464. }
  103465. declare module BABYLON {
  103466. /**
  103467. * Block used to output the vertex position
  103468. */
  103469. export class VertexOutputBlock extends NodeMaterialBlock {
  103470. /**
  103471. * Creates a new VertexOutputBlock
  103472. * @param name defines the block name
  103473. */
  103474. constructor(name: string);
  103475. /**
  103476. * Gets the current class name
  103477. * @returns the class name
  103478. */
  103479. getClassName(): string;
  103480. /**
  103481. * Gets the vector input component
  103482. */
  103483. get vector(): NodeMaterialConnectionPoint;
  103484. protected _buildBlock(state: NodeMaterialBuildState): this;
  103485. }
  103486. }
  103487. declare module BABYLON {
  103488. /**
  103489. * Block used to output the final color
  103490. */
  103491. export class FragmentOutputBlock extends NodeMaterialBlock {
  103492. /**
  103493. * Create a new FragmentOutputBlock
  103494. * @param name defines the block name
  103495. */
  103496. constructor(name: string);
  103497. /**
  103498. * Gets the current class name
  103499. * @returns the class name
  103500. */
  103501. getClassName(): string;
  103502. /**
  103503. * Gets the rgba input component
  103504. */
  103505. get rgba(): NodeMaterialConnectionPoint;
  103506. /**
  103507. * Gets the rgb input component
  103508. */
  103509. get rgb(): NodeMaterialConnectionPoint;
  103510. /**
  103511. * Gets the a input component
  103512. */
  103513. get a(): NodeMaterialConnectionPoint;
  103514. protected _buildBlock(state: NodeMaterialBuildState): this;
  103515. }
  103516. }
  103517. declare module BABYLON {
  103518. /**
  103519. * Block used for the particle ramp gradient section
  103520. */
  103521. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  103522. /**
  103523. * Create a new ParticleRampGradientBlock
  103524. * @param name defines the block name
  103525. */
  103526. constructor(name: string);
  103527. /**
  103528. * Gets the current class name
  103529. * @returns the class name
  103530. */
  103531. getClassName(): string;
  103532. /**
  103533. * Gets the color input component
  103534. */
  103535. get color(): NodeMaterialConnectionPoint;
  103536. /**
  103537. * Gets the rampColor output component
  103538. */
  103539. get rampColor(): NodeMaterialConnectionPoint;
  103540. /**
  103541. * Initialize the block and prepare the context for build
  103542. * @param state defines the state that will be used for the build
  103543. */
  103544. initialize(state: NodeMaterialBuildState): void;
  103545. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103546. }
  103547. }
  103548. declare module BABYLON {
  103549. /**
  103550. * Block used for the particle blend multiply section
  103551. */
  103552. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  103553. /**
  103554. * Create a new ParticleBlendMultiplyBlock
  103555. * @param name defines the block name
  103556. */
  103557. constructor(name: string);
  103558. /**
  103559. * Gets the current class name
  103560. * @returns the class name
  103561. */
  103562. getClassName(): string;
  103563. /**
  103564. * Gets the color input component
  103565. */
  103566. get color(): NodeMaterialConnectionPoint;
  103567. /**
  103568. * Gets the alphaTexture input component
  103569. */
  103570. get alphaTexture(): NodeMaterialConnectionPoint;
  103571. /**
  103572. * Gets the alphaColor input component
  103573. */
  103574. get alphaColor(): NodeMaterialConnectionPoint;
  103575. /**
  103576. * Gets the blendColor output component
  103577. */
  103578. get blendColor(): NodeMaterialConnectionPoint;
  103579. /**
  103580. * Initialize the block and prepare the context for build
  103581. * @param state defines the state that will be used for the build
  103582. */
  103583. initialize(state: NodeMaterialBuildState): void;
  103584. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103585. }
  103586. }
  103587. declare module BABYLON {
  103588. /**
  103589. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  103590. */
  103591. export class VectorMergerBlock extends NodeMaterialBlock {
  103592. /**
  103593. * Create a new VectorMergerBlock
  103594. * @param name defines the block name
  103595. */
  103596. constructor(name: string);
  103597. /**
  103598. * Gets the current class name
  103599. * @returns the class name
  103600. */
  103601. getClassName(): string;
  103602. /**
  103603. * Gets the xyz component (input)
  103604. */
  103605. get xyzIn(): NodeMaterialConnectionPoint;
  103606. /**
  103607. * Gets the xy component (input)
  103608. */
  103609. get xyIn(): NodeMaterialConnectionPoint;
  103610. /**
  103611. * Gets the x component (input)
  103612. */
  103613. get x(): NodeMaterialConnectionPoint;
  103614. /**
  103615. * Gets the y component (input)
  103616. */
  103617. get y(): NodeMaterialConnectionPoint;
  103618. /**
  103619. * Gets the z component (input)
  103620. */
  103621. get z(): NodeMaterialConnectionPoint;
  103622. /**
  103623. * Gets the w component (input)
  103624. */
  103625. get w(): NodeMaterialConnectionPoint;
  103626. /**
  103627. * Gets the xyzw component (output)
  103628. */
  103629. get xyzw(): NodeMaterialConnectionPoint;
  103630. /**
  103631. * Gets the xyz component (output)
  103632. */
  103633. get xyzOut(): NodeMaterialConnectionPoint;
  103634. /**
  103635. * Gets the xy component (output)
  103636. */
  103637. get xyOut(): NodeMaterialConnectionPoint;
  103638. /**
  103639. * Gets the xy component (output)
  103640. * @deprecated Please use xyOut instead.
  103641. */
  103642. get xy(): NodeMaterialConnectionPoint;
  103643. /**
  103644. * Gets the xyz component (output)
  103645. * @deprecated Please use xyzOut instead.
  103646. */
  103647. get xyz(): NodeMaterialConnectionPoint;
  103648. protected _buildBlock(state: NodeMaterialBuildState): this;
  103649. }
  103650. }
  103651. declare module BABYLON {
  103652. /**
  103653. * Block used to remap a float from a range to a new one
  103654. */
  103655. export class RemapBlock extends NodeMaterialBlock {
  103656. /**
  103657. * Gets or sets the source range
  103658. */
  103659. sourceRange: Vector2;
  103660. /**
  103661. * Gets or sets the target range
  103662. */
  103663. targetRange: Vector2;
  103664. /**
  103665. * Creates a new RemapBlock
  103666. * @param name defines the block name
  103667. */
  103668. constructor(name: string);
  103669. /**
  103670. * Gets the current class name
  103671. * @returns the class name
  103672. */
  103673. getClassName(): string;
  103674. /**
  103675. * Gets the input component
  103676. */
  103677. get input(): NodeMaterialConnectionPoint;
  103678. /**
  103679. * Gets the source min input component
  103680. */
  103681. get sourceMin(): NodeMaterialConnectionPoint;
  103682. /**
  103683. * Gets the source max input component
  103684. */
  103685. get sourceMax(): NodeMaterialConnectionPoint;
  103686. /**
  103687. * Gets the target min input component
  103688. */
  103689. get targetMin(): NodeMaterialConnectionPoint;
  103690. /**
  103691. * Gets the target max input component
  103692. */
  103693. get targetMax(): NodeMaterialConnectionPoint;
  103694. /**
  103695. * Gets the output component
  103696. */
  103697. get output(): NodeMaterialConnectionPoint;
  103698. protected _buildBlock(state: NodeMaterialBuildState): this;
  103699. protected _dumpPropertiesCode(): string;
  103700. serialize(): any;
  103701. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103702. }
  103703. }
  103704. declare module BABYLON {
  103705. /**
  103706. * Block used to multiply 2 values
  103707. */
  103708. export class MultiplyBlock extends NodeMaterialBlock {
  103709. /**
  103710. * Creates a new MultiplyBlock
  103711. * @param name defines the block name
  103712. */
  103713. constructor(name: string);
  103714. /**
  103715. * Gets the current class name
  103716. * @returns the class name
  103717. */
  103718. getClassName(): string;
  103719. /**
  103720. * Gets the left operand input component
  103721. */
  103722. get left(): NodeMaterialConnectionPoint;
  103723. /**
  103724. * Gets the right operand input component
  103725. */
  103726. get right(): NodeMaterialConnectionPoint;
  103727. /**
  103728. * Gets the output component
  103729. */
  103730. get output(): NodeMaterialConnectionPoint;
  103731. protected _buildBlock(state: NodeMaterialBuildState): this;
  103732. }
  103733. }
  103734. declare module BABYLON {
  103735. /**
  103736. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  103737. */
  103738. export class ColorSplitterBlock extends NodeMaterialBlock {
  103739. /**
  103740. * Create a new ColorSplitterBlock
  103741. * @param name defines the block name
  103742. */
  103743. constructor(name: string);
  103744. /**
  103745. * Gets the current class name
  103746. * @returns the class name
  103747. */
  103748. getClassName(): string;
  103749. /**
  103750. * Gets the rgba component (input)
  103751. */
  103752. get rgba(): NodeMaterialConnectionPoint;
  103753. /**
  103754. * Gets the rgb component (input)
  103755. */
  103756. get rgbIn(): NodeMaterialConnectionPoint;
  103757. /**
  103758. * Gets the rgb component (output)
  103759. */
  103760. get rgbOut(): NodeMaterialConnectionPoint;
  103761. /**
  103762. * Gets the r component (output)
  103763. */
  103764. get r(): NodeMaterialConnectionPoint;
  103765. /**
  103766. * Gets the g component (output)
  103767. */
  103768. get g(): NodeMaterialConnectionPoint;
  103769. /**
  103770. * Gets the b component (output)
  103771. */
  103772. get b(): NodeMaterialConnectionPoint;
  103773. /**
  103774. * Gets the a component (output)
  103775. */
  103776. get a(): NodeMaterialConnectionPoint;
  103777. protected _inputRename(name: string): string;
  103778. protected _outputRename(name: string): string;
  103779. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103780. }
  103781. }
  103782. declare module BABYLON {
  103783. /**
  103784. * Operations supported by the Trigonometry block
  103785. */
  103786. export enum TrigonometryBlockOperations {
  103787. /** Cos */
  103788. Cos = 0,
  103789. /** Sin */
  103790. Sin = 1,
  103791. /** Abs */
  103792. Abs = 2,
  103793. /** Exp */
  103794. Exp = 3,
  103795. /** Exp2 */
  103796. Exp2 = 4,
  103797. /** Round */
  103798. Round = 5,
  103799. /** Floor */
  103800. Floor = 6,
  103801. /** Ceiling */
  103802. Ceiling = 7,
  103803. /** Square root */
  103804. Sqrt = 8,
  103805. /** Log */
  103806. Log = 9,
  103807. /** Tangent */
  103808. Tan = 10,
  103809. /** Arc tangent */
  103810. ArcTan = 11,
  103811. /** Arc cosinus */
  103812. ArcCos = 12,
  103813. /** Arc sinus */
  103814. ArcSin = 13,
  103815. /** Fraction */
  103816. Fract = 14,
  103817. /** Sign */
  103818. Sign = 15,
  103819. /** To radians (from degrees) */
  103820. Radians = 16,
  103821. /** To degrees (from radians) */
  103822. Degrees = 17
  103823. }
  103824. /**
  103825. * Block used to apply trigonometry operation to floats
  103826. */
  103827. export class TrigonometryBlock extends NodeMaterialBlock {
  103828. /**
  103829. * Gets or sets the operation applied by the block
  103830. */
  103831. operation: TrigonometryBlockOperations;
  103832. /**
  103833. * Creates a new TrigonometryBlock
  103834. * @param name defines the block name
  103835. */
  103836. constructor(name: string);
  103837. /**
  103838. * Gets the current class name
  103839. * @returns the class name
  103840. */
  103841. getClassName(): string;
  103842. /**
  103843. * Gets the input component
  103844. */
  103845. get input(): NodeMaterialConnectionPoint;
  103846. /**
  103847. * Gets the output component
  103848. */
  103849. get output(): NodeMaterialConnectionPoint;
  103850. protected _buildBlock(state: NodeMaterialBuildState): this;
  103851. serialize(): any;
  103852. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103853. protected _dumpPropertiesCode(): string;
  103854. }
  103855. }
  103856. declare module BABYLON {
  103857. /**
  103858. * Interface used to configure the node material editor
  103859. */
  103860. export interface INodeMaterialEditorOptions {
  103861. /** Define the URl to load node editor script */
  103862. editorURL?: string;
  103863. }
  103864. /** @hidden */
  103865. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103866. NORMAL: boolean;
  103867. TANGENT: boolean;
  103868. UV1: boolean;
  103869. /** BONES */
  103870. NUM_BONE_INFLUENCERS: number;
  103871. BonesPerMesh: number;
  103872. BONETEXTURE: boolean;
  103873. /** MORPH TARGETS */
  103874. MORPHTARGETS: boolean;
  103875. MORPHTARGETS_NORMAL: boolean;
  103876. MORPHTARGETS_TANGENT: boolean;
  103877. MORPHTARGETS_UV: boolean;
  103878. NUM_MORPH_INFLUENCERS: number;
  103879. /** IMAGE PROCESSING */
  103880. IMAGEPROCESSING: boolean;
  103881. VIGNETTE: boolean;
  103882. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103883. VIGNETTEBLENDMODEOPAQUE: boolean;
  103884. TONEMAPPING: boolean;
  103885. TONEMAPPING_ACES: boolean;
  103886. CONTRAST: boolean;
  103887. EXPOSURE: boolean;
  103888. COLORCURVES: boolean;
  103889. COLORGRADING: boolean;
  103890. COLORGRADING3D: boolean;
  103891. SAMPLER3DGREENDEPTH: boolean;
  103892. SAMPLER3DBGRMAP: boolean;
  103893. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103894. /** MISC. */
  103895. BUMPDIRECTUV: number;
  103896. constructor();
  103897. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  103898. }
  103899. /**
  103900. * Class used to configure NodeMaterial
  103901. */
  103902. export interface INodeMaterialOptions {
  103903. /**
  103904. * Defines if blocks should emit comments
  103905. */
  103906. emitComments: boolean;
  103907. }
  103908. /**
  103909. * Class used to create a node based material built by assembling shader blocks
  103910. */
  103911. export class NodeMaterial extends PushMaterial {
  103912. private static _BuildIdGenerator;
  103913. private _options;
  103914. private _vertexCompilationState;
  103915. private _fragmentCompilationState;
  103916. private _sharedData;
  103917. private _buildId;
  103918. private _buildWasSuccessful;
  103919. private _cachedWorldViewMatrix;
  103920. private _cachedWorldViewProjectionMatrix;
  103921. private _optimizers;
  103922. private _animationFrame;
  103923. /** Define the Url to load node editor script */
  103924. static EditorURL: string;
  103925. /** Define the Url to load snippets */
  103926. static SnippetUrl: string;
  103927. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  103928. static IgnoreTexturesAtLoadTime: boolean;
  103929. private BJSNODEMATERIALEDITOR;
  103930. /** Get the inspector from bundle or global */
  103931. private _getGlobalNodeMaterialEditor;
  103932. /**
  103933. * Snippet ID if the material was created from the snippet server
  103934. */
  103935. snippetId: string;
  103936. /**
  103937. * Gets or sets data used by visual editor
  103938. * @see https://nme.babylonjs.com
  103939. */
  103940. editorData: any;
  103941. /**
  103942. * 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)
  103943. */
  103944. ignoreAlpha: boolean;
  103945. /**
  103946. * Defines the maximum number of lights that can be used in the material
  103947. */
  103948. maxSimultaneousLights: number;
  103949. /**
  103950. * Observable raised when the material is built
  103951. */
  103952. onBuildObservable: Observable<NodeMaterial>;
  103953. /**
  103954. * Gets or sets the root nodes of the material vertex shader
  103955. */
  103956. _vertexOutputNodes: NodeMaterialBlock[];
  103957. /**
  103958. * Gets or sets the root nodes of the material fragment (pixel) shader
  103959. */
  103960. _fragmentOutputNodes: NodeMaterialBlock[];
  103961. /** Gets or sets options to control the node material overall behavior */
  103962. get options(): INodeMaterialOptions;
  103963. set options(options: INodeMaterialOptions);
  103964. /**
  103965. * Default configuration related to image processing available in the standard Material.
  103966. */
  103967. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103968. /**
  103969. * Gets the image processing configuration used either in this material.
  103970. */
  103971. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103972. /**
  103973. * Sets the Default image processing configuration used either in the this material.
  103974. *
  103975. * If sets to null, the scene one is in use.
  103976. */
  103977. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103978. /**
  103979. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  103980. */
  103981. attachedBlocks: NodeMaterialBlock[];
  103982. /**
  103983. * Specifies the mode of the node material
  103984. * @hidden
  103985. */
  103986. _mode: NodeMaterialModes;
  103987. /**
  103988. * Gets the mode property
  103989. */
  103990. get mode(): NodeMaterialModes;
  103991. /**
  103992. * A free comment about the material
  103993. */
  103994. comment: string;
  103995. /**
  103996. * Create a new node based material
  103997. * @param name defines the material name
  103998. * @param scene defines the hosting scene
  103999. * @param options defines creation option
  104000. */
  104001. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  104002. /**
  104003. * Gets the current class name of the material e.g. "NodeMaterial"
  104004. * @returns the class name
  104005. */
  104006. getClassName(): string;
  104007. /**
  104008. * Keep track of the image processing observer to allow dispose and replace.
  104009. */
  104010. private _imageProcessingObserver;
  104011. /**
  104012. * Attaches a new image processing configuration to the Standard Material.
  104013. * @param configuration
  104014. */
  104015. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104016. /**
  104017. * Get a block by its name
  104018. * @param name defines the name of the block to retrieve
  104019. * @returns the required block or null if not found
  104020. */
  104021. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  104022. /**
  104023. * Get a block by its name
  104024. * @param predicate defines the predicate used to find the good candidate
  104025. * @returns the required block or null if not found
  104026. */
  104027. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  104028. /**
  104029. * Get an input block by its name
  104030. * @param predicate defines the predicate used to find the good candidate
  104031. * @returns the required input block or null if not found
  104032. */
  104033. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  104034. /**
  104035. * Gets the list of input blocks attached to this material
  104036. * @returns an array of InputBlocks
  104037. */
  104038. getInputBlocks(): InputBlock[];
  104039. /**
  104040. * Adds a new optimizer to the list of optimizers
  104041. * @param optimizer defines the optimizers to add
  104042. * @returns the current material
  104043. */
  104044. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  104045. /**
  104046. * Remove an optimizer from the list of optimizers
  104047. * @param optimizer defines the optimizers to remove
  104048. * @returns the current material
  104049. */
  104050. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  104051. /**
  104052. * Add a new block to the list of output nodes
  104053. * @param node defines the node to add
  104054. * @returns the current material
  104055. */
  104056. addOutputNode(node: NodeMaterialBlock): this;
  104057. /**
  104058. * Remove a block from the list of root nodes
  104059. * @param node defines the node to remove
  104060. * @returns the current material
  104061. */
  104062. removeOutputNode(node: NodeMaterialBlock): this;
  104063. private _addVertexOutputNode;
  104064. private _removeVertexOutputNode;
  104065. private _addFragmentOutputNode;
  104066. private _removeFragmentOutputNode;
  104067. /**
  104068. * Specifies if the material will require alpha blending
  104069. * @returns a boolean specifying if alpha blending is needed
  104070. */
  104071. needAlphaBlending(): boolean;
  104072. /**
  104073. * Specifies if this material should be rendered in alpha test mode
  104074. * @returns a boolean specifying if an alpha test is needed.
  104075. */
  104076. needAlphaTesting(): boolean;
  104077. private _initializeBlock;
  104078. private _resetDualBlocks;
  104079. /**
  104080. * Remove a block from the current node material
  104081. * @param block defines the block to remove
  104082. */
  104083. removeBlock(block: NodeMaterialBlock): void;
  104084. /**
  104085. * Build the material and generates the inner effect
  104086. * @param verbose defines if the build should log activity
  104087. */
  104088. build(verbose?: boolean): void;
  104089. /**
  104090. * Runs an otpimization phase to try to improve the shader code
  104091. */
  104092. optimize(): void;
  104093. private _prepareDefinesForAttributes;
  104094. /**
  104095. * Create a post process from the material
  104096. * @param camera The camera to apply the render pass to.
  104097. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104099. * @param engine The engine which the post process will be applied. (default: current engine)
  104100. * @param reusable If the post process can be reused on the same frame. (default: false)
  104101. * @param textureType Type of textures used when performing the post process. (default: 0)
  104102. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  104103. * @returns the post process created
  104104. */
  104105. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  104106. /**
  104107. * Create the post process effect from the material
  104108. * @param postProcess The post process to create the effect for
  104109. */
  104110. createEffectForPostProcess(postProcess: PostProcess): void;
  104111. private _createEffectForPostProcess;
  104112. /**
  104113. * Create a new procedural texture based on this node material
  104114. * @param size defines the size of the texture
  104115. * @param scene defines the hosting scene
  104116. * @returns the new procedural texture attached to this node material
  104117. */
  104118. createProceduralTexture(size: number | {
  104119. width: number;
  104120. height: number;
  104121. layers?: number;
  104122. }, scene: Scene): Nullable<ProceduralTexture>;
  104123. private _createEffectForParticles;
  104124. private _checkInternals;
  104125. /**
  104126. * Create the effect to be used as the custom effect for a particle system
  104127. * @param particleSystem Particle system to create the effect for
  104128. * @param onCompiled defines a function to call when the effect creation is successful
  104129. * @param onError defines a function to call when the effect creation has failed
  104130. */
  104131. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104132. private _processDefines;
  104133. /**
  104134. * Get if the submesh is ready to be used and all its information available.
  104135. * Child classes can use it to update shaders
  104136. * @param mesh defines the mesh to check
  104137. * @param subMesh defines which submesh to check
  104138. * @param useInstances specifies that instances should be used
  104139. * @returns a boolean indicating that the submesh is ready or not
  104140. */
  104141. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104142. /**
  104143. * Get a string representing the shaders built by the current node graph
  104144. */
  104145. get compiledShaders(): string;
  104146. /**
  104147. * Binds the world matrix to the material
  104148. * @param world defines the world transformation matrix
  104149. */
  104150. bindOnlyWorldMatrix(world: Matrix): void;
  104151. /**
  104152. * Binds the submesh to this material by preparing the effect and shader to draw
  104153. * @param world defines the world transformation matrix
  104154. * @param mesh defines the mesh containing the submesh
  104155. * @param subMesh defines the submesh to bind the material to
  104156. */
  104157. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104158. /**
  104159. * Gets the active textures from the material
  104160. * @returns an array of textures
  104161. */
  104162. getActiveTextures(): BaseTexture[];
  104163. /**
  104164. * Gets the list of texture blocks
  104165. * @returns an array of texture blocks
  104166. */
  104167. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  104168. /**
  104169. * Specifies if the material uses a texture
  104170. * @param texture defines the texture to check against the material
  104171. * @returns a boolean specifying if the material uses the texture
  104172. */
  104173. hasTexture(texture: BaseTexture): boolean;
  104174. /**
  104175. * Disposes the material
  104176. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104177. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104178. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  104179. */
  104180. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  104181. /** Creates the node editor window. */
  104182. private _createNodeEditor;
  104183. /**
  104184. * Launch the node material editor
  104185. * @param config Define the configuration of the editor
  104186. * @return a promise fulfilled when the node editor is visible
  104187. */
  104188. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  104189. /**
  104190. * Clear the current material
  104191. */
  104192. clear(): void;
  104193. /**
  104194. * Clear the current material and set it to a default state
  104195. */
  104196. setToDefault(): void;
  104197. /**
  104198. * Clear the current material and set it to a default state for post process
  104199. */
  104200. setToDefaultPostProcess(): void;
  104201. /**
  104202. * Clear the current material and set it to a default state for procedural texture
  104203. */
  104204. setToDefaultProceduralTexture(): void;
  104205. /**
  104206. * Clear the current material and set it to a default state for particle
  104207. */
  104208. setToDefaultParticle(): void;
  104209. /**
  104210. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  104211. * @param url defines the url to load from
  104212. * @returns a promise that will fullfil when the material is fully loaded
  104213. */
  104214. loadAsync(url: string): Promise<void>;
  104215. private _gatherBlocks;
  104216. /**
  104217. * Generate a string containing the code declaration required to create an equivalent of this material
  104218. * @returns a string
  104219. */
  104220. generateCode(): string;
  104221. /**
  104222. * Serializes this material in a JSON representation
  104223. * @returns the serialized material object
  104224. */
  104225. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  104226. private _restoreConnections;
  104227. /**
  104228. * Clear the current graph and load a new one from a serialization object
  104229. * @param source defines the JSON representation of the material
  104230. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104231. * @param merge defines whether or not the source must be merged or replace the current content
  104232. */
  104233. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  104234. /**
  104235. * Makes a duplicate of the current material.
  104236. * @param name - name to use for the new material.
  104237. */
  104238. clone(name: string): NodeMaterial;
  104239. /**
  104240. * Creates a node material from parsed material data
  104241. * @param source defines the JSON representation of the material
  104242. * @param scene defines the hosting scene
  104243. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104244. * @returns a new node material
  104245. */
  104246. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  104247. /**
  104248. * Creates a node material from a snippet saved in a remote file
  104249. * @param name defines the name of the material to create
  104250. * @param url defines the url to load from
  104251. * @param scene defines the hosting scene
  104252. * @returns a promise that will resolve to the new node material
  104253. */
  104254. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  104255. /**
  104256. * Creates a node material from a snippet saved by the node material editor
  104257. * @param snippetId defines the snippet to load
  104258. * @param scene defines the hosting scene
  104259. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104260. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  104261. * @returns a promise that will resolve to the new node material
  104262. */
  104263. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  104264. /**
  104265. * Creates a new node material set to default basic configuration
  104266. * @param name defines the name of the material
  104267. * @param scene defines the hosting scene
  104268. * @returns a new NodeMaterial
  104269. */
  104270. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  104271. }
  104272. }
  104273. declare module BABYLON {
  104274. interface ThinEngine {
  104275. /**
  104276. * Unbind a list of render target textures from the webGL context
  104277. * This is used only when drawBuffer extension or webGL2 are active
  104278. * @param textures defines the render target textures to unbind
  104279. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104280. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104281. */
  104282. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104283. /**
  104284. * Create a multi render target texture
  104285. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  104286. * @param size defines the size of the texture
  104287. * @param options defines the creation options
  104288. * @returns the cube texture as an InternalTexture
  104289. */
  104290. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104291. /**
  104292. * Update the sample count for a given multiple render target texture
  104293. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104294. * @param textures defines the textures to update
  104295. * @param samples defines the sample count to set
  104296. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104297. */
  104298. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104299. /**
  104300. * Select a subsets of attachments to draw to.
  104301. * @param attachments gl attachments
  104302. */
  104303. bindAttachments(attachments: number[]): void;
  104304. /**
  104305. * Creates a layout object to draw/clear on specific textures in a MRT
  104306. * @param textureStatus textureStatus[i] indicates if the i-th is active
  104307. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  104308. */
  104309. buildTextureLayout(textureStatus: boolean[]): number[];
  104310. /**
  104311. * Restores the webgl state to only draw on the main color attachment
  104312. */
  104313. restoreSingleAttachment(): void;
  104314. }
  104315. }
  104316. declare module BABYLON {
  104317. /**
  104318. * Creation options of the multi render target texture.
  104319. */
  104320. export interface IMultiRenderTargetOptions {
  104321. /**
  104322. * Define if the texture needs to create mip maps after render.
  104323. */
  104324. generateMipMaps?: boolean;
  104325. /**
  104326. * Define the types of all the draw buffers we want to create
  104327. */
  104328. types?: number[];
  104329. /**
  104330. * Define the sampling modes of all the draw buffers we want to create
  104331. */
  104332. samplingModes?: number[];
  104333. /**
  104334. * Define if a depth buffer is required
  104335. */
  104336. generateDepthBuffer?: boolean;
  104337. /**
  104338. * Define if a stencil buffer is required
  104339. */
  104340. generateStencilBuffer?: boolean;
  104341. /**
  104342. * Define if a depth texture is required instead of a depth buffer
  104343. */
  104344. generateDepthTexture?: boolean;
  104345. /**
  104346. * Define the number of desired draw buffers
  104347. */
  104348. textureCount?: number;
  104349. /**
  104350. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104351. */
  104352. doNotChangeAspectRatio?: boolean;
  104353. /**
  104354. * Define the default type of the buffers we are creating
  104355. */
  104356. defaultType?: number;
  104357. }
  104358. /**
  104359. * A multi render target, like a render target provides the ability to render to a texture.
  104360. * Unlike the render target, it can render to several draw buffers in one draw.
  104361. * This is specially interesting in deferred rendering or for any effects requiring more than
  104362. * just one color from a single pass.
  104363. */
  104364. export class MultiRenderTarget extends RenderTargetTexture {
  104365. private _internalTextures;
  104366. private _textures;
  104367. private _multiRenderTargetOptions;
  104368. private _count;
  104369. /**
  104370. * Get if draw buffers are currently supported by the used hardware and browser.
  104371. */
  104372. get isSupported(): boolean;
  104373. /**
  104374. * Get the list of textures generated by the multi render target.
  104375. */
  104376. get textures(): Texture[];
  104377. /**
  104378. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  104379. */
  104380. get count(): number;
  104381. /**
  104382. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104383. */
  104384. get depthTexture(): Texture;
  104385. /**
  104386. * Set the wrapping mode on U of all the textures we are rendering to.
  104387. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104388. */
  104389. set wrapU(wrap: number);
  104390. /**
  104391. * Set the wrapping mode on V of all the textures we are rendering to.
  104392. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104393. */
  104394. set wrapV(wrap: number);
  104395. /**
  104396. * Instantiate a new multi render target texture.
  104397. * A multi render target, like a render target provides the ability to render to a texture.
  104398. * Unlike the render target, it can render to several draw buffers in one draw.
  104399. * This is specially interesting in deferred rendering or for any effects requiring more than
  104400. * just one color from a single pass.
  104401. * @param name Define the name of the texture
  104402. * @param size Define the size of the buffers to render to
  104403. * @param count Define the number of target we are rendering into
  104404. * @param scene Define the scene the texture belongs to
  104405. * @param options Define the options used to create the multi render target
  104406. */
  104407. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104408. private _initTypes;
  104409. /** @hidden */
  104410. _rebuild(forceFullRebuild?: boolean): void;
  104411. private _createInternalTextures;
  104412. private _createTextures;
  104413. /**
  104414. * Replaces a texture within the MRT.
  104415. * @param texture The new texture to insert in the MRT
  104416. * @param index The index of the texture to replace
  104417. */
  104418. replaceTexture(texture: Texture, index: number): void;
  104419. /**
  104420. * Define the number of samples used if MSAA is enabled.
  104421. */
  104422. get samples(): number;
  104423. set samples(value: number);
  104424. /**
  104425. * Resize all the textures in the multi render target.
  104426. * Be careful as it will recreate all the data in the new texture.
  104427. * @param size Define the new size
  104428. */
  104429. resize(size: any): void;
  104430. /**
  104431. * Changes the number of render targets in this MRT
  104432. * Be careful as it will recreate all the data in the new texture.
  104433. * @param count new texture count
  104434. * @param options Specifies texture types and sampling modes for new textures
  104435. */
  104436. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  104437. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104438. /**
  104439. * Dispose the render targets and their associated resources
  104440. */
  104441. dispose(): void;
  104442. /**
  104443. * Release all the underlying texture used as draw buffers.
  104444. */
  104445. releaseInternalTextures(): void;
  104446. }
  104447. }
  104448. declare module BABYLON {
  104449. /** @hidden */
  104450. export var imageProcessingPixelShader: {
  104451. name: string;
  104452. shader: string;
  104453. };
  104454. }
  104455. declare module BABYLON {
  104456. /**
  104457. * ImageProcessingPostProcess
  104458. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104459. */
  104460. export class ImageProcessingPostProcess extends PostProcess {
  104461. /**
  104462. * Default configuration related to image processing available in the PBR Material.
  104463. */
  104464. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104465. /**
  104466. * Gets the image processing configuration used either in this material.
  104467. */
  104468. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104469. /**
  104470. * Sets the Default image processing configuration used either in the this material.
  104471. *
  104472. * If sets to null, the scene one is in use.
  104473. */
  104474. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104475. /**
  104476. * Keep track of the image processing observer to allow dispose and replace.
  104477. */
  104478. private _imageProcessingObserver;
  104479. /**
  104480. * Attaches a new image processing configuration to the PBR Material.
  104481. * @param configuration
  104482. */
  104483. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104484. /**
  104485. * If the post process is supported.
  104486. */
  104487. get isSupported(): boolean;
  104488. /**
  104489. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104490. */
  104491. get colorCurves(): Nullable<ColorCurves>;
  104492. /**
  104493. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104494. */
  104495. set colorCurves(value: Nullable<ColorCurves>);
  104496. /**
  104497. * Gets wether the color curves effect is enabled.
  104498. */
  104499. get colorCurvesEnabled(): boolean;
  104500. /**
  104501. * Sets wether the color curves effect is enabled.
  104502. */
  104503. set colorCurvesEnabled(value: boolean);
  104504. /**
  104505. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104506. */
  104507. get colorGradingTexture(): Nullable<BaseTexture>;
  104508. /**
  104509. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104510. */
  104511. set colorGradingTexture(value: Nullable<BaseTexture>);
  104512. /**
  104513. * Gets wether the color grading effect is enabled.
  104514. */
  104515. get colorGradingEnabled(): boolean;
  104516. /**
  104517. * Gets wether the color grading effect is enabled.
  104518. */
  104519. set colorGradingEnabled(value: boolean);
  104520. /**
  104521. * Gets exposure used in the effect.
  104522. */
  104523. get exposure(): number;
  104524. /**
  104525. * Sets exposure used in the effect.
  104526. */
  104527. set exposure(value: number);
  104528. /**
  104529. * Gets wether tonemapping is enabled or not.
  104530. */
  104531. get toneMappingEnabled(): boolean;
  104532. /**
  104533. * Sets wether tonemapping is enabled or not
  104534. */
  104535. set toneMappingEnabled(value: boolean);
  104536. /**
  104537. * Gets the type of tone mapping effect.
  104538. */
  104539. get toneMappingType(): number;
  104540. /**
  104541. * Sets the type of tone mapping effect.
  104542. */
  104543. set toneMappingType(value: number);
  104544. /**
  104545. * Gets contrast used in the effect.
  104546. */
  104547. get contrast(): number;
  104548. /**
  104549. * Sets contrast used in the effect.
  104550. */
  104551. set contrast(value: number);
  104552. /**
  104553. * Gets Vignette stretch size.
  104554. */
  104555. get vignetteStretch(): number;
  104556. /**
  104557. * Sets Vignette stretch size.
  104558. */
  104559. set vignetteStretch(value: number);
  104560. /**
  104561. * Gets Vignette centre X Offset.
  104562. */
  104563. get vignetteCentreX(): number;
  104564. /**
  104565. * Sets Vignette centre X Offset.
  104566. */
  104567. set vignetteCentreX(value: number);
  104568. /**
  104569. * Gets Vignette centre Y Offset.
  104570. */
  104571. get vignetteCentreY(): number;
  104572. /**
  104573. * Sets Vignette centre Y Offset.
  104574. */
  104575. set vignetteCentreY(value: number);
  104576. /**
  104577. * Gets Vignette weight or intensity of the vignette effect.
  104578. */
  104579. get vignetteWeight(): number;
  104580. /**
  104581. * Sets Vignette weight or intensity of the vignette effect.
  104582. */
  104583. set vignetteWeight(value: number);
  104584. /**
  104585. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104586. * if vignetteEnabled is set to true.
  104587. */
  104588. get vignetteColor(): Color4;
  104589. /**
  104590. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104591. * if vignetteEnabled is set to true.
  104592. */
  104593. set vignetteColor(value: Color4);
  104594. /**
  104595. * Gets Camera field of view used by the Vignette effect.
  104596. */
  104597. get vignetteCameraFov(): number;
  104598. /**
  104599. * Sets Camera field of view used by the Vignette effect.
  104600. */
  104601. set vignetteCameraFov(value: number);
  104602. /**
  104603. * Gets the vignette blend mode allowing different kind of effect.
  104604. */
  104605. get vignetteBlendMode(): number;
  104606. /**
  104607. * Sets the vignette blend mode allowing different kind of effect.
  104608. */
  104609. set vignetteBlendMode(value: number);
  104610. /**
  104611. * Gets wether the vignette effect is enabled.
  104612. */
  104613. get vignetteEnabled(): boolean;
  104614. /**
  104615. * Sets wether the vignette effect is enabled.
  104616. */
  104617. set vignetteEnabled(value: boolean);
  104618. private _fromLinearSpace;
  104619. /**
  104620. * Gets wether the input of the processing is in Gamma or Linear Space.
  104621. */
  104622. get fromLinearSpace(): boolean;
  104623. /**
  104624. * Sets wether the input of the processing is in Gamma or Linear Space.
  104625. */
  104626. set fromLinearSpace(value: boolean);
  104627. /**
  104628. * Defines cache preventing GC.
  104629. */
  104630. private _defines;
  104631. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104632. /**
  104633. * "ImageProcessingPostProcess"
  104634. * @returns "ImageProcessingPostProcess"
  104635. */
  104636. getClassName(): string;
  104637. /**
  104638. * @hidden
  104639. */
  104640. _updateParameters(): void;
  104641. dispose(camera?: Camera): void;
  104642. }
  104643. }
  104644. declare module BABYLON {
  104645. /**
  104646. * Interface for defining prepass effects in the prepass post-process pipeline
  104647. */
  104648. export interface PrePassEffectConfiguration {
  104649. /**
  104650. * Name of the effect
  104651. */
  104652. name: string;
  104653. /**
  104654. * Post process to attach for this effect
  104655. */
  104656. postProcess?: PostProcess;
  104657. /**
  104658. * Textures required in the MRT
  104659. */
  104660. texturesRequired: number[];
  104661. /**
  104662. * Is the effect enabled
  104663. */
  104664. enabled: boolean;
  104665. /**
  104666. * Disposes the effect configuration
  104667. */
  104668. dispose?: () => void;
  104669. /**
  104670. * Creates the associated post process
  104671. */
  104672. createPostProcess?: () => PostProcess;
  104673. }
  104674. }
  104675. declare module BABYLON {
  104676. /**
  104677. * Options to be used when creating a FresnelParameters.
  104678. */
  104679. export type IFresnelParametersCreationOptions = {
  104680. /**
  104681. * Define the color used on edges (grazing angle)
  104682. */
  104683. leftColor?: Color3;
  104684. /**
  104685. * Define the color used on center
  104686. */
  104687. rightColor?: Color3;
  104688. /**
  104689. * Define bias applied to computed fresnel term
  104690. */
  104691. bias?: number;
  104692. /**
  104693. * Defined the power exponent applied to fresnel term
  104694. */
  104695. power?: number;
  104696. /**
  104697. * Define if the fresnel effect is enable or not.
  104698. */
  104699. isEnabled?: boolean;
  104700. };
  104701. /**
  104702. * Serialized format for FresnelParameters.
  104703. */
  104704. export type IFresnelParametersSerialized = {
  104705. /**
  104706. * Define the color used on edges (grazing angle) [as an array]
  104707. */
  104708. leftColor: number[];
  104709. /**
  104710. * Define the color used on center [as an array]
  104711. */
  104712. rightColor: number[];
  104713. /**
  104714. * Define bias applied to computed fresnel term
  104715. */
  104716. bias: number;
  104717. /**
  104718. * Defined the power exponent applied to fresnel term
  104719. */
  104720. power?: number;
  104721. /**
  104722. * Define if the fresnel effect is enable or not.
  104723. */
  104724. isEnabled: boolean;
  104725. };
  104726. /**
  104727. * This represents all the required information to add a fresnel effect on a material:
  104728. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104729. */
  104730. export class FresnelParameters {
  104731. private _isEnabled;
  104732. /**
  104733. * Define if the fresnel effect is enable or not.
  104734. */
  104735. get isEnabled(): boolean;
  104736. set isEnabled(value: boolean);
  104737. /**
  104738. * Define the color used on edges (grazing angle)
  104739. */
  104740. leftColor: Color3;
  104741. /**
  104742. * Define the color used on center
  104743. */
  104744. rightColor: Color3;
  104745. /**
  104746. * Define bias applied to computed fresnel term
  104747. */
  104748. bias: number;
  104749. /**
  104750. * Defined the power exponent applied to fresnel term
  104751. */
  104752. power: number;
  104753. /**
  104754. * Creates a new FresnelParameters object.
  104755. *
  104756. * @param options provide your own settings to optionally to override defaults
  104757. */
  104758. constructor(options?: IFresnelParametersCreationOptions);
  104759. /**
  104760. * Clones the current fresnel and its valuues
  104761. * @returns a clone fresnel configuration
  104762. */
  104763. clone(): FresnelParameters;
  104764. /**
  104765. * Determines equality between FresnelParameters objects
  104766. * @param otherFresnelParameters defines the second operand
  104767. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  104768. */
  104769. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  104770. /**
  104771. * Serializes the current fresnel parameters to a JSON representation.
  104772. * @return the JSON serialization
  104773. */
  104774. serialize(): IFresnelParametersSerialized;
  104775. /**
  104776. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  104777. * @param parsedFresnelParameters Define the JSON representation
  104778. * @returns the parsed parameters
  104779. */
  104780. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  104781. }
  104782. }
  104783. declare module BABYLON {
  104784. /**
  104785. * This groups all the flags used to control the materials channel.
  104786. */
  104787. export class MaterialFlags {
  104788. private static _DiffuseTextureEnabled;
  104789. /**
  104790. * Are diffuse textures enabled in the application.
  104791. */
  104792. static get DiffuseTextureEnabled(): boolean;
  104793. static set DiffuseTextureEnabled(value: boolean);
  104794. private static _DetailTextureEnabled;
  104795. /**
  104796. * Are detail textures enabled in the application.
  104797. */
  104798. static get DetailTextureEnabled(): boolean;
  104799. static set DetailTextureEnabled(value: boolean);
  104800. private static _AmbientTextureEnabled;
  104801. /**
  104802. * Are ambient textures enabled in the application.
  104803. */
  104804. static get AmbientTextureEnabled(): boolean;
  104805. static set AmbientTextureEnabled(value: boolean);
  104806. private static _OpacityTextureEnabled;
  104807. /**
  104808. * Are opacity textures enabled in the application.
  104809. */
  104810. static get OpacityTextureEnabled(): boolean;
  104811. static set OpacityTextureEnabled(value: boolean);
  104812. private static _ReflectionTextureEnabled;
  104813. /**
  104814. * Are reflection textures enabled in the application.
  104815. */
  104816. static get ReflectionTextureEnabled(): boolean;
  104817. static set ReflectionTextureEnabled(value: boolean);
  104818. private static _EmissiveTextureEnabled;
  104819. /**
  104820. * Are emissive textures enabled in the application.
  104821. */
  104822. static get EmissiveTextureEnabled(): boolean;
  104823. static set EmissiveTextureEnabled(value: boolean);
  104824. private static _SpecularTextureEnabled;
  104825. /**
  104826. * Are specular textures enabled in the application.
  104827. */
  104828. static get SpecularTextureEnabled(): boolean;
  104829. static set SpecularTextureEnabled(value: boolean);
  104830. private static _BumpTextureEnabled;
  104831. /**
  104832. * Are bump textures enabled in the application.
  104833. */
  104834. static get BumpTextureEnabled(): boolean;
  104835. static set BumpTextureEnabled(value: boolean);
  104836. private static _LightmapTextureEnabled;
  104837. /**
  104838. * Are lightmap textures enabled in the application.
  104839. */
  104840. static get LightmapTextureEnabled(): boolean;
  104841. static set LightmapTextureEnabled(value: boolean);
  104842. private static _RefractionTextureEnabled;
  104843. /**
  104844. * Are refraction textures enabled in the application.
  104845. */
  104846. static get RefractionTextureEnabled(): boolean;
  104847. static set RefractionTextureEnabled(value: boolean);
  104848. private static _ColorGradingTextureEnabled;
  104849. /**
  104850. * Are color grading textures enabled in the application.
  104851. */
  104852. static get ColorGradingTextureEnabled(): boolean;
  104853. static set ColorGradingTextureEnabled(value: boolean);
  104854. private static _FresnelEnabled;
  104855. /**
  104856. * Are fresnels enabled in the application.
  104857. */
  104858. static get FresnelEnabled(): boolean;
  104859. static set FresnelEnabled(value: boolean);
  104860. private static _ClearCoatTextureEnabled;
  104861. /**
  104862. * Are clear coat textures enabled in the application.
  104863. */
  104864. static get ClearCoatTextureEnabled(): boolean;
  104865. static set ClearCoatTextureEnabled(value: boolean);
  104866. private static _ClearCoatBumpTextureEnabled;
  104867. /**
  104868. * Are clear coat bump textures enabled in the application.
  104869. */
  104870. static get ClearCoatBumpTextureEnabled(): boolean;
  104871. static set ClearCoatBumpTextureEnabled(value: boolean);
  104872. private static _ClearCoatTintTextureEnabled;
  104873. /**
  104874. * Are clear coat tint textures enabled in the application.
  104875. */
  104876. static get ClearCoatTintTextureEnabled(): boolean;
  104877. static set ClearCoatTintTextureEnabled(value: boolean);
  104878. private static _SheenTextureEnabled;
  104879. /**
  104880. * Are sheen textures enabled in the application.
  104881. */
  104882. static get SheenTextureEnabled(): boolean;
  104883. static set SheenTextureEnabled(value: boolean);
  104884. private static _AnisotropicTextureEnabled;
  104885. /**
  104886. * Are anisotropic textures enabled in the application.
  104887. */
  104888. static get AnisotropicTextureEnabled(): boolean;
  104889. static set AnisotropicTextureEnabled(value: boolean);
  104890. private static _ThicknessTextureEnabled;
  104891. /**
  104892. * Are thickness textures enabled in the application.
  104893. */
  104894. static get ThicknessTextureEnabled(): boolean;
  104895. static set ThicknessTextureEnabled(value: boolean);
  104896. }
  104897. }
  104898. declare module BABYLON {
  104899. /** @hidden */
  104900. export var defaultFragmentDeclaration: {
  104901. name: string;
  104902. shader: string;
  104903. };
  104904. }
  104905. declare module BABYLON {
  104906. /** @hidden */
  104907. export var defaultUboDeclaration: {
  104908. name: string;
  104909. shader: string;
  104910. };
  104911. }
  104912. declare module BABYLON {
  104913. /** @hidden */
  104914. export var prePassDeclaration: {
  104915. name: string;
  104916. shader: string;
  104917. };
  104918. }
  104919. declare module BABYLON {
  104920. /** @hidden */
  104921. export var lightFragmentDeclaration: {
  104922. name: string;
  104923. shader: string;
  104924. };
  104925. }
  104926. declare module BABYLON {
  104927. /** @hidden */
  104928. export var lightUboDeclaration: {
  104929. name: string;
  104930. shader: string;
  104931. };
  104932. }
  104933. declare module BABYLON {
  104934. /** @hidden */
  104935. export var lightsFragmentFunctions: {
  104936. name: string;
  104937. shader: string;
  104938. };
  104939. }
  104940. declare module BABYLON {
  104941. /** @hidden */
  104942. export var shadowsFragmentFunctions: {
  104943. name: string;
  104944. shader: string;
  104945. };
  104946. }
  104947. declare module BABYLON {
  104948. /** @hidden */
  104949. export var fresnelFunction: {
  104950. name: string;
  104951. shader: string;
  104952. };
  104953. }
  104954. declare module BABYLON {
  104955. /** @hidden */
  104956. export var bumpFragmentMainFunctions: {
  104957. name: string;
  104958. shader: string;
  104959. };
  104960. }
  104961. declare module BABYLON {
  104962. /** @hidden */
  104963. export var bumpFragmentFunctions: {
  104964. name: string;
  104965. shader: string;
  104966. };
  104967. }
  104968. declare module BABYLON {
  104969. /** @hidden */
  104970. export var logDepthDeclaration: {
  104971. name: string;
  104972. shader: string;
  104973. };
  104974. }
  104975. declare module BABYLON {
  104976. /** @hidden */
  104977. export var bumpFragment: {
  104978. name: string;
  104979. shader: string;
  104980. };
  104981. }
  104982. declare module BABYLON {
  104983. /** @hidden */
  104984. export var depthPrePass: {
  104985. name: string;
  104986. shader: string;
  104987. };
  104988. }
  104989. declare module BABYLON {
  104990. /** @hidden */
  104991. export var lightFragment: {
  104992. name: string;
  104993. shader: string;
  104994. };
  104995. }
  104996. declare module BABYLON {
  104997. /** @hidden */
  104998. export var logDepthFragment: {
  104999. name: string;
  105000. shader: string;
  105001. };
  105002. }
  105003. declare module BABYLON {
  105004. /** @hidden */
  105005. export var defaultPixelShader: {
  105006. name: string;
  105007. shader: string;
  105008. };
  105009. }
  105010. declare module BABYLON {
  105011. /** @hidden */
  105012. export var defaultVertexDeclaration: {
  105013. name: string;
  105014. shader: string;
  105015. };
  105016. }
  105017. declare module BABYLON {
  105018. /** @hidden */
  105019. export var prePassVertexDeclaration: {
  105020. name: string;
  105021. shader: string;
  105022. };
  105023. }
  105024. declare module BABYLON {
  105025. /** @hidden */
  105026. export var bumpVertexDeclaration: {
  105027. name: string;
  105028. shader: string;
  105029. };
  105030. }
  105031. declare module BABYLON {
  105032. /** @hidden */
  105033. export var prePassVertex: {
  105034. name: string;
  105035. shader: string;
  105036. };
  105037. }
  105038. declare module BABYLON {
  105039. /** @hidden */
  105040. export var bumpVertex: {
  105041. name: string;
  105042. shader: string;
  105043. };
  105044. }
  105045. declare module BABYLON {
  105046. /** @hidden */
  105047. export var fogVertex: {
  105048. name: string;
  105049. shader: string;
  105050. };
  105051. }
  105052. declare module BABYLON {
  105053. /** @hidden */
  105054. export var shadowsVertex: {
  105055. name: string;
  105056. shader: string;
  105057. };
  105058. }
  105059. declare module BABYLON {
  105060. /** @hidden */
  105061. export var pointCloudVertex: {
  105062. name: string;
  105063. shader: string;
  105064. };
  105065. }
  105066. declare module BABYLON {
  105067. /** @hidden */
  105068. export var logDepthVertex: {
  105069. name: string;
  105070. shader: string;
  105071. };
  105072. }
  105073. declare module BABYLON {
  105074. /** @hidden */
  105075. export var defaultVertexShader: {
  105076. name: string;
  105077. shader: string;
  105078. };
  105079. }
  105080. declare module BABYLON {
  105081. /**
  105082. * @hidden
  105083. */
  105084. export interface IMaterialDetailMapDefines {
  105085. DETAIL: boolean;
  105086. DETAILDIRECTUV: number;
  105087. DETAIL_NORMALBLENDMETHOD: number;
  105088. /** @hidden */
  105089. _areTexturesDirty: boolean;
  105090. }
  105091. /**
  105092. * Define the code related to the detail map parameters of a material
  105093. *
  105094. * Inspired from:
  105095. * 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
  105096. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  105097. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  105098. */
  105099. export class DetailMapConfiguration {
  105100. private _texture;
  105101. /**
  105102. * The detail texture of the material.
  105103. */
  105104. texture: Nullable<BaseTexture>;
  105105. /**
  105106. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  105107. * Bigger values mean stronger blending
  105108. */
  105109. diffuseBlendLevel: number;
  105110. /**
  105111. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  105112. * Bigger values mean stronger blending. Only used with PBR materials
  105113. */
  105114. roughnessBlendLevel: number;
  105115. /**
  105116. * Defines how strong the bump effect from the detail map is
  105117. * Bigger values mean stronger effect
  105118. */
  105119. bumpLevel: number;
  105120. private _normalBlendMethod;
  105121. /**
  105122. * The method used to blend the bump and detail normals together
  105123. */
  105124. normalBlendMethod: number;
  105125. private _isEnabled;
  105126. /**
  105127. * Enable or disable the detail map on this material
  105128. */
  105129. isEnabled: boolean;
  105130. /** @hidden */
  105131. private _internalMarkAllSubMeshesAsTexturesDirty;
  105132. /** @hidden */
  105133. _markAllSubMeshesAsTexturesDirty(): void;
  105134. /**
  105135. * Instantiate a new detail map
  105136. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105137. */
  105138. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105139. /**
  105140. * Gets whether the submesh is ready to be used or not.
  105141. * @param defines the list of "defines" to update.
  105142. * @param scene defines the scene the material belongs to.
  105143. * @returns - boolean indicating that the submesh is ready or not.
  105144. */
  105145. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  105146. /**
  105147. * Update the defines for detail map usage
  105148. * @param defines the list of "defines" to update.
  105149. * @param scene defines the scene the material belongs to.
  105150. */
  105151. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  105152. /**
  105153. * Binds the material data.
  105154. * @param uniformBuffer defines the Uniform buffer to fill in.
  105155. * @param scene defines the scene the material belongs to.
  105156. * @param isFrozen defines whether the material is frozen or not.
  105157. */
  105158. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105159. /**
  105160. * Checks to see if a texture is used in the material.
  105161. * @param texture - Base texture to use.
  105162. * @returns - Boolean specifying if a texture is used in the material.
  105163. */
  105164. hasTexture(texture: BaseTexture): boolean;
  105165. /**
  105166. * Returns an array of the actively used textures.
  105167. * @param activeTextures Array of BaseTextures
  105168. */
  105169. getActiveTextures(activeTextures: BaseTexture[]): void;
  105170. /**
  105171. * Returns the animatable textures.
  105172. * @param animatables Array of animatable textures.
  105173. */
  105174. getAnimatables(animatables: IAnimatable[]): void;
  105175. /**
  105176. * Disposes the resources of the material.
  105177. * @param forceDisposeTextures - Forces the disposal of all textures.
  105178. */
  105179. dispose(forceDisposeTextures?: boolean): void;
  105180. /**
  105181. * Get the current class name useful for serialization or dynamic coding.
  105182. * @returns "DetailMap"
  105183. */
  105184. getClassName(): string;
  105185. /**
  105186. * Add the required uniforms to the current list.
  105187. * @param uniforms defines the current uniform list.
  105188. */
  105189. static AddUniforms(uniforms: string[]): void;
  105190. /**
  105191. * Add the required samplers to the current list.
  105192. * @param samplers defines the current sampler list.
  105193. */
  105194. static AddSamplers(samplers: string[]): void;
  105195. /**
  105196. * Add the required uniforms to the current buffer.
  105197. * @param uniformBuffer defines the current uniform buffer.
  105198. */
  105199. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105200. /**
  105201. * Makes a duplicate of the current instance into another one.
  105202. * @param detailMap define the instance where to copy the info
  105203. */
  105204. copyTo(detailMap: DetailMapConfiguration): void;
  105205. /**
  105206. * Serializes this detail map instance
  105207. * @returns - An object with the serialized instance.
  105208. */
  105209. serialize(): any;
  105210. /**
  105211. * Parses a detail map setting from a serialized object.
  105212. * @param source - Serialized object.
  105213. * @param scene Defines the scene we are parsing for
  105214. * @param rootUrl Defines the rootUrl to load from
  105215. */
  105216. parse(source: any, scene: Scene, rootUrl: string): void;
  105217. }
  105218. }
  105219. declare module BABYLON {
  105220. /** @hidden */
  105221. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  105222. MAINUV1: boolean;
  105223. MAINUV2: boolean;
  105224. DIFFUSE: boolean;
  105225. DIFFUSEDIRECTUV: number;
  105226. DETAIL: boolean;
  105227. DETAILDIRECTUV: number;
  105228. DETAIL_NORMALBLENDMETHOD: number;
  105229. AMBIENT: boolean;
  105230. AMBIENTDIRECTUV: number;
  105231. OPACITY: boolean;
  105232. OPACITYDIRECTUV: number;
  105233. OPACITYRGB: boolean;
  105234. REFLECTION: boolean;
  105235. EMISSIVE: boolean;
  105236. EMISSIVEDIRECTUV: number;
  105237. SPECULAR: boolean;
  105238. SPECULARDIRECTUV: number;
  105239. BUMP: boolean;
  105240. BUMPDIRECTUV: number;
  105241. PARALLAX: boolean;
  105242. PARALLAXOCCLUSION: boolean;
  105243. SPECULAROVERALPHA: boolean;
  105244. CLIPPLANE: boolean;
  105245. CLIPPLANE2: boolean;
  105246. CLIPPLANE3: boolean;
  105247. CLIPPLANE4: boolean;
  105248. CLIPPLANE5: boolean;
  105249. CLIPPLANE6: boolean;
  105250. ALPHATEST: boolean;
  105251. DEPTHPREPASS: boolean;
  105252. ALPHAFROMDIFFUSE: boolean;
  105253. POINTSIZE: boolean;
  105254. FOG: boolean;
  105255. SPECULARTERM: boolean;
  105256. DIFFUSEFRESNEL: boolean;
  105257. OPACITYFRESNEL: boolean;
  105258. REFLECTIONFRESNEL: boolean;
  105259. REFRACTIONFRESNEL: boolean;
  105260. EMISSIVEFRESNEL: boolean;
  105261. FRESNEL: boolean;
  105262. NORMAL: boolean;
  105263. UV1: boolean;
  105264. UV2: boolean;
  105265. VERTEXCOLOR: boolean;
  105266. VERTEXALPHA: boolean;
  105267. NUM_BONE_INFLUENCERS: number;
  105268. BonesPerMesh: number;
  105269. BONETEXTURE: boolean;
  105270. BONES_VELOCITY_ENABLED: boolean;
  105271. INSTANCES: boolean;
  105272. THIN_INSTANCES: boolean;
  105273. GLOSSINESS: boolean;
  105274. ROUGHNESS: boolean;
  105275. EMISSIVEASILLUMINATION: boolean;
  105276. LINKEMISSIVEWITHDIFFUSE: boolean;
  105277. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105278. LIGHTMAP: boolean;
  105279. LIGHTMAPDIRECTUV: number;
  105280. OBJECTSPACE_NORMALMAP: boolean;
  105281. USELIGHTMAPASSHADOWMAP: boolean;
  105282. REFLECTIONMAP_3D: boolean;
  105283. REFLECTIONMAP_SPHERICAL: boolean;
  105284. REFLECTIONMAP_PLANAR: boolean;
  105285. REFLECTIONMAP_CUBIC: boolean;
  105286. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105287. REFLECTIONMAP_PROJECTION: boolean;
  105288. REFLECTIONMAP_SKYBOX: boolean;
  105289. REFLECTIONMAP_EXPLICIT: boolean;
  105290. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105291. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105292. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105293. INVERTCUBICMAP: boolean;
  105294. LOGARITHMICDEPTH: boolean;
  105295. REFRACTION: boolean;
  105296. REFRACTIONMAP_3D: boolean;
  105297. REFLECTIONOVERALPHA: boolean;
  105298. TWOSIDEDLIGHTING: boolean;
  105299. SHADOWFLOAT: boolean;
  105300. MORPHTARGETS: boolean;
  105301. MORPHTARGETS_NORMAL: boolean;
  105302. MORPHTARGETS_TANGENT: boolean;
  105303. MORPHTARGETS_UV: boolean;
  105304. NUM_MORPH_INFLUENCERS: number;
  105305. NONUNIFORMSCALING: boolean;
  105306. PREMULTIPLYALPHA: boolean;
  105307. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  105308. ALPHABLEND: boolean;
  105309. PREPASS: boolean;
  105310. PREPASS_IRRADIANCE: boolean;
  105311. PREPASS_IRRADIANCE_INDEX: number;
  105312. PREPASS_ALBEDO: boolean;
  105313. PREPASS_ALBEDO_INDEX: number;
  105314. PREPASS_DEPTHNORMAL: boolean;
  105315. PREPASS_DEPTHNORMAL_INDEX: number;
  105316. PREPASS_POSITION: boolean;
  105317. PREPASS_POSITION_INDEX: number;
  105318. PREPASS_VELOCITY: boolean;
  105319. PREPASS_VELOCITY_INDEX: number;
  105320. PREPASS_REFLECTIVITY: boolean;
  105321. PREPASS_REFLECTIVITY_INDEX: number;
  105322. SCENE_MRT_COUNT: number;
  105323. RGBDLIGHTMAP: boolean;
  105324. RGBDREFLECTION: boolean;
  105325. RGBDREFRACTION: boolean;
  105326. IMAGEPROCESSING: boolean;
  105327. VIGNETTE: boolean;
  105328. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105329. VIGNETTEBLENDMODEOPAQUE: boolean;
  105330. TONEMAPPING: boolean;
  105331. TONEMAPPING_ACES: boolean;
  105332. CONTRAST: boolean;
  105333. COLORCURVES: boolean;
  105334. COLORGRADING: boolean;
  105335. COLORGRADING3D: boolean;
  105336. SAMPLER3DGREENDEPTH: boolean;
  105337. SAMPLER3DBGRMAP: boolean;
  105338. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105339. MULTIVIEW: boolean;
  105340. /**
  105341. * If the reflection texture on this material is in linear color space
  105342. * @hidden
  105343. */
  105344. IS_REFLECTION_LINEAR: boolean;
  105345. /**
  105346. * If the refraction texture on this material is in linear color space
  105347. * @hidden
  105348. */
  105349. IS_REFRACTION_LINEAR: boolean;
  105350. EXPOSURE: boolean;
  105351. constructor();
  105352. setReflectionMode(modeToEnable: string): void;
  105353. }
  105354. /**
  105355. * This is the default material used in Babylon. It is the best trade off between quality
  105356. * and performances.
  105357. * @see https://doc.babylonjs.com/babylon101/materials
  105358. */
  105359. export class StandardMaterial extends PushMaterial {
  105360. private _diffuseTexture;
  105361. /**
  105362. * The basic texture of the material as viewed under a light.
  105363. */
  105364. diffuseTexture: Nullable<BaseTexture>;
  105365. private _ambientTexture;
  105366. /**
  105367. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105368. */
  105369. ambientTexture: Nullable<BaseTexture>;
  105370. private _opacityTexture;
  105371. /**
  105372. * Define the transparency of the material from a texture.
  105373. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105374. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105375. */
  105376. opacityTexture: Nullable<BaseTexture>;
  105377. private _reflectionTexture;
  105378. /**
  105379. * Define the texture used to display the reflection.
  105380. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105381. */
  105382. reflectionTexture: Nullable<BaseTexture>;
  105383. private _emissiveTexture;
  105384. /**
  105385. * Define texture of the material as if self lit.
  105386. * This will be mixed in the final result even in the absence of light.
  105387. */
  105388. emissiveTexture: Nullable<BaseTexture>;
  105389. private _specularTexture;
  105390. /**
  105391. * Define how the color and intensity of the highlight given by the light in the material.
  105392. */
  105393. specularTexture: Nullable<BaseTexture>;
  105394. private _bumpTexture;
  105395. /**
  105396. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105397. * 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.
  105398. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  105399. */
  105400. bumpTexture: Nullable<BaseTexture>;
  105401. private _lightmapTexture;
  105402. /**
  105403. * Complex lighting can be computationally expensive to compute at runtime.
  105404. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105405. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  105406. */
  105407. lightmapTexture: Nullable<BaseTexture>;
  105408. private _refractionTexture;
  105409. /**
  105410. * Define the texture used to display the refraction.
  105411. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105412. */
  105413. refractionTexture: Nullable<BaseTexture>;
  105414. /**
  105415. * The color of the material lit by the environmental background lighting.
  105416. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  105417. */
  105418. ambientColor: Color3;
  105419. /**
  105420. * The basic color of the material as viewed under a light.
  105421. */
  105422. diffuseColor: Color3;
  105423. /**
  105424. * Define how the color and intensity of the highlight given by the light in the material.
  105425. */
  105426. specularColor: Color3;
  105427. /**
  105428. * Define the color of the material as if self lit.
  105429. * This will be mixed in the final result even in the absence of light.
  105430. */
  105431. emissiveColor: Color3;
  105432. /**
  105433. * Defines how sharp are the highlights in the material.
  105434. * The bigger the value the sharper giving a more glossy feeling to the result.
  105435. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  105436. */
  105437. specularPower: number;
  105438. private _useAlphaFromDiffuseTexture;
  105439. /**
  105440. * Does the transparency come from the diffuse texture alpha channel.
  105441. */
  105442. useAlphaFromDiffuseTexture: boolean;
  105443. private _useEmissiveAsIllumination;
  105444. /**
  105445. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  105446. */
  105447. useEmissiveAsIllumination: boolean;
  105448. private _linkEmissiveWithDiffuse;
  105449. /**
  105450. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  105451. * the emissive level when the final color is close to one.
  105452. */
  105453. linkEmissiveWithDiffuse: boolean;
  105454. private _useSpecularOverAlpha;
  105455. /**
  105456. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105457. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105458. */
  105459. useSpecularOverAlpha: boolean;
  105460. private _useReflectionOverAlpha;
  105461. /**
  105462. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105463. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105464. */
  105465. useReflectionOverAlpha: boolean;
  105466. private _disableLighting;
  105467. /**
  105468. * Does lights from the scene impacts this material.
  105469. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  105470. */
  105471. disableLighting: boolean;
  105472. private _useObjectSpaceNormalMap;
  105473. /**
  105474. * Allows using an object space normal map (instead of tangent space).
  105475. */
  105476. useObjectSpaceNormalMap: boolean;
  105477. private _useParallax;
  105478. /**
  105479. * Is parallax enabled or not.
  105480. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  105481. */
  105482. useParallax: boolean;
  105483. private _useParallaxOcclusion;
  105484. /**
  105485. * Is parallax occlusion enabled or not.
  105486. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  105487. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  105488. */
  105489. useParallaxOcclusion: boolean;
  105490. /**
  105491. * 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.
  105492. */
  105493. parallaxScaleBias: number;
  105494. private _roughness;
  105495. /**
  105496. * Helps to define how blurry the reflections should appears in the material.
  105497. */
  105498. roughness: number;
  105499. /**
  105500. * In case of refraction, define the value of the index of refraction.
  105501. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105502. */
  105503. indexOfRefraction: number;
  105504. /**
  105505. * Invert the refraction texture alongside the y axis.
  105506. * It can be useful with procedural textures or probe for instance.
  105507. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105508. */
  105509. invertRefractionY: boolean;
  105510. /**
  105511. * Defines the alpha limits in alpha test mode.
  105512. */
  105513. alphaCutOff: number;
  105514. private _useLightmapAsShadowmap;
  105515. /**
  105516. * In case of light mapping, define whether the map contains light or shadow informations.
  105517. */
  105518. useLightmapAsShadowmap: boolean;
  105519. private _diffuseFresnelParameters;
  105520. /**
  105521. * Define the diffuse fresnel parameters of the material.
  105522. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105523. */
  105524. diffuseFresnelParameters: FresnelParameters;
  105525. private _opacityFresnelParameters;
  105526. /**
  105527. * Define the opacity fresnel parameters of the material.
  105528. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105529. */
  105530. opacityFresnelParameters: FresnelParameters;
  105531. private _reflectionFresnelParameters;
  105532. /**
  105533. * Define the reflection fresnel parameters of the material.
  105534. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105535. */
  105536. reflectionFresnelParameters: FresnelParameters;
  105537. private _refractionFresnelParameters;
  105538. /**
  105539. * Define the refraction fresnel parameters of the material.
  105540. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105541. */
  105542. refractionFresnelParameters: FresnelParameters;
  105543. private _emissiveFresnelParameters;
  105544. /**
  105545. * Define the emissive fresnel parameters of the material.
  105546. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105547. */
  105548. emissiveFresnelParameters: FresnelParameters;
  105549. private _useReflectionFresnelFromSpecular;
  105550. /**
  105551. * If true automatically deducts the fresnels values from the material specularity.
  105552. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105553. */
  105554. useReflectionFresnelFromSpecular: boolean;
  105555. private _useGlossinessFromSpecularMapAlpha;
  105556. /**
  105557. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  105558. */
  105559. useGlossinessFromSpecularMapAlpha: boolean;
  105560. private _maxSimultaneousLights;
  105561. /**
  105562. * Defines the maximum number of lights that can be used in the material
  105563. */
  105564. maxSimultaneousLights: number;
  105565. private _invertNormalMapX;
  105566. /**
  105567. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105568. */
  105569. invertNormalMapX: boolean;
  105570. private _invertNormalMapY;
  105571. /**
  105572. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105573. */
  105574. invertNormalMapY: boolean;
  105575. private _twoSidedLighting;
  105576. /**
  105577. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105578. */
  105579. twoSidedLighting: boolean;
  105580. /**
  105581. * Default configuration related to image processing available in the standard Material.
  105582. */
  105583. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105584. /**
  105585. * Gets the image processing configuration used either in this material.
  105586. */
  105587. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  105588. /**
  105589. * Sets the Default image processing configuration used either in the this material.
  105590. *
  105591. * If sets to null, the scene one is in use.
  105592. */
  105593. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  105594. /**
  105595. * Keep track of the image processing observer to allow dispose and replace.
  105596. */
  105597. private _imageProcessingObserver;
  105598. /**
  105599. * Attaches a new image processing configuration to the Standard Material.
  105600. * @param configuration
  105601. */
  105602. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105603. /**
  105604. * Defines additionnal PrePass parameters for the material.
  105605. */
  105606. readonly prePassConfiguration: PrePassConfiguration;
  105607. /**
  105608. * Gets wether the color curves effect is enabled.
  105609. */
  105610. get cameraColorCurvesEnabled(): boolean;
  105611. /**
  105612. * Sets wether the color curves effect is enabled.
  105613. */
  105614. set cameraColorCurvesEnabled(value: boolean);
  105615. /**
  105616. * Gets wether the color grading effect is enabled.
  105617. */
  105618. get cameraColorGradingEnabled(): boolean;
  105619. /**
  105620. * Gets wether the color grading effect is enabled.
  105621. */
  105622. set cameraColorGradingEnabled(value: boolean);
  105623. /**
  105624. * Gets wether tonemapping is enabled or not.
  105625. */
  105626. get cameraToneMappingEnabled(): boolean;
  105627. /**
  105628. * Sets wether tonemapping is enabled or not
  105629. */
  105630. set cameraToneMappingEnabled(value: boolean);
  105631. /**
  105632. * The camera exposure used on this material.
  105633. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105634. * This corresponds to a photographic exposure.
  105635. */
  105636. get cameraExposure(): number;
  105637. /**
  105638. * The camera exposure used on this material.
  105639. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105640. * This corresponds to a photographic exposure.
  105641. */
  105642. set cameraExposure(value: number);
  105643. /**
  105644. * Gets The camera contrast used on this material.
  105645. */
  105646. get cameraContrast(): number;
  105647. /**
  105648. * Sets The camera contrast used on this material.
  105649. */
  105650. set cameraContrast(value: number);
  105651. /**
  105652. * Gets the Color Grading 2D Lookup Texture.
  105653. */
  105654. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  105655. /**
  105656. * Sets the Color Grading 2D Lookup Texture.
  105657. */
  105658. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  105659. /**
  105660. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105661. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105662. * 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;
  105663. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105664. */
  105665. get cameraColorCurves(): Nullable<ColorCurves>;
  105666. /**
  105667. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105668. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105669. * 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;
  105670. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105671. */
  105672. set cameraColorCurves(value: Nullable<ColorCurves>);
  105673. /**
  105674. * Can this material render to several textures at once
  105675. */
  105676. get canRenderToMRT(): boolean;
  105677. /**
  105678. * Defines the detail map parameters for the material.
  105679. */
  105680. readonly detailMap: DetailMapConfiguration;
  105681. protected _renderTargets: SmartArray<RenderTargetTexture>;
  105682. protected _worldViewProjectionMatrix: Matrix;
  105683. protected _globalAmbientColor: Color3;
  105684. protected _useLogarithmicDepth: boolean;
  105685. protected _rebuildInParallel: boolean;
  105686. /**
  105687. * Instantiates a new standard material.
  105688. * This is the default material used in Babylon. It is the best trade off between quality
  105689. * and performances.
  105690. * @see https://doc.babylonjs.com/babylon101/materials
  105691. * @param name Define the name of the material in the scene
  105692. * @param scene Define the scene the material belong to
  105693. */
  105694. constructor(name: string, scene: Scene);
  105695. /**
  105696. * Gets a boolean indicating that current material needs to register RTT
  105697. */
  105698. get hasRenderTargetTextures(): boolean;
  105699. /**
  105700. * Gets the current class name of the material e.g. "StandardMaterial"
  105701. * Mainly use in serialization.
  105702. * @returns the class name
  105703. */
  105704. getClassName(): string;
  105705. /**
  105706. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  105707. * You can try switching to logarithmic depth.
  105708. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  105709. */
  105710. get useLogarithmicDepth(): boolean;
  105711. set useLogarithmicDepth(value: boolean);
  105712. /**
  105713. * Specifies if the material will require alpha blending
  105714. * @returns a boolean specifying if alpha blending is needed
  105715. */
  105716. needAlphaBlending(): boolean;
  105717. /**
  105718. * Specifies if this material should be rendered in alpha test mode
  105719. * @returns a boolean specifying if an alpha test is needed.
  105720. */
  105721. needAlphaTesting(): boolean;
  105722. /**
  105723. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  105724. */
  105725. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105726. /**
  105727. * Specifies whether or not there is a usable alpha channel for transparency.
  105728. */
  105729. protected _hasAlphaChannel(): boolean;
  105730. /**
  105731. * Get the texture used for alpha test purpose.
  105732. * @returns the diffuse texture in case of the standard material.
  105733. */
  105734. getAlphaTestTexture(): Nullable<BaseTexture>;
  105735. /**
  105736. * Get if the submesh is ready to be used and all its information available.
  105737. * Child classes can use it to update shaders
  105738. * @param mesh defines the mesh to check
  105739. * @param subMesh defines which submesh to check
  105740. * @param useInstances specifies that instances should be used
  105741. * @returns a boolean indicating that the submesh is ready or not
  105742. */
  105743. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105744. /**
  105745. * Builds the material UBO layouts.
  105746. * Used internally during the effect preparation.
  105747. */
  105748. buildUniformLayout(): void;
  105749. /**
  105750. * Unbinds the material from the mesh
  105751. */
  105752. unbind(): void;
  105753. /**
  105754. * Binds the submesh to this material by preparing the effect and shader to draw
  105755. * @param world defines the world transformation matrix
  105756. * @param mesh defines the mesh containing the submesh
  105757. * @param subMesh defines the submesh to bind the material to
  105758. */
  105759. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105760. /**
  105761. * Get the list of animatables in the material.
  105762. * @returns the list of animatables object used in the material
  105763. */
  105764. getAnimatables(): IAnimatable[];
  105765. /**
  105766. * Gets the active textures from the material
  105767. * @returns an array of textures
  105768. */
  105769. getActiveTextures(): BaseTexture[];
  105770. /**
  105771. * Specifies if the material uses a texture
  105772. * @param texture defines the texture to check against the material
  105773. * @returns a boolean specifying if the material uses the texture
  105774. */
  105775. hasTexture(texture: BaseTexture): boolean;
  105776. /**
  105777. * Disposes the material
  105778. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105779. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105780. */
  105781. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105782. /**
  105783. * Makes a duplicate of the material, and gives it a new name
  105784. * @param name defines the new name for the duplicated material
  105785. * @returns the cloned material
  105786. */
  105787. clone(name: string): StandardMaterial;
  105788. /**
  105789. * Serializes this material in a JSON representation
  105790. * @returns the serialized material object
  105791. */
  105792. serialize(): any;
  105793. /**
  105794. * Creates a standard material from parsed material data
  105795. * @param source defines the JSON representation of the material
  105796. * @param scene defines the hosting scene
  105797. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105798. * @returns a new standard material
  105799. */
  105800. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105801. /**
  105802. * Are diffuse textures enabled in the application.
  105803. */
  105804. static get DiffuseTextureEnabled(): boolean;
  105805. static set DiffuseTextureEnabled(value: boolean);
  105806. /**
  105807. * Are detail textures enabled in the application.
  105808. */
  105809. static get DetailTextureEnabled(): boolean;
  105810. static set DetailTextureEnabled(value: boolean);
  105811. /**
  105812. * Are ambient textures enabled in the application.
  105813. */
  105814. static get AmbientTextureEnabled(): boolean;
  105815. static set AmbientTextureEnabled(value: boolean);
  105816. /**
  105817. * Are opacity textures enabled in the application.
  105818. */
  105819. static get OpacityTextureEnabled(): boolean;
  105820. static set OpacityTextureEnabled(value: boolean);
  105821. /**
  105822. * Are reflection textures enabled in the application.
  105823. */
  105824. static get ReflectionTextureEnabled(): boolean;
  105825. static set ReflectionTextureEnabled(value: boolean);
  105826. /**
  105827. * Are emissive textures enabled in the application.
  105828. */
  105829. static get EmissiveTextureEnabled(): boolean;
  105830. static set EmissiveTextureEnabled(value: boolean);
  105831. /**
  105832. * Are specular textures enabled in the application.
  105833. */
  105834. static get SpecularTextureEnabled(): boolean;
  105835. static set SpecularTextureEnabled(value: boolean);
  105836. /**
  105837. * Are bump textures enabled in the application.
  105838. */
  105839. static get BumpTextureEnabled(): boolean;
  105840. static set BumpTextureEnabled(value: boolean);
  105841. /**
  105842. * Are lightmap textures enabled in the application.
  105843. */
  105844. static get LightmapTextureEnabled(): boolean;
  105845. static set LightmapTextureEnabled(value: boolean);
  105846. /**
  105847. * Are refraction textures enabled in the application.
  105848. */
  105849. static get RefractionTextureEnabled(): boolean;
  105850. static set RefractionTextureEnabled(value: boolean);
  105851. /**
  105852. * Are color grading textures enabled in the application.
  105853. */
  105854. static get ColorGradingTextureEnabled(): boolean;
  105855. static set ColorGradingTextureEnabled(value: boolean);
  105856. /**
  105857. * Are fresnels enabled in the application.
  105858. */
  105859. static get FresnelEnabled(): boolean;
  105860. static set FresnelEnabled(value: boolean);
  105861. }
  105862. }
  105863. declare module BABYLON {
  105864. /** @hidden */
  105865. export var rgbdDecodePixelShader: {
  105866. name: string;
  105867. shader: string;
  105868. };
  105869. }
  105870. declare module BABYLON {
  105871. /**
  105872. * Class used to host RGBD texture specific utilities
  105873. */
  105874. export class RGBDTextureTools {
  105875. /**
  105876. * Expand the RGBD Texture from RGBD to Half Float if possible.
  105877. * @param texture the texture to expand.
  105878. */
  105879. static ExpandRGBDTexture(texture: Texture): void;
  105880. }
  105881. }
  105882. declare module BABYLON {
  105883. /**
  105884. * Class used to host texture specific utilities
  105885. */
  105886. export class BRDFTextureTools {
  105887. /**
  105888. * Prevents texture cache collision
  105889. */
  105890. private static _instanceNumber;
  105891. /**
  105892. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  105893. * @param scene defines the hosting scene
  105894. * @returns the environment BRDF texture
  105895. */
  105896. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  105897. private static _environmentBRDFBase64Texture;
  105898. }
  105899. }
  105900. declare module BABYLON {
  105901. /**
  105902. * @hidden
  105903. */
  105904. export interface IMaterialClearCoatDefines {
  105905. CLEARCOAT: boolean;
  105906. CLEARCOAT_DEFAULTIOR: boolean;
  105907. CLEARCOAT_TEXTURE: boolean;
  105908. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  105909. CLEARCOAT_TEXTUREDIRECTUV: number;
  105910. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  105911. CLEARCOAT_BUMP: boolean;
  105912. CLEARCOAT_BUMPDIRECTUV: number;
  105913. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105914. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105915. CLEARCOAT_REMAP_F0: boolean;
  105916. CLEARCOAT_TINT: boolean;
  105917. CLEARCOAT_TINT_TEXTURE: boolean;
  105918. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105919. /** @hidden */
  105920. _areTexturesDirty: boolean;
  105921. }
  105922. /**
  105923. * Define the code related to the clear coat parameters of the pbr material.
  105924. */
  105925. export class PBRClearCoatConfiguration {
  105926. /**
  105927. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105928. * The default fits with a polyurethane material.
  105929. */
  105930. private static readonly _DefaultIndexOfRefraction;
  105931. private _isEnabled;
  105932. /**
  105933. * Defines if the clear coat is enabled in the material.
  105934. */
  105935. isEnabled: boolean;
  105936. /**
  105937. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  105938. */
  105939. intensity: number;
  105940. /**
  105941. * Defines the clear coat layer roughness.
  105942. */
  105943. roughness: number;
  105944. private _indexOfRefraction;
  105945. /**
  105946. * Defines the index of refraction of the clear coat.
  105947. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105948. * The default fits with a polyurethane material.
  105949. * Changing the default value is more performance intensive.
  105950. */
  105951. indexOfRefraction: number;
  105952. private _texture;
  105953. /**
  105954. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  105955. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  105956. * if textureRoughness is not empty, else no texture roughness is used
  105957. */
  105958. texture: Nullable<BaseTexture>;
  105959. private _useRoughnessFromMainTexture;
  105960. /**
  105961. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  105962. * If false, the green channel from textureRoughness is used for roughness
  105963. */
  105964. useRoughnessFromMainTexture: boolean;
  105965. private _textureRoughness;
  105966. /**
  105967. * Stores the clear coat roughness in a texture (green channel)
  105968. * Not used if useRoughnessFromMainTexture is true
  105969. */
  105970. textureRoughness: Nullable<BaseTexture>;
  105971. private _remapF0OnInterfaceChange;
  105972. /**
  105973. * Defines if the F0 value should be remapped to account for the interface change in the material.
  105974. */
  105975. remapF0OnInterfaceChange: boolean;
  105976. private _bumpTexture;
  105977. /**
  105978. * Define the clear coat specific bump texture.
  105979. */
  105980. bumpTexture: Nullable<BaseTexture>;
  105981. private _isTintEnabled;
  105982. /**
  105983. * Defines if the clear coat tint is enabled in the material.
  105984. */
  105985. isTintEnabled: boolean;
  105986. /**
  105987. * Defines the clear coat tint of the material.
  105988. * This is only use if tint is enabled
  105989. */
  105990. tintColor: Color3;
  105991. /**
  105992. * Defines the distance at which the tint color should be found in the
  105993. * clear coat media.
  105994. * This is only use if tint is enabled
  105995. */
  105996. tintColorAtDistance: number;
  105997. /**
  105998. * Defines the clear coat layer thickness.
  105999. * This is only use if tint is enabled
  106000. */
  106001. tintThickness: number;
  106002. private _tintTexture;
  106003. /**
  106004. * Stores the clear tint values in a texture.
  106005. * rgb is tint
  106006. * a is a thickness factor
  106007. */
  106008. tintTexture: Nullable<BaseTexture>;
  106009. /** @hidden */
  106010. private _internalMarkAllSubMeshesAsTexturesDirty;
  106011. /** @hidden */
  106012. _markAllSubMeshesAsTexturesDirty(): void;
  106013. /**
  106014. * Instantiate a new istance of clear coat configuration.
  106015. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106016. */
  106017. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106018. /**
  106019. * Gets wehter the submesh is ready to be used or not.
  106020. * @param defines the list of "defines" to update.
  106021. * @param scene defines the scene the material belongs to.
  106022. * @param engine defines the engine the material belongs to.
  106023. * @param disableBumpMap defines wether the material disables bump or not.
  106024. * @returns - boolean indicating that the submesh is ready or not.
  106025. */
  106026. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  106027. /**
  106028. * Checks to see if a texture is used in the material.
  106029. * @param defines the list of "defines" to update.
  106030. * @param scene defines the scene to the material belongs to.
  106031. */
  106032. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  106033. /**
  106034. * Binds the material data.
  106035. * @param uniformBuffer defines the Uniform buffer to fill in.
  106036. * @param scene defines the scene the material belongs to.
  106037. * @param engine defines the engine the material belongs to.
  106038. * @param disableBumpMap defines wether the material disables bump or not.
  106039. * @param isFrozen defines wether the material is frozen or not.
  106040. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  106041. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  106042. * @param subMesh the submesh to bind data for
  106043. */
  106044. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  106045. /**
  106046. * Checks to see if a texture is used in the material.
  106047. * @param texture - Base texture to use.
  106048. * @returns - Boolean specifying if a texture is used in the material.
  106049. */
  106050. hasTexture(texture: BaseTexture): boolean;
  106051. /**
  106052. * Returns an array of the actively used textures.
  106053. * @param activeTextures Array of BaseTextures
  106054. */
  106055. getActiveTextures(activeTextures: BaseTexture[]): void;
  106056. /**
  106057. * Returns the animatable textures.
  106058. * @param animatables Array of animatable textures.
  106059. */
  106060. getAnimatables(animatables: IAnimatable[]): void;
  106061. /**
  106062. * Disposes the resources of the material.
  106063. * @param forceDisposeTextures - Forces the disposal of all textures.
  106064. */
  106065. dispose(forceDisposeTextures?: boolean): void;
  106066. /**
  106067. * Get the current class name of the texture useful for serialization or dynamic coding.
  106068. * @returns "PBRClearCoatConfiguration"
  106069. */
  106070. getClassName(): string;
  106071. /**
  106072. * Add fallbacks to the effect fallbacks list.
  106073. * @param defines defines the Base texture to use.
  106074. * @param fallbacks defines the current fallback list.
  106075. * @param currentRank defines the current fallback rank.
  106076. * @returns the new fallback rank.
  106077. */
  106078. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106079. /**
  106080. * Add the required uniforms to the current list.
  106081. * @param uniforms defines the current uniform list.
  106082. */
  106083. static AddUniforms(uniforms: string[]): void;
  106084. /**
  106085. * Add the required samplers to the current list.
  106086. * @param samplers defines the current sampler list.
  106087. */
  106088. static AddSamplers(samplers: string[]): void;
  106089. /**
  106090. * Add the required uniforms to the current buffer.
  106091. * @param uniformBuffer defines the current uniform buffer.
  106092. */
  106093. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106094. /**
  106095. * Makes a duplicate of the current configuration into another one.
  106096. * @param clearCoatConfiguration define the config where to copy the info
  106097. */
  106098. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  106099. /**
  106100. * Serializes this clear coat configuration.
  106101. * @returns - An object with the serialized config.
  106102. */
  106103. serialize(): any;
  106104. /**
  106105. * Parses a anisotropy Configuration from a serialized object.
  106106. * @param source - Serialized object.
  106107. * @param scene Defines the scene we are parsing for
  106108. * @param rootUrl Defines the rootUrl to load from
  106109. */
  106110. parse(source: any, scene: Scene, rootUrl: string): void;
  106111. }
  106112. }
  106113. declare module BABYLON {
  106114. /**
  106115. * @hidden
  106116. */
  106117. export interface IMaterialAnisotropicDefines {
  106118. ANISOTROPIC: boolean;
  106119. ANISOTROPIC_TEXTURE: boolean;
  106120. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106121. MAINUV1: boolean;
  106122. _areTexturesDirty: boolean;
  106123. _needUVs: boolean;
  106124. }
  106125. /**
  106126. * Define the code related to the anisotropic parameters of the pbr material.
  106127. */
  106128. export class PBRAnisotropicConfiguration {
  106129. private _isEnabled;
  106130. /**
  106131. * Defines if the anisotropy is enabled in the material.
  106132. */
  106133. isEnabled: boolean;
  106134. /**
  106135. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  106136. */
  106137. intensity: number;
  106138. /**
  106139. * Defines if the effect is along the tangents, bitangents or in between.
  106140. * By default, the effect is "strectching" the highlights along the tangents.
  106141. */
  106142. direction: Vector2;
  106143. private _texture;
  106144. /**
  106145. * Stores the anisotropy values in a texture.
  106146. * rg is direction (like normal from -1 to 1)
  106147. * b is a intensity
  106148. */
  106149. texture: Nullable<BaseTexture>;
  106150. /** @hidden */
  106151. private _internalMarkAllSubMeshesAsTexturesDirty;
  106152. /** @hidden */
  106153. _markAllSubMeshesAsTexturesDirty(): void;
  106154. /**
  106155. * Instantiate a new istance of anisotropy configuration.
  106156. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106157. */
  106158. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106159. /**
  106160. * Specifies that the submesh is ready to be used.
  106161. * @param defines the list of "defines" to update.
  106162. * @param scene defines the scene the material belongs to.
  106163. * @returns - boolean indicating that the submesh is ready or not.
  106164. */
  106165. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  106166. /**
  106167. * Checks to see if a texture is used in the material.
  106168. * @param defines the list of "defines" to update.
  106169. * @param mesh the mesh we are preparing the defines for.
  106170. * @param scene defines the scene the material belongs to.
  106171. */
  106172. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  106173. /**
  106174. * Binds the material data.
  106175. * @param uniformBuffer defines the Uniform buffer to fill in.
  106176. * @param scene defines the scene the material belongs to.
  106177. * @param isFrozen defines wether the material is frozen or not.
  106178. */
  106179. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  106180. /**
  106181. * Checks to see if a texture is used in the material.
  106182. * @param texture - Base texture to use.
  106183. * @returns - Boolean specifying if a texture is used in the material.
  106184. */
  106185. hasTexture(texture: BaseTexture): boolean;
  106186. /**
  106187. * Returns an array of the actively used textures.
  106188. * @param activeTextures Array of BaseTextures
  106189. */
  106190. getActiveTextures(activeTextures: BaseTexture[]): void;
  106191. /**
  106192. * Returns the animatable textures.
  106193. * @param animatables Array of animatable textures.
  106194. */
  106195. getAnimatables(animatables: IAnimatable[]): void;
  106196. /**
  106197. * Disposes the resources of the material.
  106198. * @param forceDisposeTextures - Forces the disposal of all textures.
  106199. */
  106200. dispose(forceDisposeTextures?: boolean): void;
  106201. /**
  106202. * Get the current class name of the texture useful for serialization or dynamic coding.
  106203. * @returns "PBRAnisotropicConfiguration"
  106204. */
  106205. getClassName(): string;
  106206. /**
  106207. * Add fallbacks to the effect fallbacks list.
  106208. * @param defines defines the Base texture to use.
  106209. * @param fallbacks defines the current fallback list.
  106210. * @param currentRank defines the current fallback rank.
  106211. * @returns the new fallback rank.
  106212. */
  106213. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106214. /**
  106215. * Add the required uniforms to the current list.
  106216. * @param uniforms defines the current uniform list.
  106217. */
  106218. static AddUniforms(uniforms: string[]): void;
  106219. /**
  106220. * Add the required uniforms to the current buffer.
  106221. * @param uniformBuffer defines the current uniform buffer.
  106222. */
  106223. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106224. /**
  106225. * Add the required samplers to the current list.
  106226. * @param samplers defines the current sampler list.
  106227. */
  106228. static AddSamplers(samplers: string[]): void;
  106229. /**
  106230. * Makes a duplicate of the current configuration into another one.
  106231. * @param anisotropicConfiguration define the config where to copy the info
  106232. */
  106233. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  106234. /**
  106235. * Serializes this anisotropy configuration.
  106236. * @returns - An object with the serialized config.
  106237. */
  106238. serialize(): any;
  106239. /**
  106240. * Parses a anisotropy Configuration from a serialized object.
  106241. * @param source - Serialized object.
  106242. * @param scene Defines the scene we are parsing for
  106243. * @param rootUrl Defines the rootUrl to load from
  106244. */
  106245. parse(source: any, scene: Scene, rootUrl: string): void;
  106246. }
  106247. }
  106248. declare module BABYLON {
  106249. /**
  106250. * @hidden
  106251. */
  106252. export interface IMaterialBRDFDefines {
  106253. BRDF_V_HEIGHT_CORRELATED: boolean;
  106254. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106255. SPHERICAL_HARMONICS: boolean;
  106256. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106257. /** @hidden */
  106258. _areMiscDirty: boolean;
  106259. }
  106260. /**
  106261. * Define the code related to the BRDF parameters of the pbr material.
  106262. */
  106263. export class PBRBRDFConfiguration {
  106264. /**
  106265. * Default value used for the energy conservation.
  106266. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  106267. */
  106268. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  106269. /**
  106270. * Default value used for the Smith Visibility Height Correlated mode.
  106271. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  106272. */
  106273. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  106274. /**
  106275. * Default value used for the IBL diffuse part.
  106276. * This can help switching back to the polynomials mode globally which is a tiny bit
  106277. * less GPU intensive at the drawback of a lower quality.
  106278. */
  106279. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  106280. /**
  106281. * Default value used for activating energy conservation for the specular workflow.
  106282. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  106283. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  106284. */
  106285. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  106286. private _useEnergyConservation;
  106287. /**
  106288. * Defines if the material uses energy conservation.
  106289. */
  106290. useEnergyConservation: boolean;
  106291. private _useSmithVisibilityHeightCorrelated;
  106292. /**
  106293. * LEGACY Mode set to false
  106294. * Defines if the material uses height smith correlated visibility term.
  106295. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  106296. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  106297. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  106298. * Not relying on height correlated will also disable energy conservation.
  106299. */
  106300. useSmithVisibilityHeightCorrelated: boolean;
  106301. private _useSphericalHarmonics;
  106302. /**
  106303. * LEGACY Mode set to false
  106304. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  106305. * diffuse part of the IBL.
  106306. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  106307. * to the ground truth.
  106308. */
  106309. useSphericalHarmonics: boolean;
  106310. private _useSpecularGlossinessInputEnergyConservation;
  106311. /**
  106312. * Defines if the material uses energy conservation, when the specular workflow is active.
  106313. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  106314. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  106315. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  106316. */
  106317. useSpecularGlossinessInputEnergyConservation: boolean;
  106318. /** @hidden */
  106319. private _internalMarkAllSubMeshesAsMiscDirty;
  106320. /** @hidden */
  106321. _markAllSubMeshesAsMiscDirty(): void;
  106322. /**
  106323. * Instantiate a new istance of clear coat configuration.
  106324. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  106325. */
  106326. constructor(markAllSubMeshesAsMiscDirty: () => void);
  106327. /**
  106328. * Checks to see if a texture is used in the material.
  106329. * @param defines the list of "defines" to update.
  106330. */
  106331. prepareDefines(defines: IMaterialBRDFDefines): void;
  106332. /**
  106333. * Get the current class name of the texture useful for serialization or dynamic coding.
  106334. * @returns "PBRClearCoatConfiguration"
  106335. */
  106336. getClassName(): string;
  106337. /**
  106338. * Makes a duplicate of the current configuration into another one.
  106339. * @param brdfConfiguration define the config where to copy the info
  106340. */
  106341. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  106342. /**
  106343. * Serializes this BRDF configuration.
  106344. * @returns - An object with the serialized config.
  106345. */
  106346. serialize(): any;
  106347. /**
  106348. * Parses a anisotropy Configuration from a serialized object.
  106349. * @param source - Serialized object.
  106350. * @param scene Defines the scene we are parsing for
  106351. * @param rootUrl Defines the rootUrl to load from
  106352. */
  106353. parse(source: any, scene: Scene, rootUrl: string): void;
  106354. }
  106355. }
  106356. declare module BABYLON {
  106357. /**
  106358. * @hidden
  106359. */
  106360. export interface IMaterialSheenDefines {
  106361. SHEEN: boolean;
  106362. SHEEN_TEXTURE: boolean;
  106363. SHEEN_TEXTURE_ROUGHNESS: boolean;
  106364. SHEEN_TEXTUREDIRECTUV: number;
  106365. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  106366. SHEEN_LINKWITHALBEDO: boolean;
  106367. SHEEN_ROUGHNESS: boolean;
  106368. SHEEN_ALBEDOSCALING: boolean;
  106369. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106370. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106371. /** @hidden */
  106372. _areTexturesDirty: boolean;
  106373. }
  106374. /**
  106375. * Define the code related to the Sheen parameters of the pbr material.
  106376. */
  106377. export class PBRSheenConfiguration {
  106378. private _isEnabled;
  106379. /**
  106380. * Defines if the material uses sheen.
  106381. */
  106382. isEnabled: boolean;
  106383. private _linkSheenWithAlbedo;
  106384. /**
  106385. * Defines if the sheen is linked to the sheen color.
  106386. */
  106387. linkSheenWithAlbedo: boolean;
  106388. /**
  106389. * Defines the sheen intensity.
  106390. */
  106391. intensity: number;
  106392. /**
  106393. * Defines the sheen color.
  106394. */
  106395. color: Color3;
  106396. private _texture;
  106397. /**
  106398. * Stores the sheen tint values in a texture.
  106399. * rgb is tint
  106400. * 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)
  106401. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  106402. */
  106403. texture: Nullable<BaseTexture>;
  106404. private _useRoughnessFromMainTexture;
  106405. /**
  106406. * Indicates that the alpha channel of the texture property will be used for roughness.
  106407. * Has no effect if the roughness (and texture!) property is not defined
  106408. */
  106409. useRoughnessFromMainTexture: boolean;
  106410. private _roughness;
  106411. /**
  106412. * Defines the sheen roughness.
  106413. * It is not taken into account if linkSheenWithAlbedo is true.
  106414. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  106415. */
  106416. roughness: Nullable<number>;
  106417. private _textureRoughness;
  106418. /**
  106419. * Stores the sheen roughness in a texture.
  106420. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  106421. */
  106422. textureRoughness: Nullable<BaseTexture>;
  106423. private _albedoScaling;
  106424. /**
  106425. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  106426. * It allows the strength of the sheen effect to not depend on the base color of the material,
  106427. * making it easier to setup and tweak the effect
  106428. */
  106429. albedoScaling: boolean;
  106430. /** @hidden */
  106431. private _internalMarkAllSubMeshesAsTexturesDirty;
  106432. /** @hidden */
  106433. _markAllSubMeshesAsTexturesDirty(): void;
  106434. /**
  106435. * Instantiate a new istance of clear coat configuration.
  106436. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106437. */
  106438. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106439. /**
  106440. * Specifies that the submesh is ready to be used.
  106441. * @param defines the list of "defines" to update.
  106442. * @param scene defines the scene the material belongs to.
  106443. * @returns - boolean indicating that the submesh is ready or not.
  106444. */
  106445. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  106446. /**
  106447. * Checks to see if a texture is used in the material.
  106448. * @param defines the list of "defines" to update.
  106449. * @param scene defines the scene the material belongs to.
  106450. */
  106451. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  106452. /**
  106453. * Binds the material data.
  106454. * @param uniformBuffer defines the Uniform buffer to fill in.
  106455. * @param scene defines the scene the material belongs to.
  106456. * @param isFrozen defines wether the material is frozen or not.
  106457. * @param subMesh the submesh to bind data for
  106458. */
  106459. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  106460. /**
  106461. * Checks to see if a texture is used in the material.
  106462. * @param texture - Base texture to use.
  106463. * @returns - Boolean specifying if a texture is used in the material.
  106464. */
  106465. hasTexture(texture: BaseTexture): boolean;
  106466. /**
  106467. * Returns an array of the actively used textures.
  106468. * @param activeTextures Array of BaseTextures
  106469. */
  106470. getActiveTextures(activeTextures: BaseTexture[]): void;
  106471. /**
  106472. * Returns the animatable textures.
  106473. * @param animatables Array of animatable textures.
  106474. */
  106475. getAnimatables(animatables: IAnimatable[]): void;
  106476. /**
  106477. * Disposes the resources of the material.
  106478. * @param forceDisposeTextures - Forces the disposal of all textures.
  106479. */
  106480. dispose(forceDisposeTextures?: boolean): void;
  106481. /**
  106482. * Get the current class name of the texture useful for serialization or dynamic coding.
  106483. * @returns "PBRSheenConfiguration"
  106484. */
  106485. getClassName(): string;
  106486. /**
  106487. * Add fallbacks to the effect fallbacks list.
  106488. * @param defines defines the Base texture to use.
  106489. * @param fallbacks defines the current fallback list.
  106490. * @param currentRank defines the current fallback rank.
  106491. * @returns the new fallback rank.
  106492. */
  106493. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106494. /**
  106495. * Add the required uniforms to the current list.
  106496. * @param uniforms defines the current uniform list.
  106497. */
  106498. static AddUniforms(uniforms: string[]): void;
  106499. /**
  106500. * Add the required uniforms to the current buffer.
  106501. * @param uniformBuffer defines the current uniform buffer.
  106502. */
  106503. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106504. /**
  106505. * Add the required samplers to the current list.
  106506. * @param samplers defines the current sampler list.
  106507. */
  106508. static AddSamplers(samplers: string[]): void;
  106509. /**
  106510. * Makes a duplicate of the current configuration into another one.
  106511. * @param sheenConfiguration define the config where to copy the info
  106512. */
  106513. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  106514. /**
  106515. * Serializes this BRDF configuration.
  106516. * @returns - An object with the serialized config.
  106517. */
  106518. serialize(): any;
  106519. /**
  106520. * Parses a anisotropy Configuration from a serialized object.
  106521. * @param source - Serialized object.
  106522. * @param scene Defines the scene we are parsing for
  106523. * @param rootUrl Defines the rootUrl to load from
  106524. */
  106525. parse(source: any, scene: Scene, rootUrl: string): void;
  106526. }
  106527. }
  106528. declare module BABYLON {
  106529. /**
  106530. * @hidden
  106531. */
  106532. export interface IMaterialSubSurfaceDefines {
  106533. SUBSURFACE: boolean;
  106534. SS_REFRACTION: boolean;
  106535. SS_TRANSLUCENCY: boolean;
  106536. SS_SCATTERING: boolean;
  106537. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106538. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106539. SS_REFRACTIONMAP_3D: boolean;
  106540. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106541. SS_LODINREFRACTIONALPHA: boolean;
  106542. SS_GAMMAREFRACTION: boolean;
  106543. SS_RGBDREFRACTION: boolean;
  106544. SS_LINEARSPECULARREFRACTION: boolean;
  106545. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106546. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106547. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106548. /** @hidden */
  106549. _areTexturesDirty: boolean;
  106550. }
  106551. /**
  106552. * Define the code related to the sub surface parameters of the pbr material.
  106553. */
  106554. export class PBRSubSurfaceConfiguration {
  106555. private _isRefractionEnabled;
  106556. /**
  106557. * Defines if the refraction is enabled in the material.
  106558. */
  106559. isRefractionEnabled: boolean;
  106560. private _isTranslucencyEnabled;
  106561. /**
  106562. * Defines if the translucency is enabled in the material.
  106563. */
  106564. isTranslucencyEnabled: boolean;
  106565. private _isScatteringEnabled;
  106566. /**
  106567. * Defines if the sub surface scattering is enabled in the material.
  106568. */
  106569. isScatteringEnabled: boolean;
  106570. private _scatteringDiffusionProfileIndex;
  106571. /**
  106572. * Diffusion profile for subsurface scattering.
  106573. * Useful for better scattering in the skins or foliages.
  106574. */
  106575. get scatteringDiffusionProfile(): Nullable<Color3>;
  106576. set scatteringDiffusionProfile(c: Nullable<Color3>);
  106577. /**
  106578. * Defines the refraction intensity of the material.
  106579. * The refraction when enabled replaces the Diffuse part of the material.
  106580. * The intensity helps transitionning between diffuse and refraction.
  106581. */
  106582. refractionIntensity: number;
  106583. /**
  106584. * Defines the translucency intensity of the material.
  106585. * When translucency has been enabled, this defines how much of the "translucency"
  106586. * is addded to the diffuse part of the material.
  106587. */
  106588. translucencyIntensity: number;
  106589. /**
  106590. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  106591. */
  106592. useAlbedoToTintRefraction: boolean;
  106593. private _thicknessTexture;
  106594. /**
  106595. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  106596. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  106597. * 0 would mean minimumThickness
  106598. * 1 would mean maximumThickness
  106599. * The other channels might be use as a mask to vary the different effects intensity.
  106600. */
  106601. thicknessTexture: Nullable<BaseTexture>;
  106602. private _refractionTexture;
  106603. /**
  106604. * Defines the texture to use for refraction.
  106605. */
  106606. refractionTexture: Nullable<BaseTexture>;
  106607. private _indexOfRefraction;
  106608. /**
  106609. * Index of refraction of the material base layer.
  106610. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106611. *
  106612. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  106613. *
  106614. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  106615. */
  106616. indexOfRefraction: number;
  106617. private _volumeIndexOfRefraction;
  106618. /**
  106619. * Index of refraction of the material's volume.
  106620. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106621. *
  106622. * This ONLY impacts refraction. If not provided or given a non-valid value,
  106623. * the volume will use the same IOR as the surface.
  106624. */
  106625. get volumeIndexOfRefraction(): number;
  106626. set volumeIndexOfRefraction(value: number);
  106627. private _invertRefractionY;
  106628. /**
  106629. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  106630. */
  106631. invertRefractionY: boolean;
  106632. private _linkRefractionWithTransparency;
  106633. /**
  106634. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  106635. * Materials half opaque for instance using refraction could benefit from this control.
  106636. */
  106637. linkRefractionWithTransparency: boolean;
  106638. /**
  106639. * Defines the minimum thickness stored in the thickness map.
  106640. * If no thickness map is defined, this value will be used to simulate thickness.
  106641. */
  106642. minimumThickness: number;
  106643. /**
  106644. * Defines the maximum thickness stored in the thickness map.
  106645. */
  106646. maximumThickness: number;
  106647. /**
  106648. * Defines the volume tint of the material.
  106649. * This is used for both translucency and scattering.
  106650. */
  106651. tintColor: Color3;
  106652. /**
  106653. * Defines the distance at which the tint color should be found in the media.
  106654. * This is used for refraction only.
  106655. */
  106656. tintColorAtDistance: number;
  106657. /**
  106658. * Defines how far each channel transmit through the media.
  106659. * It is defined as a color to simplify it selection.
  106660. */
  106661. diffusionDistance: Color3;
  106662. private _useMaskFromThicknessTexture;
  106663. /**
  106664. * Stores the intensity of the different subsurface effects in the thickness texture.
  106665. * * the green channel is the translucency intensity.
  106666. * * the blue channel is the scattering intensity.
  106667. * * the alpha channel is the refraction intensity.
  106668. */
  106669. useMaskFromThicknessTexture: boolean;
  106670. private _scene;
  106671. /** @hidden */
  106672. private _internalMarkAllSubMeshesAsTexturesDirty;
  106673. private _internalMarkScenePrePassDirty;
  106674. /** @hidden */
  106675. _markAllSubMeshesAsTexturesDirty(): void;
  106676. /** @hidden */
  106677. _markScenePrePassDirty(): void;
  106678. /**
  106679. * Instantiate a new istance of sub surface configuration.
  106680. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106681. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  106682. * @param scene The scene
  106683. */
  106684. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  106685. /**
  106686. * Gets wehter the submesh is ready to be used or not.
  106687. * @param defines the list of "defines" to update.
  106688. * @param scene defines the scene the material belongs to.
  106689. * @returns - boolean indicating that the submesh is ready or not.
  106690. */
  106691. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  106692. /**
  106693. * Checks to see if a texture is used in the material.
  106694. * @param defines the list of "defines" to update.
  106695. * @param scene defines the scene to the material belongs to.
  106696. */
  106697. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  106698. /**
  106699. * Binds the material data.
  106700. * @param uniformBuffer defines the Uniform buffer to fill in.
  106701. * @param scene defines the scene the material belongs to.
  106702. * @param engine defines the engine the material belongs to.
  106703. * @param isFrozen defines whether the material is frozen or not.
  106704. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  106705. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  106706. */
  106707. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  106708. /**
  106709. * Unbinds the material from the mesh.
  106710. * @param activeEffect defines the effect that should be unbound from.
  106711. * @returns true if unbound, otherwise false
  106712. */
  106713. unbind(activeEffect: Effect): boolean;
  106714. /**
  106715. * Returns the texture used for refraction or null if none is used.
  106716. * @param scene defines the scene the material belongs to.
  106717. * @returns - Refraction texture if present. If no refraction texture and refraction
  106718. * is linked with transparency, returns environment texture. Otherwise, returns null.
  106719. */
  106720. private _getRefractionTexture;
  106721. /**
  106722. * Returns true if alpha blending should be disabled.
  106723. */
  106724. get disableAlphaBlending(): boolean;
  106725. /**
  106726. * Fills the list of render target textures.
  106727. * @param renderTargets the list of render targets to update
  106728. */
  106729. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  106730. /**
  106731. * Checks to see if a texture is used in the material.
  106732. * @param texture - Base texture to use.
  106733. * @returns - Boolean specifying if a texture is used in the material.
  106734. */
  106735. hasTexture(texture: BaseTexture): boolean;
  106736. /**
  106737. * Gets a boolean indicating that current material needs to register RTT
  106738. * @returns true if this uses a render target otherwise false.
  106739. */
  106740. hasRenderTargetTextures(): boolean;
  106741. /**
  106742. * Returns an array of the actively used textures.
  106743. * @param activeTextures Array of BaseTextures
  106744. */
  106745. getActiveTextures(activeTextures: BaseTexture[]): void;
  106746. /**
  106747. * Returns the animatable textures.
  106748. * @param animatables Array of animatable textures.
  106749. */
  106750. getAnimatables(animatables: IAnimatable[]): void;
  106751. /**
  106752. * Disposes the resources of the material.
  106753. * @param forceDisposeTextures - Forces the disposal of all textures.
  106754. */
  106755. dispose(forceDisposeTextures?: boolean): void;
  106756. /**
  106757. * Get the current class name of the texture useful for serialization or dynamic coding.
  106758. * @returns "PBRSubSurfaceConfiguration"
  106759. */
  106760. getClassName(): string;
  106761. /**
  106762. * Add fallbacks to the effect fallbacks list.
  106763. * @param defines defines the Base texture to use.
  106764. * @param fallbacks defines the current fallback list.
  106765. * @param currentRank defines the current fallback rank.
  106766. * @returns the new fallback rank.
  106767. */
  106768. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106769. /**
  106770. * Add the required uniforms to the current list.
  106771. * @param uniforms defines the current uniform list.
  106772. */
  106773. static AddUniforms(uniforms: string[]): void;
  106774. /**
  106775. * Add the required samplers to the current list.
  106776. * @param samplers defines the current sampler list.
  106777. */
  106778. static AddSamplers(samplers: string[]): void;
  106779. /**
  106780. * Add the required uniforms to the current buffer.
  106781. * @param uniformBuffer defines the current uniform buffer.
  106782. */
  106783. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106784. /**
  106785. * Makes a duplicate of the current configuration into another one.
  106786. * @param configuration define the config where to copy the info
  106787. */
  106788. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  106789. /**
  106790. * Serializes this Sub Surface configuration.
  106791. * @returns - An object with the serialized config.
  106792. */
  106793. serialize(): any;
  106794. /**
  106795. * Parses a anisotropy Configuration from a serialized object.
  106796. * @param source - Serialized object.
  106797. * @param scene Defines the scene we are parsing for
  106798. * @param rootUrl Defines the rootUrl to load from
  106799. */
  106800. parse(source: any, scene: Scene, rootUrl: string): void;
  106801. }
  106802. }
  106803. declare module BABYLON {
  106804. /**
  106805. * Class representing spherical harmonics coefficients to the 3rd degree
  106806. */
  106807. export class SphericalHarmonics {
  106808. /**
  106809. * Defines whether or not the harmonics have been prescaled for rendering.
  106810. */
  106811. preScaled: boolean;
  106812. /**
  106813. * The l0,0 coefficients of the spherical harmonics
  106814. */
  106815. l00: Vector3;
  106816. /**
  106817. * The l1,-1 coefficients of the spherical harmonics
  106818. */
  106819. l1_1: Vector3;
  106820. /**
  106821. * The l1,0 coefficients of the spherical harmonics
  106822. */
  106823. l10: Vector3;
  106824. /**
  106825. * The l1,1 coefficients of the spherical harmonics
  106826. */
  106827. l11: Vector3;
  106828. /**
  106829. * The l2,-2 coefficients of the spherical harmonics
  106830. */
  106831. l2_2: Vector3;
  106832. /**
  106833. * The l2,-1 coefficients of the spherical harmonics
  106834. */
  106835. l2_1: Vector3;
  106836. /**
  106837. * The l2,0 coefficients of the spherical harmonics
  106838. */
  106839. l20: Vector3;
  106840. /**
  106841. * The l2,1 coefficients of the spherical harmonics
  106842. */
  106843. l21: Vector3;
  106844. /**
  106845. * The l2,2 coefficients of the spherical harmonics
  106846. */
  106847. l22: Vector3;
  106848. /**
  106849. * Adds a light to the spherical harmonics
  106850. * @param direction the direction of the light
  106851. * @param color the color of the light
  106852. * @param deltaSolidAngle the delta solid angle of the light
  106853. */
  106854. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106855. /**
  106856. * Scales the spherical harmonics by the given amount
  106857. * @param scale the amount to scale
  106858. */
  106859. scaleInPlace(scale: number): void;
  106860. /**
  106861. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106862. *
  106863. * ```
  106864. * E_lm = A_l * L_lm
  106865. * ```
  106866. *
  106867. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106868. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106869. * the scaling factors are given in equation 9.
  106870. */
  106871. convertIncidentRadianceToIrradiance(): void;
  106872. /**
  106873. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106874. *
  106875. * ```
  106876. * L = (1/pi) * E * rho
  106877. * ```
  106878. *
  106879. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106880. */
  106881. convertIrradianceToLambertianRadiance(): void;
  106882. /**
  106883. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106884. * required operations at run time.
  106885. *
  106886. * This is simply done by scaling back the SH with Ylm constants parameter.
  106887. * The trigonometric part being applied by the shader at run time.
  106888. */
  106889. preScaleForRendering(): void;
  106890. /**
  106891. * Constructs a spherical harmonics from an array.
  106892. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106893. * @returns the spherical harmonics
  106894. */
  106895. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106896. /**
  106897. * Gets the spherical harmonics from polynomial
  106898. * @param polynomial the spherical polynomial
  106899. * @returns the spherical harmonics
  106900. */
  106901. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106902. }
  106903. /**
  106904. * Class representing spherical polynomial coefficients to the 3rd degree
  106905. */
  106906. export class SphericalPolynomial {
  106907. private _harmonics;
  106908. /**
  106909. * The spherical harmonics used to create the polynomials.
  106910. */
  106911. get preScaledHarmonics(): SphericalHarmonics;
  106912. /**
  106913. * The x coefficients of the spherical polynomial
  106914. */
  106915. x: Vector3;
  106916. /**
  106917. * The y coefficients of the spherical polynomial
  106918. */
  106919. y: Vector3;
  106920. /**
  106921. * The z coefficients of the spherical polynomial
  106922. */
  106923. z: Vector3;
  106924. /**
  106925. * The xx coefficients of the spherical polynomial
  106926. */
  106927. xx: Vector3;
  106928. /**
  106929. * The yy coefficients of the spherical polynomial
  106930. */
  106931. yy: Vector3;
  106932. /**
  106933. * The zz coefficients of the spherical polynomial
  106934. */
  106935. zz: Vector3;
  106936. /**
  106937. * The xy coefficients of the spherical polynomial
  106938. */
  106939. xy: Vector3;
  106940. /**
  106941. * The yz coefficients of the spherical polynomial
  106942. */
  106943. yz: Vector3;
  106944. /**
  106945. * The zx coefficients of the spherical polynomial
  106946. */
  106947. zx: Vector3;
  106948. /**
  106949. * Adds an ambient color to the spherical polynomial
  106950. * @param color the color to add
  106951. */
  106952. addAmbient(color: Color3): void;
  106953. /**
  106954. * Scales the spherical polynomial by the given amount
  106955. * @param scale the amount to scale
  106956. */
  106957. scaleInPlace(scale: number): void;
  106958. /**
  106959. * Gets the spherical polynomial from harmonics
  106960. * @param harmonics the spherical harmonics
  106961. * @returns the spherical polynomial
  106962. */
  106963. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106964. /**
  106965. * Constructs a spherical polynomial from an array.
  106966. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106967. * @returns the spherical polynomial
  106968. */
  106969. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106970. }
  106971. }
  106972. declare module BABYLON {
  106973. /**
  106974. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  106975. */
  106976. export interface CubeMapInfo {
  106977. /**
  106978. * The pixel array for the front face.
  106979. * This is stored in format, left to right, up to down format.
  106980. */
  106981. front: Nullable<ArrayBufferView>;
  106982. /**
  106983. * The pixel array for the back face.
  106984. * This is stored in format, left to right, up to down format.
  106985. */
  106986. back: Nullable<ArrayBufferView>;
  106987. /**
  106988. * The pixel array for the left face.
  106989. * This is stored in format, left to right, up to down format.
  106990. */
  106991. left: Nullable<ArrayBufferView>;
  106992. /**
  106993. * The pixel array for the right face.
  106994. * This is stored in format, left to right, up to down format.
  106995. */
  106996. right: Nullable<ArrayBufferView>;
  106997. /**
  106998. * The pixel array for the up face.
  106999. * This is stored in format, left to right, up to down format.
  107000. */
  107001. up: Nullable<ArrayBufferView>;
  107002. /**
  107003. * The pixel array for the down face.
  107004. * This is stored in format, left to right, up to down format.
  107005. */
  107006. down: Nullable<ArrayBufferView>;
  107007. /**
  107008. * The size of the cubemap stored.
  107009. *
  107010. * Each faces will be size * size pixels.
  107011. */
  107012. size: number;
  107013. /**
  107014. * The format of the texture.
  107015. *
  107016. * RGBA, RGB.
  107017. */
  107018. format: number;
  107019. /**
  107020. * The type of the texture data.
  107021. *
  107022. * UNSIGNED_INT, FLOAT.
  107023. */
  107024. type: number;
  107025. /**
  107026. * Specifies whether the texture is in gamma space.
  107027. */
  107028. gammaSpace: boolean;
  107029. }
  107030. /**
  107031. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  107032. */
  107033. export class PanoramaToCubeMapTools {
  107034. private static FACE_LEFT;
  107035. private static FACE_RIGHT;
  107036. private static FACE_FRONT;
  107037. private static FACE_BACK;
  107038. private static FACE_DOWN;
  107039. private static FACE_UP;
  107040. /**
  107041. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  107042. *
  107043. * @param float32Array The source data.
  107044. * @param inputWidth The width of the input panorama.
  107045. * @param inputHeight The height of the input panorama.
  107046. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  107047. * @return The cubemap data
  107048. */
  107049. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  107050. private static CreateCubemapTexture;
  107051. private static CalcProjectionSpherical;
  107052. }
  107053. }
  107054. declare module BABYLON {
  107055. /**
  107056. * Helper class dealing with the extraction of spherical polynomial dataArray
  107057. * from a cube map.
  107058. */
  107059. export class CubeMapToSphericalPolynomialTools {
  107060. private static FileFaces;
  107061. /**
  107062. * Converts a texture to the according Spherical Polynomial data.
  107063. * This extracts the first 3 orders only as they are the only one used in the lighting.
  107064. *
  107065. * @param texture The texture to extract the information from.
  107066. * @return The Spherical Polynomial data.
  107067. */
  107068. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  107069. /**
  107070. * Converts a cubemap to the according Spherical Polynomial data.
  107071. * This extracts the first 3 orders only as they are the only one used in the lighting.
  107072. *
  107073. * @param cubeInfo The Cube map to extract the information from.
  107074. * @return The Spherical Polynomial data.
  107075. */
  107076. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  107077. }
  107078. }
  107079. declare module BABYLON {
  107080. interface BaseTexture {
  107081. /**
  107082. * Get the polynomial representation of the texture data.
  107083. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  107084. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  107085. */
  107086. sphericalPolynomial: Nullable<SphericalPolynomial>;
  107087. }
  107088. }
  107089. declare module BABYLON {
  107090. /** @hidden */
  107091. export var pbrFragmentDeclaration: {
  107092. name: string;
  107093. shader: string;
  107094. };
  107095. }
  107096. declare module BABYLON {
  107097. /** @hidden */
  107098. export var pbrUboDeclaration: {
  107099. name: string;
  107100. shader: string;
  107101. };
  107102. }
  107103. declare module BABYLON {
  107104. /** @hidden */
  107105. export var pbrFragmentExtraDeclaration: {
  107106. name: string;
  107107. shader: string;
  107108. };
  107109. }
  107110. declare module BABYLON {
  107111. /** @hidden */
  107112. export var pbrFragmentSamplersDeclaration: {
  107113. name: string;
  107114. shader: string;
  107115. };
  107116. }
  107117. declare module BABYLON {
  107118. /** @hidden */
  107119. export var subSurfaceScatteringFunctions: {
  107120. name: string;
  107121. shader: string;
  107122. };
  107123. }
  107124. declare module BABYLON {
  107125. /** @hidden */
  107126. export var importanceSampling: {
  107127. name: string;
  107128. shader: string;
  107129. };
  107130. }
  107131. declare module BABYLON {
  107132. /** @hidden */
  107133. export var pbrHelperFunctions: {
  107134. name: string;
  107135. shader: string;
  107136. };
  107137. }
  107138. declare module BABYLON {
  107139. /** @hidden */
  107140. export var harmonicsFunctions: {
  107141. name: string;
  107142. shader: string;
  107143. };
  107144. }
  107145. declare module BABYLON {
  107146. /** @hidden */
  107147. export var pbrDirectLightingSetupFunctions: {
  107148. name: string;
  107149. shader: string;
  107150. };
  107151. }
  107152. declare module BABYLON {
  107153. /** @hidden */
  107154. export var pbrDirectLightingFalloffFunctions: {
  107155. name: string;
  107156. shader: string;
  107157. };
  107158. }
  107159. declare module BABYLON {
  107160. /** @hidden */
  107161. export var pbrBRDFFunctions: {
  107162. name: string;
  107163. shader: string;
  107164. };
  107165. }
  107166. declare module BABYLON {
  107167. /** @hidden */
  107168. export var hdrFilteringFunctions: {
  107169. name: string;
  107170. shader: string;
  107171. };
  107172. }
  107173. declare module BABYLON {
  107174. /** @hidden */
  107175. export var pbrDirectLightingFunctions: {
  107176. name: string;
  107177. shader: string;
  107178. };
  107179. }
  107180. declare module BABYLON {
  107181. /** @hidden */
  107182. export var pbrIBLFunctions: {
  107183. name: string;
  107184. shader: string;
  107185. };
  107186. }
  107187. declare module BABYLON {
  107188. /** @hidden */
  107189. export var pbrBlockAlbedoOpacity: {
  107190. name: string;
  107191. shader: string;
  107192. };
  107193. }
  107194. declare module BABYLON {
  107195. /** @hidden */
  107196. export var pbrBlockReflectivity: {
  107197. name: string;
  107198. shader: string;
  107199. };
  107200. }
  107201. declare module BABYLON {
  107202. /** @hidden */
  107203. export var pbrBlockAmbientOcclusion: {
  107204. name: string;
  107205. shader: string;
  107206. };
  107207. }
  107208. declare module BABYLON {
  107209. /** @hidden */
  107210. export var pbrBlockAlphaFresnel: {
  107211. name: string;
  107212. shader: string;
  107213. };
  107214. }
  107215. declare module BABYLON {
  107216. /** @hidden */
  107217. export var pbrBlockAnisotropic: {
  107218. name: string;
  107219. shader: string;
  107220. };
  107221. }
  107222. declare module BABYLON {
  107223. /** @hidden */
  107224. export var pbrBlockReflection: {
  107225. name: string;
  107226. shader: string;
  107227. };
  107228. }
  107229. declare module BABYLON {
  107230. /** @hidden */
  107231. export var pbrBlockSheen: {
  107232. name: string;
  107233. shader: string;
  107234. };
  107235. }
  107236. declare module BABYLON {
  107237. /** @hidden */
  107238. export var pbrBlockClearcoat: {
  107239. name: string;
  107240. shader: string;
  107241. };
  107242. }
  107243. declare module BABYLON {
  107244. /** @hidden */
  107245. export var pbrBlockSubSurface: {
  107246. name: string;
  107247. shader: string;
  107248. };
  107249. }
  107250. declare module BABYLON {
  107251. /** @hidden */
  107252. export var pbrBlockNormalGeometric: {
  107253. name: string;
  107254. shader: string;
  107255. };
  107256. }
  107257. declare module BABYLON {
  107258. /** @hidden */
  107259. export var pbrBlockNormalFinal: {
  107260. name: string;
  107261. shader: string;
  107262. };
  107263. }
  107264. declare module BABYLON {
  107265. /** @hidden */
  107266. export var pbrBlockLightmapInit: {
  107267. name: string;
  107268. shader: string;
  107269. };
  107270. }
  107271. declare module BABYLON {
  107272. /** @hidden */
  107273. export var pbrBlockGeometryInfo: {
  107274. name: string;
  107275. shader: string;
  107276. };
  107277. }
  107278. declare module BABYLON {
  107279. /** @hidden */
  107280. export var pbrBlockReflectance0: {
  107281. name: string;
  107282. shader: string;
  107283. };
  107284. }
  107285. declare module BABYLON {
  107286. /** @hidden */
  107287. export var pbrBlockReflectance: {
  107288. name: string;
  107289. shader: string;
  107290. };
  107291. }
  107292. declare module BABYLON {
  107293. /** @hidden */
  107294. export var pbrBlockDirectLighting: {
  107295. name: string;
  107296. shader: string;
  107297. };
  107298. }
  107299. declare module BABYLON {
  107300. /** @hidden */
  107301. export var pbrBlockFinalLitComponents: {
  107302. name: string;
  107303. shader: string;
  107304. };
  107305. }
  107306. declare module BABYLON {
  107307. /** @hidden */
  107308. export var pbrBlockFinalUnlitComponents: {
  107309. name: string;
  107310. shader: string;
  107311. };
  107312. }
  107313. declare module BABYLON {
  107314. /** @hidden */
  107315. export var pbrBlockFinalColorComposition: {
  107316. name: string;
  107317. shader: string;
  107318. };
  107319. }
  107320. declare module BABYLON {
  107321. /** @hidden */
  107322. export var pbrBlockImageProcessing: {
  107323. name: string;
  107324. shader: string;
  107325. };
  107326. }
  107327. declare module BABYLON {
  107328. /** @hidden */
  107329. export var pbrDebug: {
  107330. name: string;
  107331. shader: string;
  107332. };
  107333. }
  107334. declare module BABYLON {
  107335. /** @hidden */
  107336. export var pbrPixelShader: {
  107337. name: string;
  107338. shader: string;
  107339. };
  107340. }
  107341. declare module BABYLON {
  107342. /** @hidden */
  107343. export var pbrVertexDeclaration: {
  107344. name: string;
  107345. shader: string;
  107346. };
  107347. }
  107348. declare module BABYLON {
  107349. /** @hidden */
  107350. export var pbrVertexShader: {
  107351. name: string;
  107352. shader: string;
  107353. };
  107354. }
  107355. declare module BABYLON {
  107356. /**
  107357. * Manages the defines for the PBR Material.
  107358. * @hidden
  107359. */
  107360. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  107361. PBR: boolean;
  107362. NUM_SAMPLES: string;
  107363. REALTIME_FILTERING: boolean;
  107364. MAINUV1: boolean;
  107365. MAINUV2: boolean;
  107366. UV1: boolean;
  107367. UV2: boolean;
  107368. ALBEDO: boolean;
  107369. GAMMAALBEDO: boolean;
  107370. ALBEDODIRECTUV: number;
  107371. VERTEXCOLOR: boolean;
  107372. DETAIL: boolean;
  107373. DETAILDIRECTUV: number;
  107374. DETAIL_NORMALBLENDMETHOD: number;
  107375. AMBIENT: boolean;
  107376. AMBIENTDIRECTUV: number;
  107377. AMBIENTINGRAYSCALE: boolean;
  107378. OPACITY: boolean;
  107379. VERTEXALPHA: boolean;
  107380. OPACITYDIRECTUV: number;
  107381. OPACITYRGB: boolean;
  107382. ALPHATEST: boolean;
  107383. DEPTHPREPASS: boolean;
  107384. ALPHABLEND: boolean;
  107385. ALPHAFROMALBEDO: boolean;
  107386. ALPHATESTVALUE: string;
  107387. SPECULAROVERALPHA: boolean;
  107388. RADIANCEOVERALPHA: boolean;
  107389. ALPHAFRESNEL: boolean;
  107390. LINEARALPHAFRESNEL: boolean;
  107391. PREMULTIPLYALPHA: boolean;
  107392. EMISSIVE: boolean;
  107393. EMISSIVEDIRECTUV: number;
  107394. REFLECTIVITY: boolean;
  107395. REFLECTIVITYDIRECTUV: number;
  107396. SPECULARTERM: boolean;
  107397. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  107398. MICROSURFACEAUTOMATIC: boolean;
  107399. LODBASEDMICROSFURACE: boolean;
  107400. MICROSURFACEMAP: boolean;
  107401. MICROSURFACEMAPDIRECTUV: number;
  107402. METALLICWORKFLOW: boolean;
  107403. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  107404. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  107405. METALLNESSSTOREINMETALMAPBLUE: boolean;
  107406. AOSTOREINMETALMAPRED: boolean;
  107407. METALLIC_REFLECTANCE: boolean;
  107408. METALLIC_REFLECTANCEDIRECTUV: number;
  107409. ENVIRONMENTBRDF: boolean;
  107410. ENVIRONMENTBRDF_RGBD: boolean;
  107411. NORMAL: boolean;
  107412. TANGENT: boolean;
  107413. BUMP: boolean;
  107414. BUMPDIRECTUV: number;
  107415. OBJECTSPACE_NORMALMAP: boolean;
  107416. PARALLAX: boolean;
  107417. PARALLAXOCCLUSION: boolean;
  107418. NORMALXYSCALE: boolean;
  107419. LIGHTMAP: boolean;
  107420. LIGHTMAPDIRECTUV: number;
  107421. USELIGHTMAPASSHADOWMAP: boolean;
  107422. GAMMALIGHTMAP: boolean;
  107423. RGBDLIGHTMAP: boolean;
  107424. REFLECTION: boolean;
  107425. REFLECTIONMAP_3D: boolean;
  107426. REFLECTIONMAP_SPHERICAL: boolean;
  107427. REFLECTIONMAP_PLANAR: boolean;
  107428. REFLECTIONMAP_CUBIC: boolean;
  107429. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107430. REFLECTIONMAP_PROJECTION: boolean;
  107431. REFLECTIONMAP_SKYBOX: boolean;
  107432. REFLECTIONMAP_EXPLICIT: boolean;
  107433. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107434. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107435. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107436. INVERTCUBICMAP: boolean;
  107437. USESPHERICALFROMREFLECTIONMAP: boolean;
  107438. USEIRRADIANCEMAP: boolean;
  107439. SPHERICAL_HARMONICS: boolean;
  107440. USESPHERICALINVERTEX: boolean;
  107441. REFLECTIONMAP_OPPOSITEZ: boolean;
  107442. LODINREFLECTIONALPHA: boolean;
  107443. GAMMAREFLECTION: boolean;
  107444. RGBDREFLECTION: boolean;
  107445. LINEARSPECULARREFLECTION: boolean;
  107446. RADIANCEOCCLUSION: boolean;
  107447. HORIZONOCCLUSION: boolean;
  107448. INSTANCES: boolean;
  107449. THIN_INSTANCES: boolean;
  107450. PREPASS: boolean;
  107451. PREPASS_IRRADIANCE: boolean;
  107452. PREPASS_IRRADIANCE_INDEX: number;
  107453. PREPASS_ALBEDO: boolean;
  107454. PREPASS_ALBEDO_INDEX: number;
  107455. PREPASS_DEPTHNORMAL: boolean;
  107456. PREPASS_DEPTHNORMAL_INDEX: number;
  107457. PREPASS_POSITION: boolean;
  107458. PREPASS_POSITION_INDEX: number;
  107459. PREPASS_VELOCITY: boolean;
  107460. PREPASS_VELOCITY_INDEX: number;
  107461. PREPASS_REFLECTIVITY: boolean;
  107462. PREPASS_REFLECTIVITY_INDEX: number;
  107463. SCENE_MRT_COUNT: number;
  107464. NUM_BONE_INFLUENCERS: number;
  107465. BonesPerMesh: number;
  107466. BONETEXTURE: boolean;
  107467. BONES_VELOCITY_ENABLED: boolean;
  107468. NONUNIFORMSCALING: boolean;
  107469. MORPHTARGETS: boolean;
  107470. MORPHTARGETS_NORMAL: boolean;
  107471. MORPHTARGETS_TANGENT: boolean;
  107472. MORPHTARGETS_UV: boolean;
  107473. NUM_MORPH_INFLUENCERS: number;
  107474. IMAGEPROCESSING: boolean;
  107475. VIGNETTE: boolean;
  107476. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107477. VIGNETTEBLENDMODEOPAQUE: boolean;
  107478. TONEMAPPING: boolean;
  107479. TONEMAPPING_ACES: boolean;
  107480. CONTRAST: boolean;
  107481. COLORCURVES: boolean;
  107482. COLORGRADING: boolean;
  107483. COLORGRADING3D: boolean;
  107484. SAMPLER3DGREENDEPTH: boolean;
  107485. SAMPLER3DBGRMAP: boolean;
  107486. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107487. EXPOSURE: boolean;
  107488. MULTIVIEW: boolean;
  107489. USEPHYSICALLIGHTFALLOFF: boolean;
  107490. USEGLTFLIGHTFALLOFF: boolean;
  107491. TWOSIDEDLIGHTING: boolean;
  107492. SHADOWFLOAT: boolean;
  107493. CLIPPLANE: boolean;
  107494. CLIPPLANE2: boolean;
  107495. CLIPPLANE3: boolean;
  107496. CLIPPLANE4: boolean;
  107497. CLIPPLANE5: boolean;
  107498. CLIPPLANE6: boolean;
  107499. POINTSIZE: boolean;
  107500. FOG: boolean;
  107501. LOGARITHMICDEPTH: boolean;
  107502. FORCENORMALFORWARD: boolean;
  107503. SPECULARAA: boolean;
  107504. CLEARCOAT: boolean;
  107505. CLEARCOAT_DEFAULTIOR: boolean;
  107506. CLEARCOAT_TEXTURE: boolean;
  107507. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  107508. CLEARCOAT_TEXTUREDIRECTUV: number;
  107509. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  107510. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  107511. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  107512. CLEARCOAT_BUMP: boolean;
  107513. CLEARCOAT_BUMPDIRECTUV: number;
  107514. CLEARCOAT_REMAP_F0: boolean;
  107515. CLEARCOAT_TINT: boolean;
  107516. CLEARCOAT_TINT_TEXTURE: boolean;
  107517. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107518. ANISOTROPIC: boolean;
  107519. ANISOTROPIC_TEXTURE: boolean;
  107520. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107521. BRDF_V_HEIGHT_CORRELATED: boolean;
  107522. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107523. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  107524. SHEEN: boolean;
  107525. SHEEN_TEXTURE: boolean;
  107526. SHEEN_TEXTURE_ROUGHNESS: boolean;
  107527. SHEEN_TEXTUREDIRECTUV: number;
  107528. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  107529. SHEEN_LINKWITHALBEDO: boolean;
  107530. SHEEN_ROUGHNESS: boolean;
  107531. SHEEN_ALBEDOSCALING: boolean;
  107532. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  107533. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  107534. SUBSURFACE: boolean;
  107535. SS_REFRACTION: boolean;
  107536. SS_TRANSLUCENCY: boolean;
  107537. SS_SCATTERING: boolean;
  107538. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107539. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107540. SS_REFRACTIONMAP_3D: boolean;
  107541. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107542. SS_LODINREFRACTIONALPHA: boolean;
  107543. SS_GAMMAREFRACTION: boolean;
  107544. SS_RGBDREFRACTION: boolean;
  107545. SS_LINEARSPECULARREFRACTION: boolean;
  107546. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107547. SS_ALBEDOFORREFRACTIONTINT: boolean;
  107548. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107549. UNLIT: boolean;
  107550. DEBUGMODE: number;
  107551. /**
  107552. * Initializes the PBR Material defines.
  107553. */
  107554. constructor();
  107555. /**
  107556. * Resets the PBR Material defines.
  107557. */
  107558. reset(): void;
  107559. }
  107560. /**
  107561. * The Physically based material base class of BJS.
  107562. *
  107563. * This offers the main features of a standard PBR material.
  107564. * For more information, please refer to the documentation :
  107565. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107566. */
  107567. export abstract class PBRBaseMaterial extends PushMaterial {
  107568. /**
  107569. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107570. */
  107571. static readonly PBRMATERIAL_OPAQUE: number;
  107572. /**
  107573. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107574. */
  107575. static readonly PBRMATERIAL_ALPHATEST: number;
  107576. /**
  107577. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107578. */
  107579. static readonly PBRMATERIAL_ALPHABLEND: number;
  107580. /**
  107581. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107582. * They are also discarded below the alpha cutoff threshold to improve performances.
  107583. */
  107584. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107585. /**
  107586. * Defines the default value of how much AO map is occluding the analytical lights
  107587. * (point spot...).
  107588. */
  107589. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107590. /**
  107591. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  107592. */
  107593. static readonly LIGHTFALLOFF_PHYSICAL: number;
  107594. /**
  107595. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  107596. * to enhance interoperability with other engines.
  107597. */
  107598. static readonly LIGHTFALLOFF_GLTF: number;
  107599. /**
  107600. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  107601. * to enhance interoperability with other materials.
  107602. */
  107603. static readonly LIGHTFALLOFF_STANDARD: number;
  107604. /**
  107605. * Intensity of the direct lights e.g. the four lights available in your scene.
  107606. * This impacts both the direct diffuse and specular highlights.
  107607. */
  107608. protected _directIntensity: number;
  107609. /**
  107610. * Intensity of the emissive part of the material.
  107611. * This helps controlling the emissive effect without modifying the emissive color.
  107612. */
  107613. protected _emissiveIntensity: number;
  107614. /**
  107615. * Intensity of the environment e.g. how much the environment will light the object
  107616. * either through harmonics for rough material or through the refelction for shiny ones.
  107617. */
  107618. protected _environmentIntensity: number;
  107619. /**
  107620. * This is a special control allowing the reduction of the specular highlights coming from the
  107621. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107622. */
  107623. protected _specularIntensity: number;
  107624. /**
  107625. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  107626. */
  107627. private _lightingInfos;
  107628. /**
  107629. * Debug Control allowing disabling the bump map on this material.
  107630. */
  107631. protected _disableBumpMap: boolean;
  107632. /**
  107633. * AKA Diffuse Texture in standard nomenclature.
  107634. */
  107635. protected _albedoTexture: Nullable<BaseTexture>;
  107636. /**
  107637. * AKA Occlusion Texture in other nomenclature.
  107638. */
  107639. protected _ambientTexture: Nullable<BaseTexture>;
  107640. /**
  107641. * AKA Occlusion Texture Intensity in other nomenclature.
  107642. */
  107643. protected _ambientTextureStrength: number;
  107644. /**
  107645. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107646. * 1 means it completely occludes it
  107647. * 0 mean it has no impact
  107648. */
  107649. protected _ambientTextureImpactOnAnalyticalLights: number;
  107650. /**
  107651. * Stores the alpha values in a texture.
  107652. */
  107653. protected _opacityTexture: Nullable<BaseTexture>;
  107654. /**
  107655. * Stores the reflection values in a texture.
  107656. */
  107657. protected _reflectionTexture: Nullable<BaseTexture>;
  107658. /**
  107659. * Stores the emissive values in a texture.
  107660. */
  107661. protected _emissiveTexture: Nullable<BaseTexture>;
  107662. /**
  107663. * AKA Specular texture in other nomenclature.
  107664. */
  107665. protected _reflectivityTexture: Nullable<BaseTexture>;
  107666. /**
  107667. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107668. */
  107669. protected _metallicTexture: Nullable<BaseTexture>;
  107670. /**
  107671. * Specifies the metallic scalar of the metallic/roughness workflow.
  107672. * Can also be used to scale the metalness values of the metallic texture.
  107673. */
  107674. protected _metallic: Nullable<number>;
  107675. /**
  107676. * Specifies the roughness scalar of the metallic/roughness workflow.
  107677. * Can also be used to scale the roughness values of the metallic texture.
  107678. */
  107679. protected _roughness: Nullable<number>;
  107680. /**
  107681. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107682. * By default the indexOfrefraction is used to compute F0;
  107683. *
  107684. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107685. *
  107686. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107687. * F90 = metallicReflectanceColor;
  107688. */
  107689. protected _metallicF0Factor: number;
  107690. /**
  107691. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107692. * By default the F90 is always 1;
  107693. *
  107694. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107695. *
  107696. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107697. * F90 = metallicReflectanceColor;
  107698. */
  107699. protected _metallicReflectanceColor: Color3;
  107700. /**
  107701. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107702. * This is multiply against the scalar values defined in the material.
  107703. */
  107704. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  107705. /**
  107706. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107707. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107708. */
  107709. protected _microSurfaceTexture: Nullable<BaseTexture>;
  107710. /**
  107711. * Stores surface normal data used to displace a mesh in a texture.
  107712. */
  107713. protected _bumpTexture: Nullable<BaseTexture>;
  107714. /**
  107715. * Stores the pre-calculated light information of a mesh in a texture.
  107716. */
  107717. protected _lightmapTexture: Nullable<BaseTexture>;
  107718. /**
  107719. * The color of a material in ambient lighting.
  107720. */
  107721. protected _ambientColor: Color3;
  107722. /**
  107723. * AKA Diffuse Color in other nomenclature.
  107724. */
  107725. protected _albedoColor: Color3;
  107726. /**
  107727. * AKA Specular Color in other nomenclature.
  107728. */
  107729. protected _reflectivityColor: Color3;
  107730. /**
  107731. * The color applied when light is reflected from a material.
  107732. */
  107733. protected _reflectionColor: Color3;
  107734. /**
  107735. * The color applied when light is emitted from a material.
  107736. */
  107737. protected _emissiveColor: Color3;
  107738. /**
  107739. * AKA Glossiness in other nomenclature.
  107740. */
  107741. protected _microSurface: number;
  107742. /**
  107743. * Specifies that the material will use the light map as a show map.
  107744. */
  107745. protected _useLightmapAsShadowmap: boolean;
  107746. /**
  107747. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107748. * makes the reflect vector face the model (under horizon).
  107749. */
  107750. protected _useHorizonOcclusion: boolean;
  107751. /**
  107752. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107753. * too much the area relying on ambient texture to define their ambient occlusion.
  107754. */
  107755. protected _useRadianceOcclusion: boolean;
  107756. /**
  107757. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107758. */
  107759. protected _useAlphaFromAlbedoTexture: boolean;
  107760. /**
  107761. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  107762. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107763. */
  107764. protected _useSpecularOverAlpha: boolean;
  107765. /**
  107766. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107767. */
  107768. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107769. /**
  107770. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107771. */
  107772. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  107773. /**
  107774. * Specifies if the metallic texture contains the roughness information in its green channel.
  107775. */
  107776. protected _useRoughnessFromMetallicTextureGreen: boolean;
  107777. /**
  107778. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107779. */
  107780. protected _useMetallnessFromMetallicTextureBlue: boolean;
  107781. /**
  107782. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107783. */
  107784. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  107785. /**
  107786. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107787. */
  107788. protected _useAmbientInGrayScale: boolean;
  107789. /**
  107790. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107791. * The material will try to infer what glossiness each pixel should be.
  107792. */
  107793. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  107794. /**
  107795. * Defines the falloff type used in this material.
  107796. * It by default is Physical.
  107797. */
  107798. protected _lightFalloff: number;
  107799. /**
  107800. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107801. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107802. */
  107803. protected _useRadianceOverAlpha: boolean;
  107804. /**
  107805. * Allows using an object space normal map (instead of tangent space).
  107806. */
  107807. protected _useObjectSpaceNormalMap: boolean;
  107808. /**
  107809. * Allows using the bump map in parallax mode.
  107810. */
  107811. protected _useParallax: boolean;
  107812. /**
  107813. * Allows using the bump map in parallax occlusion mode.
  107814. */
  107815. protected _useParallaxOcclusion: boolean;
  107816. /**
  107817. * Controls the scale bias of the parallax mode.
  107818. */
  107819. protected _parallaxScaleBias: number;
  107820. /**
  107821. * If sets to true, disables all the lights affecting the material.
  107822. */
  107823. protected _disableLighting: boolean;
  107824. /**
  107825. * Number of Simultaneous lights allowed on the material.
  107826. */
  107827. protected _maxSimultaneousLights: number;
  107828. /**
  107829. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107830. */
  107831. protected _invertNormalMapX: boolean;
  107832. /**
  107833. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107834. */
  107835. protected _invertNormalMapY: boolean;
  107836. /**
  107837. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107838. */
  107839. protected _twoSidedLighting: boolean;
  107840. /**
  107841. * Defines the alpha limits in alpha test mode.
  107842. */
  107843. protected _alphaCutOff: number;
  107844. /**
  107845. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107846. */
  107847. protected _forceAlphaTest: boolean;
  107848. /**
  107849. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107850. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107851. */
  107852. protected _useAlphaFresnel: boolean;
  107853. /**
  107854. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107855. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107856. */
  107857. protected _useLinearAlphaFresnel: boolean;
  107858. /**
  107859. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  107860. * from cos thetav and roughness:
  107861. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  107862. */
  107863. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  107864. /**
  107865. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107866. */
  107867. protected _forceIrradianceInFragment: boolean;
  107868. private _realTimeFiltering;
  107869. /**
  107870. * Enables realtime filtering on the texture.
  107871. */
  107872. get realTimeFiltering(): boolean;
  107873. set realTimeFiltering(b: boolean);
  107874. private _realTimeFilteringQuality;
  107875. /**
  107876. * Quality switch for realtime filtering
  107877. */
  107878. get realTimeFilteringQuality(): number;
  107879. set realTimeFilteringQuality(n: number);
  107880. /**
  107881. * Can this material render to several textures at once
  107882. */
  107883. get canRenderToMRT(): boolean;
  107884. /**
  107885. * Force normal to face away from face.
  107886. */
  107887. protected _forceNormalForward: boolean;
  107888. /**
  107889. * Enables specular anti aliasing in the PBR shader.
  107890. * It will both interacts on the Geometry for analytical and IBL lighting.
  107891. * It also prefilter the roughness map based on the bump values.
  107892. */
  107893. protected _enableSpecularAntiAliasing: boolean;
  107894. /**
  107895. * Default configuration related to image processing available in the PBR Material.
  107896. */
  107897. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107898. /**
  107899. * Keep track of the image processing observer to allow dispose and replace.
  107900. */
  107901. private _imageProcessingObserver;
  107902. /**
  107903. * Attaches a new image processing configuration to the PBR Material.
  107904. * @param configuration
  107905. */
  107906. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107907. /**
  107908. * Stores the available render targets.
  107909. */
  107910. private _renderTargets;
  107911. /**
  107912. * Sets the global ambient color for the material used in lighting calculations.
  107913. */
  107914. private _globalAmbientColor;
  107915. /**
  107916. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  107917. */
  107918. private _useLogarithmicDepth;
  107919. /**
  107920. * If set to true, no lighting calculations will be applied.
  107921. */
  107922. private _unlit;
  107923. private _debugMode;
  107924. /**
  107925. * @hidden
  107926. * This is reserved for the inspector.
  107927. * Defines the material debug mode.
  107928. * It helps seeing only some components of the material while troubleshooting.
  107929. */
  107930. debugMode: number;
  107931. /**
  107932. * @hidden
  107933. * This is reserved for the inspector.
  107934. * Specify from where on screen the debug mode should start.
  107935. * The value goes from -1 (full screen) to 1 (not visible)
  107936. * It helps with side by side comparison against the final render
  107937. * This defaults to -1
  107938. */
  107939. private debugLimit;
  107940. /**
  107941. * @hidden
  107942. * This is reserved for the inspector.
  107943. * As the default viewing range might not be enough (if the ambient is really small for instance)
  107944. * You can use the factor to better multiply the final value.
  107945. */
  107946. private debugFactor;
  107947. /**
  107948. * Defines the clear coat layer parameters for the material.
  107949. */
  107950. readonly clearCoat: PBRClearCoatConfiguration;
  107951. /**
  107952. * Defines the anisotropic parameters for the material.
  107953. */
  107954. readonly anisotropy: PBRAnisotropicConfiguration;
  107955. /**
  107956. * Defines the BRDF parameters for the material.
  107957. */
  107958. readonly brdf: PBRBRDFConfiguration;
  107959. /**
  107960. * Defines the Sheen parameters for the material.
  107961. */
  107962. readonly sheen: PBRSheenConfiguration;
  107963. /**
  107964. * Defines the SubSurface parameters for the material.
  107965. */
  107966. readonly subSurface: PBRSubSurfaceConfiguration;
  107967. /**
  107968. * Defines additionnal PrePass parameters for the material.
  107969. */
  107970. readonly prePassConfiguration: PrePassConfiguration;
  107971. /**
  107972. * Defines the detail map parameters for the material.
  107973. */
  107974. readonly detailMap: DetailMapConfiguration;
  107975. protected _rebuildInParallel: boolean;
  107976. /**
  107977. * Instantiates a new PBRMaterial instance.
  107978. *
  107979. * @param name The material name
  107980. * @param scene The scene the material will be use in.
  107981. */
  107982. constructor(name: string, scene: Scene);
  107983. /**
  107984. * Gets a boolean indicating that current material needs to register RTT
  107985. */
  107986. get hasRenderTargetTextures(): boolean;
  107987. /**
  107988. * Gets the name of the material class.
  107989. */
  107990. getClassName(): string;
  107991. /**
  107992. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107993. */
  107994. get useLogarithmicDepth(): boolean;
  107995. /**
  107996. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107997. */
  107998. set useLogarithmicDepth(value: boolean);
  107999. /**
  108000. * Returns true if alpha blending should be disabled.
  108001. */
  108002. protected get _disableAlphaBlending(): boolean;
  108003. /**
  108004. * Specifies whether or not this material should be rendered in alpha blend mode.
  108005. */
  108006. needAlphaBlending(): boolean;
  108007. /**
  108008. * Specifies whether or not this material should be rendered in alpha test mode.
  108009. */
  108010. needAlphaTesting(): boolean;
  108011. /**
  108012. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  108013. */
  108014. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  108015. /**
  108016. * Specifies whether or not there is a usable alpha channel for transparency.
  108017. */
  108018. protected _hasAlphaChannel(): boolean;
  108019. /**
  108020. * Gets the texture used for the alpha test.
  108021. */
  108022. getAlphaTestTexture(): Nullable<BaseTexture>;
  108023. /**
  108024. * Specifies that the submesh is ready to be used.
  108025. * @param mesh - BJS mesh.
  108026. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  108027. * @param useInstances - Specifies that instances should be used.
  108028. * @returns - boolean indicating that the submesh is ready or not.
  108029. */
  108030. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108031. /**
  108032. * Specifies if the material uses metallic roughness workflow.
  108033. * @returns boolean specifiying if the material uses metallic roughness workflow.
  108034. */
  108035. isMetallicWorkflow(): boolean;
  108036. private _prepareEffect;
  108037. private _prepareDefines;
  108038. /**
  108039. * Force shader compilation
  108040. */
  108041. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  108042. /**
  108043. * Initializes the uniform buffer layout for the shader.
  108044. */
  108045. buildUniformLayout(): void;
  108046. /**
  108047. * Unbinds the material from the mesh
  108048. */
  108049. unbind(): void;
  108050. /**
  108051. * Binds the submesh data.
  108052. * @param world - The world matrix.
  108053. * @param mesh - The BJS mesh.
  108054. * @param subMesh - A submesh of the BJS mesh.
  108055. */
  108056. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108057. /**
  108058. * Returns the animatable textures.
  108059. * @returns - Array of animatable textures.
  108060. */
  108061. getAnimatables(): IAnimatable[];
  108062. /**
  108063. * Returns the texture used for reflections.
  108064. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  108065. */
  108066. private _getReflectionTexture;
  108067. /**
  108068. * Returns an array of the actively used textures.
  108069. * @returns - Array of BaseTextures
  108070. */
  108071. getActiveTextures(): BaseTexture[];
  108072. /**
  108073. * Checks to see if a texture is used in the material.
  108074. * @param texture - Base texture to use.
  108075. * @returns - Boolean specifying if a texture is used in the material.
  108076. */
  108077. hasTexture(texture: BaseTexture): boolean;
  108078. /**
  108079. * Sets the required values to the prepass renderer.
  108080. * @param prePassRenderer defines the prepass renderer to setup
  108081. */
  108082. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  108083. /**
  108084. * Disposes the resources of the material.
  108085. * @param forceDisposeEffect - Forces the disposal of effects.
  108086. * @param forceDisposeTextures - Forces the disposal of all textures.
  108087. */
  108088. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108089. }
  108090. }
  108091. declare module BABYLON {
  108092. /**
  108093. * The Physically based material of BJS.
  108094. *
  108095. * This offers the main features of a standard PBR material.
  108096. * For more information, please refer to the documentation :
  108097. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108098. */
  108099. export class PBRMaterial extends PBRBaseMaterial {
  108100. /**
  108101. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108102. */
  108103. static readonly PBRMATERIAL_OPAQUE: number;
  108104. /**
  108105. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108106. */
  108107. static readonly PBRMATERIAL_ALPHATEST: number;
  108108. /**
  108109. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108110. */
  108111. static readonly PBRMATERIAL_ALPHABLEND: number;
  108112. /**
  108113. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108114. * They are also discarded below the alpha cutoff threshold to improve performances.
  108115. */
  108116. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108117. /**
  108118. * Defines the default value of how much AO map is occluding the analytical lights
  108119. * (point spot...).
  108120. */
  108121. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108122. /**
  108123. * Intensity of the direct lights e.g. the four lights available in your scene.
  108124. * This impacts both the direct diffuse and specular highlights.
  108125. */
  108126. directIntensity: number;
  108127. /**
  108128. * Intensity of the emissive part of the material.
  108129. * This helps controlling the emissive effect without modifying the emissive color.
  108130. */
  108131. emissiveIntensity: number;
  108132. /**
  108133. * Intensity of the environment e.g. how much the environment will light the object
  108134. * either through harmonics for rough material or through the refelction for shiny ones.
  108135. */
  108136. environmentIntensity: number;
  108137. /**
  108138. * This is a special control allowing the reduction of the specular highlights coming from the
  108139. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108140. */
  108141. specularIntensity: number;
  108142. /**
  108143. * Debug Control allowing disabling the bump map on this material.
  108144. */
  108145. disableBumpMap: boolean;
  108146. /**
  108147. * AKA Diffuse Texture in standard nomenclature.
  108148. */
  108149. albedoTexture: BaseTexture;
  108150. /**
  108151. * AKA Occlusion Texture in other nomenclature.
  108152. */
  108153. ambientTexture: BaseTexture;
  108154. /**
  108155. * AKA Occlusion Texture Intensity in other nomenclature.
  108156. */
  108157. ambientTextureStrength: number;
  108158. /**
  108159. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108160. * 1 means it completely occludes it
  108161. * 0 mean it has no impact
  108162. */
  108163. ambientTextureImpactOnAnalyticalLights: number;
  108164. /**
  108165. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  108166. */
  108167. opacityTexture: BaseTexture;
  108168. /**
  108169. * Stores the reflection values in a texture.
  108170. */
  108171. reflectionTexture: Nullable<BaseTexture>;
  108172. /**
  108173. * Stores the emissive values in a texture.
  108174. */
  108175. emissiveTexture: BaseTexture;
  108176. /**
  108177. * AKA Specular texture in other nomenclature.
  108178. */
  108179. reflectivityTexture: BaseTexture;
  108180. /**
  108181. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108182. */
  108183. metallicTexture: BaseTexture;
  108184. /**
  108185. * Specifies the metallic scalar of the metallic/roughness workflow.
  108186. * Can also be used to scale the metalness values of the metallic texture.
  108187. */
  108188. metallic: Nullable<number>;
  108189. /**
  108190. * Specifies the roughness scalar of the metallic/roughness workflow.
  108191. * Can also be used to scale the roughness values of the metallic texture.
  108192. */
  108193. roughness: Nullable<number>;
  108194. /**
  108195. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  108196. * By default the indexOfrefraction is used to compute F0;
  108197. *
  108198. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  108199. *
  108200. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  108201. * F90 = metallicReflectanceColor;
  108202. */
  108203. metallicF0Factor: number;
  108204. /**
  108205. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  108206. * By default the F90 is always 1;
  108207. *
  108208. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  108209. *
  108210. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  108211. * F90 = metallicReflectanceColor;
  108212. */
  108213. metallicReflectanceColor: Color3;
  108214. /**
  108215. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  108216. * This is multiply against the scalar values defined in the material.
  108217. */
  108218. metallicReflectanceTexture: Nullable<BaseTexture>;
  108219. /**
  108220. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108221. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108222. */
  108223. microSurfaceTexture: BaseTexture;
  108224. /**
  108225. * Stores surface normal data used to displace a mesh in a texture.
  108226. */
  108227. bumpTexture: BaseTexture;
  108228. /**
  108229. * Stores the pre-calculated light information of a mesh in a texture.
  108230. */
  108231. lightmapTexture: BaseTexture;
  108232. /**
  108233. * Stores the refracted light information in a texture.
  108234. */
  108235. get refractionTexture(): Nullable<BaseTexture>;
  108236. set refractionTexture(value: Nullable<BaseTexture>);
  108237. /**
  108238. * The color of a material in ambient lighting.
  108239. */
  108240. ambientColor: Color3;
  108241. /**
  108242. * AKA Diffuse Color in other nomenclature.
  108243. */
  108244. albedoColor: Color3;
  108245. /**
  108246. * AKA Specular Color in other nomenclature.
  108247. */
  108248. reflectivityColor: Color3;
  108249. /**
  108250. * The color reflected from the material.
  108251. */
  108252. reflectionColor: Color3;
  108253. /**
  108254. * The color emitted from the material.
  108255. */
  108256. emissiveColor: Color3;
  108257. /**
  108258. * AKA Glossiness in other nomenclature.
  108259. */
  108260. microSurface: number;
  108261. /**
  108262. * Index of refraction of the material base layer.
  108263. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  108264. *
  108265. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  108266. *
  108267. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  108268. */
  108269. get indexOfRefraction(): number;
  108270. set indexOfRefraction(value: number);
  108271. /**
  108272. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108273. */
  108274. get invertRefractionY(): boolean;
  108275. set invertRefractionY(value: boolean);
  108276. /**
  108277. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108278. * Materials half opaque for instance using refraction could benefit from this control.
  108279. */
  108280. get linkRefractionWithTransparency(): boolean;
  108281. set linkRefractionWithTransparency(value: boolean);
  108282. /**
  108283. * If true, the light map contains occlusion information instead of lighting info.
  108284. */
  108285. useLightmapAsShadowmap: boolean;
  108286. /**
  108287. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108288. */
  108289. useAlphaFromAlbedoTexture: boolean;
  108290. /**
  108291. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108292. */
  108293. forceAlphaTest: boolean;
  108294. /**
  108295. * Defines the alpha limits in alpha test mode.
  108296. */
  108297. alphaCutOff: number;
  108298. /**
  108299. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108300. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108301. */
  108302. useSpecularOverAlpha: boolean;
  108303. /**
  108304. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108305. */
  108306. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108307. /**
  108308. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108309. */
  108310. useRoughnessFromMetallicTextureAlpha: boolean;
  108311. /**
  108312. * Specifies if the metallic texture contains the roughness information in its green channel.
  108313. */
  108314. useRoughnessFromMetallicTextureGreen: boolean;
  108315. /**
  108316. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108317. */
  108318. useMetallnessFromMetallicTextureBlue: boolean;
  108319. /**
  108320. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108321. */
  108322. useAmbientOcclusionFromMetallicTextureRed: boolean;
  108323. /**
  108324. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108325. */
  108326. useAmbientInGrayScale: boolean;
  108327. /**
  108328. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108329. * The material will try to infer what glossiness each pixel should be.
  108330. */
  108331. useAutoMicroSurfaceFromReflectivityMap: boolean;
  108332. /**
  108333. * BJS is using an harcoded light falloff based on a manually sets up range.
  108334. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108335. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108336. */
  108337. get usePhysicalLightFalloff(): boolean;
  108338. /**
  108339. * BJS is using an harcoded light falloff based on a manually sets up range.
  108340. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108341. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108342. */
  108343. set usePhysicalLightFalloff(value: boolean);
  108344. /**
  108345. * In order to support the falloff compatibility with gltf, a special mode has been added
  108346. * to reproduce the gltf light falloff.
  108347. */
  108348. get useGLTFLightFalloff(): boolean;
  108349. /**
  108350. * In order to support the falloff compatibility with gltf, a special mode has been added
  108351. * to reproduce the gltf light falloff.
  108352. */
  108353. set useGLTFLightFalloff(value: boolean);
  108354. /**
  108355. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108356. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108357. */
  108358. useRadianceOverAlpha: boolean;
  108359. /**
  108360. * Allows using an object space normal map (instead of tangent space).
  108361. */
  108362. useObjectSpaceNormalMap: boolean;
  108363. /**
  108364. * Allows using the bump map in parallax mode.
  108365. */
  108366. useParallax: boolean;
  108367. /**
  108368. * Allows using the bump map in parallax occlusion mode.
  108369. */
  108370. useParallaxOcclusion: boolean;
  108371. /**
  108372. * Controls the scale bias of the parallax mode.
  108373. */
  108374. parallaxScaleBias: number;
  108375. /**
  108376. * If sets to true, disables all the lights affecting the material.
  108377. */
  108378. disableLighting: boolean;
  108379. /**
  108380. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108381. */
  108382. forceIrradianceInFragment: boolean;
  108383. /**
  108384. * Number of Simultaneous lights allowed on the material.
  108385. */
  108386. maxSimultaneousLights: number;
  108387. /**
  108388. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108389. */
  108390. invertNormalMapX: boolean;
  108391. /**
  108392. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108393. */
  108394. invertNormalMapY: boolean;
  108395. /**
  108396. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108397. */
  108398. twoSidedLighting: boolean;
  108399. /**
  108400. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108401. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108402. */
  108403. useAlphaFresnel: boolean;
  108404. /**
  108405. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108406. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108407. */
  108408. useLinearAlphaFresnel: boolean;
  108409. /**
  108410. * Let user defines the brdf lookup texture used for IBL.
  108411. * A default 8bit version is embedded but you could point at :
  108412. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  108413. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108414. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  108415. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108416. */
  108417. environmentBRDFTexture: Nullable<BaseTexture>;
  108418. /**
  108419. * Force normal to face away from face.
  108420. */
  108421. forceNormalForward: boolean;
  108422. /**
  108423. * Enables specular anti aliasing in the PBR shader.
  108424. * It will both interacts on the Geometry for analytical and IBL lighting.
  108425. * It also prefilter the roughness map based on the bump values.
  108426. */
  108427. enableSpecularAntiAliasing: boolean;
  108428. /**
  108429. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108430. * makes the reflect vector face the model (under horizon).
  108431. */
  108432. useHorizonOcclusion: boolean;
  108433. /**
  108434. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108435. * too much the area relying on ambient texture to define their ambient occlusion.
  108436. */
  108437. useRadianceOcclusion: boolean;
  108438. /**
  108439. * If set to true, no lighting calculations will be applied.
  108440. */
  108441. unlit: boolean;
  108442. /**
  108443. * Gets the image processing configuration used either in this material.
  108444. */
  108445. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108446. /**
  108447. * Sets the Default image processing configuration used either in the this material.
  108448. *
  108449. * If sets to null, the scene one is in use.
  108450. */
  108451. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  108452. /**
  108453. * Gets wether the color curves effect is enabled.
  108454. */
  108455. get cameraColorCurvesEnabled(): boolean;
  108456. /**
  108457. * Sets wether the color curves effect is enabled.
  108458. */
  108459. set cameraColorCurvesEnabled(value: boolean);
  108460. /**
  108461. * Gets wether the color grading effect is enabled.
  108462. */
  108463. get cameraColorGradingEnabled(): boolean;
  108464. /**
  108465. * Gets wether the color grading effect is enabled.
  108466. */
  108467. set cameraColorGradingEnabled(value: boolean);
  108468. /**
  108469. * Gets wether tonemapping is enabled or not.
  108470. */
  108471. get cameraToneMappingEnabled(): boolean;
  108472. /**
  108473. * Sets wether tonemapping is enabled or not
  108474. */
  108475. set cameraToneMappingEnabled(value: boolean);
  108476. /**
  108477. * The camera exposure used on this material.
  108478. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108479. * This corresponds to a photographic exposure.
  108480. */
  108481. get cameraExposure(): number;
  108482. /**
  108483. * The camera exposure used on this material.
  108484. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108485. * This corresponds to a photographic exposure.
  108486. */
  108487. set cameraExposure(value: number);
  108488. /**
  108489. * Gets The camera contrast used on this material.
  108490. */
  108491. get cameraContrast(): number;
  108492. /**
  108493. * Sets The camera contrast used on this material.
  108494. */
  108495. set cameraContrast(value: number);
  108496. /**
  108497. * Gets the Color Grading 2D Lookup Texture.
  108498. */
  108499. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  108500. /**
  108501. * Sets the Color Grading 2D Lookup Texture.
  108502. */
  108503. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  108504. /**
  108505. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108506. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108507. * 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;
  108508. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108509. */
  108510. get cameraColorCurves(): Nullable<ColorCurves>;
  108511. /**
  108512. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108513. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108514. * 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;
  108515. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108516. */
  108517. set cameraColorCurves(value: Nullable<ColorCurves>);
  108518. /**
  108519. * Instantiates a new PBRMaterial instance.
  108520. *
  108521. * @param name The material name
  108522. * @param scene The scene the material will be use in.
  108523. */
  108524. constructor(name: string, scene: Scene);
  108525. /**
  108526. * Returns the name of this material class.
  108527. */
  108528. getClassName(): string;
  108529. /**
  108530. * Makes a duplicate of the current material.
  108531. * @param name - name to use for the new material.
  108532. */
  108533. clone(name: string): PBRMaterial;
  108534. /**
  108535. * Serializes this PBR Material.
  108536. * @returns - An object with the serialized material.
  108537. */
  108538. serialize(): any;
  108539. /**
  108540. * Parses a PBR Material from a serialized object.
  108541. * @param source - Serialized object.
  108542. * @param scene - BJS scene instance.
  108543. * @param rootUrl - url for the scene object
  108544. * @returns - PBRMaterial
  108545. */
  108546. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  108547. }
  108548. }
  108549. declare module BABYLON {
  108550. /** @hidden */
  108551. export var mrtFragmentDeclaration: {
  108552. name: string;
  108553. shader: string;
  108554. };
  108555. }
  108556. declare module BABYLON {
  108557. /** @hidden */
  108558. export var geometryPixelShader: {
  108559. name: string;
  108560. shader: string;
  108561. };
  108562. }
  108563. declare module BABYLON {
  108564. /** @hidden */
  108565. export var geometryVertexShader: {
  108566. name: string;
  108567. shader: string;
  108568. };
  108569. }
  108570. declare module BABYLON {
  108571. /** @hidden */
  108572. interface ISavedTransformationMatrix {
  108573. world: Matrix;
  108574. viewProjection: Matrix;
  108575. }
  108576. /**
  108577. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108578. */
  108579. export class GeometryBufferRenderer {
  108580. /**
  108581. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  108582. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  108583. */
  108584. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  108585. /**
  108586. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108587. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108588. */
  108589. static readonly POSITION_TEXTURE_TYPE: number;
  108590. /**
  108591. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108592. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108593. */
  108594. static readonly VELOCITY_TEXTURE_TYPE: number;
  108595. /**
  108596. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  108597. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  108598. */
  108599. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  108600. /**
  108601. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108602. * in order to compute objects velocities when enableVelocity is set to "true"
  108603. * @hidden
  108604. */
  108605. _previousTransformationMatrices: {
  108606. [index: number]: ISavedTransformationMatrix;
  108607. };
  108608. /**
  108609. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  108610. * in order to compute objects velocities when enableVelocity is set to "true"
  108611. * @hidden
  108612. */
  108613. _previousBonesTransformationMatrices: {
  108614. [index: number]: Float32Array;
  108615. };
  108616. /**
  108617. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  108618. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  108619. */
  108620. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  108621. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  108622. renderTransparentMeshes: boolean;
  108623. private _scene;
  108624. private _resizeObserver;
  108625. private _multiRenderTarget;
  108626. private _ratio;
  108627. private _enablePosition;
  108628. private _enableVelocity;
  108629. private _enableReflectivity;
  108630. private _positionIndex;
  108631. private _velocityIndex;
  108632. private _reflectivityIndex;
  108633. private _depthNormalIndex;
  108634. private _linkedWithPrePass;
  108635. private _prePassRenderer;
  108636. private _attachments;
  108637. protected _effect: Effect;
  108638. protected _cachedDefines: string;
  108639. /**
  108640. * @hidden
  108641. * Sets up internal structures to share outputs with PrePassRenderer
  108642. * This method should only be called by the PrePassRenderer itself
  108643. */
  108644. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  108645. /**
  108646. * @hidden
  108647. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  108648. * This method should only be called by the PrePassRenderer itself
  108649. */
  108650. _unlinkPrePassRenderer(): void;
  108651. /**
  108652. * @hidden
  108653. * Resets the geometry buffer layout
  108654. */
  108655. _resetLayout(): void;
  108656. /**
  108657. * @hidden
  108658. * Replaces a texture in the geometry buffer renderer
  108659. * Useful when linking textures of the prepass renderer
  108660. */
  108661. _forceTextureType(geometryBufferType: number, index: number): void;
  108662. /**
  108663. * @hidden
  108664. * Sets texture attachments
  108665. * Useful when linking textures of the prepass renderer
  108666. */
  108667. _setAttachments(attachments: number[]): void;
  108668. /**
  108669. * @hidden
  108670. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  108671. * Useful when linking textures of the prepass renderer
  108672. */
  108673. _linkInternalTexture(internalTexture: InternalTexture): void;
  108674. /**
  108675. * Gets the render list (meshes to be rendered) used in the G buffer.
  108676. */
  108677. get renderList(): Nullable<AbstractMesh[]>;
  108678. /**
  108679. * Set the render list (meshes to be rendered) used in the G buffer.
  108680. */
  108681. set renderList(meshes: Nullable<AbstractMesh[]>);
  108682. /**
  108683. * Gets wether or not G buffer are supported by the running hardware.
  108684. * This requires draw buffer supports
  108685. */
  108686. get isSupported(): boolean;
  108687. /**
  108688. * Returns the index of the given texture type in the G-Buffer textures array
  108689. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108690. * @returns the index of the given texture type in the G-Buffer textures array
  108691. */
  108692. getTextureIndex(textureType: number): number;
  108693. /**
  108694. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108695. */
  108696. get enablePosition(): boolean;
  108697. /**
  108698. * Sets whether or not objects positions are enabled for the G buffer.
  108699. */
  108700. set enablePosition(enable: boolean);
  108701. /**
  108702. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108703. */
  108704. get enableVelocity(): boolean;
  108705. /**
  108706. * Sets wether or not objects velocities are enabled for the G buffer.
  108707. */
  108708. set enableVelocity(enable: boolean);
  108709. /**
  108710. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  108711. */
  108712. get enableReflectivity(): boolean;
  108713. /**
  108714. * Sets wether or not objects roughness are enabled for the G buffer.
  108715. */
  108716. set enableReflectivity(enable: boolean);
  108717. /**
  108718. * Gets the scene associated with the buffer.
  108719. */
  108720. get scene(): Scene;
  108721. /**
  108722. * Gets the ratio used by the buffer during its creation.
  108723. * How big is the buffer related to the main canvas.
  108724. */
  108725. get ratio(): number;
  108726. /** @hidden */
  108727. static _SceneComponentInitialization: (scene: Scene) => void;
  108728. /**
  108729. * Creates a new G Buffer for the scene
  108730. * @param scene The scene the buffer belongs to
  108731. * @param ratio How big is the buffer related to the main canvas.
  108732. */
  108733. constructor(scene: Scene, ratio?: number);
  108734. /**
  108735. * Checks wether everything is ready to render a submesh to the G buffer.
  108736. * @param subMesh the submesh to check readiness for
  108737. * @param useInstances is the mesh drawn using instance or not
  108738. * @returns true if ready otherwise false
  108739. */
  108740. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108741. /**
  108742. * Gets the current underlying G Buffer.
  108743. * @returns the buffer
  108744. */
  108745. getGBuffer(): MultiRenderTarget;
  108746. /**
  108747. * Gets the number of samples used to render the buffer (anti aliasing).
  108748. */
  108749. get samples(): number;
  108750. /**
  108751. * Sets the number of samples used to render the buffer (anti aliasing).
  108752. */
  108753. set samples(value: number);
  108754. /**
  108755. * Disposes the renderer and frees up associated resources.
  108756. */
  108757. dispose(): void;
  108758. private _assignRenderTargetIndices;
  108759. protected _createRenderTargets(): void;
  108760. private _copyBonesTransformationMatrices;
  108761. }
  108762. }
  108763. declare module BABYLON {
  108764. /**
  108765. * Renders a pre pass of the scene
  108766. * This means every mesh in the scene will be rendered to a render target texture
  108767. * And then this texture will be composited to the rendering canvas with post processes
  108768. * It is necessary for effects like subsurface scattering or deferred shading
  108769. */
  108770. export class PrePassRenderer {
  108771. /** @hidden */
  108772. static _SceneComponentInitialization: (scene: Scene) => void;
  108773. private _textureFormats;
  108774. /**
  108775. * To save performance, we can excluded skinned meshes from the prepass
  108776. */
  108777. excludedSkinnedMesh: AbstractMesh[];
  108778. /**
  108779. * Force material to be excluded from the prepass
  108780. * Can be useful when `useGeometryBufferFallback` is set to `true`
  108781. * and you don't want a material to show in the effect.
  108782. */
  108783. excludedMaterials: Material[];
  108784. private _textureIndices;
  108785. private _scene;
  108786. private _engine;
  108787. private _isDirty;
  108788. /**
  108789. * Number of textures in the multi render target texture where the scene is directly rendered
  108790. */
  108791. mrtCount: number;
  108792. /**
  108793. * The render target where the scene is directly rendered
  108794. */
  108795. prePassRT: MultiRenderTarget;
  108796. private _multiRenderAttachments;
  108797. private _defaultAttachments;
  108798. private _clearAttachments;
  108799. private _postProcesses;
  108800. private readonly _clearColor;
  108801. /**
  108802. * Image processing post process for composition
  108803. */
  108804. imageProcessingPostProcess: ImageProcessingPostProcess;
  108805. /**
  108806. * Configuration for prepass effects
  108807. */
  108808. private _effectConfigurations;
  108809. private _mrtFormats;
  108810. private _mrtLayout;
  108811. private _enabled;
  108812. /**
  108813. * Indicates if the prepass is enabled
  108814. */
  108815. get enabled(): boolean;
  108816. /**
  108817. * How many samples are used for MSAA of the scene render target
  108818. */
  108819. get samples(): number;
  108820. set samples(n: number);
  108821. private _geometryBuffer;
  108822. private _useGeometryBufferFallback;
  108823. /**
  108824. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  108825. */
  108826. get useGeometryBufferFallback(): boolean;
  108827. set useGeometryBufferFallback(value: boolean);
  108828. /**
  108829. * Instanciates a prepass renderer
  108830. * @param scene The scene
  108831. */
  108832. constructor(scene: Scene);
  108833. private _initializeAttachments;
  108834. private _createCompositionEffect;
  108835. /**
  108836. * Indicates if rendering a prepass is supported
  108837. */
  108838. get isSupported(): boolean;
  108839. /**
  108840. * Sets the proper output textures to draw in the engine.
  108841. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  108842. * @param subMesh Submesh on which the effect is applied
  108843. */
  108844. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  108845. /**
  108846. * @hidden
  108847. */
  108848. _beforeCameraDraw(): void;
  108849. /**
  108850. * @hidden
  108851. */
  108852. _afterCameraDraw(): void;
  108853. private _checkRTSize;
  108854. private _bindFrameBuffer;
  108855. /**
  108856. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  108857. */
  108858. clear(): void;
  108859. private _setState;
  108860. private _updateGeometryBufferLayout;
  108861. /**
  108862. * Adds an effect configuration to the prepass.
  108863. * If an effect has already been added, it won't add it twice and will return the configuration
  108864. * already present.
  108865. * @param cfg the effect configuration
  108866. * @return the effect configuration now used by the prepass
  108867. */
  108868. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  108869. /**
  108870. * Returns the index of a texture in the multi render target texture array.
  108871. * @param type Texture type
  108872. * @return The index
  108873. */
  108874. getIndex(type: number): number;
  108875. private _enable;
  108876. private _disable;
  108877. private _resetLayout;
  108878. private _resetPostProcessChain;
  108879. private _bindPostProcessChain;
  108880. /**
  108881. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  108882. */
  108883. markAsDirty(): void;
  108884. /**
  108885. * Enables a texture on the MultiRenderTarget for prepass
  108886. */
  108887. private _enableTextures;
  108888. private _update;
  108889. private _markAllMaterialsAsPrePassDirty;
  108890. /**
  108891. * Disposes the prepass renderer.
  108892. */
  108893. dispose(): void;
  108894. }
  108895. }
  108896. declare module BABYLON {
  108897. /**
  108898. * Size options for a post process
  108899. */
  108900. export type PostProcessOptions = {
  108901. width: number;
  108902. height: number;
  108903. };
  108904. /**
  108905. * PostProcess can be used to apply a shader to a texture after it has been rendered
  108906. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108907. */
  108908. export class PostProcess {
  108909. /**
  108910. * Gets or sets the unique id of the post process
  108911. */
  108912. uniqueId: number;
  108913. /** Name of the PostProcess. */
  108914. name: string;
  108915. /**
  108916. * Width of the texture to apply the post process on
  108917. */
  108918. width: number;
  108919. /**
  108920. * Height of the texture to apply the post process on
  108921. */
  108922. height: number;
  108923. /**
  108924. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  108925. */
  108926. nodeMaterialSource: Nullable<NodeMaterial>;
  108927. /**
  108928. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  108929. * @hidden
  108930. */
  108931. _outputTexture: Nullable<InternalTexture>;
  108932. /**
  108933. * Sampling mode used by the shader
  108934. * See https://doc.babylonjs.com/classes/3.1/texture
  108935. */
  108936. renderTargetSamplingMode: number;
  108937. /**
  108938. * Clear color to use when screen clearing
  108939. */
  108940. clearColor: Color4;
  108941. /**
  108942. * If the buffer needs to be cleared before applying the post process. (default: true)
  108943. * Should be set to false if shader will overwrite all previous pixels.
  108944. */
  108945. autoClear: boolean;
  108946. /**
  108947. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  108948. */
  108949. alphaMode: number;
  108950. /**
  108951. * Sets the setAlphaBlendConstants of the babylon engine
  108952. */
  108953. alphaConstants: Color4;
  108954. /**
  108955. * Animations to be used for the post processing
  108956. */
  108957. animations: Animation[];
  108958. /**
  108959. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  108960. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  108961. */
  108962. enablePixelPerfectMode: boolean;
  108963. /**
  108964. * Force the postprocess to be applied without taking in account viewport
  108965. */
  108966. forceFullscreenViewport: boolean;
  108967. /**
  108968. * List of inspectable custom properties (used by the Inspector)
  108969. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108970. */
  108971. inspectableCustomProperties: IInspectable[];
  108972. /**
  108973. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  108974. *
  108975. * | Value | Type | Description |
  108976. * | ----- | ----------------------------------- | ----------- |
  108977. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  108978. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  108979. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  108980. *
  108981. */
  108982. scaleMode: number;
  108983. /**
  108984. * Force textures to be a power of two (default: false)
  108985. */
  108986. alwaysForcePOT: boolean;
  108987. private _samples;
  108988. /**
  108989. * Number of sample textures (default: 1)
  108990. */
  108991. get samples(): number;
  108992. set samples(n: number);
  108993. /**
  108994. * Modify the scale of the post process to be the same as the viewport (default: false)
  108995. */
  108996. adaptScaleToCurrentViewport: boolean;
  108997. private _camera;
  108998. protected _scene: Scene;
  108999. private _engine;
  109000. private _options;
  109001. private _reusable;
  109002. private _textureType;
  109003. private _textureFormat;
  109004. /**
  109005. * Smart array of input and output textures for the post process.
  109006. * @hidden
  109007. */
  109008. _textures: SmartArray<InternalTexture>;
  109009. /**
  109010. * The index in _textures that corresponds to the output texture.
  109011. * @hidden
  109012. */
  109013. _currentRenderTextureInd: number;
  109014. private _effect;
  109015. private _samplers;
  109016. private _fragmentUrl;
  109017. private _vertexUrl;
  109018. private _parameters;
  109019. private _scaleRatio;
  109020. protected _indexParameters: any;
  109021. private _shareOutputWithPostProcess;
  109022. private _texelSize;
  109023. private _forcedOutputTexture;
  109024. /**
  109025. * Prepass configuration in case this post process needs a texture from prepass
  109026. * @hidden
  109027. */
  109028. _prePassEffectConfiguration: PrePassEffectConfiguration;
  109029. /**
  109030. * Returns the fragment url or shader name used in the post process.
  109031. * @returns the fragment url or name in the shader store.
  109032. */
  109033. getEffectName(): string;
  109034. /**
  109035. * An event triggered when the postprocess is activated.
  109036. */
  109037. onActivateObservable: Observable<Camera>;
  109038. private _onActivateObserver;
  109039. /**
  109040. * A function that is added to the onActivateObservable
  109041. */
  109042. set onActivate(callback: Nullable<(camera: Camera) => void>);
  109043. /**
  109044. * An event triggered when the postprocess changes its size.
  109045. */
  109046. onSizeChangedObservable: Observable<PostProcess>;
  109047. private _onSizeChangedObserver;
  109048. /**
  109049. * A function that is added to the onSizeChangedObservable
  109050. */
  109051. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  109052. /**
  109053. * An event triggered when the postprocess applies its effect.
  109054. */
  109055. onApplyObservable: Observable<Effect>;
  109056. private _onApplyObserver;
  109057. /**
  109058. * A function that is added to the onApplyObservable
  109059. */
  109060. set onApply(callback: (effect: Effect) => void);
  109061. /**
  109062. * An event triggered before rendering the postprocess
  109063. */
  109064. onBeforeRenderObservable: Observable<Effect>;
  109065. private _onBeforeRenderObserver;
  109066. /**
  109067. * A function that is added to the onBeforeRenderObservable
  109068. */
  109069. set onBeforeRender(callback: (effect: Effect) => void);
  109070. /**
  109071. * An event triggered after rendering the postprocess
  109072. */
  109073. onAfterRenderObservable: Observable<Effect>;
  109074. private _onAfterRenderObserver;
  109075. /**
  109076. * A function that is added to the onAfterRenderObservable
  109077. */
  109078. set onAfterRender(callback: (efect: Effect) => void);
  109079. /**
  109080. * 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
  109081. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  109082. */
  109083. get inputTexture(): InternalTexture;
  109084. set inputTexture(value: InternalTexture);
  109085. /**
  109086. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  109087. * the only way to unset it is to use this function to restore its internal state
  109088. */
  109089. restoreDefaultInputTexture(): void;
  109090. /**
  109091. * Gets the camera which post process is applied to.
  109092. * @returns The camera the post process is applied to.
  109093. */
  109094. getCamera(): Camera;
  109095. /**
  109096. * Gets the texel size of the postprocess.
  109097. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  109098. */
  109099. get texelSize(): Vector2;
  109100. /**
  109101. * Creates a new instance PostProcess
  109102. * @param name The name of the PostProcess.
  109103. * @param fragmentUrl The url of the fragment shader to be used.
  109104. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  109105. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  109106. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  109107. * @param camera The camera to apply the render pass to.
  109108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109109. * @param engine The engine which the post process will be applied. (default: current engine)
  109110. * @param reusable If the post process can be reused on the same frame. (default: false)
  109111. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  109112. * @param textureType Type of textures used when performing the post process. (default: 0)
  109113. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  109114. * @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
  109115. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  109116. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  109117. */
  109118. 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);
  109119. /**
  109120. * Gets a string identifying the name of the class
  109121. * @returns "PostProcess" string
  109122. */
  109123. getClassName(): string;
  109124. /**
  109125. * Gets the engine which this post process belongs to.
  109126. * @returns The engine the post process was enabled with.
  109127. */
  109128. getEngine(): Engine;
  109129. /**
  109130. * The effect that is created when initializing the post process.
  109131. * @returns The created effect corresponding the the postprocess.
  109132. */
  109133. getEffect(): Effect;
  109134. /**
  109135. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  109136. * @param postProcess The post process to share the output with.
  109137. * @returns This post process.
  109138. */
  109139. shareOutputWith(postProcess: PostProcess): PostProcess;
  109140. /**
  109141. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  109142. * This should be called if the post process that shares output with this post process is disabled/disposed.
  109143. */
  109144. useOwnOutput(): void;
  109145. /**
  109146. * Updates the effect with the current post process compile time values and recompiles the shader.
  109147. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  109148. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  109149. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  109150. * @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
  109151. * @param onCompiled Called when the shader has been compiled.
  109152. * @param onError Called if there is an error when compiling a shader.
  109153. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  109154. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  109155. */
  109156. 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;
  109157. /**
  109158. * The post process is reusable if it can be used multiple times within one frame.
  109159. * @returns If the post process is reusable
  109160. */
  109161. isReusable(): boolean;
  109162. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  109163. markTextureDirty(): void;
  109164. /**
  109165. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  109166. * 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.
  109167. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  109168. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  109169. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  109170. * @returns The target texture that was bound to be written to.
  109171. */
  109172. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  109173. /**
  109174. * If the post process is supported.
  109175. */
  109176. get isSupported(): boolean;
  109177. /**
  109178. * The aspect ratio of the output texture.
  109179. */
  109180. get aspectRatio(): number;
  109181. /**
  109182. * Get a value indicating if the post-process is ready to be used
  109183. * @returns true if the post-process is ready (shader is compiled)
  109184. */
  109185. isReady(): boolean;
  109186. /**
  109187. * Binds all textures and uniforms to the shader, this will be run on every pass.
  109188. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  109189. */
  109190. apply(): Nullable<Effect>;
  109191. private _disposeTextures;
  109192. /**
  109193. * Sets the required values to the prepass renderer.
  109194. * @param prePassRenderer defines the prepass renderer to setup.
  109195. * @returns true if the pre pass is needed.
  109196. */
  109197. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  109198. /**
  109199. * Disposes the post process.
  109200. * @param camera The camera to dispose the post process on.
  109201. */
  109202. dispose(camera?: Camera): void;
  109203. /**
  109204. * Serializes the particle system to a JSON object
  109205. * @returns the JSON object
  109206. */
  109207. serialize(): any;
  109208. /**
  109209. * Creates a material from parsed material data
  109210. * @param parsedPostProcess defines parsed post process data
  109211. * @param scene defines the hosting scene
  109212. * @param rootUrl defines the root URL to use to load textures
  109213. * @returns a new post process
  109214. */
  109215. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  109216. }
  109217. }
  109218. declare module BABYLON {
  109219. /** @hidden */
  109220. export var kernelBlurVaryingDeclaration: {
  109221. name: string;
  109222. shader: string;
  109223. };
  109224. }
  109225. declare module BABYLON {
  109226. /** @hidden */
  109227. export var kernelBlurFragment: {
  109228. name: string;
  109229. shader: string;
  109230. };
  109231. }
  109232. declare module BABYLON {
  109233. /** @hidden */
  109234. export var kernelBlurFragment2: {
  109235. name: string;
  109236. shader: string;
  109237. };
  109238. }
  109239. declare module BABYLON {
  109240. /** @hidden */
  109241. export var kernelBlurPixelShader: {
  109242. name: string;
  109243. shader: string;
  109244. };
  109245. }
  109246. declare module BABYLON {
  109247. /** @hidden */
  109248. export var kernelBlurVertex: {
  109249. name: string;
  109250. shader: string;
  109251. };
  109252. }
  109253. declare module BABYLON {
  109254. /** @hidden */
  109255. export var kernelBlurVertexShader: {
  109256. name: string;
  109257. shader: string;
  109258. };
  109259. }
  109260. declare module BABYLON {
  109261. /**
  109262. * The Blur Post Process which blurs an image based on a kernel and direction.
  109263. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  109264. */
  109265. export class BlurPostProcess extends PostProcess {
  109266. private blockCompilation;
  109267. protected _kernel: number;
  109268. protected _idealKernel: number;
  109269. protected _packedFloat: boolean;
  109270. private _staticDefines;
  109271. /** The direction in which to blur the image. */
  109272. direction: Vector2;
  109273. /**
  109274. * Sets the length in pixels of the blur sample region
  109275. */
  109276. set kernel(v: number);
  109277. /**
  109278. * Gets the length in pixels of the blur sample region
  109279. */
  109280. get kernel(): number;
  109281. /**
  109282. * Sets wether or not the blur needs to unpack/repack floats
  109283. */
  109284. set packedFloat(v: boolean);
  109285. /**
  109286. * Gets wether or not the blur is unpacking/repacking floats
  109287. */
  109288. get packedFloat(): boolean;
  109289. /**
  109290. * Gets a string identifying the name of the class
  109291. * @returns "BlurPostProcess" string
  109292. */
  109293. getClassName(): string;
  109294. /**
  109295. * Creates a new instance BlurPostProcess
  109296. * @param name The name of the effect.
  109297. * @param direction The direction in which to blur the image.
  109298. * @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.
  109299. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  109300. * @param camera The camera to apply the render pass to.
  109301. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109302. * @param engine The engine which the post process will be applied. (default: current engine)
  109303. * @param reusable If the post process can be reused on the same frame. (default: false)
  109304. * @param textureType Type of textures used when performing the post process. (default: 0)
  109305. * @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)
  109306. */
  109307. 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);
  109308. /**
  109309. * Updates the effect with the current post process compile time values and recompiles the shader.
  109310. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  109311. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  109312. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  109313. * @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
  109314. * @param onCompiled Called when the shader has been compiled.
  109315. * @param onError Called if there is an error when compiling a shader.
  109316. */
  109317. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  109318. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  109319. /**
  109320. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  109321. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  109322. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  109323. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  109324. * The gaps between physical kernels are compensated for in the weighting of the samples
  109325. * @param idealKernel Ideal blur kernel.
  109326. * @return Nearest best kernel.
  109327. */
  109328. protected _nearestBestKernel(idealKernel: number): number;
  109329. /**
  109330. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  109331. * @param x The point on the Gaussian distribution to sample.
  109332. * @return the value of the Gaussian function at x.
  109333. */
  109334. protected _gaussianWeight(x: number): number;
  109335. /**
  109336. * Generates a string that can be used as a floating point number in GLSL.
  109337. * @param x Value to print.
  109338. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  109339. * @return GLSL float string.
  109340. */
  109341. protected _glslFloat(x: number, decimalFigures?: number): string;
  109342. /** @hidden */
  109343. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  109344. }
  109345. }
  109346. declare module BABYLON {
  109347. /**
  109348. * Mirror texture can be used to simulate the view from a mirror in a scene.
  109349. * It will dynamically be rendered every frame to adapt to the camera point of view.
  109350. * You can then easily use it as a reflectionTexture on a flat surface.
  109351. * In case the surface is not a plane, please consider relying on reflection probes.
  109352. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  109353. */
  109354. export class MirrorTexture extends RenderTargetTexture {
  109355. private scene;
  109356. /**
  109357. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  109358. * 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.
  109359. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  109360. */
  109361. mirrorPlane: Plane;
  109362. /**
  109363. * Define the blur ratio used to blur the reflection if needed.
  109364. */
  109365. set blurRatio(value: number);
  109366. get blurRatio(): number;
  109367. /**
  109368. * Define the adaptive blur kernel used to blur the reflection if needed.
  109369. * This will autocompute the closest best match for the `blurKernel`
  109370. */
  109371. set adaptiveBlurKernel(value: number);
  109372. /**
  109373. * Define the blur kernel used to blur the reflection if needed.
  109374. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  109375. */
  109376. set blurKernel(value: number);
  109377. /**
  109378. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  109379. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  109380. */
  109381. set blurKernelX(value: number);
  109382. get blurKernelX(): number;
  109383. /**
  109384. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  109385. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  109386. */
  109387. set blurKernelY(value: number);
  109388. get blurKernelY(): number;
  109389. private _autoComputeBlurKernel;
  109390. protected _onRatioRescale(): void;
  109391. private _updateGammaSpace;
  109392. private _imageProcessingConfigChangeObserver;
  109393. private _transformMatrix;
  109394. private _mirrorMatrix;
  109395. private _savedViewMatrix;
  109396. private _blurX;
  109397. private _blurY;
  109398. private _adaptiveBlurKernel;
  109399. private _blurKernelX;
  109400. private _blurKernelY;
  109401. private _blurRatio;
  109402. /**
  109403. * Instantiates a Mirror Texture.
  109404. * Mirror texture can be used to simulate the view from a mirror in a scene.
  109405. * It will dynamically be rendered every frame to adapt to the camera point of view.
  109406. * You can then easily use it as a reflectionTexture on a flat surface.
  109407. * In case the surface is not a plane, please consider relying on reflection probes.
  109408. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  109409. * @param name
  109410. * @param size
  109411. * @param scene
  109412. * @param generateMipMaps
  109413. * @param type
  109414. * @param samplingMode
  109415. * @param generateDepthBuffer
  109416. */
  109417. constructor(name: string, size: number | {
  109418. width: number;
  109419. height: number;
  109420. } | {
  109421. ratio: number;
  109422. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  109423. private _preparePostProcesses;
  109424. /**
  109425. * Clone the mirror texture.
  109426. * @returns the cloned texture
  109427. */
  109428. clone(): MirrorTexture;
  109429. /**
  109430. * Serialize the texture to a JSON representation you could use in Parse later on
  109431. * @returns the serialized JSON representation
  109432. */
  109433. serialize(): any;
  109434. /**
  109435. * Dispose the texture and release its associated resources.
  109436. */
  109437. dispose(): void;
  109438. }
  109439. }
  109440. declare module BABYLON {
  109441. /**
  109442. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  109443. * @see https://doc.babylonjs.com/babylon101/materials#texture
  109444. */
  109445. export class Texture extends BaseTexture {
  109446. /**
  109447. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  109448. */
  109449. static SerializeBuffers: boolean;
  109450. /** @hidden */
  109451. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  109452. /** @hidden */
  109453. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  109454. /** @hidden */
  109455. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  109456. /** nearest is mag = nearest and min = nearest and mip = linear */
  109457. static readonly NEAREST_SAMPLINGMODE: number;
  109458. /** nearest is mag = nearest and min = nearest and mip = linear */
  109459. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  109460. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109461. static readonly BILINEAR_SAMPLINGMODE: number;
  109462. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109463. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  109464. /** Trilinear is mag = linear and min = linear and mip = linear */
  109465. static readonly TRILINEAR_SAMPLINGMODE: number;
  109466. /** Trilinear is mag = linear and min = linear and mip = linear */
  109467. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  109468. /** mag = nearest and min = nearest and mip = nearest */
  109469. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  109470. /** mag = nearest and min = linear and mip = nearest */
  109471. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  109472. /** mag = nearest and min = linear and mip = linear */
  109473. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  109474. /** mag = nearest and min = linear and mip = none */
  109475. static readonly NEAREST_LINEAR: number;
  109476. /** mag = nearest and min = nearest and mip = none */
  109477. static readonly NEAREST_NEAREST: number;
  109478. /** mag = linear and min = nearest and mip = nearest */
  109479. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  109480. /** mag = linear and min = nearest and mip = linear */
  109481. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  109482. /** mag = linear and min = linear and mip = none */
  109483. static readonly LINEAR_LINEAR: number;
  109484. /** mag = linear and min = nearest and mip = none */
  109485. static readonly LINEAR_NEAREST: number;
  109486. /** Explicit coordinates mode */
  109487. static readonly EXPLICIT_MODE: number;
  109488. /** Spherical coordinates mode */
  109489. static readonly SPHERICAL_MODE: number;
  109490. /** Planar coordinates mode */
  109491. static readonly PLANAR_MODE: number;
  109492. /** Cubic coordinates mode */
  109493. static readonly CUBIC_MODE: number;
  109494. /** Projection coordinates mode */
  109495. static readonly PROJECTION_MODE: number;
  109496. /** Inverse Cubic coordinates mode */
  109497. static readonly SKYBOX_MODE: number;
  109498. /** Inverse Cubic coordinates mode */
  109499. static readonly INVCUBIC_MODE: number;
  109500. /** Equirectangular coordinates mode */
  109501. static readonly EQUIRECTANGULAR_MODE: number;
  109502. /** Equirectangular Fixed coordinates mode */
  109503. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  109504. /** Equirectangular Fixed Mirrored coordinates mode */
  109505. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  109506. /** Texture is not repeating outside of 0..1 UVs */
  109507. static readonly CLAMP_ADDRESSMODE: number;
  109508. /** Texture is repeating outside of 0..1 UVs */
  109509. static readonly WRAP_ADDRESSMODE: number;
  109510. /** Texture is repeating and mirrored */
  109511. static readonly MIRROR_ADDRESSMODE: number;
  109512. /**
  109513. * 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
  109514. */
  109515. static UseSerializedUrlIfAny: boolean;
  109516. /**
  109517. * Define the url of the texture.
  109518. */
  109519. url: Nullable<string>;
  109520. /**
  109521. * Define an offset on the texture to offset the u coordinates of the UVs
  109522. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  109523. */
  109524. uOffset: number;
  109525. /**
  109526. * Define an offset on the texture to offset the v coordinates of the UVs
  109527. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  109528. */
  109529. vOffset: number;
  109530. /**
  109531. * Define an offset on the texture to scale the u coordinates of the UVs
  109532. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  109533. */
  109534. uScale: number;
  109535. /**
  109536. * Define an offset on the texture to scale the v coordinates of the UVs
  109537. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  109538. */
  109539. vScale: number;
  109540. /**
  109541. * Define an offset on the texture to rotate around the u coordinates of the UVs
  109542. * @see https://doc.babylonjs.com/how_to/more_materials
  109543. */
  109544. uAng: number;
  109545. /**
  109546. * Define an offset on the texture to rotate around the v coordinates of the UVs
  109547. * @see https://doc.babylonjs.com/how_to/more_materials
  109548. */
  109549. vAng: number;
  109550. /**
  109551. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  109552. * @see https://doc.babylonjs.com/how_to/more_materials
  109553. */
  109554. wAng: number;
  109555. /**
  109556. * Defines the center of rotation (U)
  109557. */
  109558. uRotationCenter: number;
  109559. /**
  109560. * Defines the center of rotation (V)
  109561. */
  109562. vRotationCenter: number;
  109563. /**
  109564. * Defines the center of rotation (W)
  109565. */
  109566. wRotationCenter: number;
  109567. /**
  109568. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  109569. */
  109570. homogeneousRotationInUVTransform: boolean;
  109571. /**
  109572. * Are mip maps generated for this texture or not.
  109573. */
  109574. get noMipmap(): boolean;
  109575. /**
  109576. * List of inspectable custom properties (used by the Inspector)
  109577. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109578. */
  109579. inspectableCustomProperties: Nullable<IInspectable[]>;
  109580. private _noMipmap;
  109581. /** @hidden */
  109582. _invertY: boolean;
  109583. private _rowGenerationMatrix;
  109584. private _cachedTextureMatrix;
  109585. private _projectionModeMatrix;
  109586. private _t0;
  109587. private _t1;
  109588. private _t2;
  109589. private _cachedUOffset;
  109590. private _cachedVOffset;
  109591. private _cachedUScale;
  109592. private _cachedVScale;
  109593. private _cachedUAng;
  109594. private _cachedVAng;
  109595. private _cachedWAng;
  109596. private _cachedProjectionMatrixId;
  109597. private _cachedURotationCenter;
  109598. private _cachedVRotationCenter;
  109599. private _cachedWRotationCenter;
  109600. private _cachedHomogeneousRotationInUVTransform;
  109601. private _cachedCoordinatesMode;
  109602. /** @hidden */
  109603. protected _initialSamplingMode: number;
  109604. /** @hidden */
  109605. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  109606. private _deleteBuffer;
  109607. protected _format: Nullable<number>;
  109608. private _delayedOnLoad;
  109609. private _delayedOnError;
  109610. private _mimeType?;
  109611. private _loaderOptions?;
  109612. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  109613. get mimeType(): string | undefined;
  109614. /**
  109615. * Observable triggered once the texture has been loaded.
  109616. */
  109617. onLoadObservable: Observable<Texture>;
  109618. protected _isBlocking: boolean;
  109619. /**
  109620. * Is the texture preventing material to render while loading.
  109621. * If false, a default texture will be used instead of the loading one during the preparation step.
  109622. */
  109623. set isBlocking(value: boolean);
  109624. get isBlocking(): boolean;
  109625. /**
  109626. * Get the current sampling mode associated with the texture.
  109627. */
  109628. get samplingMode(): number;
  109629. /**
  109630. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  109631. */
  109632. get invertY(): boolean;
  109633. /**
  109634. * Instantiates a new texture.
  109635. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  109636. * @see https://doc.babylonjs.com/babylon101/materials#texture
  109637. * @param url defines the url of the picture to load as a texture
  109638. * @param sceneOrEngine defines the scene or engine the texture will belong to
  109639. * @param noMipmap defines if the texture will require mip maps or not
  109640. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  109641. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109642. * @param onLoad defines a callback triggered when the texture has been loaded
  109643. * @param onError defines a callback triggered when an error occurred during the loading session
  109644. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  109645. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  109646. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109647. * @param mimeType defines an optional mime type information
  109648. * @param loaderOptions options to be passed to the loader
  109649. */
  109650. 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);
  109651. /**
  109652. * Update the url (and optional buffer) of this texture if url was null during construction.
  109653. * @param url the url of the texture
  109654. * @param buffer the buffer of the texture (defaults to null)
  109655. * @param onLoad callback called when the texture is loaded (defaults to null)
  109656. */
  109657. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  109658. /**
  109659. * Finish the loading sequence of a texture flagged as delayed load.
  109660. * @hidden
  109661. */
  109662. delayLoad(): void;
  109663. private _prepareRowForTextureGeneration;
  109664. /**
  109665. * Checks if the texture has the same transform matrix than another texture
  109666. * @param texture texture to check against
  109667. * @returns true if the transforms are the same, else false
  109668. */
  109669. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  109670. /**
  109671. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  109672. * @returns the transform matrix of the texture.
  109673. */
  109674. getTextureMatrix(uBase?: number): Matrix;
  109675. /**
  109676. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  109677. * @returns The reflection texture transform
  109678. */
  109679. getReflectionTextureMatrix(): Matrix;
  109680. /**
  109681. * Clones the texture.
  109682. * @returns the cloned texture
  109683. */
  109684. clone(): Texture;
  109685. /**
  109686. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109687. * @returns The JSON representation of the texture
  109688. */
  109689. serialize(): any;
  109690. /**
  109691. * Get the current class name of the texture useful for serialization or dynamic coding.
  109692. * @returns "Texture"
  109693. */
  109694. getClassName(): string;
  109695. /**
  109696. * Dispose the texture and release its associated resources.
  109697. */
  109698. dispose(): void;
  109699. /**
  109700. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  109701. * @param parsedTexture Define the JSON representation of the texture
  109702. * @param scene Define the scene the parsed texture should be instantiated in
  109703. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  109704. * @returns The parsed texture if successful
  109705. */
  109706. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  109707. /**
  109708. * Creates a texture from its base 64 representation.
  109709. * @param data Define the base64 payload without the data: prefix
  109710. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109711. * @param scene Define the scene the texture should belong to
  109712. * @param noMipmap Forces the texture to not create mip map information if true
  109713. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109714. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109715. * @param onLoad define a callback triggered when the texture has been loaded
  109716. * @param onError define a callback triggered when an error occurred during the loading session
  109717. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109718. * @returns the created texture
  109719. */
  109720. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  109721. /**
  109722. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  109723. * @param data Define the base64 payload without the data: prefix
  109724. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109725. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  109726. * @param scene Define the scene the texture should belong to
  109727. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  109728. * @param noMipmap Forces the texture to not create mip map information if true
  109729. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109730. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109731. * @param onLoad define a callback triggered when the texture has been loaded
  109732. * @param onError define a callback triggered when an error occurred during the loading session
  109733. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109734. * @returns the created texture
  109735. */
  109736. 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;
  109737. }
  109738. }
  109739. declare module BABYLON {
  109740. /**
  109741. * PostProcessManager is used to manage one or more post processes or post process pipelines
  109742. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109743. */
  109744. export class PostProcessManager {
  109745. private _scene;
  109746. private _indexBuffer;
  109747. private _vertexBuffers;
  109748. /**
  109749. * Creates a new instance PostProcess
  109750. * @param scene The scene that the post process is associated with.
  109751. */
  109752. constructor(scene: Scene);
  109753. private _prepareBuffers;
  109754. private _buildIndexBuffer;
  109755. /**
  109756. * Rebuilds the vertex buffers of the manager.
  109757. * @hidden
  109758. */
  109759. _rebuild(): void;
  109760. /**
  109761. * Prepares a frame to be run through a post process.
  109762. * @param sourceTexture The input texture to the post procesess. (default: null)
  109763. * @param postProcesses An array of post processes to be run. (default: null)
  109764. * @returns True if the post processes were able to be run.
  109765. * @hidden
  109766. */
  109767. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  109768. /**
  109769. * Manually render a set of post processes to a texture.
  109770. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  109771. * @param postProcesses An array of post processes to be run.
  109772. * @param targetTexture The target texture to render to.
  109773. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  109774. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  109775. * @param lodLevel defines which lod of the texture to render to
  109776. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  109777. */
  109778. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  109779. /**
  109780. * Finalize the result of the output of the postprocesses.
  109781. * @param doNotPresent If true the result will not be displayed to the screen.
  109782. * @param targetTexture The target texture to render to.
  109783. * @param faceIndex The index of the face to bind the target texture to.
  109784. * @param postProcesses The array of post processes to render.
  109785. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  109786. * @hidden
  109787. */
  109788. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  109789. /**
  109790. * Disposes of the post process manager.
  109791. */
  109792. dispose(): void;
  109793. }
  109794. }
  109795. declare module BABYLON {
  109796. /**
  109797. * This Helps creating a texture that will be created from a camera in your scene.
  109798. * It is basically a dynamic texture that could be used to create special effects for instance.
  109799. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  109800. */
  109801. export class RenderTargetTexture extends Texture {
  109802. /**
  109803. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  109804. */
  109805. static readonly REFRESHRATE_RENDER_ONCE: number;
  109806. /**
  109807. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  109808. */
  109809. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  109810. /**
  109811. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  109812. * the central point of your effect and can save a lot of performances.
  109813. */
  109814. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  109815. /**
  109816. * Use this predicate to dynamically define the list of mesh you want to render.
  109817. * If set, the renderList property will be overwritten.
  109818. */
  109819. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  109820. private _renderList;
  109821. /**
  109822. * Use this list to define the list of mesh you want to render.
  109823. */
  109824. get renderList(): Nullable<Array<AbstractMesh>>;
  109825. set renderList(value: Nullable<Array<AbstractMesh>>);
  109826. /**
  109827. * Use this function to overload the renderList array at rendering time.
  109828. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  109829. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  109830. * the cube (if the RTT is a cube, else layerOrFace=0).
  109831. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  109832. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  109833. * hold dummy elements!
  109834. */
  109835. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  109836. private _hookArray;
  109837. /**
  109838. * Define if particles should be rendered in your texture.
  109839. */
  109840. renderParticles: boolean;
  109841. /**
  109842. * Define if sprites should be rendered in your texture.
  109843. */
  109844. renderSprites: boolean;
  109845. /**
  109846. * Define the camera used to render the texture.
  109847. */
  109848. activeCamera: Nullable<Camera>;
  109849. /**
  109850. * Override the mesh isReady function with your own one.
  109851. */
  109852. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  109853. /**
  109854. * Override the render function of the texture with your own one.
  109855. */
  109856. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  109857. /**
  109858. * Define if camera post processes should be use while rendering the texture.
  109859. */
  109860. useCameraPostProcesses: boolean;
  109861. /**
  109862. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  109863. */
  109864. ignoreCameraViewport: boolean;
  109865. private _postProcessManager;
  109866. private _postProcesses;
  109867. private _resizeObserver;
  109868. /**
  109869. * An event triggered when the texture is unbind.
  109870. */
  109871. onBeforeBindObservable: Observable<RenderTargetTexture>;
  109872. /**
  109873. * An event triggered when the texture is unbind.
  109874. */
  109875. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  109876. private _onAfterUnbindObserver;
  109877. /**
  109878. * Set a after unbind callback in the texture.
  109879. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  109880. */
  109881. set onAfterUnbind(callback: () => void);
  109882. /**
  109883. * An event triggered before rendering the texture
  109884. */
  109885. onBeforeRenderObservable: Observable<number>;
  109886. private _onBeforeRenderObserver;
  109887. /**
  109888. * Set a before render callback in the texture.
  109889. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  109890. */
  109891. set onBeforeRender(callback: (faceIndex: number) => void);
  109892. /**
  109893. * An event triggered after rendering the texture
  109894. */
  109895. onAfterRenderObservable: Observable<number>;
  109896. private _onAfterRenderObserver;
  109897. /**
  109898. * Set a after render callback in the texture.
  109899. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  109900. */
  109901. set onAfterRender(callback: (faceIndex: number) => void);
  109902. /**
  109903. * An event triggered after the texture clear
  109904. */
  109905. onClearObservable: Observable<Engine>;
  109906. private _onClearObserver;
  109907. /**
  109908. * Set a clear callback in the texture.
  109909. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  109910. */
  109911. set onClear(callback: (Engine: Engine) => void);
  109912. /**
  109913. * An event triggered when the texture is resized.
  109914. */
  109915. onResizeObservable: Observable<RenderTargetTexture>;
  109916. /**
  109917. * Define the clear color of the Render Target if it should be different from the scene.
  109918. */
  109919. clearColor: Color4;
  109920. protected _size: number | {
  109921. width: number;
  109922. height: number;
  109923. layers?: number;
  109924. };
  109925. protected _initialSizeParameter: number | {
  109926. width: number;
  109927. height: number;
  109928. } | {
  109929. ratio: number;
  109930. };
  109931. protected _sizeRatio: Nullable<number>;
  109932. /** @hidden */
  109933. _generateMipMaps: boolean;
  109934. protected _renderingManager: RenderingManager;
  109935. /** @hidden */
  109936. _waitingRenderList?: string[];
  109937. protected _doNotChangeAspectRatio: boolean;
  109938. protected _currentRefreshId: number;
  109939. protected _refreshRate: number;
  109940. protected _textureMatrix: Matrix;
  109941. protected _samples: number;
  109942. protected _renderTargetOptions: RenderTargetCreationOptions;
  109943. /**
  109944. * Gets render target creation options that were used.
  109945. */
  109946. get renderTargetOptions(): RenderTargetCreationOptions;
  109947. protected _onRatioRescale(): void;
  109948. /**
  109949. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  109950. * It must define where the camera used to render the texture is set
  109951. */
  109952. boundingBoxPosition: Vector3;
  109953. private _boundingBoxSize;
  109954. /**
  109955. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  109956. * When defined, the cubemap will switch to local mode
  109957. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  109958. * @example https://www.babylonjs-playground.com/#RNASML
  109959. */
  109960. set boundingBoxSize(value: Vector3);
  109961. get boundingBoxSize(): Vector3;
  109962. /**
  109963. * In case the RTT has been created with a depth texture, get the associated
  109964. * depth texture.
  109965. * Otherwise, return null.
  109966. */
  109967. get depthStencilTexture(): Nullable<InternalTexture>;
  109968. /**
  109969. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  109970. * or used a shadow, depth texture...
  109971. * @param name The friendly name of the texture
  109972. * @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)
  109973. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  109974. * @param generateMipMaps True if mip maps need to be generated after render.
  109975. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  109976. * @param type The type of the buffer in the RTT (int, half float, float...)
  109977. * @param isCube True if a cube texture needs to be created
  109978. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  109979. * @param generateDepthBuffer True to generate a depth buffer
  109980. * @param generateStencilBuffer True to generate a stencil buffer
  109981. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  109982. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  109983. * @param delayAllocation if the texture allocation should be delayed (default: false)
  109984. */
  109985. constructor(name: string, size: number | {
  109986. width: number;
  109987. height: number;
  109988. layers?: number;
  109989. } | {
  109990. ratio: number;
  109991. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  109992. /**
  109993. * Creates a depth stencil texture.
  109994. * This is only available in WebGL 2 or with the depth texture extension available.
  109995. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  109996. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  109997. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  109998. */
  109999. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  110000. private _processSizeParameter;
  110001. /**
  110002. * Define the number of samples to use in case of MSAA.
  110003. * It defaults to one meaning no MSAA has been enabled.
  110004. */
  110005. get samples(): number;
  110006. set samples(value: number);
  110007. /**
  110008. * Resets the refresh counter of the texture and start bak from scratch.
  110009. * Could be useful to regenerate the texture if it is setup to render only once.
  110010. */
  110011. resetRefreshCounter(): void;
  110012. /**
  110013. * Define the refresh rate of the texture or the rendering frequency.
  110014. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  110015. */
  110016. get refreshRate(): number;
  110017. set refreshRate(value: number);
  110018. /**
  110019. * Adds a post process to the render target rendering passes.
  110020. * @param postProcess define the post process to add
  110021. */
  110022. addPostProcess(postProcess: PostProcess): void;
  110023. /**
  110024. * Clear all the post processes attached to the render target
  110025. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  110026. */
  110027. clearPostProcesses(dispose?: boolean): void;
  110028. /**
  110029. * Remove one of the post process from the list of attached post processes to the texture
  110030. * @param postProcess define the post process to remove from the list
  110031. */
  110032. removePostProcess(postProcess: PostProcess): void;
  110033. /** @hidden */
  110034. _shouldRender(): boolean;
  110035. /**
  110036. * Gets the actual render size of the texture.
  110037. * @returns the width of the render size
  110038. */
  110039. getRenderSize(): number;
  110040. /**
  110041. * Gets the actual render width of the texture.
  110042. * @returns the width of the render size
  110043. */
  110044. getRenderWidth(): number;
  110045. /**
  110046. * Gets the actual render height of the texture.
  110047. * @returns the height of the render size
  110048. */
  110049. getRenderHeight(): number;
  110050. /**
  110051. * Gets the actual number of layers of the texture.
  110052. * @returns the number of layers
  110053. */
  110054. getRenderLayers(): number;
  110055. /**
  110056. * Get if the texture can be rescaled or not.
  110057. */
  110058. get canRescale(): boolean;
  110059. /**
  110060. * Resize the texture using a ratio.
  110061. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  110062. */
  110063. scale(ratio: number): void;
  110064. /**
  110065. * Get the texture reflection matrix used to rotate/transform the reflection.
  110066. * @returns the reflection matrix
  110067. */
  110068. getReflectionTextureMatrix(): Matrix;
  110069. /**
  110070. * Resize the texture to a new desired size.
  110071. * Be carrefull as it will recreate all the data in the new texture.
  110072. * @param size Define the new size. It can be:
  110073. * - a number for squared texture,
  110074. * - an object containing { width: number, height: number }
  110075. * - or an object containing a ratio { ratio: number }
  110076. */
  110077. resize(size: number | {
  110078. width: number;
  110079. height: number;
  110080. } | {
  110081. ratio: number;
  110082. }): void;
  110083. private _defaultRenderListPrepared;
  110084. /**
  110085. * Renders all the objects from the render list into the texture.
  110086. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  110087. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  110088. */
  110089. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  110090. private _bestReflectionRenderTargetDimension;
  110091. private _prepareRenderingManager;
  110092. /**
  110093. * @hidden
  110094. * @param faceIndex face index to bind to if this is a cubetexture
  110095. * @param layer defines the index of the texture to bind in the array
  110096. */
  110097. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  110098. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  110099. private renderToTarget;
  110100. /**
  110101. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110102. * This allowed control for front to back rendering or reversly depending of the special needs.
  110103. *
  110104. * @param renderingGroupId The rendering group id corresponding to its index
  110105. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110106. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110107. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110108. */
  110109. 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;
  110110. /**
  110111. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110112. *
  110113. * @param renderingGroupId The rendering group id corresponding to its index
  110114. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110115. */
  110116. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  110117. /**
  110118. * Clones the texture.
  110119. * @returns the cloned texture
  110120. */
  110121. clone(): RenderTargetTexture;
  110122. /**
  110123. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  110124. * @returns The JSON representation of the texture
  110125. */
  110126. serialize(): any;
  110127. /**
  110128. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  110129. */
  110130. disposeFramebufferObjects(): void;
  110131. /**
  110132. * Dispose the texture and release its associated resources.
  110133. */
  110134. dispose(): void;
  110135. /** @hidden */
  110136. _rebuild(): void;
  110137. /**
  110138. * Clear the info related to rendering groups preventing retention point in material dispose.
  110139. */
  110140. freeRenderingGroups(): void;
  110141. /**
  110142. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  110143. * @returns the view count
  110144. */
  110145. getViewCount(): number;
  110146. }
  110147. }
  110148. declare module BABYLON {
  110149. /**
  110150. * Class used to manipulate GUIDs
  110151. */
  110152. export class GUID {
  110153. /**
  110154. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110155. * Be aware Math.random() could cause collisions, but:
  110156. * "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"
  110157. * @returns a pseudo random id
  110158. */
  110159. static RandomId(): string;
  110160. }
  110161. }
  110162. declare module BABYLON {
  110163. /**
  110164. * Options to be used when creating a shadow depth material
  110165. */
  110166. export interface IIOptionShadowDepthMaterial {
  110167. /** Variables in the vertex shader code that need to have their names remapped.
  110168. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  110169. * "var_name" should be either: worldPos or vNormalW
  110170. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  110171. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  110172. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  110173. */
  110174. remappedVariables?: string[];
  110175. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  110176. standalone?: boolean;
  110177. }
  110178. /**
  110179. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  110180. */
  110181. export class ShadowDepthWrapper {
  110182. private _scene;
  110183. private _options?;
  110184. private _baseMaterial;
  110185. private _onEffectCreatedObserver;
  110186. private _subMeshToEffect;
  110187. private _subMeshToDepthEffect;
  110188. private _meshes;
  110189. /** @hidden */
  110190. _matriceNames: any;
  110191. /** Gets the standalone status of the wrapper */
  110192. get standalone(): boolean;
  110193. /** Gets the base material the wrapper is built upon */
  110194. get baseMaterial(): Material;
  110195. /**
  110196. * Instantiate a new shadow depth wrapper.
  110197. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  110198. * generate the shadow depth map. For more information, please refer to the documentation:
  110199. * https://doc.babylonjs.com/babylon101/shadows
  110200. * @param baseMaterial Material to wrap
  110201. * @param scene Define the scene the material belongs to
  110202. * @param options Options used to create the wrapper
  110203. */
  110204. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  110205. /**
  110206. * Gets the effect to use to generate the depth map
  110207. * @param subMesh subMesh to get the effect for
  110208. * @param shadowGenerator shadow generator to get the effect for
  110209. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  110210. */
  110211. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  110212. /**
  110213. * Specifies that the submesh is ready to be used for depth rendering
  110214. * @param subMesh submesh to check
  110215. * @param defines the list of defines to take into account when checking the effect
  110216. * @param shadowGenerator combined with subMesh, it defines the effect to check
  110217. * @param useInstances specifies that instances should be used
  110218. * @returns a boolean indicating that the submesh is ready or not
  110219. */
  110220. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  110221. /**
  110222. * Disposes the resources
  110223. */
  110224. dispose(): void;
  110225. private _makeEffect;
  110226. }
  110227. }
  110228. declare module BABYLON {
  110229. /**
  110230. * Options for compiling materials.
  110231. */
  110232. export interface IMaterialCompilationOptions {
  110233. /**
  110234. * Defines whether clip planes are enabled.
  110235. */
  110236. clipPlane: boolean;
  110237. /**
  110238. * Defines whether instances are enabled.
  110239. */
  110240. useInstances: boolean;
  110241. }
  110242. /**
  110243. * Options passed when calling customShaderNameResolve
  110244. */
  110245. export interface ICustomShaderNameResolveOptions {
  110246. /**
  110247. * 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
  110248. */
  110249. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  110250. }
  110251. /**
  110252. * Base class for the main features of a material in Babylon.js
  110253. */
  110254. export class Material implements IAnimatable {
  110255. /**
  110256. * Returns the triangle fill mode
  110257. */
  110258. static readonly TriangleFillMode: number;
  110259. /**
  110260. * Returns the wireframe mode
  110261. */
  110262. static readonly WireFrameFillMode: number;
  110263. /**
  110264. * Returns the point fill mode
  110265. */
  110266. static readonly PointFillMode: number;
  110267. /**
  110268. * Returns the point list draw mode
  110269. */
  110270. static readonly PointListDrawMode: number;
  110271. /**
  110272. * Returns the line list draw mode
  110273. */
  110274. static readonly LineListDrawMode: number;
  110275. /**
  110276. * Returns the line loop draw mode
  110277. */
  110278. static readonly LineLoopDrawMode: number;
  110279. /**
  110280. * Returns the line strip draw mode
  110281. */
  110282. static readonly LineStripDrawMode: number;
  110283. /**
  110284. * Returns the triangle strip draw mode
  110285. */
  110286. static readonly TriangleStripDrawMode: number;
  110287. /**
  110288. * Returns the triangle fan draw mode
  110289. */
  110290. static readonly TriangleFanDrawMode: number;
  110291. /**
  110292. * Stores the clock-wise side orientation
  110293. */
  110294. static readonly ClockWiseSideOrientation: number;
  110295. /**
  110296. * Stores the counter clock-wise side orientation
  110297. */
  110298. static readonly CounterClockWiseSideOrientation: number;
  110299. /**
  110300. * The dirty texture flag value
  110301. */
  110302. static readonly TextureDirtyFlag: number;
  110303. /**
  110304. * The dirty light flag value
  110305. */
  110306. static readonly LightDirtyFlag: number;
  110307. /**
  110308. * The dirty fresnel flag value
  110309. */
  110310. static readonly FresnelDirtyFlag: number;
  110311. /**
  110312. * The dirty attribute flag value
  110313. */
  110314. static readonly AttributesDirtyFlag: number;
  110315. /**
  110316. * The dirty misc flag value
  110317. */
  110318. static readonly MiscDirtyFlag: number;
  110319. /**
  110320. * The dirty prepass flag value
  110321. */
  110322. static readonly PrePassDirtyFlag: number;
  110323. /**
  110324. * The all dirty flag value
  110325. */
  110326. static readonly AllDirtyFlag: number;
  110327. /**
  110328. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110329. */
  110330. static readonly MATERIAL_OPAQUE: number;
  110331. /**
  110332. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110333. */
  110334. static readonly MATERIAL_ALPHATEST: number;
  110335. /**
  110336. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110337. */
  110338. static readonly MATERIAL_ALPHABLEND: number;
  110339. /**
  110340. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110341. * They are also discarded below the alpha cutoff threshold to improve performances.
  110342. */
  110343. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  110344. /**
  110345. * The Whiteout method is used to blend normals.
  110346. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  110347. */
  110348. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  110349. /**
  110350. * The Reoriented Normal Mapping method is used to blend normals.
  110351. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  110352. */
  110353. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  110354. /**
  110355. * Custom callback helping to override the default shader used in the material.
  110356. */
  110357. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  110358. /**
  110359. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  110360. */
  110361. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  110362. /**
  110363. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  110364. * This means that the material can keep using a previous shader while a new one is being compiled.
  110365. * This is mostly used when shader parallel compilation is supported (true by default)
  110366. */
  110367. allowShaderHotSwapping: boolean;
  110368. /**
  110369. * The ID of the material
  110370. */
  110371. id: string;
  110372. /**
  110373. * Gets or sets the unique id of the material
  110374. */
  110375. uniqueId: number;
  110376. /**
  110377. * The name of the material
  110378. */
  110379. name: string;
  110380. /**
  110381. * Gets or sets user defined metadata
  110382. */
  110383. metadata: any;
  110384. /**
  110385. * For internal use only. Please do not use.
  110386. */
  110387. reservedDataStore: any;
  110388. /**
  110389. * Specifies if the ready state should be checked on each call
  110390. */
  110391. checkReadyOnEveryCall: boolean;
  110392. /**
  110393. * Specifies if the ready state should be checked once
  110394. */
  110395. checkReadyOnlyOnce: boolean;
  110396. /**
  110397. * The state of the material
  110398. */
  110399. state: string;
  110400. /**
  110401. * If the material can be rendered to several textures with MRT extension
  110402. */
  110403. get canRenderToMRT(): boolean;
  110404. /**
  110405. * The alpha value of the material
  110406. */
  110407. protected _alpha: number;
  110408. /**
  110409. * List of inspectable custom properties (used by the Inspector)
  110410. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110411. */
  110412. inspectableCustomProperties: IInspectable[];
  110413. /**
  110414. * Sets the alpha value of the material
  110415. */
  110416. set alpha(value: number);
  110417. /**
  110418. * Gets the alpha value of the material
  110419. */
  110420. get alpha(): number;
  110421. /**
  110422. * Specifies if back face culling is enabled
  110423. */
  110424. protected _backFaceCulling: boolean;
  110425. /**
  110426. * Sets the back-face culling state
  110427. */
  110428. set backFaceCulling(value: boolean);
  110429. /**
  110430. * Gets the back-face culling state
  110431. */
  110432. get backFaceCulling(): boolean;
  110433. /**
  110434. * Stores the value for side orientation
  110435. */
  110436. sideOrientation: number;
  110437. /**
  110438. * Callback triggered when the material is compiled
  110439. */
  110440. onCompiled: Nullable<(effect: Effect) => void>;
  110441. /**
  110442. * Callback triggered when an error occurs
  110443. */
  110444. onError: Nullable<(effect: Effect, errors: string) => void>;
  110445. /**
  110446. * Callback triggered to get the render target textures
  110447. */
  110448. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  110449. /**
  110450. * Gets a boolean indicating that current material needs to register RTT
  110451. */
  110452. get hasRenderTargetTextures(): boolean;
  110453. /**
  110454. * Specifies if the material should be serialized
  110455. */
  110456. doNotSerialize: boolean;
  110457. /**
  110458. * @hidden
  110459. */
  110460. _storeEffectOnSubMeshes: boolean;
  110461. /**
  110462. * Stores the animations for the material
  110463. */
  110464. animations: Nullable<Array<Animation>>;
  110465. /**
  110466. * An event triggered when the material is disposed
  110467. */
  110468. onDisposeObservable: Observable<Material>;
  110469. /**
  110470. * An observer which watches for dispose events
  110471. */
  110472. private _onDisposeObserver;
  110473. private _onUnBindObservable;
  110474. /**
  110475. * Called during a dispose event
  110476. */
  110477. set onDispose(callback: () => void);
  110478. private _onBindObservable;
  110479. /**
  110480. * An event triggered when the material is bound
  110481. */
  110482. get onBindObservable(): Observable<AbstractMesh>;
  110483. /**
  110484. * An observer which watches for bind events
  110485. */
  110486. private _onBindObserver;
  110487. /**
  110488. * Called during a bind event
  110489. */
  110490. set onBind(callback: (Mesh: AbstractMesh) => void);
  110491. /**
  110492. * An event triggered when the material is unbound
  110493. */
  110494. get onUnBindObservable(): Observable<Material>;
  110495. protected _onEffectCreatedObservable: Nullable<Observable<{
  110496. effect: Effect;
  110497. subMesh: Nullable<SubMesh>;
  110498. }>>;
  110499. /**
  110500. * An event triggered when the effect is (re)created
  110501. */
  110502. get onEffectCreatedObservable(): Observable<{
  110503. effect: Effect;
  110504. subMesh: Nullable<SubMesh>;
  110505. }>;
  110506. /**
  110507. * Stores the value of the alpha mode
  110508. */
  110509. private _alphaMode;
  110510. /**
  110511. * Sets the value of the alpha mode.
  110512. *
  110513. * | Value | Type | Description |
  110514. * | --- | --- | --- |
  110515. * | 0 | ALPHA_DISABLE | |
  110516. * | 1 | ALPHA_ADD | |
  110517. * | 2 | ALPHA_COMBINE | |
  110518. * | 3 | ALPHA_SUBTRACT | |
  110519. * | 4 | ALPHA_MULTIPLY | |
  110520. * | 5 | ALPHA_MAXIMIZED | |
  110521. * | 6 | ALPHA_ONEONE | |
  110522. * | 7 | ALPHA_PREMULTIPLIED | |
  110523. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  110524. * | 9 | ALPHA_INTERPOLATE | |
  110525. * | 10 | ALPHA_SCREENMODE | |
  110526. *
  110527. */
  110528. set alphaMode(value: number);
  110529. /**
  110530. * Gets the value of the alpha mode
  110531. */
  110532. get alphaMode(): number;
  110533. /**
  110534. * Stores the state of the need depth pre-pass value
  110535. */
  110536. private _needDepthPrePass;
  110537. /**
  110538. * Sets the need depth pre-pass value
  110539. */
  110540. set needDepthPrePass(value: boolean);
  110541. /**
  110542. * Gets the depth pre-pass value
  110543. */
  110544. get needDepthPrePass(): boolean;
  110545. /**
  110546. * Specifies if depth writing should be disabled
  110547. */
  110548. disableDepthWrite: boolean;
  110549. /**
  110550. * Specifies if color writing should be disabled
  110551. */
  110552. disableColorWrite: boolean;
  110553. /**
  110554. * Specifies if depth writing should be forced
  110555. */
  110556. forceDepthWrite: boolean;
  110557. /**
  110558. * Specifies the depth function that should be used. 0 means the default engine function
  110559. */
  110560. depthFunction: number;
  110561. /**
  110562. * Specifies if there should be a separate pass for culling
  110563. */
  110564. separateCullingPass: boolean;
  110565. /**
  110566. * Stores the state specifing if fog should be enabled
  110567. */
  110568. private _fogEnabled;
  110569. /**
  110570. * Sets the state for enabling fog
  110571. */
  110572. set fogEnabled(value: boolean);
  110573. /**
  110574. * Gets the value of the fog enabled state
  110575. */
  110576. get fogEnabled(): boolean;
  110577. /**
  110578. * Stores the size of points
  110579. */
  110580. pointSize: number;
  110581. /**
  110582. * Stores the z offset value
  110583. */
  110584. zOffset: number;
  110585. get wireframe(): boolean;
  110586. /**
  110587. * Sets the state of wireframe mode
  110588. */
  110589. set wireframe(value: boolean);
  110590. /**
  110591. * Gets the value specifying if point clouds are enabled
  110592. */
  110593. get pointsCloud(): boolean;
  110594. /**
  110595. * Sets the state of point cloud mode
  110596. */
  110597. set pointsCloud(value: boolean);
  110598. /**
  110599. * Gets the material fill mode
  110600. */
  110601. get fillMode(): number;
  110602. /**
  110603. * Sets the material fill mode
  110604. */
  110605. set fillMode(value: number);
  110606. /**
  110607. * @hidden
  110608. * Stores the effects for the material
  110609. */
  110610. _effect: Nullable<Effect>;
  110611. /**
  110612. * Specifies if uniform buffers should be used
  110613. */
  110614. private _useUBO;
  110615. /**
  110616. * Stores a reference to the scene
  110617. */
  110618. private _scene;
  110619. /**
  110620. * Stores the fill mode state
  110621. */
  110622. private _fillMode;
  110623. /**
  110624. * Specifies if the depth write state should be cached
  110625. */
  110626. private _cachedDepthWriteState;
  110627. /**
  110628. * Specifies if the color write state should be cached
  110629. */
  110630. private _cachedColorWriteState;
  110631. /**
  110632. * Specifies if the depth function state should be cached
  110633. */
  110634. private _cachedDepthFunctionState;
  110635. /**
  110636. * Stores the uniform buffer
  110637. */
  110638. protected _uniformBuffer: UniformBuffer;
  110639. /** @hidden */
  110640. _indexInSceneMaterialArray: number;
  110641. /** @hidden */
  110642. meshMap: Nullable<{
  110643. [id: string]: AbstractMesh | undefined;
  110644. }>;
  110645. /**
  110646. * Creates a material instance
  110647. * @param name defines the name of the material
  110648. * @param scene defines the scene to reference
  110649. * @param doNotAdd specifies if the material should be added to the scene
  110650. */
  110651. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  110652. /**
  110653. * Returns a string representation of the current material
  110654. * @param fullDetails defines a boolean indicating which levels of logging is desired
  110655. * @returns a string with material information
  110656. */
  110657. toString(fullDetails?: boolean): string;
  110658. /**
  110659. * Gets the class name of the material
  110660. * @returns a string with the class name of the material
  110661. */
  110662. getClassName(): string;
  110663. /**
  110664. * Specifies if updates for the material been locked
  110665. */
  110666. get isFrozen(): boolean;
  110667. /**
  110668. * Locks updates for the material
  110669. */
  110670. freeze(): void;
  110671. /**
  110672. * Unlocks updates for the material
  110673. */
  110674. unfreeze(): void;
  110675. /**
  110676. * Specifies if the material is ready to be used
  110677. * @param mesh defines the mesh to check
  110678. * @param useInstances specifies if instances should be used
  110679. * @returns a boolean indicating if the material is ready to be used
  110680. */
  110681. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  110682. /**
  110683. * Specifies that the submesh is ready to be used
  110684. * @param mesh defines the mesh to check
  110685. * @param subMesh defines which submesh to check
  110686. * @param useInstances specifies that instances should be used
  110687. * @returns a boolean indicating that the submesh is ready or not
  110688. */
  110689. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110690. /**
  110691. * Returns the material effect
  110692. * @returns the effect associated with the material
  110693. */
  110694. getEffect(): Nullable<Effect>;
  110695. /**
  110696. * Returns the current scene
  110697. * @returns a Scene
  110698. */
  110699. getScene(): Scene;
  110700. /**
  110701. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110702. */
  110703. protected _forceAlphaTest: boolean;
  110704. /**
  110705. * The transparency mode of the material.
  110706. */
  110707. protected _transparencyMode: Nullable<number>;
  110708. /**
  110709. * Gets the current transparency mode.
  110710. */
  110711. get transparencyMode(): Nullable<number>;
  110712. /**
  110713. * Sets the transparency mode of the material.
  110714. *
  110715. * | Value | Type | Description |
  110716. * | ----- | ----------------------------------- | ----------- |
  110717. * | 0 | OPAQUE | |
  110718. * | 1 | ALPHATEST | |
  110719. * | 2 | ALPHABLEND | |
  110720. * | 3 | ALPHATESTANDBLEND | |
  110721. *
  110722. */
  110723. set transparencyMode(value: Nullable<number>);
  110724. /**
  110725. * Returns true if alpha blending should be disabled.
  110726. */
  110727. protected get _disableAlphaBlending(): boolean;
  110728. /**
  110729. * Specifies whether or not this material should be rendered in alpha blend mode.
  110730. * @returns a boolean specifying if alpha blending is needed
  110731. */
  110732. needAlphaBlending(): boolean;
  110733. /**
  110734. * Specifies if the mesh will require alpha blending
  110735. * @param mesh defines the mesh to check
  110736. * @returns a boolean specifying if alpha blending is needed for the mesh
  110737. */
  110738. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  110739. /**
  110740. * Specifies whether or not this material should be rendered in alpha test mode.
  110741. * @returns a boolean specifying if an alpha test is needed.
  110742. */
  110743. needAlphaTesting(): boolean;
  110744. /**
  110745. * Specifies if material alpha testing should be turned on for the mesh
  110746. * @param mesh defines the mesh to check
  110747. */
  110748. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  110749. /**
  110750. * Gets the texture used for the alpha test
  110751. * @returns the texture to use for alpha testing
  110752. */
  110753. getAlphaTestTexture(): Nullable<BaseTexture>;
  110754. /**
  110755. * Marks the material to indicate that it needs to be re-calculated
  110756. */
  110757. markDirty(): void;
  110758. /** @hidden */
  110759. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  110760. /**
  110761. * Binds the material to the mesh
  110762. * @param world defines the world transformation matrix
  110763. * @param mesh defines the mesh to bind the material to
  110764. */
  110765. bind(world: Matrix, mesh?: Mesh): void;
  110766. /**
  110767. * Binds the submesh to the material
  110768. * @param world defines the world transformation matrix
  110769. * @param mesh defines the mesh containing the submesh
  110770. * @param subMesh defines the submesh to bind the material to
  110771. */
  110772. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110773. /**
  110774. * Binds the world matrix to the material
  110775. * @param world defines the world transformation matrix
  110776. */
  110777. bindOnlyWorldMatrix(world: Matrix): void;
  110778. /**
  110779. * Binds the scene's uniform buffer to the effect.
  110780. * @param effect defines the effect to bind to the scene uniform buffer
  110781. * @param sceneUbo defines the uniform buffer storing scene data
  110782. */
  110783. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  110784. /**
  110785. * Binds the view matrix to the effect
  110786. * @param effect defines the effect to bind the view matrix to
  110787. */
  110788. bindView(effect: Effect): void;
  110789. /**
  110790. * Binds the view projection matrix to the effect
  110791. * @param effect defines the effect to bind the view projection matrix to
  110792. */
  110793. bindViewProjection(effect: Effect): void;
  110794. /**
  110795. * Processes to execute after binding the material to a mesh
  110796. * @param mesh defines the rendered mesh
  110797. */
  110798. protected _afterBind(mesh?: Mesh): void;
  110799. /**
  110800. * Unbinds the material from the mesh
  110801. */
  110802. unbind(): void;
  110803. /**
  110804. * Gets the active textures from the material
  110805. * @returns an array of textures
  110806. */
  110807. getActiveTextures(): BaseTexture[];
  110808. /**
  110809. * Specifies if the material uses a texture
  110810. * @param texture defines the texture to check against the material
  110811. * @returns a boolean specifying if the material uses the texture
  110812. */
  110813. hasTexture(texture: BaseTexture): boolean;
  110814. /**
  110815. * Makes a duplicate of the material, and gives it a new name
  110816. * @param name defines the new name for the duplicated material
  110817. * @returns the cloned material
  110818. */
  110819. clone(name: string): Nullable<Material>;
  110820. /**
  110821. * Gets the meshes bound to the material
  110822. * @returns an array of meshes bound to the material
  110823. */
  110824. getBindedMeshes(): AbstractMesh[];
  110825. /**
  110826. * Force shader compilation
  110827. * @param mesh defines the mesh associated with this material
  110828. * @param onCompiled defines a function to execute once the material is compiled
  110829. * @param options defines the options to configure the compilation
  110830. * @param onError defines a function to execute if the material fails compiling
  110831. */
  110832. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  110833. /**
  110834. * Force shader compilation
  110835. * @param mesh defines the mesh that will use this material
  110836. * @param options defines additional options for compiling the shaders
  110837. * @returns a promise that resolves when the compilation completes
  110838. */
  110839. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  110840. private static readonly _AllDirtyCallBack;
  110841. private static readonly _ImageProcessingDirtyCallBack;
  110842. private static readonly _TextureDirtyCallBack;
  110843. private static readonly _FresnelDirtyCallBack;
  110844. private static readonly _MiscDirtyCallBack;
  110845. private static readonly _PrePassDirtyCallBack;
  110846. private static readonly _LightsDirtyCallBack;
  110847. private static readonly _AttributeDirtyCallBack;
  110848. private static _FresnelAndMiscDirtyCallBack;
  110849. private static _TextureAndMiscDirtyCallBack;
  110850. private static readonly _DirtyCallbackArray;
  110851. private static readonly _RunDirtyCallBacks;
  110852. /**
  110853. * Marks a define in the material to indicate that it needs to be re-computed
  110854. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  110855. */
  110856. markAsDirty(flag: number): void;
  110857. /**
  110858. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  110859. * @param func defines a function which checks material defines against the submeshes
  110860. */
  110861. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  110862. /**
  110863. * Indicates that the scene should check if the rendering now needs a prepass
  110864. */
  110865. protected _markScenePrePassDirty(): void;
  110866. /**
  110867. * Indicates that we need to re-calculated for all submeshes
  110868. */
  110869. protected _markAllSubMeshesAsAllDirty(): void;
  110870. /**
  110871. * Indicates that image processing needs to be re-calculated for all submeshes
  110872. */
  110873. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  110874. /**
  110875. * Indicates that textures need to be re-calculated for all submeshes
  110876. */
  110877. protected _markAllSubMeshesAsTexturesDirty(): void;
  110878. /**
  110879. * Indicates that fresnel needs to be re-calculated for all submeshes
  110880. */
  110881. protected _markAllSubMeshesAsFresnelDirty(): void;
  110882. /**
  110883. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  110884. */
  110885. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  110886. /**
  110887. * Indicates that lights need to be re-calculated for all submeshes
  110888. */
  110889. protected _markAllSubMeshesAsLightsDirty(): void;
  110890. /**
  110891. * Indicates that attributes need to be re-calculated for all submeshes
  110892. */
  110893. protected _markAllSubMeshesAsAttributesDirty(): void;
  110894. /**
  110895. * Indicates that misc needs to be re-calculated for all submeshes
  110896. */
  110897. protected _markAllSubMeshesAsMiscDirty(): void;
  110898. /**
  110899. * Indicates that prepass needs to be re-calculated for all submeshes
  110900. */
  110901. protected _markAllSubMeshesAsPrePassDirty(): void;
  110902. /**
  110903. * Indicates that textures and misc need to be re-calculated for all submeshes
  110904. */
  110905. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  110906. /**
  110907. * Sets the required values to the prepass renderer.
  110908. * @param prePassRenderer defines the prepass renderer to setup.
  110909. * @returns true if the pre pass is needed.
  110910. */
  110911. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  110912. /**
  110913. * Disposes the material
  110914. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110915. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110916. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  110917. */
  110918. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  110919. /** @hidden */
  110920. private releaseVertexArrayObject;
  110921. /**
  110922. * Serializes this material
  110923. * @returns the serialized material object
  110924. */
  110925. serialize(): any;
  110926. /**
  110927. * Creates a material from parsed material data
  110928. * @param parsedMaterial defines parsed material data
  110929. * @param scene defines the hosting scene
  110930. * @param rootUrl defines the root URL to use to load textures
  110931. * @returns a new material
  110932. */
  110933. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  110934. }
  110935. }
  110936. declare module BABYLON {
  110937. /**
  110938. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110939. * separate meshes. This can be use to improve performances.
  110940. * @see https://doc.babylonjs.com/how_to/multi_materials
  110941. */
  110942. export class MultiMaterial extends Material {
  110943. private _subMaterials;
  110944. /**
  110945. * Gets or Sets the list of Materials used within the multi material.
  110946. * They need to be ordered according to the submeshes order in the associated mesh
  110947. */
  110948. get subMaterials(): Nullable<Material>[];
  110949. set subMaterials(value: Nullable<Material>[]);
  110950. /**
  110951. * Function used to align with Node.getChildren()
  110952. * @returns the list of Materials used within the multi material
  110953. */
  110954. getChildren(): Nullable<Material>[];
  110955. /**
  110956. * Instantiates a new Multi Material
  110957. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110958. * separate meshes. This can be use to improve performances.
  110959. * @see https://doc.babylonjs.com/how_to/multi_materials
  110960. * @param name Define the name in the scene
  110961. * @param scene Define the scene the material belongs to
  110962. */
  110963. constructor(name: string, scene: Scene);
  110964. private _hookArray;
  110965. /**
  110966. * Get one of the submaterial by its index in the submaterials array
  110967. * @param index The index to look the sub material at
  110968. * @returns The Material if the index has been defined
  110969. */
  110970. getSubMaterial(index: number): Nullable<Material>;
  110971. /**
  110972. * Get the list of active textures for the whole sub materials list.
  110973. * @returns All the textures that will be used during the rendering
  110974. */
  110975. getActiveTextures(): BaseTexture[];
  110976. /**
  110977. * Gets the current class name of the material e.g. "MultiMaterial"
  110978. * Mainly use in serialization.
  110979. * @returns the class name
  110980. */
  110981. getClassName(): string;
  110982. /**
  110983. * Checks if the material is ready to render the requested sub mesh
  110984. * @param mesh Define the mesh the submesh belongs to
  110985. * @param subMesh Define the sub mesh to look readyness for
  110986. * @param useInstances Define whether or not the material is used with instances
  110987. * @returns true if ready, otherwise false
  110988. */
  110989. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110990. /**
  110991. * Clones the current material and its related sub materials
  110992. * @param name Define the name of the newly cloned material
  110993. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  110994. * @returns the cloned material
  110995. */
  110996. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  110997. /**
  110998. * Serializes the materials into a JSON representation.
  110999. * @returns the JSON representation
  111000. */
  111001. serialize(): any;
  111002. /**
  111003. * Dispose the material and release its associated resources
  111004. * @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)
  111005. * @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)
  111006. * @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)
  111007. */
  111008. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  111009. /**
  111010. * Creates a MultiMaterial from parsed MultiMaterial data.
  111011. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  111012. * @param scene defines the hosting scene
  111013. * @returns a new MultiMaterial
  111014. */
  111015. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  111016. }
  111017. }
  111018. declare module BABYLON {
  111019. /**
  111020. * Defines a subdivision inside a mesh
  111021. */
  111022. export class SubMesh implements ICullable {
  111023. /** the material index to use */
  111024. materialIndex: number;
  111025. /** vertex index start */
  111026. verticesStart: number;
  111027. /** vertices count */
  111028. verticesCount: number;
  111029. /** index start */
  111030. indexStart: number;
  111031. /** indices count */
  111032. indexCount: number;
  111033. /** @hidden */
  111034. _materialDefines: Nullable<MaterialDefines>;
  111035. /** @hidden */
  111036. _materialEffect: Nullable<Effect>;
  111037. /** @hidden */
  111038. _effectOverride: Nullable<Effect>;
  111039. /**
  111040. * Gets material defines used by the effect associated to the sub mesh
  111041. */
  111042. get materialDefines(): Nullable<MaterialDefines>;
  111043. /**
  111044. * Sets material defines used by the effect associated to the sub mesh
  111045. */
  111046. set materialDefines(defines: Nullable<MaterialDefines>);
  111047. /**
  111048. * Gets associated effect
  111049. */
  111050. get effect(): Nullable<Effect>;
  111051. /**
  111052. * Sets associated effect (effect used to render this submesh)
  111053. * @param effect defines the effect to associate with
  111054. * @param defines defines the set of defines used to compile this effect
  111055. */
  111056. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  111057. /** @hidden */
  111058. _linesIndexCount: number;
  111059. private _mesh;
  111060. private _renderingMesh;
  111061. private _boundingInfo;
  111062. private _linesIndexBuffer;
  111063. /** @hidden */
  111064. _lastColliderWorldVertices: Nullable<Vector3[]>;
  111065. /** @hidden */
  111066. _trianglePlanes: Plane[];
  111067. /** @hidden */
  111068. _lastColliderTransformMatrix: Nullable<Matrix>;
  111069. /** @hidden */
  111070. _renderId: number;
  111071. /** @hidden */
  111072. _alphaIndex: number;
  111073. /** @hidden */
  111074. _distanceToCamera: number;
  111075. /** @hidden */
  111076. _id: number;
  111077. private _currentMaterial;
  111078. /**
  111079. * Add a new submesh to a mesh
  111080. * @param materialIndex defines the material index to use
  111081. * @param verticesStart defines vertex index start
  111082. * @param verticesCount defines vertices count
  111083. * @param indexStart defines index start
  111084. * @param indexCount defines indices count
  111085. * @param mesh defines the parent mesh
  111086. * @param renderingMesh defines an optional rendering mesh
  111087. * @param createBoundingBox defines if bounding box should be created for this submesh
  111088. * @returns the new submesh
  111089. */
  111090. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  111091. /**
  111092. * Creates a new submesh
  111093. * @param materialIndex defines the material index to use
  111094. * @param verticesStart defines vertex index start
  111095. * @param verticesCount defines vertices count
  111096. * @param indexStart defines index start
  111097. * @param indexCount defines indices count
  111098. * @param mesh defines the parent mesh
  111099. * @param renderingMesh defines an optional rendering mesh
  111100. * @param createBoundingBox defines if bounding box should be created for this submesh
  111101. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  111102. */
  111103. constructor(
  111104. /** the material index to use */
  111105. materialIndex: number,
  111106. /** vertex index start */
  111107. verticesStart: number,
  111108. /** vertices count */
  111109. verticesCount: number,
  111110. /** index start */
  111111. indexStart: number,
  111112. /** indices count */
  111113. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  111114. /**
  111115. * Returns true if this submesh covers the entire parent mesh
  111116. * @ignorenaming
  111117. */
  111118. get IsGlobal(): boolean;
  111119. /**
  111120. * Returns the submesh BoudingInfo object
  111121. * @returns current bounding info (or mesh's one if the submesh is global)
  111122. */
  111123. getBoundingInfo(): BoundingInfo;
  111124. /**
  111125. * Sets the submesh BoundingInfo
  111126. * @param boundingInfo defines the new bounding info to use
  111127. * @returns the SubMesh
  111128. */
  111129. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  111130. /**
  111131. * Returns the mesh of the current submesh
  111132. * @return the parent mesh
  111133. */
  111134. getMesh(): AbstractMesh;
  111135. /**
  111136. * Returns the rendering mesh of the submesh
  111137. * @returns the rendering mesh (could be different from parent mesh)
  111138. */
  111139. getRenderingMesh(): Mesh;
  111140. /**
  111141. * Returns the replacement mesh of the submesh
  111142. * @returns the replacement mesh (could be different from parent mesh)
  111143. */
  111144. getReplacementMesh(): Nullable<AbstractMesh>;
  111145. /**
  111146. * Returns the effective mesh of the submesh
  111147. * @returns the effective mesh (could be different from parent mesh)
  111148. */
  111149. getEffectiveMesh(): AbstractMesh;
  111150. /**
  111151. * Returns the submesh material
  111152. * @returns null or the current material
  111153. */
  111154. getMaterial(): Nullable<Material>;
  111155. private _IsMultiMaterial;
  111156. /**
  111157. * Sets a new updated BoundingInfo object to the submesh
  111158. * @param data defines an optional position array to use to determine the bounding info
  111159. * @returns the SubMesh
  111160. */
  111161. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  111162. /** @hidden */
  111163. _checkCollision(collider: Collider): boolean;
  111164. /**
  111165. * Updates the submesh BoundingInfo
  111166. * @param world defines the world matrix to use to update the bounding info
  111167. * @returns the submesh
  111168. */
  111169. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  111170. /**
  111171. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  111172. * @param frustumPlanes defines the frustum planes
  111173. * @returns true if the submesh is intersecting with the frustum
  111174. */
  111175. isInFrustum(frustumPlanes: Plane[]): boolean;
  111176. /**
  111177. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  111178. * @param frustumPlanes defines the frustum planes
  111179. * @returns true if the submesh is inside the frustum
  111180. */
  111181. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111182. /**
  111183. * Renders the submesh
  111184. * @param enableAlphaMode defines if alpha needs to be used
  111185. * @returns the submesh
  111186. */
  111187. render(enableAlphaMode: boolean): SubMesh;
  111188. /**
  111189. * @hidden
  111190. */
  111191. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  111192. /**
  111193. * Checks if the submesh intersects with a ray
  111194. * @param ray defines the ray to test
  111195. * @returns true is the passed ray intersects the submesh bounding box
  111196. */
  111197. canIntersects(ray: Ray): boolean;
  111198. /**
  111199. * Intersects current submesh with a ray
  111200. * @param ray defines the ray to test
  111201. * @param positions defines mesh's positions array
  111202. * @param indices defines mesh's indices array
  111203. * @param fastCheck defines if the first intersection will be used (and not the closest)
  111204. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111205. * @returns intersection info or null if no intersection
  111206. */
  111207. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  111208. /** @hidden */
  111209. private _intersectLines;
  111210. /** @hidden */
  111211. private _intersectUnIndexedLines;
  111212. /** @hidden */
  111213. private _intersectTriangles;
  111214. /** @hidden */
  111215. private _intersectUnIndexedTriangles;
  111216. /** @hidden */
  111217. _rebuild(): void;
  111218. /**
  111219. * Creates a new submesh from the passed mesh
  111220. * @param newMesh defines the new hosting mesh
  111221. * @param newRenderingMesh defines an optional rendering mesh
  111222. * @returns the new submesh
  111223. */
  111224. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  111225. /**
  111226. * Release associated resources
  111227. */
  111228. dispose(): void;
  111229. /**
  111230. * Gets the class name
  111231. * @returns the string "SubMesh".
  111232. */
  111233. getClassName(): string;
  111234. /**
  111235. * Creates a new submesh from indices data
  111236. * @param materialIndex the index of the main mesh material
  111237. * @param startIndex the index where to start the copy in the mesh indices array
  111238. * @param indexCount the number of indices to copy then from the startIndex
  111239. * @param mesh the main mesh to create the submesh from
  111240. * @param renderingMesh the optional rendering mesh
  111241. * @returns a new submesh
  111242. */
  111243. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  111244. }
  111245. }
  111246. declare module BABYLON {
  111247. /**
  111248. * Class used to represent data loading progression
  111249. */
  111250. export class SceneLoaderFlags {
  111251. private static _ForceFullSceneLoadingForIncremental;
  111252. private static _ShowLoadingScreen;
  111253. private static _CleanBoneMatrixWeights;
  111254. private static _loggingLevel;
  111255. /**
  111256. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111257. */
  111258. static get ForceFullSceneLoadingForIncremental(): boolean;
  111259. static set ForceFullSceneLoadingForIncremental(value: boolean);
  111260. /**
  111261. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111262. */
  111263. static get ShowLoadingScreen(): boolean;
  111264. static set ShowLoadingScreen(value: boolean);
  111265. /**
  111266. * Defines the current logging level (while loading the scene)
  111267. * @ignorenaming
  111268. */
  111269. static get loggingLevel(): number;
  111270. static set loggingLevel(value: number);
  111271. /**
  111272. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111273. */
  111274. static get CleanBoneMatrixWeights(): boolean;
  111275. static set CleanBoneMatrixWeights(value: boolean);
  111276. }
  111277. }
  111278. declare module BABYLON {
  111279. /**
  111280. * Class used to store geometry data (vertex buffers + index buffer)
  111281. */
  111282. export class Geometry implements IGetSetVerticesData {
  111283. /**
  111284. * Gets or sets the ID of the geometry
  111285. */
  111286. id: string;
  111287. /**
  111288. * Gets or sets the unique ID of the geometry
  111289. */
  111290. uniqueId: number;
  111291. /**
  111292. * Gets the delay loading state of the geometry (none by default which means not delayed)
  111293. */
  111294. delayLoadState: number;
  111295. /**
  111296. * Gets the file containing the data to load when running in delay load state
  111297. */
  111298. delayLoadingFile: Nullable<string>;
  111299. /**
  111300. * Callback called when the geometry is updated
  111301. */
  111302. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  111303. private _scene;
  111304. private _engine;
  111305. private _meshes;
  111306. private _totalVertices;
  111307. /** @hidden */
  111308. _indices: IndicesArray;
  111309. /** @hidden */
  111310. _vertexBuffers: {
  111311. [key: string]: VertexBuffer;
  111312. };
  111313. private _isDisposed;
  111314. private _extend;
  111315. private _boundingBias;
  111316. /** @hidden */
  111317. _delayInfo: Array<string>;
  111318. private _indexBuffer;
  111319. private _indexBufferIsUpdatable;
  111320. /** @hidden */
  111321. _boundingInfo: Nullable<BoundingInfo>;
  111322. /** @hidden */
  111323. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  111324. /** @hidden */
  111325. _softwareSkinningFrameId: number;
  111326. private _vertexArrayObjects;
  111327. private _updatable;
  111328. /** @hidden */
  111329. _positions: Nullable<Vector3[]>;
  111330. private _positionsCache;
  111331. /**
  111332. * 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
  111333. */
  111334. get boundingBias(): Vector2;
  111335. /**
  111336. * 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
  111337. */
  111338. set boundingBias(value: Vector2);
  111339. /**
  111340. * Static function used to attach a new empty geometry to a mesh
  111341. * @param mesh defines the mesh to attach the geometry to
  111342. * @returns the new Geometry
  111343. */
  111344. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  111345. /** Get the list of meshes using this geometry */
  111346. get meshes(): Mesh[];
  111347. /**
  111348. * 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
  111349. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  111350. */
  111351. useBoundingInfoFromGeometry: boolean;
  111352. /**
  111353. * Creates a new geometry
  111354. * @param id defines the unique ID
  111355. * @param scene defines the hosting scene
  111356. * @param vertexData defines the VertexData used to get geometry data
  111357. * @param updatable defines if geometry must be updatable (false by default)
  111358. * @param mesh defines the mesh that will be associated with the geometry
  111359. */
  111360. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  111361. /**
  111362. * Gets the current extend of the geometry
  111363. */
  111364. get extend(): {
  111365. minimum: Vector3;
  111366. maximum: Vector3;
  111367. };
  111368. /**
  111369. * Gets the hosting scene
  111370. * @returns the hosting Scene
  111371. */
  111372. getScene(): Scene;
  111373. /**
  111374. * Gets the hosting engine
  111375. * @returns the hosting Engine
  111376. */
  111377. getEngine(): Engine;
  111378. /**
  111379. * Defines if the geometry is ready to use
  111380. * @returns true if the geometry is ready to be used
  111381. */
  111382. isReady(): boolean;
  111383. /**
  111384. * Gets a value indicating that the geometry should not be serialized
  111385. */
  111386. get doNotSerialize(): boolean;
  111387. /** @hidden */
  111388. _rebuild(): void;
  111389. /**
  111390. * Affects all geometry data in one call
  111391. * @param vertexData defines the geometry data
  111392. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  111393. */
  111394. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  111395. /**
  111396. * Set specific vertex data
  111397. * @param kind defines the data kind (Position, normal, etc...)
  111398. * @param data defines the vertex data to use
  111399. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  111400. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  111401. */
  111402. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  111403. /**
  111404. * Removes a specific vertex data
  111405. * @param kind defines the data kind (Position, normal, etc...)
  111406. */
  111407. removeVerticesData(kind: string): void;
  111408. /**
  111409. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  111410. * @param buffer defines the vertex buffer to use
  111411. * @param totalVertices defines the total number of vertices for position kind (could be null)
  111412. */
  111413. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  111414. /**
  111415. * Update a specific vertex buffer
  111416. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  111417. * It will do nothing if the buffer is not updatable
  111418. * @param kind defines the data kind (Position, normal, etc...)
  111419. * @param data defines the data to use
  111420. * @param offset defines the offset in the target buffer where to store the data
  111421. * @param useBytes set to true if the offset is in bytes
  111422. */
  111423. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  111424. /**
  111425. * Update a specific vertex buffer
  111426. * This function will create a new buffer if the current one is not updatable
  111427. * @param kind defines the data kind (Position, normal, etc...)
  111428. * @param data defines the data to use
  111429. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  111430. */
  111431. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  111432. private _updateBoundingInfo;
  111433. /** @hidden */
  111434. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  111435. /**
  111436. * Gets total number of vertices
  111437. * @returns the total number of vertices
  111438. */
  111439. getTotalVertices(): number;
  111440. /**
  111441. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  111442. * @param kind defines the data kind (Position, normal, etc...)
  111443. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111444. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111445. * @returns a float array containing vertex data
  111446. */
  111447. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  111448. /**
  111449. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  111450. * @param kind defines the data kind (Position, normal, etc...)
  111451. * @returns true if the vertex buffer with the specified kind is updatable
  111452. */
  111453. isVertexBufferUpdatable(kind: string): boolean;
  111454. /**
  111455. * Gets a specific vertex buffer
  111456. * @param kind defines the data kind (Position, normal, etc...)
  111457. * @returns a VertexBuffer
  111458. */
  111459. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  111460. /**
  111461. * Returns all vertex buffers
  111462. * @return an object holding all vertex buffers indexed by kind
  111463. */
  111464. getVertexBuffers(): Nullable<{
  111465. [key: string]: VertexBuffer;
  111466. }>;
  111467. /**
  111468. * Gets a boolean indicating if specific vertex buffer is present
  111469. * @param kind defines the data kind (Position, normal, etc...)
  111470. * @returns true if data is present
  111471. */
  111472. isVerticesDataPresent(kind: string): boolean;
  111473. /**
  111474. * Gets a list of all attached data kinds (Position, normal, etc...)
  111475. * @returns a list of string containing all kinds
  111476. */
  111477. getVerticesDataKinds(): string[];
  111478. /**
  111479. * Update index buffer
  111480. * @param indices defines the indices to store in the index buffer
  111481. * @param offset defines the offset in the target buffer where to store the data
  111482. * @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)
  111483. */
  111484. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  111485. /**
  111486. * Creates a new index buffer
  111487. * @param indices defines the indices to store in the index buffer
  111488. * @param totalVertices defines the total number of vertices (could be null)
  111489. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  111490. */
  111491. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  111492. /**
  111493. * Return the total number of indices
  111494. * @returns the total number of indices
  111495. */
  111496. getTotalIndices(): number;
  111497. /**
  111498. * Gets the index buffer array
  111499. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111500. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111501. * @returns the index buffer array
  111502. */
  111503. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  111504. /**
  111505. * Gets the index buffer
  111506. * @return the index buffer
  111507. */
  111508. getIndexBuffer(): Nullable<DataBuffer>;
  111509. /** @hidden */
  111510. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  111511. /**
  111512. * Release the associated resources for a specific mesh
  111513. * @param mesh defines the source mesh
  111514. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  111515. */
  111516. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  111517. /**
  111518. * Apply current geometry to a given mesh
  111519. * @param mesh defines the mesh to apply geometry to
  111520. */
  111521. applyToMesh(mesh: Mesh): void;
  111522. private _updateExtend;
  111523. private _applyToMesh;
  111524. private notifyUpdate;
  111525. /**
  111526. * Load the geometry if it was flagged as delay loaded
  111527. * @param scene defines the hosting scene
  111528. * @param onLoaded defines a callback called when the geometry is loaded
  111529. */
  111530. load(scene: Scene, onLoaded?: () => void): void;
  111531. private _queueLoad;
  111532. /**
  111533. * Invert the geometry to move from a right handed system to a left handed one.
  111534. */
  111535. toLeftHanded(): void;
  111536. /** @hidden */
  111537. _resetPointsArrayCache(): void;
  111538. /** @hidden */
  111539. _generatePointsArray(): boolean;
  111540. /**
  111541. * Gets a value indicating if the geometry is disposed
  111542. * @returns true if the geometry was disposed
  111543. */
  111544. isDisposed(): boolean;
  111545. private _disposeVertexArrayObjects;
  111546. /**
  111547. * Free all associated resources
  111548. */
  111549. dispose(): void;
  111550. /**
  111551. * Clone the current geometry into a new geometry
  111552. * @param id defines the unique ID of the new geometry
  111553. * @returns a new geometry object
  111554. */
  111555. copy(id: string): Geometry;
  111556. /**
  111557. * Serialize the current geometry info (and not the vertices data) into a JSON object
  111558. * @return a JSON representation of the current geometry data (without the vertices data)
  111559. */
  111560. serialize(): any;
  111561. private toNumberArray;
  111562. /**
  111563. * Serialize all vertices data into a JSON oject
  111564. * @returns a JSON representation of the current geometry data
  111565. */
  111566. serializeVerticeData(): any;
  111567. /**
  111568. * Extracts a clone of a mesh geometry
  111569. * @param mesh defines the source mesh
  111570. * @param id defines the unique ID of the new geometry object
  111571. * @returns the new geometry object
  111572. */
  111573. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  111574. /**
  111575. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  111576. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  111577. * Be aware Math.random() could cause collisions, but:
  111578. * "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"
  111579. * @returns a string containing a new GUID
  111580. */
  111581. static RandomId(): string;
  111582. /** @hidden */
  111583. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  111584. private static _CleanMatricesWeights;
  111585. /**
  111586. * Create a new geometry from persisted data (Using .babylon file format)
  111587. * @param parsedVertexData defines the persisted data
  111588. * @param scene defines the hosting scene
  111589. * @param rootUrl defines the root url to use to load assets (like delayed data)
  111590. * @returns the new geometry object
  111591. */
  111592. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  111593. }
  111594. }
  111595. declare module BABYLON {
  111596. /**
  111597. * Define an interface for all classes that will get and set the data on vertices
  111598. */
  111599. export interface IGetSetVerticesData {
  111600. /**
  111601. * Gets a boolean indicating if specific vertex data is present
  111602. * @param kind defines the vertex data kind to use
  111603. * @returns true is data kind is present
  111604. */
  111605. isVerticesDataPresent(kind: string): boolean;
  111606. /**
  111607. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  111608. * @param kind defines the data kind (Position, normal, etc...)
  111609. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111610. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111611. * @returns a float array containing vertex data
  111612. */
  111613. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  111614. /**
  111615. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  111616. * @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.
  111617. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111618. * @returns the indices array or an empty array if the mesh has no geometry
  111619. */
  111620. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  111621. /**
  111622. * Set specific vertex data
  111623. * @param kind defines the data kind (Position, normal, etc...)
  111624. * @param data defines the vertex data to use
  111625. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  111626. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  111627. */
  111628. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  111629. /**
  111630. * Update a specific associated vertex buffer
  111631. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  111632. * - VertexBuffer.PositionKind
  111633. * - VertexBuffer.UVKind
  111634. * - VertexBuffer.UV2Kind
  111635. * - VertexBuffer.UV3Kind
  111636. * - VertexBuffer.UV4Kind
  111637. * - VertexBuffer.UV5Kind
  111638. * - VertexBuffer.UV6Kind
  111639. * - VertexBuffer.ColorKind
  111640. * - VertexBuffer.MatricesIndicesKind
  111641. * - VertexBuffer.MatricesIndicesExtraKind
  111642. * - VertexBuffer.MatricesWeightsKind
  111643. * - VertexBuffer.MatricesWeightsExtraKind
  111644. * @param data defines the data source
  111645. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  111646. * @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)
  111647. */
  111648. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  111649. /**
  111650. * Creates a new index buffer
  111651. * @param indices defines the indices to store in the index buffer
  111652. * @param totalVertices defines the total number of vertices (could be null)
  111653. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  111654. */
  111655. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  111656. }
  111657. /**
  111658. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  111659. */
  111660. export class VertexData {
  111661. /**
  111662. * Mesh side orientation : usually the external or front surface
  111663. */
  111664. static readonly FRONTSIDE: number;
  111665. /**
  111666. * Mesh side orientation : usually the internal or back surface
  111667. */
  111668. static readonly BACKSIDE: number;
  111669. /**
  111670. * Mesh side orientation : both internal and external or front and back surfaces
  111671. */
  111672. static readonly DOUBLESIDE: number;
  111673. /**
  111674. * Mesh side orientation : by default, `FRONTSIDE`
  111675. */
  111676. static readonly DEFAULTSIDE: number;
  111677. /**
  111678. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  111679. */
  111680. positions: Nullable<FloatArray>;
  111681. /**
  111682. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  111683. */
  111684. normals: Nullable<FloatArray>;
  111685. /**
  111686. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  111687. */
  111688. tangents: Nullable<FloatArray>;
  111689. /**
  111690. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111691. */
  111692. uvs: Nullable<FloatArray>;
  111693. /**
  111694. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111695. */
  111696. uvs2: Nullable<FloatArray>;
  111697. /**
  111698. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111699. */
  111700. uvs3: Nullable<FloatArray>;
  111701. /**
  111702. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111703. */
  111704. uvs4: Nullable<FloatArray>;
  111705. /**
  111706. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111707. */
  111708. uvs5: Nullable<FloatArray>;
  111709. /**
  111710. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111711. */
  111712. uvs6: Nullable<FloatArray>;
  111713. /**
  111714. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  111715. */
  111716. colors: Nullable<FloatArray>;
  111717. /**
  111718. * 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).
  111719. */
  111720. matricesIndices: Nullable<FloatArray>;
  111721. /**
  111722. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  111723. */
  111724. matricesWeights: Nullable<FloatArray>;
  111725. /**
  111726. * An array extending the number of possible indices
  111727. */
  111728. matricesIndicesExtra: Nullable<FloatArray>;
  111729. /**
  111730. * An array extending the number of possible weights when the number of indices is extended
  111731. */
  111732. matricesWeightsExtra: Nullable<FloatArray>;
  111733. /**
  111734. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  111735. */
  111736. indices: Nullable<IndicesArray>;
  111737. /**
  111738. * Uses the passed data array to set the set the values for the specified kind of data
  111739. * @param data a linear array of floating numbers
  111740. * @param kind the type of data that is being set, eg positions, colors etc
  111741. */
  111742. set(data: FloatArray, kind: string): void;
  111743. /**
  111744. * Associates the vertexData to the passed Mesh.
  111745. * Sets it as updatable or not (default `false`)
  111746. * @param mesh the mesh the vertexData is applied to
  111747. * @param updatable when used and having the value true allows new data to update the vertexData
  111748. * @returns the VertexData
  111749. */
  111750. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  111751. /**
  111752. * Associates the vertexData to the passed Geometry.
  111753. * Sets it as updatable or not (default `false`)
  111754. * @param geometry the geometry the vertexData is applied to
  111755. * @param updatable when used and having the value true allows new data to update the vertexData
  111756. * @returns VertexData
  111757. */
  111758. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  111759. /**
  111760. * Updates the associated mesh
  111761. * @param mesh the mesh to be updated
  111762. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111763. * @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
  111764. * @returns VertexData
  111765. */
  111766. updateMesh(mesh: Mesh): VertexData;
  111767. /**
  111768. * Updates the associated geometry
  111769. * @param geometry the geometry to be updated
  111770. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111771. * @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
  111772. * @returns VertexData.
  111773. */
  111774. updateGeometry(geometry: Geometry): VertexData;
  111775. private _applyTo;
  111776. private _update;
  111777. /**
  111778. * Transforms each position and each normal of the vertexData according to the passed Matrix
  111779. * @param matrix the transforming matrix
  111780. * @returns the VertexData
  111781. */
  111782. transform(matrix: Matrix): VertexData;
  111783. /**
  111784. * Merges the passed VertexData into the current one
  111785. * @param other the VertexData to be merged into the current one
  111786. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  111787. * @returns the modified VertexData
  111788. */
  111789. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  111790. private _mergeElement;
  111791. private _validate;
  111792. /**
  111793. * Serializes the VertexData
  111794. * @returns a serialized object
  111795. */
  111796. serialize(): any;
  111797. /**
  111798. * Extracts the vertexData from a mesh
  111799. * @param mesh the mesh from which to extract the VertexData
  111800. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  111801. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111802. * @returns the object VertexData associated to the passed mesh
  111803. */
  111804. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111805. /**
  111806. * Extracts the vertexData from the geometry
  111807. * @param geometry the geometry from which to extract the VertexData
  111808. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  111809. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111810. * @returns the object VertexData associated to the passed mesh
  111811. */
  111812. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111813. private static _ExtractFrom;
  111814. /**
  111815. * Creates the VertexData for a Ribbon
  111816. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  111817. * * pathArray array of paths, each of which an array of successive Vector3
  111818. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  111819. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  111820. * * 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
  111821. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111822. * * 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)
  111823. * * 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)
  111824. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  111825. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  111826. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  111827. * @returns the VertexData of the ribbon
  111828. */
  111829. static CreateRibbon(options: {
  111830. pathArray: Vector3[][];
  111831. closeArray?: boolean;
  111832. closePath?: boolean;
  111833. offset?: number;
  111834. sideOrientation?: number;
  111835. frontUVs?: Vector4;
  111836. backUVs?: Vector4;
  111837. invertUV?: boolean;
  111838. uvs?: Vector2[];
  111839. colors?: Color4[];
  111840. }): VertexData;
  111841. /**
  111842. * Creates the VertexData for a box
  111843. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111844. * * size sets the width, height and depth of the box to the value of size, optional default 1
  111845. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  111846. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  111847. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  111848. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111849. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111850. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111851. * * 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)
  111852. * * 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)
  111853. * @returns the VertexData of the box
  111854. */
  111855. static CreateBox(options: {
  111856. size?: number;
  111857. width?: number;
  111858. height?: number;
  111859. depth?: number;
  111860. faceUV?: Vector4[];
  111861. faceColors?: Color4[];
  111862. sideOrientation?: number;
  111863. frontUVs?: Vector4;
  111864. backUVs?: Vector4;
  111865. }): VertexData;
  111866. /**
  111867. * Creates the VertexData for a tiled box
  111868. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111869. * * faceTiles sets the pattern, tile size and number of tiles for a face
  111870. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111871. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111872. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111873. * @returns the VertexData of the box
  111874. */
  111875. static CreateTiledBox(options: {
  111876. pattern?: number;
  111877. width?: number;
  111878. height?: number;
  111879. depth?: number;
  111880. tileSize?: number;
  111881. tileWidth?: number;
  111882. tileHeight?: number;
  111883. alignHorizontal?: number;
  111884. alignVertical?: number;
  111885. faceUV?: Vector4[];
  111886. faceColors?: Color4[];
  111887. sideOrientation?: number;
  111888. }): VertexData;
  111889. /**
  111890. * Creates the VertexData for a tiled plane
  111891. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111892. * * pattern a limited pattern arrangement depending on the number
  111893. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  111894. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  111895. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  111896. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111897. * * 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)
  111898. * * 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)
  111899. * @returns the VertexData of the tiled plane
  111900. */
  111901. static CreateTiledPlane(options: {
  111902. pattern?: number;
  111903. tileSize?: number;
  111904. tileWidth?: number;
  111905. tileHeight?: number;
  111906. size?: number;
  111907. width?: number;
  111908. height?: number;
  111909. alignHorizontal?: number;
  111910. alignVertical?: number;
  111911. sideOrientation?: number;
  111912. frontUVs?: Vector4;
  111913. backUVs?: Vector4;
  111914. }): VertexData;
  111915. /**
  111916. * Creates the VertexData for an ellipsoid, defaults to a sphere
  111917. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111918. * * segments sets the number of horizontal strips optional, default 32
  111919. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  111920. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  111921. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  111922. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  111923. * * 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
  111924. * * 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
  111925. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111926. * * 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)
  111927. * * 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)
  111928. * @returns the VertexData of the ellipsoid
  111929. */
  111930. static CreateSphere(options: {
  111931. segments?: number;
  111932. diameter?: number;
  111933. diameterX?: number;
  111934. diameterY?: number;
  111935. diameterZ?: number;
  111936. arc?: number;
  111937. slice?: number;
  111938. sideOrientation?: number;
  111939. frontUVs?: Vector4;
  111940. backUVs?: Vector4;
  111941. }): VertexData;
  111942. /**
  111943. * Creates the VertexData for a cylinder, cone or prism
  111944. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111945. * * height sets the height (y direction) of the cylinder, optional, default 2
  111946. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  111947. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  111948. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  111949. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111950. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  111951. * * 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
  111952. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111953. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111954. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  111955. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  111956. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111957. * * 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)
  111958. * * 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)
  111959. * @returns the VertexData of the cylinder, cone or prism
  111960. */
  111961. static CreateCylinder(options: {
  111962. height?: number;
  111963. diameterTop?: number;
  111964. diameterBottom?: number;
  111965. diameter?: number;
  111966. tessellation?: number;
  111967. subdivisions?: number;
  111968. arc?: number;
  111969. faceColors?: Color4[];
  111970. faceUV?: Vector4[];
  111971. hasRings?: boolean;
  111972. enclose?: boolean;
  111973. sideOrientation?: number;
  111974. frontUVs?: Vector4;
  111975. backUVs?: Vector4;
  111976. }): VertexData;
  111977. /**
  111978. * Creates the VertexData for a torus
  111979. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111980. * * diameter the diameter of the torus, optional default 1
  111981. * * thickness the diameter of the tube forming the torus, optional default 0.5
  111982. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111983. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111984. * * 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)
  111985. * * 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)
  111986. * @returns the VertexData of the torus
  111987. */
  111988. static CreateTorus(options: {
  111989. diameter?: number;
  111990. thickness?: number;
  111991. tessellation?: number;
  111992. sideOrientation?: number;
  111993. frontUVs?: Vector4;
  111994. backUVs?: Vector4;
  111995. }): VertexData;
  111996. /**
  111997. * Creates the VertexData of the LineSystem
  111998. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  111999. * - lines an array of lines, each line being an array of successive Vector3
  112000. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  112001. * @returns the VertexData of the LineSystem
  112002. */
  112003. static CreateLineSystem(options: {
  112004. lines: Vector3[][];
  112005. colors?: Nullable<Color4[][]>;
  112006. }): VertexData;
  112007. /**
  112008. * Create the VertexData for a DashedLines
  112009. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  112010. * - points an array successive Vector3
  112011. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  112012. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  112013. * - dashNb the intended total number of dashes, optional, default 200
  112014. * @returns the VertexData for the DashedLines
  112015. */
  112016. static CreateDashedLines(options: {
  112017. points: Vector3[];
  112018. dashSize?: number;
  112019. gapSize?: number;
  112020. dashNb?: number;
  112021. }): VertexData;
  112022. /**
  112023. * Creates the VertexData for a Ground
  112024. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  112025. * - width the width (x direction) of the ground, optional, default 1
  112026. * - height the height (z direction) of the ground, optional, default 1
  112027. * - subdivisions the number of subdivisions per side, optional, default 1
  112028. * @returns the VertexData of the Ground
  112029. */
  112030. static CreateGround(options: {
  112031. width?: number;
  112032. height?: number;
  112033. subdivisions?: number;
  112034. subdivisionsX?: number;
  112035. subdivisionsY?: number;
  112036. }): VertexData;
  112037. /**
  112038. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  112039. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  112040. * * xmin the ground minimum X coordinate, optional, default -1
  112041. * * zmin the ground minimum Z coordinate, optional, default -1
  112042. * * xmax the ground maximum X coordinate, optional, default 1
  112043. * * zmax the ground maximum Z coordinate, optional, default 1
  112044. * * 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}
  112045. * * 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}
  112046. * @returns the VertexData of the TiledGround
  112047. */
  112048. static CreateTiledGround(options: {
  112049. xmin: number;
  112050. zmin: number;
  112051. xmax: number;
  112052. zmax: number;
  112053. subdivisions?: {
  112054. w: number;
  112055. h: number;
  112056. };
  112057. precision?: {
  112058. w: number;
  112059. h: number;
  112060. };
  112061. }): VertexData;
  112062. /**
  112063. * Creates the VertexData of the Ground designed from a heightmap
  112064. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  112065. * * width the width (x direction) of the ground
  112066. * * height the height (z direction) of the ground
  112067. * * subdivisions the number of subdivisions per side
  112068. * * minHeight the minimum altitude on the ground, optional, default 0
  112069. * * maxHeight the maximum altitude on the ground, optional default 1
  112070. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  112071. * * buffer the array holding the image color data
  112072. * * bufferWidth the width of image
  112073. * * bufferHeight the height of image
  112074. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  112075. * @returns the VertexData of the Ground designed from a heightmap
  112076. */
  112077. static CreateGroundFromHeightMap(options: {
  112078. width: number;
  112079. height: number;
  112080. subdivisions: number;
  112081. minHeight: number;
  112082. maxHeight: number;
  112083. colorFilter: Color3;
  112084. buffer: Uint8Array;
  112085. bufferWidth: number;
  112086. bufferHeight: number;
  112087. alphaFilter: number;
  112088. }): VertexData;
  112089. /**
  112090. * Creates the VertexData for a Plane
  112091. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  112092. * * size sets the width and height of the plane to the value of size, optional default 1
  112093. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  112094. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  112095. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112096. * * 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)
  112097. * * 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)
  112098. * @returns the VertexData of the box
  112099. */
  112100. static CreatePlane(options: {
  112101. size?: number;
  112102. width?: number;
  112103. height?: number;
  112104. sideOrientation?: number;
  112105. frontUVs?: Vector4;
  112106. backUVs?: Vector4;
  112107. }): VertexData;
  112108. /**
  112109. * Creates the VertexData of the Disc or regular Polygon
  112110. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  112111. * * radius the radius of the disc, optional default 0.5
  112112. * * tessellation the number of polygon sides, optional, default 64
  112113. * * 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
  112114. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112115. * * 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)
  112116. * * 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)
  112117. * @returns the VertexData of the box
  112118. */
  112119. static CreateDisc(options: {
  112120. radius?: number;
  112121. tessellation?: number;
  112122. arc?: number;
  112123. sideOrientation?: number;
  112124. frontUVs?: Vector4;
  112125. backUVs?: Vector4;
  112126. }): VertexData;
  112127. /**
  112128. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  112129. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  112130. * @param polygon a mesh built from polygonTriangulation.build()
  112131. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112132. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  112133. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  112134. * @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)
  112135. * @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)
  112136. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  112137. * @returns the VertexData of the Polygon
  112138. */
  112139. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  112140. /**
  112141. * Creates the VertexData of the IcoSphere
  112142. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  112143. * * radius the radius of the IcoSphere, optional default 1
  112144. * * radiusX allows stretching in the x direction, optional, default radius
  112145. * * radiusY allows stretching in the y direction, optional, default radius
  112146. * * radiusZ allows stretching in the z direction, optional, default radius
  112147. * * flat when true creates a flat shaded mesh, optional, default true
  112148. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  112149. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112150. * * 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)
  112151. * * 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)
  112152. * @returns the VertexData of the IcoSphere
  112153. */
  112154. static CreateIcoSphere(options: {
  112155. radius?: number;
  112156. radiusX?: number;
  112157. radiusY?: number;
  112158. radiusZ?: number;
  112159. flat?: boolean;
  112160. subdivisions?: number;
  112161. sideOrientation?: number;
  112162. frontUVs?: Vector4;
  112163. backUVs?: Vector4;
  112164. }): VertexData;
  112165. /**
  112166. * Creates the VertexData for a Polyhedron
  112167. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  112168. * * type provided types are:
  112169. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  112170. * * 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)
  112171. * * size the size of the IcoSphere, optional default 1
  112172. * * sizeX allows stretching in the x direction, optional, default size
  112173. * * sizeY allows stretching in the y direction, optional, default size
  112174. * * sizeZ allows stretching in the z direction, optional, default size
  112175. * * 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
  112176. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  112177. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  112178. * * flat when true creates a flat shaded mesh, optional, default true
  112179. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  112180. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112181. * * 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)
  112182. * * 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)
  112183. * @returns the VertexData of the Polyhedron
  112184. */
  112185. static CreatePolyhedron(options: {
  112186. type?: number;
  112187. size?: number;
  112188. sizeX?: number;
  112189. sizeY?: number;
  112190. sizeZ?: number;
  112191. custom?: any;
  112192. faceUV?: Vector4[];
  112193. faceColors?: Color4[];
  112194. flat?: boolean;
  112195. sideOrientation?: number;
  112196. frontUVs?: Vector4;
  112197. backUVs?: Vector4;
  112198. }): VertexData;
  112199. /**
  112200. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  112201. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  112202. * @returns the VertexData of the Capsule
  112203. */
  112204. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  112205. /**
  112206. * Creates the VertexData for a TorusKnot
  112207. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  112208. * * radius the radius of the torus knot, optional, default 2
  112209. * * tube the thickness of the tube, optional, default 0.5
  112210. * * radialSegments the number of sides on each tube segments, optional, default 32
  112211. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  112212. * * p the number of windings around the z axis, optional, default 2
  112213. * * q the number of windings around the x axis, optional, default 3
  112214. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112215. * * 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)
  112216. * * 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)
  112217. * @returns the VertexData of the Torus Knot
  112218. */
  112219. static CreateTorusKnot(options: {
  112220. radius?: number;
  112221. tube?: number;
  112222. radialSegments?: number;
  112223. tubularSegments?: number;
  112224. p?: number;
  112225. q?: number;
  112226. sideOrientation?: number;
  112227. frontUVs?: Vector4;
  112228. backUVs?: Vector4;
  112229. }): VertexData;
  112230. /**
  112231. * Compute normals for given positions and indices
  112232. * @param positions an array of vertex positions, [...., x, y, z, ......]
  112233. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  112234. * @param normals an array of vertex normals, [...., x, y, z, ......]
  112235. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  112236. * * facetNormals : optional array of facet normals (vector3)
  112237. * * facetPositions : optional array of facet positions (vector3)
  112238. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  112239. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  112240. * * bInfo : optional bounding info, required for facetPartitioning computation
  112241. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  112242. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  112243. * * useRightHandedSystem: optional boolean to for right handed system computation
  112244. * * depthSort : optional boolean to enable the facet depth sort computation
  112245. * * distanceTo : optional Vector3 to compute the facet depth from this location
  112246. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  112247. */
  112248. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  112249. facetNormals?: any;
  112250. facetPositions?: any;
  112251. facetPartitioning?: any;
  112252. ratio?: number;
  112253. bInfo?: any;
  112254. bbSize?: Vector3;
  112255. subDiv?: any;
  112256. useRightHandedSystem?: boolean;
  112257. depthSort?: boolean;
  112258. distanceTo?: Vector3;
  112259. depthSortedFacets?: any;
  112260. }): void;
  112261. /** @hidden */
  112262. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  112263. /**
  112264. * Applies VertexData created from the imported parameters to the geometry
  112265. * @param parsedVertexData the parsed data from an imported file
  112266. * @param geometry the geometry to apply the VertexData to
  112267. */
  112268. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  112269. }
  112270. }
  112271. declare module BABYLON {
  112272. /**
  112273. * Defines a target to use with MorphTargetManager
  112274. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112275. */
  112276. export class MorphTarget implements IAnimatable {
  112277. /** defines the name of the target */
  112278. name: string;
  112279. /**
  112280. * Gets or sets the list of animations
  112281. */
  112282. animations: Animation[];
  112283. private _scene;
  112284. private _positions;
  112285. private _normals;
  112286. private _tangents;
  112287. private _uvs;
  112288. private _influence;
  112289. private _uniqueId;
  112290. /**
  112291. * Observable raised when the influence changes
  112292. */
  112293. onInfluenceChanged: Observable<boolean>;
  112294. /** @hidden */
  112295. _onDataLayoutChanged: Observable<void>;
  112296. /**
  112297. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  112298. */
  112299. get influence(): number;
  112300. set influence(influence: number);
  112301. /**
  112302. * Gets or sets the id of the morph Target
  112303. */
  112304. id: string;
  112305. private _animationPropertiesOverride;
  112306. /**
  112307. * Gets or sets the animation properties override
  112308. */
  112309. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112310. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112311. /**
  112312. * Creates a new MorphTarget
  112313. * @param name defines the name of the target
  112314. * @param influence defines the influence to use
  112315. * @param scene defines the scene the morphtarget belongs to
  112316. */
  112317. constructor(
  112318. /** defines the name of the target */
  112319. name: string, influence?: number, scene?: Nullable<Scene>);
  112320. /**
  112321. * Gets the unique ID of this manager
  112322. */
  112323. get uniqueId(): number;
  112324. /**
  112325. * Gets a boolean defining if the target contains position data
  112326. */
  112327. get hasPositions(): boolean;
  112328. /**
  112329. * Gets a boolean defining if the target contains normal data
  112330. */
  112331. get hasNormals(): boolean;
  112332. /**
  112333. * Gets a boolean defining if the target contains tangent data
  112334. */
  112335. get hasTangents(): boolean;
  112336. /**
  112337. * Gets a boolean defining if the target contains texture coordinates data
  112338. */
  112339. get hasUVs(): boolean;
  112340. /**
  112341. * Affects position data to this target
  112342. * @param data defines the position data to use
  112343. */
  112344. setPositions(data: Nullable<FloatArray>): void;
  112345. /**
  112346. * Gets the position data stored in this target
  112347. * @returns a FloatArray containing the position data (or null if not present)
  112348. */
  112349. getPositions(): Nullable<FloatArray>;
  112350. /**
  112351. * Affects normal data to this target
  112352. * @param data defines the normal data to use
  112353. */
  112354. setNormals(data: Nullable<FloatArray>): void;
  112355. /**
  112356. * Gets the normal data stored in this target
  112357. * @returns a FloatArray containing the normal data (or null if not present)
  112358. */
  112359. getNormals(): Nullable<FloatArray>;
  112360. /**
  112361. * Affects tangent data to this target
  112362. * @param data defines the tangent data to use
  112363. */
  112364. setTangents(data: Nullable<FloatArray>): void;
  112365. /**
  112366. * Gets the tangent data stored in this target
  112367. * @returns a FloatArray containing the tangent data (or null if not present)
  112368. */
  112369. getTangents(): Nullable<FloatArray>;
  112370. /**
  112371. * Affects texture coordinates data to this target
  112372. * @param data defines the texture coordinates data to use
  112373. */
  112374. setUVs(data: Nullable<FloatArray>): void;
  112375. /**
  112376. * Gets the texture coordinates data stored in this target
  112377. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  112378. */
  112379. getUVs(): Nullable<FloatArray>;
  112380. /**
  112381. * Clone the current target
  112382. * @returns a new MorphTarget
  112383. */
  112384. clone(): MorphTarget;
  112385. /**
  112386. * Serializes the current target into a Serialization object
  112387. * @returns the serialized object
  112388. */
  112389. serialize(): any;
  112390. /**
  112391. * Returns the string "MorphTarget"
  112392. * @returns "MorphTarget"
  112393. */
  112394. getClassName(): string;
  112395. /**
  112396. * Creates a new target from serialized data
  112397. * @param serializationObject defines the serialized data to use
  112398. * @returns a new MorphTarget
  112399. */
  112400. static Parse(serializationObject: any): MorphTarget;
  112401. /**
  112402. * Creates a MorphTarget from mesh data
  112403. * @param mesh defines the source mesh
  112404. * @param name defines the name to use for the new target
  112405. * @param influence defines the influence to attach to the target
  112406. * @returns a new MorphTarget
  112407. */
  112408. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  112409. }
  112410. }
  112411. declare module BABYLON {
  112412. /**
  112413. * This class is used to deform meshes using morphing between different targets
  112414. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112415. */
  112416. export class MorphTargetManager {
  112417. private _targets;
  112418. private _targetInfluenceChangedObservers;
  112419. private _targetDataLayoutChangedObservers;
  112420. private _activeTargets;
  112421. private _scene;
  112422. private _influences;
  112423. private _supportsNormals;
  112424. private _supportsTangents;
  112425. private _supportsUVs;
  112426. private _vertexCount;
  112427. private _uniqueId;
  112428. private _tempInfluences;
  112429. /**
  112430. * Gets or sets a boolean indicating if normals must be morphed
  112431. */
  112432. enableNormalMorphing: boolean;
  112433. /**
  112434. * Gets or sets a boolean indicating if tangents must be morphed
  112435. */
  112436. enableTangentMorphing: boolean;
  112437. /**
  112438. * Gets or sets a boolean indicating if UV must be morphed
  112439. */
  112440. enableUVMorphing: boolean;
  112441. /**
  112442. * Creates a new MorphTargetManager
  112443. * @param scene defines the current scene
  112444. */
  112445. constructor(scene?: Nullable<Scene>);
  112446. /**
  112447. * Gets the unique ID of this manager
  112448. */
  112449. get uniqueId(): number;
  112450. /**
  112451. * Gets the number of vertices handled by this manager
  112452. */
  112453. get vertexCount(): number;
  112454. /**
  112455. * Gets a boolean indicating if this manager supports morphing of normals
  112456. */
  112457. get supportsNormals(): boolean;
  112458. /**
  112459. * Gets a boolean indicating if this manager supports morphing of tangents
  112460. */
  112461. get supportsTangents(): boolean;
  112462. /**
  112463. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  112464. */
  112465. get supportsUVs(): boolean;
  112466. /**
  112467. * Gets the number of targets stored in this manager
  112468. */
  112469. get numTargets(): number;
  112470. /**
  112471. * Gets the number of influencers (ie. the number of targets with influences > 0)
  112472. */
  112473. get numInfluencers(): number;
  112474. /**
  112475. * Gets the list of influences (one per target)
  112476. */
  112477. get influences(): Float32Array;
  112478. /**
  112479. * Gets the active target at specified index. An active target is a target with an influence > 0
  112480. * @param index defines the index to check
  112481. * @returns the requested target
  112482. */
  112483. getActiveTarget(index: number): MorphTarget;
  112484. /**
  112485. * Gets the target at specified index
  112486. * @param index defines the index to check
  112487. * @returns the requested target
  112488. */
  112489. getTarget(index: number): MorphTarget;
  112490. /**
  112491. * Add a new target to this manager
  112492. * @param target defines the target to add
  112493. */
  112494. addTarget(target: MorphTarget): void;
  112495. /**
  112496. * Removes a target from the manager
  112497. * @param target defines the target to remove
  112498. */
  112499. removeTarget(target: MorphTarget): void;
  112500. /**
  112501. * Clone the current manager
  112502. * @returns a new MorphTargetManager
  112503. */
  112504. clone(): MorphTargetManager;
  112505. /**
  112506. * Serializes the current manager into a Serialization object
  112507. * @returns the serialized object
  112508. */
  112509. serialize(): any;
  112510. private _syncActiveTargets;
  112511. /**
  112512. * Syncrhonize the targets with all the meshes using this morph target manager
  112513. */
  112514. synchronize(): void;
  112515. /**
  112516. * Creates a new MorphTargetManager from serialized data
  112517. * @param serializationObject defines the serialized data
  112518. * @param scene defines the hosting scene
  112519. * @returns the new MorphTargetManager
  112520. */
  112521. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  112522. }
  112523. }
  112524. declare module BABYLON {
  112525. /**
  112526. * Class used to represent a specific level of detail of a mesh
  112527. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  112528. */
  112529. export class MeshLODLevel {
  112530. /** Defines the distance where this level should start being displayed */
  112531. distance: number;
  112532. /** Defines the mesh to use to render this level */
  112533. mesh: Nullable<Mesh>;
  112534. /**
  112535. * Creates a new LOD level
  112536. * @param distance defines the distance where this level should star being displayed
  112537. * @param mesh defines the mesh to use to render this level
  112538. */
  112539. constructor(
  112540. /** Defines the distance where this level should start being displayed */
  112541. distance: number,
  112542. /** Defines the mesh to use to render this level */
  112543. mesh: Nullable<Mesh>);
  112544. }
  112545. }
  112546. declare module BABYLON {
  112547. /**
  112548. * Helper class used to generate a canvas to manipulate images
  112549. */
  112550. export class CanvasGenerator {
  112551. /**
  112552. * Create a new canvas (or offscreen canvas depending on the context)
  112553. * @param width defines the expected width
  112554. * @param height defines the expected height
  112555. * @return a new canvas or offscreen canvas
  112556. */
  112557. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  112558. }
  112559. }
  112560. declare module BABYLON {
  112561. /**
  112562. * Mesh representing the gorund
  112563. */
  112564. export class GroundMesh extends Mesh {
  112565. /** If octree should be generated */
  112566. generateOctree: boolean;
  112567. private _heightQuads;
  112568. /** @hidden */
  112569. _subdivisionsX: number;
  112570. /** @hidden */
  112571. _subdivisionsY: number;
  112572. /** @hidden */
  112573. _width: number;
  112574. /** @hidden */
  112575. _height: number;
  112576. /** @hidden */
  112577. _minX: number;
  112578. /** @hidden */
  112579. _maxX: number;
  112580. /** @hidden */
  112581. _minZ: number;
  112582. /** @hidden */
  112583. _maxZ: number;
  112584. constructor(name: string, scene: Scene);
  112585. /**
  112586. * "GroundMesh"
  112587. * @returns "GroundMesh"
  112588. */
  112589. getClassName(): string;
  112590. /**
  112591. * The minimum of x and y subdivisions
  112592. */
  112593. get subdivisions(): number;
  112594. /**
  112595. * X subdivisions
  112596. */
  112597. get subdivisionsX(): number;
  112598. /**
  112599. * Y subdivisions
  112600. */
  112601. get subdivisionsY(): number;
  112602. /**
  112603. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  112604. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112605. * @param chunksCount the number of subdivisions for x and y
  112606. * @param octreeBlocksSize (Default: 32)
  112607. */
  112608. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  112609. /**
  112610. * Returns a height (y) value in the Worl system :
  112611. * the ground altitude at the coordinates (x, z) expressed in the World system.
  112612. * @param x x coordinate
  112613. * @param z z coordinate
  112614. * @returns the ground y position if (x, z) are outside the ground surface.
  112615. */
  112616. getHeightAtCoordinates(x: number, z: number): number;
  112617. /**
  112618. * Returns a normalized vector (Vector3) orthogonal to the ground
  112619. * at the ground coordinates (x, z) expressed in the World system.
  112620. * @param x x coordinate
  112621. * @param z z coordinate
  112622. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  112623. */
  112624. getNormalAtCoordinates(x: number, z: number): Vector3;
  112625. /**
  112626. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  112627. * at the ground coordinates (x, z) expressed in the World system.
  112628. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  112629. * @param x x coordinate
  112630. * @param z z coordinate
  112631. * @param ref vector to store the result
  112632. * @returns the GroundMesh.
  112633. */
  112634. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  112635. /**
  112636. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  112637. * if the ground has been updated.
  112638. * This can be used in the render loop.
  112639. * @returns the GroundMesh.
  112640. */
  112641. updateCoordinateHeights(): GroundMesh;
  112642. private _getFacetAt;
  112643. private _initHeightQuads;
  112644. private _computeHeightQuads;
  112645. /**
  112646. * Serializes this ground mesh
  112647. * @param serializationObject object to write serialization to
  112648. */
  112649. serialize(serializationObject: any): void;
  112650. /**
  112651. * Parses a serialized ground mesh
  112652. * @param parsedMesh the serialized mesh
  112653. * @param scene the scene to create the ground mesh in
  112654. * @returns the created ground mesh
  112655. */
  112656. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  112657. }
  112658. }
  112659. declare module BABYLON {
  112660. /**
  112661. * Interface for Physics-Joint data
  112662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112663. */
  112664. export interface PhysicsJointData {
  112665. /**
  112666. * The main pivot of the joint
  112667. */
  112668. mainPivot?: Vector3;
  112669. /**
  112670. * The connected pivot of the joint
  112671. */
  112672. connectedPivot?: Vector3;
  112673. /**
  112674. * The main axis of the joint
  112675. */
  112676. mainAxis?: Vector3;
  112677. /**
  112678. * The connected axis of the joint
  112679. */
  112680. connectedAxis?: Vector3;
  112681. /**
  112682. * The collision of the joint
  112683. */
  112684. collision?: boolean;
  112685. /**
  112686. * Native Oimo/Cannon/Energy data
  112687. */
  112688. nativeParams?: any;
  112689. }
  112690. /**
  112691. * This is a holder class for the physics joint created by the physics plugin
  112692. * It holds a set of functions to control the underlying joint
  112693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112694. */
  112695. export class PhysicsJoint {
  112696. /**
  112697. * The type of the physics joint
  112698. */
  112699. type: number;
  112700. /**
  112701. * The data for the physics joint
  112702. */
  112703. jointData: PhysicsJointData;
  112704. private _physicsJoint;
  112705. protected _physicsPlugin: IPhysicsEnginePlugin;
  112706. /**
  112707. * Initializes the physics joint
  112708. * @param type The type of the physics joint
  112709. * @param jointData The data for the physics joint
  112710. */
  112711. constructor(
  112712. /**
  112713. * The type of the physics joint
  112714. */
  112715. type: number,
  112716. /**
  112717. * The data for the physics joint
  112718. */
  112719. jointData: PhysicsJointData);
  112720. /**
  112721. * Gets the physics joint
  112722. */
  112723. get physicsJoint(): any;
  112724. /**
  112725. * Sets the physics joint
  112726. */
  112727. set physicsJoint(newJoint: any);
  112728. /**
  112729. * Sets the physics plugin
  112730. */
  112731. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  112732. /**
  112733. * Execute a function that is physics-plugin specific.
  112734. * @param {Function} func the function that will be executed.
  112735. * It accepts two parameters: the physics world and the physics joint
  112736. */
  112737. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  112738. /**
  112739. * Distance-Joint type
  112740. */
  112741. static DistanceJoint: number;
  112742. /**
  112743. * Hinge-Joint type
  112744. */
  112745. static HingeJoint: number;
  112746. /**
  112747. * Ball-and-Socket joint type
  112748. */
  112749. static BallAndSocketJoint: number;
  112750. /**
  112751. * Wheel-Joint type
  112752. */
  112753. static WheelJoint: number;
  112754. /**
  112755. * Slider-Joint type
  112756. */
  112757. static SliderJoint: number;
  112758. /**
  112759. * Prismatic-Joint type
  112760. */
  112761. static PrismaticJoint: number;
  112762. /**
  112763. * Universal-Joint type
  112764. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112765. */
  112766. static UniversalJoint: number;
  112767. /**
  112768. * Hinge-Joint 2 type
  112769. */
  112770. static Hinge2Joint: number;
  112771. /**
  112772. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112773. */
  112774. static PointToPointJoint: number;
  112775. /**
  112776. * Spring-Joint type
  112777. */
  112778. static SpringJoint: number;
  112779. /**
  112780. * Lock-Joint type
  112781. */
  112782. static LockJoint: number;
  112783. }
  112784. /**
  112785. * A class representing a physics distance joint
  112786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112787. */
  112788. export class DistanceJoint extends PhysicsJoint {
  112789. /**
  112790. *
  112791. * @param jointData The data for the Distance-Joint
  112792. */
  112793. constructor(jointData: DistanceJointData);
  112794. /**
  112795. * Update the predefined distance.
  112796. * @param maxDistance The maximum preferred distance
  112797. * @param minDistance The minimum preferred distance
  112798. */
  112799. updateDistance(maxDistance: number, minDistance?: number): void;
  112800. }
  112801. /**
  112802. * Represents a Motor-Enabled Joint
  112803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112804. */
  112805. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  112806. /**
  112807. * Initializes the Motor-Enabled Joint
  112808. * @param type The type of the joint
  112809. * @param jointData The physica joint data for the joint
  112810. */
  112811. constructor(type: number, jointData: PhysicsJointData);
  112812. /**
  112813. * Set the motor values.
  112814. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112815. * @param force the force to apply
  112816. * @param maxForce max force for this motor.
  112817. */
  112818. setMotor(force?: number, maxForce?: number): void;
  112819. /**
  112820. * Set the motor's limits.
  112821. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112822. * @param upperLimit The upper limit of the motor
  112823. * @param lowerLimit The lower limit of the motor
  112824. */
  112825. setLimit(upperLimit: number, lowerLimit?: number): void;
  112826. }
  112827. /**
  112828. * This class represents a single physics Hinge-Joint
  112829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112830. */
  112831. export class HingeJoint extends MotorEnabledJoint {
  112832. /**
  112833. * Initializes the Hinge-Joint
  112834. * @param jointData The joint data for the Hinge-Joint
  112835. */
  112836. constructor(jointData: PhysicsJointData);
  112837. /**
  112838. * Set the motor values.
  112839. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112840. * @param {number} force the force to apply
  112841. * @param {number} maxForce max force for this motor.
  112842. */
  112843. setMotor(force?: number, maxForce?: number): void;
  112844. /**
  112845. * Set the motor's limits.
  112846. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112847. * @param upperLimit The upper limit of the motor
  112848. * @param lowerLimit The lower limit of the motor
  112849. */
  112850. setLimit(upperLimit: number, lowerLimit?: number): void;
  112851. }
  112852. /**
  112853. * This class represents a dual hinge physics joint (same as wheel joint)
  112854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112855. */
  112856. export class Hinge2Joint extends MotorEnabledJoint {
  112857. /**
  112858. * Initializes the Hinge2-Joint
  112859. * @param jointData The joint data for the Hinge2-Joint
  112860. */
  112861. constructor(jointData: PhysicsJointData);
  112862. /**
  112863. * Set the motor values.
  112864. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112865. * @param {number} targetSpeed the speed the motor is to reach
  112866. * @param {number} maxForce max force for this motor.
  112867. * @param {motorIndex} the motor's index, 0 or 1.
  112868. */
  112869. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112870. /**
  112871. * Set the motor limits.
  112872. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112873. * @param {number} upperLimit the upper limit
  112874. * @param {number} lowerLimit lower limit
  112875. * @param {motorIndex} the motor's index, 0 or 1.
  112876. */
  112877. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112878. }
  112879. /**
  112880. * Interface for a motor enabled joint
  112881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112882. */
  112883. export interface IMotorEnabledJoint {
  112884. /**
  112885. * Physics joint
  112886. */
  112887. physicsJoint: any;
  112888. /**
  112889. * Sets the motor of the motor-enabled joint
  112890. * @param force The force of the motor
  112891. * @param maxForce The maximum force of the motor
  112892. * @param motorIndex The index of the motor
  112893. */
  112894. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112895. /**
  112896. * Sets the limit of the motor
  112897. * @param upperLimit The upper limit of the motor
  112898. * @param lowerLimit The lower limit of the motor
  112899. * @param motorIndex The index of the motor
  112900. */
  112901. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112902. }
  112903. /**
  112904. * Joint data for a Distance-Joint
  112905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112906. */
  112907. export interface DistanceJointData extends PhysicsJointData {
  112908. /**
  112909. * Max distance the 2 joint objects can be apart
  112910. */
  112911. maxDistance: number;
  112912. }
  112913. /**
  112914. * Joint data from a spring joint
  112915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112916. */
  112917. export interface SpringJointData extends PhysicsJointData {
  112918. /**
  112919. * Length of the spring
  112920. */
  112921. length: number;
  112922. /**
  112923. * Stiffness of the spring
  112924. */
  112925. stiffness: number;
  112926. /**
  112927. * Damping of the spring
  112928. */
  112929. damping: number;
  112930. /** this callback will be called when applying the force to the impostors. */
  112931. forceApplicationCallback: () => void;
  112932. }
  112933. }
  112934. declare module BABYLON {
  112935. /**
  112936. * Holds the data for the raycast result
  112937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112938. */
  112939. export class PhysicsRaycastResult {
  112940. private _hasHit;
  112941. private _hitDistance;
  112942. private _hitNormalWorld;
  112943. private _hitPointWorld;
  112944. private _rayFromWorld;
  112945. private _rayToWorld;
  112946. /**
  112947. * Gets if there was a hit
  112948. */
  112949. get hasHit(): boolean;
  112950. /**
  112951. * Gets the distance from the hit
  112952. */
  112953. get hitDistance(): number;
  112954. /**
  112955. * Gets the hit normal/direction in the world
  112956. */
  112957. get hitNormalWorld(): Vector3;
  112958. /**
  112959. * Gets the hit point in the world
  112960. */
  112961. get hitPointWorld(): Vector3;
  112962. /**
  112963. * Gets the ray "start point" of the ray in the world
  112964. */
  112965. get rayFromWorld(): Vector3;
  112966. /**
  112967. * Gets the ray "end point" of the ray in the world
  112968. */
  112969. get rayToWorld(): Vector3;
  112970. /**
  112971. * Sets the hit data (normal & point in world space)
  112972. * @param hitNormalWorld defines the normal in world space
  112973. * @param hitPointWorld defines the point in world space
  112974. */
  112975. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  112976. /**
  112977. * Sets the distance from the start point to the hit point
  112978. * @param distance
  112979. */
  112980. setHitDistance(distance: number): void;
  112981. /**
  112982. * Calculates the distance manually
  112983. */
  112984. calculateHitDistance(): void;
  112985. /**
  112986. * Resets all the values to default
  112987. * @param from The from point on world space
  112988. * @param to The to point on world space
  112989. */
  112990. reset(from?: Vector3, to?: Vector3): void;
  112991. }
  112992. /**
  112993. * Interface for the size containing width and height
  112994. */
  112995. interface IXYZ {
  112996. /**
  112997. * X
  112998. */
  112999. x: number;
  113000. /**
  113001. * Y
  113002. */
  113003. y: number;
  113004. /**
  113005. * Z
  113006. */
  113007. z: number;
  113008. }
  113009. }
  113010. declare module BABYLON {
  113011. /**
  113012. * Interface used to describe a physics joint
  113013. */
  113014. export interface PhysicsImpostorJoint {
  113015. /** Defines the main impostor to which the joint is linked */
  113016. mainImpostor: PhysicsImpostor;
  113017. /** Defines the impostor that is connected to the main impostor using this joint */
  113018. connectedImpostor: PhysicsImpostor;
  113019. /** Defines the joint itself */
  113020. joint: PhysicsJoint;
  113021. }
  113022. /** @hidden */
  113023. export interface IPhysicsEnginePlugin {
  113024. world: any;
  113025. name: string;
  113026. setGravity(gravity: Vector3): void;
  113027. setTimeStep(timeStep: number): void;
  113028. getTimeStep(): number;
  113029. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113030. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113031. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113032. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113033. removePhysicsBody(impostor: PhysicsImpostor): void;
  113034. generateJoint(joint: PhysicsImpostorJoint): void;
  113035. removeJoint(joint: PhysicsImpostorJoint): void;
  113036. isSupported(): boolean;
  113037. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113038. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113039. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  113040. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  113041. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113042. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113043. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113044. getBodyMass(impostor: PhysicsImpostor): number;
  113045. getBodyFriction(impostor: PhysicsImpostor): number;
  113046. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113047. getBodyRestitution(impostor: PhysicsImpostor): number;
  113048. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113049. getBodyPressure?(impostor: PhysicsImpostor): number;
  113050. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  113051. getBodyStiffness?(impostor: PhysicsImpostor): number;
  113052. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  113053. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  113054. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  113055. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  113056. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  113057. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  113058. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  113059. sleepBody(impostor: PhysicsImpostor): void;
  113060. wakeUpBody(impostor: PhysicsImpostor): void;
  113061. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113062. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113063. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  113064. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  113065. getRadius(impostor: PhysicsImpostor): number;
  113066. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113067. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113068. dispose(): void;
  113069. }
  113070. /**
  113071. * Interface used to define a physics engine
  113072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113073. */
  113074. export interface IPhysicsEngine {
  113075. /**
  113076. * Gets the gravity vector used by the simulation
  113077. */
  113078. gravity: Vector3;
  113079. /**
  113080. * Sets the gravity vector used by the simulation
  113081. * @param gravity defines the gravity vector to use
  113082. */
  113083. setGravity(gravity: Vector3): void;
  113084. /**
  113085. * Set the time step of the physics engine.
  113086. * Default is 1/60.
  113087. * To slow it down, enter 1/600 for example.
  113088. * To speed it up, 1/30
  113089. * @param newTimeStep the new timestep to apply to this world.
  113090. */
  113091. setTimeStep(newTimeStep: number): void;
  113092. /**
  113093. * Get the time step of the physics engine.
  113094. * @returns the current time step
  113095. */
  113096. getTimeStep(): number;
  113097. /**
  113098. * Set the sub time step of the physics engine.
  113099. * Default is 0 meaning there is no sub steps
  113100. * To increase physics resolution precision, set a small value (like 1 ms)
  113101. * @param subTimeStep defines the new sub timestep used for physics resolution.
  113102. */
  113103. setSubTimeStep(subTimeStep: number): void;
  113104. /**
  113105. * Get the sub time step of the physics engine.
  113106. * @returns the current sub time step
  113107. */
  113108. getSubTimeStep(): number;
  113109. /**
  113110. * Release all resources
  113111. */
  113112. dispose(): void;
  113113. /**
  113114. * Gets the name of the current physics plugin
  113115. * @returns the name of the plugin
  113116. */
  113117. getPhysicsPluginName(): string;
  113118. /**
  113119. * Adding a new impostor for the impostor tracking.
  113120. * This will be done by the impostor itself.
  113121. * @param impostor the impostor to add
  113122. */
  113123. addImpostor(impostor: PhysicsImpostor): void;
  113124. /**
  113125. * Remove an impostor from the engine.
  113126. * This impostor and its mesh will not longer be updated by the physics engine.
  113127. * @param impostor the impostor to remove
  113128. */
  113129. removeImpostor(impostor: PhysicsImpostor): void;
  113130. /**
  113131. * Add a joint to the physics engine
  113132. * @param mainImpostor defines the main impostor to which the joint is added.
  113133. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  113134. * @param joint defines the joint that will connect both impostors.
  113135. */
  113136. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113137. /**
  113138. * Removes a joint from the simulation
  113139. * @param mainImpostor defines the impostor used with the joint
  113140. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  113141. * @param joint defines the joint to remove
  113142. */
  113143. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113144. /**
  113145. * Gets the current plugin used to run the simulation
  113146. * @returns current plugin
  113147. */
  113148. getPhysicsPlugin(): IPhysicsEnginePlugin;
  113149. /**
  113150. * Gets the list of physic impostors
  113151. * @returns an array of PhysicsImpostor
  113152. */
  113153. getImpostors(): Array<PhysicsImpostor>;
  113154. /**
  113155. * Gets the impostor for a physics enabled object
  113156. * @param object defines the object impersonated by the impostor
  113157. * @returns the PhysicsImpostor or null if not found
  113158. */
  113159. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113160. /**
  113161. * Gets the impostor for a physics body object
  113162. * @param body defines physics body used by the impostor
  113163. * @returns the PhysicsImpostor or null if not found
  113164. */
  113165. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  113166. /**
  113167. * Does a raycast in the physics world
  113168. * @param from when should the ray start?
  113169. * @param to when should the ray end?
  113170. * @returns PhysicsRaycastResult
  113171. */
  113172. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113173. /**
  113174. * Called by the scene. No need to call it.
  113175. * @param delta defines the timespam between frames
  113176. */
  113177. _step(delta: number): void;
  113178. }
  113179. }
  113180. declare module BABYLON {
  113181. /**
  113182. * The interface for the physics imposter parameters
  113183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113184. */
  113185. export interface PhysicsImpostorParameters {
  113186. /**
  113187. * The mass of the physics imposter
  113188. */
  113189. mass: number;
  113190. /**
  113191. * The friction of the physics imposter
  113192. */
  113193. friction?: number;
  113194. /**
  113195. * The coefficient of restitution of the physics imposter
  113196. */
  113197. restitution?: number;
  113198. /**
  113199. * The native options of the physics imposter
  113200. */
  113201. nativeOptions?: any;
  113202. /**
  113203. * Specifies if the parent should be ignored
  113204. */
  113205. ignoreParent?: boolean;
  113206. /**
  113207. * Specifies if bi-directional transformations should be disabled
  113208. */
  113209. disableBidirectionalTransformation?: boolean;
  113210. /**
  113211. * The pressure inside the physics imposter, soft object only
  113212. */
  113213. pressure?: number;
  113214. /**
  113215. * The stiffness the physics imposter, soft object only
  113216. */
  113217. stiffness?: number;
  113218. /**
  113219. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  113220. */
  113221. velocityIterations?: number;
  113222. /**
  113223. * The number of iterations used in maintaining consistent vertex positions, soft object only
  113224. */
  113225. positionIterations?: number;
  113226. /**
  113227. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  113228. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  113229. * Add to fix multiple points
  113230. */
  113231. fixedPoints?: number;
  113232. /**
  113233. * The collision margin around a soft object
  113234. */
  113235. margin?: number;
  113236. /**
  113237. * The collision margin around a soft object
  113238. */
  113239. damping?: number;
  113240. /**
  113241. * The path for a rope based on an extrusion
  113242. */
  113243. path?: any;
  113244. /**
  113245. * The shape of an extrusion used for a rope based on an extrusion
  113246. */
  113247. shape?: any;
  113248. }
  113249. /**
  113250. * Interface for a physics-enabled object
  113251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113252. */
  113253. export interface IPhysicsEnabledObject {
  113254. /**
  113255. * The position of the physics-enabled object
  113256. */
  113257. position: Vector3;
  113258. /**
  113259. * The rotation of the physics-enabled object
  113260. */
  113261. rotationQuaternion: Nullable<Quaternion>;
  113262. /**
  113263. * The scale of the physics-enabled object
  113264. */
  113265. scaling: Vector3;
  113266. /**
  113267. * The rotation of the physics-enabled object
  113268. */
  113269. rotation?: Vector3;
  113270. /**
  113271. * The parent of the physics-enabled object
  113272. */
  113273. parent?: any;
  113274. /**
  113275. * The bounding info of the physics-enabled object
  113276. * @returns The bounding info of the physics-enabled object
  113277. */
  113278. getBoundingInfo(): BoundingInfo;
  113279. /**
  113280. * Computes the world matrix
  113281. * @param force Specifies if the world matrix should be computed by force
  113282. * @returns A world matrix
  113283. */
  113284. computeWorldMatrix(force: boolean): Matrix;
  113285. /**
  113286. * Gets the world matrix
  113287. * @returns A world matrix
  113288. */
  113289. getWorldMatrix?(): Matrix;
  113290. /**
  113291. * Gets the child meshes
  113292. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  113293. * @returns An array of abstract meshes
  113294. */
  113295. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  113296. /**
  113297. * Gets the vertex data
  113298. * @param kind The type of vertex data
  113299. * @returns A nullable array of numbers, or a float32 array
  113300. */
  113301. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  113302. /**
  113303. * Gets the indices from the mesh
  113304. * @returns A nullable array of index arrays
  113305. */
  113306. getIndices?(): Nullable<IndicesArray>;
  113307. /**
  113308. * Gets the scene from the mesh
  113309. * @returns the indices array or null
  113310. */
  113311. getScene?(): Scene;
  113312. /**
  113313. * Gets the absolute position from the mesh
  113314. * @returns the absolute position
  113315. */
  113316. getAbsolutePosition(): Vector3;
  113317. /**
  113318. * Gets the absolute pivot point from the mesh
  113319. * @returns the absolute pivot point
  113320. */
  113321. getAbsolutePivotPoint(): Vector3;
  113322. /**
  113323. * Rotates the mesh
  113324. * @param axis The axis of rotation
  113325. * @param amount The amount of rotation
  113326. * @param space The space of the rotation
  113327. * @returns The rotation transform node
  113328. */
  113329. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  113330. /**
  113331. * Translates the mesh
  113332. * @param axis The axis of translation
  113333. * @param distance The distance of translation
  113334. * @param space The space of the translation
  113335. * @returns The transform node
  113336. */
  113337. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  113338. /**
  113339. * Sets the absolute position of the mesh
  113340. * @param absolutePosition The absolute position of the mesh
  113341. * @returns The transform node
  113342. */
  113343. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  113344. /**
  113345. * Gets the class name of the mesh
  113346. * @returns The class name
  113347. */
  113348. getClassName(): string;
  113349. }
  113350. /**
  113351. * Represents a physics imposter
  113352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113353. */
  113354. export class PhysicsImpostor {
  113355. /**
  113356. * The physics-enabled object used as the physics imposter
  113357. */
  113358. object: IPhysicsEnabledObject;
  113359. /**
  113360. * The type of the physics imposter
  113361. */
  113362. type: number;
  113363. private _options;
  113364. private _scene?;
  113365. /**
  113366. * The default object size of the imposter
  113367. */
  113368. static DEFAULT_OBJECT_SIZE: Vector3;
  113369. /**
  113370. * The identity quaternion of the imposter
  113371. */
  113372. static IDENTITY_QUATERNION: Quaternion;
  113373. /** @hidden */
  113374. _pluginData: any;
  113375. private _physicsEngine;
  113376. private _physicsBody;
  113377. private _bodyUpdateRequired;
  113378. private _onBeforePhysicsStepCallbacks;
  113379. private _onAfterPhysicsStepCallbacks;
  113380. /** @hidden */
  113381. _onPhysicsCollideCallbacks: Array<{
  113382. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  113383. otherImpostors: Array<PhysicsImpostor>;
  113384. }>;
  113385. private _deltaPosition;
  113386. private _deltaRotation;
  113387. private _deltaRotationConjugated;
  113388. /** @hidden */
  113389. _isFromLine: boolean;
  113390. private _parent;
  113391. private _isDisposed;
  113392. private static _tmpVecs;
  113393. private static _tmpQuat;
  113394. /**
  113395. * Specifies if the physics imposter is disposed
  113396. */
  113397. get isDisposed(): boolean;
  113398. /**
  113399. * Gets the mass of the physics imposter
  113400. */
  113401. get mass(): number;
  113402. set mass(value: number);
  113403. /**
  113404. * Gets the coefficient of friction
  113405. */
  113406. get friction(): number;
  113407. /**
  113408. * Sets the coefficient of friction
  113409. */
  113410. set friction(value: number);
  113411. /**
  113412. * Gets the coefficient of restitution
  113413. */
  113414. get restitution(): number;
  113415. /**
  113416. * Sets the coefficient of restitution
  113417. */
  113418. set restitution(value: number);
  113419. /**
  113420. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  113421. */
  113422. get pressure(): number;
  113423. /**
  113424. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  113425. */
  113426. set pressure(value: number);
  113427. /**
  113428. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113429. */
  113430. get stiffness(): number;
  113431. /**
  113432. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113433. */
  113434. set stiffness(value: number);
  113435. /**
  113436. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113437. */
  113438. get velocityIterations(): number;
  113439. /**
  113440. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113441. */
  113442. set velocityIterations(value: number);
  113443. /**
  113444. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113445. */
  113446. get positionIterations(): number;
  113447. /**
  113448. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113449. */
  113450. set positionIterations(value: number);
  113451. /**
  113452. * The unique id of the physics imposter
  113453. * set by the physics engine when adding this impostor to the array
  113454. */
  113455. uniqueId: number;
  113456. /**
  113457. * @hidden
  113458. */
  113459. soft: boolean;
  113460. /**
  113461. * @hidden
  113462. */
  113463. segments: number;
  113464. private _joints;
  113465. /**
  113466. * Initializes the physics imposter
  113467. * @param object The physics-enabled object used as the physics imposter
  113468. * @param type The type of the physics imposter
  113469. * @param _options The options for the physics imposter
  113470. * @param _scene The Babylon scene
  113471. */
  113472. constructor(
  113473. /**
  113474. * The physics-enabled object used as the physics imposter
  113475. */
  113476. object: IPhysicsEnabledObject,
  113477. /**
  113478. * The type of the physics imposter
  113479. */
  113480. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  113481. /**
  113482. * This function will completly initialize this impostor.
  113483. * It will create a new body - but only if this mesh has no parent.
  113484. * If it has, this impostor will not be used other than to define the impostor
  113485. * of the child mesh.
  113486. * @hidden
  113487. */
  113488. _init(): void;
  113489. private _getPhysicsParent;
  113490. /**
  113491. * Should a new body be generated.
  113492. * @returns boolean specifying if body initialization is required
  113493. */
  113494. isBodyInitRequired(): boolean;
  113495. /**
  113496. * Sets the updated scaling
  113497. * @param updated Specifies if the scaling is updated
  113498. */
  113499. setScalingUpdated(): void;
  113500. /**
  113501. * Force a regeneration of this or the parent's impostor's body.
  113502. * Use under cautious - This will remove all joints already implemented.
  113503. */
  113504. forceUpdate(): void;
  113505. /**
  113506. * Gets the body that holds this impostor. Either its own, or its parent.
  113507. */
  113508. get physicsBody(): any;
  113509. /**
  113510. * Get the parent of the physics imposter
  113511. * @returns Physics imposter or null
  113512. */
  113513. get parent(): Nullable<PhysicsImpostor>;
  113514. /**
  113515. * Sets the parent of the physics imposter
  113516. */
  113517. set parent(value: Nullable<PhysicsImpostor>);
  113518. /**
  113519. * Set the physics body. Used mainly by the physics engine/plugin
  113520. */
  113521. set physicsBody(physicsBody: any);
  113522. /**
  113523. * Resets the update flags
  113524. */
  113525. resetUpdateFlags(): void;
  113526. /**
  113527. * Gets the object extend size
  113528. * @returns the object extend size
  113529. */
  113530. getObjectExtendSize(): Vector3;
  113531. /**
  113532. * Gets the object center
  113533. * @returns The object center
  113534. */
  113535. getObjectCenter(): Vector3;
  113536. /**
  113537. * Get a specific parameter from the options parameters
  113538. * @param paramName The object parameter name
  113539. * @returns The object parameter
  113540. */
  113541. getParam(paramName: string): any;
  113542. /**
  113543. * Sets a specific parameter in the options given to the physics plugin
  113544. * @param paramName The parameter name
  113545. * @param value The value of the parameter
  113546. */
  113547. setParam(paramName: string, value: number): void;
  113548. /**
  113549. * Specifically change the body's mass option. Won't recreate the physics body object
  113550. * @param mass The mass of the physics imposter
  113551. */
  113552. setMass(mass: number): void;
  113553. /**
  113554. * Gets the linear velocity
  113555. * @returns linear velocity or null
  113556. */
  113557. getLinearVelocity(): Nullable<Vector3>;
  113558. /**
  113559. * Sets the linear velocity
  113560. * @param velocity linear velocity or null
  113561. */
  113562. setLinearVelocity(velocity: Nullable<Vector3>): void;
  113563. /**
  113564. * Gets the angular velocity
  113565. * @returns angular velocity or null
  113566. */
  113567. getAngularVelocity(): Nullable<Vector3>;
  113568. /**
  113569. * Sets the angular velocity
  113570. * @param velocity The velocity or null
  113571. */
  113572. setAngularVelocity(velocity: Nullable<Vector3>): void;
  113573. /**
  113574. * Execute a function with the physics plugin native code
  113575. * Provide a function the will have two variables - the world object and the physics body object
  113576. * @param func The function to execute with the physics plugin native code
  113577. */
  113578. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  113579. /**
  113580. * Register a function that will be executed before the physics world is stepping forward
  113581. * @param func The function to execute before the physics world is stepped forward
  113582. */
  113583. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113584. /**
  113585. * Unregister a function that will be executed before the physics world is stepping forward
  113586. * @param func The function to execute before the physics world is stepped forward
  113587. */
  113588. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113589. /**
  113590. * Register a function that will be executed after the physics step
  113591. * @param func The function to execute after physics step
  113592. */
  113593. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113594. /**
  113595. * Unregisters a function that will be executed after the physics step
  113596. * @param func The function to execute after physics step
  113597. */
  113598. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113599. /**
  113600. * register a function that will be executed when this impostor collides against a different body
  113601. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  113602. * @param func Callback that is executed on collision
  113603. */
  113604. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  113605. /**
  113606. * Unregisters the physics imposter on contact
  113607. * @param collideAgainst The physics object to collide against
  113608. * @param func Callback to execute on collision
  113609. */
  113610. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  113611. private _tmpQuat;
  113612. private _tmpQuat2;
  113613. /**
  113614. * Get the parent rotation
  113615. * @returns The parent rotation
  113616. */
  113617. getParentsRotation(): Quaternion;
  113618. /**
  113619. * this function is executed by the physics engine.
  113620. */
  113621. beforeStep: () => void;
  113622. /**
  113623. * this function is executed by the physics engine
  113624. */
  113625. afterStep: () => void;
  113626. /**
  113627. * Legacy collision detection event support
  113628. */
  113629. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  113630. /**
  113631. * event and body object due to cannon's event-based architecture.
  113632. */
  113633. onCollide: (e: {
  113634. body: any;
  113635. point: Nullable<Vector3>;
  113636. }) => void;
  113637. /**
  113638. * Apply a force
  113639. * @param force The force to apply
  113640. * @param contactPoint The contact point for the force
  113641. * @returns The physics imposter
  113642. */
  113643. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113644. /**
  113645. * Apply an impulse
  113646. * @param force The impulse force
  113647. * @param contactPoint The contact point for the impulse force
  113648. * @returns The physics imposter
  113649. */
  113650. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113651. /**
  113652. * A help function to create a joint
  113653. * @param otherImpostor A physics imposter used to create a joint
  113654. * @param jointType The type of joint
  113655. * @param jointData The data for the joint
  113656. * @returns The physics imposter
  113657. */
  113658. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  113659. /**
  113660. * Add a joint to this impostor with a different impostor
  113661. * @param otherImpostor A physics imposter used to add a joint
  113662. * @param joint The joint to add
  113663. * @returns The physics imposter
  113664. */
  113665. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  113666. /**
  113667. * Add an anchor to a cloth impostor
  113668. * @param otherImpostor rigid impostor to anchor to
  113669. * @param width ratio across width from 0 to 1
  113670. * @param height ratio up height from 0 to 1
  113671. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113672. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  113673. * @returns impostor the soft imposter
  113674. */
  113675. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113676. /**
  113677. * Add a hook to a rope impostor
  113678. * @param otherImpostor rigid impostor to anchor to
  113679. * @param length ratio across rope from 0 to 1
  113680. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  113681. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113682. * @returns impostor the rope imposter
  113683. */
  113684. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113685. /**
  113686. * Will keep this body still, in a sleep mode.
  113687. * @returns the physics imposter
  113688. */
  113689. sleep(): PhysicsImpostor;
  113690. /**
  113691. * Wake the body up.
  113692. * @returns The physics imposter
  113693. */
  113694. wakeUp(): PhysicsImpostor;
  113695. /**
  113696. * Clones the physics imposter
  113697. * @param newObject The physics imposter clones to this physics-enabled object
  113698. * @returns A nullable physics imposter
  113699. */
  113700. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113701. /**
  113702. * Disposes the physics imposter
  113703. */
  113704. dispose(): void;
  113705. /**
  113706. * Sets the delta position
  113707. * @param position The delta position amount
  113708. */
  113709. setDeltaPosition(position: Vector3): void;
  113710. /**
  113711. * Sets the delta rotation
  113712. * @param rotation The delta rotation amount
  113713. */
  113714. setDeltaRotation(rotation: Quaternion): void;
  113715. /**
  113716. * Gets the box size of the physics imposter and stores the result in the input parameter
  113717. * @param result Stores the box size
  113718. * @returns The physics imposter
  113719. */
  113720. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  113721. /**
  113722. * Gets the radius of the physics imposter
  113723. * @returns Radius of the physics imposter
  113724. */
  113725. getRadius(): number;
  113726. /**
  113727. * Sync a bone with this impostor
  113728. * @param bone The bone to sync to the impostor.
  113729. * @param boneMesh The mesh that the bone is influencing.
  113730. * @param jointPivot The pivot of the joint / bone in local space.
  113731. * @param distToJoint Optional distance from the impostor to the joint.
  113732. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113733. */
  113734. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  113735. /**
  113736. * Sync impostor to a bone
  113737. * @param bone The bone that the impostor will be synced to.
  113738. * @param boneMesh The mesh that the bone is influencing.
  113739. * @param jointPivot The pivot of the joint / bone in local space.
  113740. * @param distToJoint Optional distance from the impostor to the joint.
  113741. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113742. * @param boneAxis Optional vector3 axis the bone is aligned with
  113743. */
  113744. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  113745. /**
  113746. * No-Imposter type
  113747. */
  113748. static NoImpostor: number;
  113749. /**
  113750. * Sphere-Imposter type
  113751. */
  113752. static SphereImpostor: number;
  113753. /**
  113754. * Box-Imposter type
  113755. */
  113756. static BoxImpostor: number;
  113757. /**
  113758. * Plane-Imposter type
  113759. */
  113760. static PlaneImpostor: number;
  113761. /**
  113762. * Mesh-imposter type
  113763. */
  113764. static MeshImpostor: number;
  113765. /**
  113766. * Capsule-Impostor type (Ammo.js plugin only)
  113767. */
  113768. static CapsuleImpostor: number;
  113769. /**
  113770. * Cylinder-Imposter type
  113771. */
  113772. static CylinderImpostor: number;
  113773. /**
  113774. * Particle-Imposter type
  113775. */
  113776. static ParticleImpostor: number;
  113777. /**
  113778. * Heightmap-Imposter type
  113779. */
  113780. static HeightmapImpostor: number;
  113781. /**
  113782. * ConvexHull-Impostor type (Ammo.js plugin only)
  113783. */
  113784. static ConvexHullImpostor: number;
  113785. /**
  113786. * Custom-Imposter type (Ammo.js plugin only)
  113787. */
  113788. static CustomImpostor: number;
  113789. /**
  113790. * Rope-Imposter type
  113791. */
  113792. static RopeImpostor: number;
  113793. /**
  113794. * Cloth-Imposter type
  113795. */
  113796. static ClothImpostor: number;
  113797. /**
  113798. * Softbody-Imposter type
  113799. */
  113800. static SoftbodyImpostor: number;
  113801. }
  113802. }
  113803. declare module BABYLON {
  113804. /**
  113805. * @hidden
  113806. **/
  113807. export class _CreationDataStorage {
  113808. closePath?: boolean;
  113809. closeArray?: boolean;
  113810. idx: number[];
  113811. dashSize: number;
  113812. gapSize: number;
  113813. path3D: Path3D;
  113814. pathArray: Vector3[][];
  113815. arc: number;
  113816. radius: number;
  113817. cap: number;
  113818. tessellation: number;
  113819. }
  113820. /**
  113821. * @hidden
  113822. **/
  113823. class _InstanceDataStorage {
  113824. visibleInstances: any;
  113825. batchCache: _InstancesBatch;
  113826. instancesBufferSize: number;
  113827. instancesBuffer: Nullable<Buffer>;
  113828. instancesData: Float32Array;
  113829. overridenInstanceCount: number;
  113830. isFrozen: boolean;
  113831. previousBatch: Nullable<_InstancesBatch>;
  113832. hardwareInstancedRendering: boolean;
  113833. sideOrientation: number;
  113834. manualUpdate: boolean;
  113835. previousRenderId: number;
  113836. }
  113837. /**
  113838. * @hidden
  113839. **/
  113840. export class _InstancesBatch {
  113841. mustReturn: boolean;
  113842. visibleInstances: Nullable<InstancedMesh[]>[];
  113843. renderSelf: boolean[];
  113844. hardwareInstancedRendering: boolean[];
  113845. }
  113846. /**
  113847. * @hidden
  113848. **/
  113849. class _ThinInstanceDataStorage {
  113850. instancesCount: number;
  113851. matrixBuffer: Nullable<Buffer>;
  113852. matrixBufferSize: number;
  113853. matrixData: Nullable<Float32Array>;
  113854. boundingVectors: Array<Vector3>;
  113855. worldMatrices: Nullable<Matrix[]>;
  113856. }
  113857. /**
  113858. * Class used to represent renderable models
  113859. */
  113860. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113861. /**
  113862. * Mesh side orientation : usually the external or front surface
  113863. */
  113864. static readonly FRONTSIDE: number;
  113865. /**
  113866. * Mesh side orientation : usually the internal or back surface
  113867. */
  113868. static readonly BACKSIDE: number;
  113869. /**
  113870. * Mesh side orientation : both internal and external or front and back surfaces
  113871. */
  113872. static readonly DOUBLESIDE: number;
  113873. /**
  113874. * Mesh side orientation : by default, `FRONTSIDE`
  113875. */
  113876. static readonly DEFAULTSIDE: number;
  113877. /**
  113878. * Mesh cap setting : no cap
  113879. */
  113880. static readonly NO_CAP: number;
  113881. /**
  113882. * Mesh cap setting : one cap at the beginning of the mesh
  113883. */
  113884. static readonly CAP_START: number;
  113885. /**
  113886. * Mesh cap setting : one cap at the end of the mesh
  113887. */
  113888. static readonly CAP_END: number;
  113889. /**
  113890. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113891. */
  113892. static readonly CAP_ALL: number;
  113893. /**
  113894. * Mesh pattern setting : no flip or rotate
  113895. */
  113896. static readonly NO_FLIP: number;
  113897. /**
  113898. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113899. */
  113900. static readonly FLIP_TILE: number;
  113901. /**
  113902. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113903. */
  113904. static readonly ROTATE_TILE: number;
  113905. /**
  113906. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113907. */
  113908. static readonly FLIP_ROW: number;
  113909. /**
  113910. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113911. */
  113912. static readonly ROTATE_ROW: number;
  113913. /**
  113914. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113915. */
  113916. static readonly FLIP_N_ROTATE_TILE: number;
  113917. /**
  113918. * Mesh pattern setting : rotate pattern and rotate
  113919. */
  113920. static readonly FLIP_N_ROTATE_ROW: number;
  113921. /**
  113922. * Mesh tile positioning : part tiles same on left/right or top/bottom
  113923. */
  113924. static readonly CENTER: number;
  113925. /**
  113926. * Mesh tile positioning : part tiles on left
  113927. */
  113928. static readonly LEFT: number;
  113929. /**
  113930. * Mesh tile positioning : part tiles on right
  113931. */
  113932. static readonly RIGHT: number;
  113933. /**
  113934. * Mesh tile positioning : part tiles on top
  113935. */
  113936. static readonly TOP: number;
  113937. /**
  113938. * Mesh tile positioning : part tiles on bottom
  113939. */
  113940. static readonly BOTTOM: number;
  113941. /**
  113942. * Gets the default side orientation.
  113943. * @param orientation the orientation to value to attempt to get
  113944. * @returns the default orientation
  113945. * @hidden
  113946. */
  113947. static _GetDefaultSideOrientation(orientation?: number): number;
  113948. private _internalMeshDataInfo;
  113949. get computeBonesUsingShaders(): boolean;
  113950. set computeBonesUsingShaders(value: boolean);
  113951. /**
  113952. * An event triggered before rendering the mesh
  113953. */
  113954. get onBeforeRenderObservable(): Observable<Mesh>;
  113955. /**
  113956. * An event triggered before binding the mesh
  113957. */
  113958. get onBeforeBindObservable(): Observable<Mesh>;
  113959. /**
  113960. * An event triggered after rendering the mesh
  113961. */
  113962. get onAfterRenderObservable(): Observable<Mesh>;
  113963. /**
  113964. * An event triggered before drawing the mesh
  113965. */
  113966. get onBeforeDrawObservable(): Observable<Mesh>;
  113967. private _onBeforeDrawObserver;
  113968. /**
  113969. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  113970. */
  113971. set onBeforeDraw(callback: () => void);
  113972. get hasInstances(): boolean;
  113973. get hasThinInstances(): boolean;
  113974. /**
  113975. * Gets the delay loading state of the mesh (when delay loading is turned on)
  113976. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  113977. */
  113978. delayLoadState: number;
  113979. /**
  113980. * Gets the list of instances created from this mesh
  113981. * it is not supposed to be modified manually.
  113982. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  113983. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113984. */
  113985. instances: InstancedMesh[];
  113986. /**
  113987. * Gets the file containing delay loading data for this mesh
  113988. */
  113989. delayLoadingFile: string;
  113990. /** @hidden */
  113991. _binaryInfo: any;
  113992. /**
  113993. * User defined function used to change how LOD level selection is done
  113994. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113995. */
  113996. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  113997. /**
  113998. * Gets or sets the morph target manager
  113999. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  114000. */
  114001. get morphTargetManager(): Nullable<MorphTargetManager>;
  114002. set morphTargetManager(value: Nullable<MorphTargetManager>);
  114003. /** @hidden */
  114004. _creationDataStorage: Nullable<_CreationDataStorage>;
  114005. /** @hidden */
  114006. _geometry: Nullable<Geometry>;
  114007. /** @hidden */
  114008. _delayInfo: Array<string>;
  114009. /** @hidden */
  114010. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  114011. /** @hidden */
  114012. _instanceDataStorage: _InstanceDataStorage;
  114013. /** @hidden */
  114014. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  114015. private _effectiveMaterial;
  114016. /** @hidden */
  114017. _shouldGenerateFlatShading: boolean;
  114018. /** @hidden */
  114019. _originalBuilderSideOrientation: number;
  114020. /**
  114021. * Use this property to change the original side orientation defined at construction time
  114022. */
  114023. overrideMaterialSideOrientation: Nullable<number>;
  114024. /**
  114025. * Gets the source mesh (the one used to clone this one from)
  114026. */
  114027. get source(): Nullable<Mesh>;
  114028. /**
  114029. * Gets the list of clones of this mesh
  114030. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  114031. * Note that useClonedMeshMap=true is the default setting
  114032. */
  114033. get cloneMeshMap(): Nullable<{
  114034. [id: string]: Mesh | undefined;
  114035. }>;
  114036. /**
  114037. * Gets or sets a boolean indicating that this mesh does not use index buffer
  114038. */
  114039. get isUnIndexed(): boolean;
  114040. set isUnIndexed(value: boolean);
  114041. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  114042. get worldMatrixInstancedBuffer(): Float32Array;
  114043. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  114044. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  114045. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  114046. /**
  114047. * @constructor
  114048. * @param name The value used by scene.getMeshByName() to do a lookup.
  114049. * @param scene The scene to add this mesh to.
  114050. * @param parent The parent of this mesh, if it has one
  114051. * @param source An optional Mesh from which geometry is shared, cloned.
  114052. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  114053. * When false, achieved by calling a clone(), also passing False.
  114054. * This will make creation of children, recursive.
  114055. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  114056. */
  114057. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  114058. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  114059. doNotInstantiate: boolean;
  114060. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  114061. /**
  114062. * Gets the class name
  114063. * @returns the string "Mesh".
  114064. */
  114065. getClassName(): string;
  114066. /** @hidden */
  114067. get _isMesh(): boolean;
  114068. /**
  114069. * Returns a description of this mesh
  114070. * @param fullDetails define if full details about this mesh must be used
  114071. * @returns a descriptive string representing this mesh
  114072. */
  114073. toString(fullDetails?: boolean): string;
  114074. /** @hidden */
  114075. _unBindEffect(): void;
  114076. /**
  114077. * Gets a boolean indicating if this mesh has LOD
  114078. */
  114079. get hasLODLevels(): boolean;
  114080. /**
  114081. * Gets the list of MeshLODLevel associated with the current mesh
  114082. * @returns an array of MeshLODLevel
  114083. */
  114084. getLODLevels(): MeshLODLevel[];
  114085. private _sortLODLevels;
  114086. /**
  114087. * Add a mesh as LOD level triggered at the given distance.
  114088. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114089. * @param distance The distance from the center of the object to show this level
  114090. * @param mesh The mesh to be added as LOD level (can be null)
  114091. * @return This mesh (for chaining)
  114092. */
  114093. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  114094. /**
  114095. * Returns the LOD level mesh at the passed distance or null if not found.
  114096. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114097. * @param distance The distance from the center of the object to show this level
  114098. * @returns a Mesh or `null`
  114099. */
  114100. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  114101. /**
  114102. * Remove a mesh from the LOD array
  114103. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114104. * @param mesh defines the mesh to be removed
  114105. * @return This mesh (for chaining)
  114106. */
  114107. removeLODLevel(mesh: Mesh): Mesh;
  114108. /**
  114109. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  114110. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114111. * @param camera defines the camera to use to compute distance
  114112. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  114113. * @return This mesh (for chaining)
  114114. */
  114115. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  114116. /**
  114117. * Gets the mesh internal Geometry object
  114118. */
  114119. get geometry(): Nullable<Geometry>;
  114120. /**
  114121. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  114122. * @returns the total number of vertices
  114123. */
  114124. getTotalVertices(): number;
  114125. /**
  114126. * Returns the content of an associated vertex buffer
  114127. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114128. * - VertexBuffer.PositionKind
  114129. * - VertexBuffer.UVKind
  114130. * - VertexBuffer.UV2Kind
  114131. * - VertexBuffer.UV3Kind
  114132. * - VertexBuffer.UV4Kind
  114133. * - VertexBuffer.UV5Kind
  114134. * - VertexBuffer.UV6Kind
  114135. * - VertexBuffer.ColorKind
  114136. * - VertexBuffer.MatricesIndicesKind
  114137. * - VertexBuffer.MatricesIndicesExtraKind
  114138. * - VertexBuffer.MatricesWeightsKind
  114139. * - VertexBuffer.MatricesWeightsExtraKind
  114140. * @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
  114141. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  114142. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  114143. */
  114144. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  114145. /**
  114146. * Returns the mesh VertexBuffer object from the requested `kind`
  114147. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114148. * - VertexBuffer.PositionKind
  114149. * - VertexBuffer.NormalKind
  114150. * - VertexBuffer.UVKind
  114151. * - VertexBuffer.UV2Kind
  114152. * - VertexBuffer.UV3Kind
  114153. * - VertexBuffer.UV4Kind
  114154. * - VertexBuffer.UV5Kind
  114155. * - VertexBuffer.UV6Kind
  114156. * - VertexBuffer.ColorKind
  114157. * - VertexBuffer.MatricesIndicesKind
  114158. * - VertexBuffer.MatricesIndicesExtraKind
  114159. * - VertexBuffer.MatricesWeightsKind
  114160. * - VertexBuffer.MatricesWeightsExtraKind
  114161. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  114162. */
  114163. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  114164. /**
  114165. * Tests if a specific vertex buffer is associated with this mesh
  114166. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  114167. * - VertexBuffer.PositionKind
  114168. * - VertexBuffer.NormalKind
  114169. * - VertexBuffer.UVKind
  114170. * - VertexBuffer.UV2Kind
  114171. * - VertexBuffer.UV3Kind
  114172. * - VertexBuffer.UV4Kind
  114173. * - VertexBuffer.UV5Kind
  114174. * - VertexBuffer.UV6Kind
  114175. * - VertexBuffer.ColorKind
  114176. * - VertexBuffer.MatricesIndicesKind
  114177. * - VertexBuffer.MatricesIndicesExtraKind
  114178. * - VertexBuffer.MatricesWeightsKind
  114179. * - VertexBuffer.MatricesWeightsExtraKind
  114180. * @returns a boolean
  114181. */
  114182. isVerticesDataPresent(kind: string): boolean;
  114183. /**
  114184. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  114185. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  114186. * - VertexBuffer.PositionKind
  114187. * - VertexBuffer.UVKind
  114188. * - VertexBuffer.UV2Kind
  114189. * - VertexBuffer.UV3Kind
  114190. * - VertexBuffer.UV4Kind
  114191. * - VertexBuffer.UV5Kind
  114192. * - VertexBuffer.UV6Kind
  114193. * - VertexBuffer.ColorKind
  114194. * - VertexBuffer.MatricesIndicesKind
  114195. * - VertexBuffer.MatricesIndicesExtraKind
  114196. * - VertexBuffer.MatricesWeightsKind
  114197. * - VertexBuffer.MatricesWeightsExtraKind
  114198. * @returns a boolean
  114199. */
  114200. isVertexBufferUpdatable(kind: string): boolean;
  114201. /**
  114202. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  114203. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114204. * - VertexBuffer.PositionKind
  114205. * - VertexBuffer.NormalKind
  114206. * - VertexBuffer.UVKind
  114207. * - VertexBuffer.UV2Kind
  114208. * - VertexBuffer.UV3Kind
  114209. * - VertexBuffer.UV4Kind
  114210. * - VertexBuffer.UV5Kind
  114211. * - VertexBuffer.UV6Kind
  114212. * - VertexBuffer.ColorKind
  114213. * - VertexBuffer.MatricesIndicesKind
  114214. * - VertexBuffer.MatricesIndicesExtraKind
  114215. * - VertexBuffer.MatricesWeightsKind
  114216. * - VertexBuffer.MatricesWeightsExtraKind
  114217. * @returns an array of strings
  114218. */
  114219. getVerticesDataKinds(): string[];
  114220. /**
  114221. * Returns a positive integer : the total number of indices in this mesh geometry.
  114222. * @returns the numner of indices or zero if the mesh has no geometry.
  114223. */
  114224. getTotalIndices(): number;
  114225. /**
  114226. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  114227. * @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.
  114228. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  114229. * @returns the indices array or an empty array if the mesh has no geometry
  114230. */
  114231. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  114232. get isBlocked(): boolean;
  114233. /**
  114234. * Determine if the current mesh is ready to be rendered
  114235. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  114236. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  114237. * @returns true if all associated assets are ready (material, textures, shaders)
  114238. */
  114239. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  114240. /**
  114241. * 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.
  114242. */
  114243. get areNormalsFrozen(): boolean;
  114244. /**
  114245. * 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.
  114246. * @returns the current mesh
  114247. */
  114248. freezeNormals(): Mesh;
  114249. /**
  114250. * 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
  114251. * @returns the current mesh
  114252. */
  114253. unfreezeNormals(): Mesh;
  114254. /**
  114255. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  114256. */
  114257. set overridenInstanceCount(count: number);
  114258. /** @hidden */
  114259. _preActivate(): Mesh;
  114260. /** @hidden */
  114261. _preActivateForIntermediateRendering(renderId: number): Mesh;
  114262. /** @hidden */
  114263. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  114264. protected _afterComputeWorldMatrix(): void;
  114265. /** @hidden */
  114266. _postActivate(): void;
  114267. /**
  114268. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  114269. * This means the mesh underlying bounding box and sphere are recomputed.
  114270. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  114271. * @returns the current mesh
  114272. */
  114273. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  114274. /** @hidden */
  114275. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  114276. /**
  114277. * This function will subdivide the mesh into multiple submeshes
  114278. * @param count defines the expected number of submeshes
  114279. */
  114280. subdivide(count: number): void;
  114281. /**
  114282. * Copy a FloatArray into a specific associated vertex buffer
  114283. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114284. * - VertexBuffer.PositionKind
  114285. * - VertexBuffer.UVKind
  114286. * - VertexBuffer.UV2Kind
  114287. * - VertexBuffer.UV3Kind
  114288. * - VertexBuffer.UV4Kind
  114289. * - VertexBuffer.UV5Kind
  114290. * - VertexBuffer.UV6Kind
  114291. * - VertexBuffer.ColorKind
  114292. * - VertexBuffer.MatricesIndicesKind
  114293. * - VertexBuffer.MatricesIndicesExtraKind
  114294. * - VertexBuffer.MatricesWeightsKind
  114295. * - VertexBuffer.MatricesWeightsExtraKind
  114296. * @param data defines the data source
  114297. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114298. * @param stride defines the data stride size (can be null)
  114299. * @returns the current mesh
  114300. */
  114301. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  114302. /**
  114303. * Delete a vertex buffer associated with this mesh
  114304. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  114305. * - VertexBuffer.PositionKind
  114306. * - VertexBuffer.UVKind
  114307. * - VertexBuffer.UV2Kind
  114308. * - VertexBuffer.UV3Kind
  114309. * - VertexBuffer.UV4Kind
  114310. * - VertexBuffer.UV5Kind
  114311. * - VertexBuffer.UV6Kind
  114312. * - VertexBuffer.ColorKind
  114313. * - VertexBuffer.MatricesIndicesKind
  114314. * - VertexBuffer.MatricesIndicesExtraKind
  114315. * - VertexBuffer.MatricesWeightsKind
  114316. * - VertexBuffer.MatricesWeightsExtraKind
  114317. */
  114318. removeVerticesData(kind: string): void;
  114319. /**
  114320. * Flags an associated vertex buffer as updatable
  114321. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  114322. * - VertexBuffer.PositionKind
  114323. * - VertexBuffer.UVKind
  114324. * - VertexBuffer.UV2Kind
  114325. * - VertexBuffer.UV3Kind
  114326. * - VertexBuffer.UV4Kind
  114327. * - VertexBuffer.UV5Kind
  114328. * - VertexBuffer.UV6Kind
  114329. * - VertexBuffer.ColorKind
  114330. * - VertexBuffer.MatricesIndicesKind
  114331. * - VertexBuffer.MatricesIndicesExtraKind
  114332. * - VertexBuffer.MatricesWeightsKind
  114333. * - VertexBuffer.MatricesWeightsExtraKind
  114334. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114335. */
  114336. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  114337. /**
  114338. * Sets the mesh global Vertex Buffer
  114339. * @param buffer defines the buffer to use
  114340. * @returns the current mesh
  114341. */
  114342. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  114343. /**
  114344. * Update a specific associated vertex buffer
  114345. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114346. * - VertexBuffer.PositionKind
  114347. * - VertexBuffer.UVKind
  114348. * - VertexBuffer.UV2Kind
  114349. * - VertexBuffer.UV3Kind
  114350. * - VertexBuffer.UV4Kind
  114351. * - VertexBuffer.UV5Kind
  114352. * - VertexBuffer.UV6Kind
  114353. * - VertexBuffer.ColorKind
  114354. * - VertexBuffer.MatricesIndicesKind
  114355. * - VertexBuffer.MatricesIndicesExtraKind
  114356. * - VertexBuffer.MatricesWeightsKind
  114357. * - VertexBuffer.MatricesWeightsExtraKind
  114358. * @param data defines the data source
  114359. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  114360. * @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)
  114361. * @returns the current mesh
  114362. */
  114363. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  114364. /**
  114365. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  114366. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  114367. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  114368. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  114369. * @returns the current mesh
  114370. */
  114371. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  114372. /**
  114373. * Creates a un-shared specific occurence of the geometry for the mesh.
  114374. * @returns the current mesh
  114375. */
  114376. makeGeometryUnique(): Mesh;
  114377. /**
  114378. * Set the index buffer of this mesh
  114379. * @param indices defines the source data
  114380. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  114381. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  114382. * @returns the current mesh
  114383. */
  114384. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  114385. /**
  114386. * Update the current index buffer
  114387. * @param indices defines the source data
  114388. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  114389. * @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)
  114390. * @returns the current mesh
  114391. */
  114392. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  114393. /**
  114394. * Invert the geometry to move from a right handed system to a left handed one.
  114395. * @returns the current mesh
  114396. */
  114397. toLeftHanded(): Mesh;
  114398. /** @hidden */
  114399. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  114400. /** @hidden */
  114401. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  114402. /**
  114403. * Registers for this mesh a javascript function called just before the rendering process
  114404. * @param func defines the function to call before rendering this mesh
  114405. * @returns the current mesh
  114406. */
  114407. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114408. /**
  114409. * Disposes a previously registered javascript function called before the rendering
  114410. * @param func defines the function to remove
  114411. * @returns the current mesh
  114412. */
  114413. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114414. /**
  114415. * Registers for this mesh a javascript function called just after the rendering is complete
  114416. * @param func defines the function to call after rendering this mesh
  114417. * @returns the current mesh
  114418. */
  114419. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114420. /**
  114421. * Disposes a previously registered javascript function called after the rendering.
  114422. * @param func defines the function to remove
  114423. * @returns the current mesh
  114424. */
  114425. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114426. /** @hidden */
  114427. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  114428. /** @hidden */
  114429. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  114430. /** @hidden */
  114431. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  114432. /** @hidden */
  114433. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  114434. /** @hidden */
  114435. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  114436. /** @hidden */
  114437. _rebuild(): void;
  114438. /** @hidden */
  114439. _freeze(): void;
  114440. /** @hidden */
  114441. _unFreeze(): void;
  114442. /**
  114443. * 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
  114444. * @param subMesh defines the subMesh to render
  114445. * @param enableAlphaMode defines if alpha mode can be changed
  114446. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  114447. * @returns the current mesh
  114448. */
  114449. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  114450. private _onBeforeDraw;
  114451. /**
  114452. * Renormalize the mesh and patch it up if there are no weights
  114453. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  114454. * However in the case of zero weights then we set just a single influence to 1.
  114455. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  114456. */
  114457. cleanMatrixWeights(): void;
  114458. private normalizeSkinFourWeights;
  114459. private normalizeSkinWeightsAndExtra;
  114460. /**
  114461. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  114462. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  114463. * the user know there was an issue with importing the mesh
  114464. * @returns a validation object with skinned, valid and report string
  114465. */
  114466. validateSkinning(): {
  114467. skinned: boolean;
  114468. valid: boolean;
  114469. report: string;
  114470. };
  114471. /** @hidden */
  114472. _checkDelayState(): Mesh;
  114473. private _queueLoad;
  114474. /**
  114475. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  114476. * A mesh is in the frustum if its bounding box intersects the frustum
  114477. * @param frustumPlanes defines the frustum to test
  114478. * @returns true if the mesh is in the frustum planes
  114479. */
  114480. isInFrustum(frustumPlanes: Plane[]): boolean;
  114481. /**
  114482. * Sets the mesh material by the material or multiMaterial `id` property
  114483. * @param id is a string identifying the material or the multiMaterial
  114484. * @returns the current mesh
  114485. */
  114486. setMaterialByID(id: string): Mesh;
  114487. /**
  114488. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  114489. * @returns an array of IAnimatable
  114490. */
  114491. getAnimatables(): IAnimatable[];
  114492. /**
  114493. * Modifies the mesh geometry according to the passed transformation matrix.
  114494. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  114495. * The mesh normals are modified using the same transformation.
  114496. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114497. * @param transform defines the transform matrix to use
  114498. * @see https://doc.babylonjs.com/resources/baking_transformations
  114499. * @returns the current mesh
  114500. */
  114501. bakeTransformIntoVertices(transform: Matrix): Mesh;
  114502. /**
  114503. * Modifies the mesh geometry according to its own current World Matrix.
  114504. * The mesh World Matrix is then reset.
  114505. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  114506. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114507. * @see https://doc.babylonjs.com/resources/baking_transformations
  114508. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  114509. * @returns the current mesh
  114510. */
  114511. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  114512. /** @hidden */
  114513. get _positions(): Nullable<Vector3[]>;
  114514. /** @hidden */
  114515. _resetPointsArrayCache(): Mesh;
  114516. /** @hidden */
  114517. _generatePointsArray(): boolean;
  114518. /**
  114519. * Returns a new Mesh object generated from the current mesh properties.
  114520. * This method must not get confused with createInstance()
  114521. * @param name is a string, the name given to the new mesh
  114522. * @param newParent can be any Node object (default `null`)
  114523. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  114524. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  114525. * @returns a new mesh
  114526. */
  114527. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  114528. /**
  114529. * Releases resources associated with this mesh.
  114530. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114531. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114532. */
  114533. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114534. /** @hidden */
  114535. _disposeInstanceSpecificData(): void;
  114536. /** @hidden */
  114537. _disposeThinInstanceSpecificData(): void;
  114538. /**
  114539. * Modifies the mesh geometry according to a displacement map.
  114540. * 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.
  114541. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114542. * @param url is a string, the URL from the image file is to be downloaded.
  114543. * @param minHeight is the lower limit of the displacement.
  114544. * @param maxHeight is the upper limit of the displacement.
  114545. * @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.
  114546. * @param uvOffset is an optional vector2 used to offset UV.
  114547. * @param uvScale is an optional vector2 used to scale UV.
  114548. * @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.
  114549. * @returns the Mesh.
  114550. */
  114551. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114552. /**
  114553. * Modifies the mesh geometry according to a displacementMap buffer.
  114554. * 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.
  114555. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114556. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  114557. * @param heightMapWidth is the width of the buffer image.
  114558. * @param heightMapHeight is the height of the buffer image.
  114559. * @param minHeight is the lower limit of the displacement.
  114560. * @param maxHeight is the upper limit of the displacement.
  114561. * @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.
  114562. * @param uvOffset is an optional vector2 used to offset UV.
  114563. * @param uvScale is an optional vector2 used to scale UV.
  114564. * @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.
  114565. * @returns the Mesh.
  114566. */
  114567. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114568. /**
  114569. * Modify the mesh to get a flat shading rendering.
  114570. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  114571. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  114572. * @returns current mesh
  114573. */
  114574. convertToFlatShadedMesh(): Mesh;
  114575. /**
  114576. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  114577. * In other words, more vertices, no more indices and a single bigger VBO.
  114578. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  114579. * @returns current mesh
  114580. */
  114581. convertToUnIndexedMesh(): Mesh;
  114582. /**
  114583. * Inverses facet orientations.
  114584. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114585. * @param flipNormals will also inverts the normals
  114586. * @returns current mesh
  114587. */
  114588. flipFaces(flipNormals?: boolean): Mesh;
  114589. /**
  114590. * Increase the number of facets and hence vertices in a mesh
  114591. * Vertex normals are interpolated from existing vertex normals
  114592. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114593. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  114594. */
  114595. increaseVertices(numberPerEdge: number): void;
  114596. /**
  114597. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  114598. * This will undo any application of covertToFlatShadedMesh
  114599. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114600. */
  114601. forceSharedVertices(): void;
  114602. /** @hidden */
  114603. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  114604. /** @hidden */
  114605. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  114606. /**
  114607. * Creates a new InstancedMesh object from the mesh model.
  114608. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114609. * @param name defines the name of the new instance
  114610. * @returns a new InstancedMesh
  114611. */
  114612. createInstance(name: string): InstancedMesh;
  114613. /**
  114614. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  114615. * After this call, all the mesh instances have the same submeshes than the current mesh.
  114616. * @returns the current mesh
  114617. */
  114618. synchronizeInstances(): Mesh;
  114619. /**
  114620. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  114621. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  114622. * This should be used together with the simplification to avoid disappearing triangles.
  114623. * @param successCallback an optional success callback to be called after the optimization finished.
  114624. * @returns the current mesh
  114625. */
  114626. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  114627. /**
  114628. * Serialize current mesh
  114629. * @param serializationObject defines the object which will receive the serialization data
  114630. */
  114631. serialize(serializationObject: any): void;
  114632. /** @hidden */
  114633. _syncGeometryWithMorphTargetManager(): void;
  114634. /** @hidden */
  114635. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  114636. /**
  114637. * Returns a new Mesh object parsed from the source provided.
  114638. * @param parsedMesh is the source
  114639. * @param scene defines the hosting scene
  114640. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  114641. * @returns a new Mesh
  114642. */
  114643. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  114644. /**
  114645. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  114646. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114647. * @param name defines the name of the mesh to create
  114648. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  114649. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  114650. * @param closePath creates a seam between the first and the last points of each path of the path array
  114651. * @param offset is taken in account only if the `pathArray` is containing a single path
  114652. * @param scene defines the hosting scene
  114653. * @param updatable defines if the mesh must be flagged as updatable
  114654. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114655. * @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)
  114656. * @returns a new Mesh
  114657. */
  114658. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114659. /**
  114660. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  114661. * @param name defines the name of the mesh to create
  114662. * @param radius sets the radius size (float) of the polygon (default 0.5)
  114663. * @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
  114664. * @param scene defines the hosting scene
  114665. * @param updatable defines if the mesh must be flagged as updatable
  114666. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114667. * @returns a new Mesh
  114668. */
  114669. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114670. /**
  114671. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  114672. * @param name defines the name of the mesh to create
  114673. * @param size sets the size (float) of each box side (default 1)
  114674. * @param scene defines the hosting scene
  114675. * @param updatable defines if the mesh must be flagged as updatable
  114676. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114677. * @returns a new Mesh
  114678. */
  114679. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114680. /**
  114681. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  114682. * @param name defines the name of the mesh to create
  114683. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114684. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114685. * @param scene defines the hosting scene
  114686. * @param updatable defines if the mesh must be flagged as updatable
  114687. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114688. * @returns a new Mesh
  114689. */
  114690. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114691. /**
  114692. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  114693. * @param name defines the name of the mesh to create
  114694. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114695. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114696. * @param scene defines the hosting scene
  114697. * @returns a new Mesh
  114698. */
  114699. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  114700. /**
  114701. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  114702. * @param name defines the name of the mesh to create
  114703. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  114704. * @param diameterTop set the top cap diameter (floats, default 1)
  114705. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  114706. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  114707. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  114708. * @param scene defines the hosting scene
  114709. * @param updatable defines if the mesh must be flagged as updatable
  114710. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114711. * @returns a new Mesh
  114712. */
  114713. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  114714. /**
  114715. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  114716. * @param name defines the name of the mesh to create
  114717. * @param diameter sets the diameter size (float) of the torus (default 1)
  114718. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  114719. * @param tessellation sets the number of torus sides (postive integer, default 16)
  114720. * @param scene defines the hosting scene
  114721. * @param updatable defines if the mesh must be flagged as updatable
  114722. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114723. * @returns a new Mesh
  114724. */
  114725. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114726. /**
  114727. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  114728. * @param name defines the name of the mesh to create
  114729. * @param radius sets the global radius size (float) of the torus knot (default 2)
  114730. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  114731. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  114732. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  114733. * @param p the number of windings on X axis (positive integers, default 2)
  114734. * @param q the number of windings on Y axis (positive integers, default 3)
  114735. * @param scene defines the hosting scene
  114736. * @param updatable defines if the mesh must be flagged as updatable
  114737. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114738. * @returns a new Mesh
  114739. */
  114740. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114741. /**
  114742. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  114743. * @param name defines the name of the mesh to create
  114744. * @param points is an array successive Vector3
  114745. * @param scene defines the hosting scene
  114746. * @param updatable defines if the mesh must be flagged as updatable
  114747. * @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).
  114748. * @returns a new Mesh
  114749. */
  114750. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  114751. /**
  114752. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  114753. * @param name defines the name of the mesh to create
  114754. * @param points is an array successive Vector3
  114755. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  114756. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114757. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  114758. * @param scene defines the hosting scene
  114759. * @param updatable defines if the mesh must be flagged as updatable
  114760. * @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)
  114761. * @returns a new Mesh
  114762. */
  114763. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  114764. /**
  114765. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  114766. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  114767. * 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.
  114768. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114769. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114770. * Remember you can only change the shape positions, not their number when updating a polygon.
  114771. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114772. * @param name defines the name of the mesh to create
  114773. * @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
  114774. * @param scene defines the hosting scene
  114775. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114776. * @param updatable defines if the mesh must be flagged as updatable
  114777. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114778. * @param earcutInjection can be used to inject your own earcut reference
  114779. * @returns a new Mesh
  114780. */
  114781. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114782. /**
  114783. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  114784. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  114785. * @param name defines the name of the mesh to create
  114786. * @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
  114787. * @param depth defines the height of extrusion
  114788. * @param scene defines the hosting scene
  114789. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114790. * @param updatable defines if the mesh must be flagged as updatable
  114791. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114792. * @param earcutInjection can be used to inject your own earcut reference
  114793. * @returns a new Mesh
  114794. */
  114795. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114796. /**
  114797. * Creates an extruded shape mesh.
  114798. * 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
  114799. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114801. * @param name defines the name of the mesh to create
  114802. * @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
  114803. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114804. * @param scale is the value to scale the shape
  114805. * @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
  114806. * @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
  114807. * @param scene defines the hosting scene
  114808. * @param updatable defines if the mesh must be flagged as updatable
  114809. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114810. * @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)
  114811. * @returns a new Mesh
  114812. */
  114813. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114814. /**
  114815. * Creates an custom extruded shape mesh.
  114816. * The custom extrusion is a parametric shape.
  114817. * It has no predefined shape. Its final shape will depend on the input parameters.
  114818. * Please consider using the same method from the MeshBuilder class instead
  114819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114820. * @param name defines the name of the mesh to create
  114821. * @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
  114822. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114823. * @param scaleFunction is a custom Javascript function called on each path point
  114824. * @param rotationFunction is a custom Javascript function called on each path point
  114825. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114826. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  114827. * @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
  114828. * @param scene defines the hosting scene
  114829. * @param updatable defines if the mesh must be flagged as updatable
  114830. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114831. * @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)
  114832. * @returns a new Mesh
  114833. */
  114834. 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;
  114835. /**
  114836. * Creates lathe mesh.
  114837. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  114838. * Please consider using the same method from the MeshBuilder class instead
  114839. * @param name defines the name of the mesh to create
  114840. * @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
  114841. * @param radius is the radius value of the lathe
  114842. * @param tessellation is the side number of the lathe.
  114843. * @param scene defines the hosting scene
  114844. * @param updatable defines if the mesh must be flagged as updatable
  114845. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114846. * @returns a new Mesh
  114847. */
  114848. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114849. /**
  114850. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114851. * @param name defines the name of the mesh to create
  114852. * @param size sets the size (float) of both sides of the plane at once (default 1)
  114853. * @param scene defines the hosting scene
  114854. * @param updatable defines if the mesh must be flagged as updatable
  114855. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114856. * @returns a new Mesh
  114857. */
  114858. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114859. /**
  114860. * Creates a ground mesh.
  114861. * Please consider using the same method from the MeshBuilder class instead
  114862. * @param name defines the name of the mesh to create
  114863. * @param width set the width of the ground
  114864. * @param height set the height of the ground
  114865. * @param subdivisions sets the number of subdivisions per side
  114866. * @param scene defines the hosting scene
  114867. * @param updatable defines if the mesh must be flagged as updatable
  114868. * @returns a new Mesh
  114869. */
  114870. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114871. /**
  114872. * Creates a tiled ground mesh.
  114873. * Please consider using the same method from the MeshBuilder class instead
  114874. * @param name defines the name of the mesh to create
  114875. * @param xmin set the ground minimum X coordinate
  114876. * @param zmin set the ground minimum Y coordinate
  114877. * @param xmax set the ground maximum X coordinate
  114878. * @param zmax set the ground maximum Z coordinate
  114879. * @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
  114880. * @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
  114881. * @param scene defines the hosting scene
  114882. * @param updatable defines if the mesh must be flagged as updatable
  114883. * @returns a new Mesh
  114884. */
  114885. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114886. w: number;
  114887. h: number;
  114888. }, precision: {
  114889. w: number;
  114890. h: number;
  114891. }, scene: Scene, updatable?: boolean): Mesh;
  114892. /**
  114893. * Creates a ground mesh from a height map.
  114894. * Please consider using the same method from the MeshBuilder class instead
  114895. * @see https://doc.babylonjs.com/babylon101/height_map
  114896. * @param name defines the name of the mesh to create
  114897. * @param url sets the URL of the height map image resource
  114898. * @param width set the ground width size
  114899. * @param height set the ground height size
  114900. * @param subdivisions sets the number of subdivision per side
  114901. * @param minHeight is the minimum altitude on the ground
  114902. * @param maxHeight is the maximum altitude on the ground
  114903. * @param scene defines the hosting scene
  114904. * @param updatable defines if the mesh must be flagged as updatable
  114905. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114906. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114907. * @returns a new Mesh
  114908. */
  114909. 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;
  114910. /**
  114911. * Creates a tube mesh.
  114912. * The tube is a parametric shape.
  114913. * It has no predefined shape. Its final shape will depend on the input parameters.
  114914. * Please consider using the same method from the MeshBuilder class instead
  114915. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114916. * @param name defines the name of the mesh to create
  114917. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114918. * @param radius sets the tube radius size
  114919. * @param tessellation is the number of sides on the tubular surface
  114920. * @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
  114921. * @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
  114922. * @param scene defines the hosting scene
  114923. * @param updatable defines if the mesh must be flagged as updatable
  114924. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114925. * @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)
  114926. * @returns a new Mesh
  114927. */
  114928. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  114929. (i: number, distance: number): number;
  114930. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114931. /**
  114932. * Creates a polyhedron mesh.
  114933. * Please consider using the same method from the MeshBuilder class instead.
  114934. * * 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
  114935. * * The parameter `size` (positive float, default 1) sets the polygon size
  114936. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114937. * * 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`
  114938. * * 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
  114939. * * 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)`)
  114940. * * 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
  114941. * * 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
  114942. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114943. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114945. * @param name defines the name of the mesh to create
  114946. * @param options defines the options used to create the mesh
  114947. * @param scene defines the hosting scene
  114948. * @returns a new Mesh
  114949. */
  114950. static CreatePolyhedron(name: string, options: {
  114951. type?: number;
  114952. size?: number;
  114953. sizeX?: number;
  114954. sizeY?: number;
  114955. sizeZ?: number;
  114956. custom?: any;
  114957. faceUV?: Vector4[];
  114958. faceColors?: Color4[];
  114959. updatable?: boolean;
  114960. sideOrientation?: number;
  114961. }, scene: Scene): Mesh;
  114962. /**
  114963. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114964. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114965. * * 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`)
  114966. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114967. * * 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
  114968. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114971. * @param name defines the name of the mesh
  114972. * @param options defines the options used to create the mesh
  114973. * @param scene defines the hosting scene
  114974. * @returns a new Mesh
  114975. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114976. */
  114977. static CreateIcoSphere(name: string, options: {
  114978. radius?: number;
  114979. flat?: boolean;
  114980. subdivisions?: number;
  114981. sideOrientation?: number;
  114982. updatable?: boolean;
  114983. }, scene: Scene): Mesh;
  114984. /**
  114985. * Creates a decal mesh.
  114986. * Please consider using the same method from the MeshBuilder class instead.
  114987. * A decal is a mesh usually applied as a model onto the surface of another mesh
  114988. * @param name defines the name of the mesh
  114989. * @param sourceMesh defines the mesh receiving the decal
  114990. * @param position sets the position of the decal in world coordinates
  114991. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  114992. * @param size sets the decal scaling
  114993. * @param angle sets the angle to rotate the decal
  114994. * @returns a new Mesh
  114995. */
  114996. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  114997. /** Creates a Capsule Mesh
  114998. * @param name defines the name of the mesh.
  114999. * @param options the constructors options used to shape the mesh.
  115000. * @param scene defines the scene the mesh is scoped to.
  115001. * @returns the capsule mesh
  115002. * @see https://doc.babylonjs.com/how_to/capsule_shape
  115003. */
  115004. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  115005. /**
  115006. * Prepare internal position array for software CPU skinning
  115007. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  115008. */
  115009. setPositionsForCPUSkinning(): Float32Array;
  115010. /**
  115011. * Prepare internal normal array for software CPU skinning
  115012. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  115013. */
  115014. setNormalsForCPUSkinning(): Float32Array;
  115015. /**
  115016. * Updates the vertex buffer by applying transformation from the bones
  115017. * @param skeleton defines the skeleton to apply to current mesh
  115018. * @returns the current mesh
  115019. */
  115020. applySkeleton(skeleton: Skeleton): Mesh;
  115021. /**
  115022. * 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
  115023. * @param meshes defines the list of meshes to scan
  115024. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  115025. */
  115026. static MinMax(meshes: AbstractMesh[]): {
  115027. min: Vector3;
  115028. max: Vector3;
  115029. };
  115030. /**
  115031. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  115032. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  115033. * @returns a vector3
  115034. */
  115035. static Center(meshesOrMinMaxVector: {
  115036. min: Vector3;
  115037. max: Vector3;
  115038. } | AbstractMesh[]): Vector3;
  115039. /**
  115040. * Merge the array of meshes into a single mesh for performance reasons.
  115041. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  115042. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  115043. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  115044. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  115045. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  115046. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  115047. * @returns a new mesh
  115048. */
  115049. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  115050. /** @hidden */
  115051. addInstance(instance: InstancedMesh): void;
  115052. /** @hidden */
  115053. removeInstance(instance: InstancedMesh): void;
  115054. }
  115055. }
  115056. declare module BABYLON {
  115057. /**
  115058. * This is the base class of all the camera used in the application.
  115059. * @see https://doc.babylonjs.com/features/cameras
  115060. */
  115061. export class Camera extends Node {
  115062. /** @hidden */
  115063. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  115064. /**
  115065. * This is the default projection mode used by the cameras.
  115066. * It helps recreating a feeling of perspective and better appreciate depth.
  115067. * This is the best way to simulate real life cameras.
  115068. */
  115069. static readonly PERSPECTIVE_CAMERA: number;
  115070. /**
  115071. * This helps creating camera with an orthographic mode.
  115072. * 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.
  115073. */
  115074. static readonly ORTHOGRAPHIC_CAMERA: number;
  115075. /**
  115076. * This is the default FOV mode for perspective cameras.
  115077. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  115078. */
  115079. static readonly FOVMODE_VERTICAL_FIXED: number;
  115080. /**
  115081. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  115082. */
  115083. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  115084. /**
  115085. * This specifies ther is no need for a camera rig.
  115086. * Basically only one eye is rendered corresponding to the camera.
  115087. */
  115088. static readonly RIG_MODE_NONE: number;
  115089. /**
  115090. * Simulates a camera Rig with one blue eye and one red eye.
  115091. * This can be use with 3d blue and red glasses.
  115092. */
  115093. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  115094. /**
  115095. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  115096. */
  115097. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  115098. /**
  115099. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  115100. */
  115101. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  115102. /**
  115103. * Defines that both eyes of the camera will be rendered over under each other.
  115104. */
  115105. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  115106. /**
  115107. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  115108. */
  115109. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  115110. /**
  115111. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  115112. */
  115113. static readonly RIG_MODE_VR: number;
  115114. /**
  115115. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  115116. */
  115117. static readonly RIG_MODE_WEBVR: number;
  115118. /**
  115119. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  115120. */
  115121. static readonly RIG_MODE_CUSTOM: number;
  115122. /**
  115123. * Defines if by default attaching controls should prevent the default javascript event to continue.
  115124. */
  115125. static ForceAttachControlToAlwaysPreventDefault: boolean;
  115126. /**
  115127. * Define the input manager associated with the camera.
  115128. */
  115129. inputs: CameraInputsManager<Camera>;
  115130. /** @hidden */
  115131. _position: Vector3;
  115132. /**
  115133. * Define the current local position of the camera in the scene
  115134. */
  115135. get position(): Vector3;
  115136. set position(newPosition: Vector3);
  115137. protected _upVector: Vector3;
  115138. /**
  115139. * The vector the camera should consider as up.
  115140. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  115141. */
  115142. set upVector(vec: Vector3);
  115143. get upVector(): Vector3;
  115144. /**
  115145. * Define the current limit on the left side for an orthographic camera
  115146. * In scene unit
  115147. */
  115148. orthoLeft: Nullable<number>;
  115149. /**
  115150. * Define the current limit on the right side for an orthographic camera
  115151. * In scene unit
  115152. */
  115153. orthoRight: Nullable<number>;
  115154. /**
  115155. * Define the current limit on the bottom side for an orthographic camera
  115156. * In scene unit
  115157. */
  115158. orthoBottom: Nullable<number>;
  115159. /**
  115160. * Define the current limit on the top side for an orthographic camera
  115161. * In scene unit
  115162. */
  115163. orthoTop: Nullable<number>;
  115164. /**
  115165. * Field Of View is set in Radians. (default is 0.8)
  115166. */
  115167. fov: number;
  115168. /**
  115169. * Define the minimum distance the camera can see from.
  115170. * This is important to note that the depth buffer are not infinite and the closer it starts
  115171. * the more your scene might encounter depth fighting issue.
  115172. */
  115173. minZ: number;
  115174. /**
  115175. * Define the maximum distance the camera can see to.
  115176. * This is important to note that the depth buffer are not infinite and the further it end
  115177. * the more your scene might encounter depth fighting issue.
  115178. */
  115179. maxZ: number;
  115180. /**
  115181. * Define the default inertia of the camera.
  115182. * This helps giving a smooth feeling to the camera movement.
  115183. */
  115184. inertia: number;
  115185. /**
  115186. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  115187. */
  115188. mode: number;
  115189. /**
  115190. * Define whether the camera is intermediate.
  115191. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  115192. */
  115193. isIntermediate: boolean;
  115194. /**
  115195. * Define the viewport of the camera.
  115196. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  115197. */
  115198. viewport: Viewport;
  115199. /**
  115200. * Restricts the camera to viewing objects with the same layerMask.
  115201. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  115202. */
  115203. layerMask: number;
  115204. /**
  115205. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  115206. */
  115207. fovMode: number;
  115208. /**
  115209. * Rig mode of the camera.
  115210. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  115211. * This is normally controlled byt the camera themselves as internal use.
  115212. */
  115213. cameraRigMode: number;
  115214. /**
  115215. * Defines the distance between both "eyes" in case of a RIG
  115216. */
  115217. interaxialDistance: number;
  115218. /**
  115219. * Defines if stereoscopic rendering is done side by side or over under.
  115220. */
  115221. isStereoscopicSideBySide: boolean;
  115222. /**
  115223. * 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
  115224. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  115225. * else in the scene. (Eg. security camera)
  115226. *
  115227. * 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)
  115228. */
  115229. customRenderTargets: RenderTargetTexture[];
  115230. /**
  115231. * When set, the camera will render to this render target instead of the default canvas
  115232. *
  115233. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  115234. */
  115235. outputRenderTarget: Nullable<RenderTargetTexture>;
  115236. /**
  115237. * Observable triggered when the camera view matrix has changed.
  115238. */
  115239. onViewMatrixChangedObservable: Observable<Camera>;
  115240. /**
  115241. * Observable triggered when the camera Projection matrix has changed.
  115242. */
  115243. onProjectionMatrixChangedObservable: Observable<Camera>;
  115244. /**
  115245. * Observable triggered when the inputs have been processed.
  115246. */
  115247. onAfterCheckInputsObservable: Observable<Camera>;
  115248. /**
  115249. * Observable triggered when reset has been called and applied to the camera.
  115250. */
  115251. onRestoreStateObservable: Observable<Camera>;
  115252. /**
  115253. * Is this camera a part of a rig system?
  115254. */
  115255. isRigCamera: boolean;
  115256. /**
  115257. * If isRigCamera set to true this will be set with the parent camera.
  115258. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  115259. */
  115260. rigParent?: Camera;
  115261. /** @hidden */
  115262. _cameraRigParams: any;
  115263. /** @hidden */
  115264. _rigCameras: Camera[];
  115265. /** @hidden */
  115266. _rigPostProcess: Nullable<PostProcess>;
  115267. protected _webvrViewMatrix: Matrix;
  115268. /** @hidden */
  115269. _skipRendering: boolean;
  115270. /** @hidden */
  115271. _projectionMatrix: Matrix;
  115272. /** @hidden */
  115273. _postProcesses: Nullable<PostProcess>[];
  115274. /** @hidden */
  115275. _activeMeshes: SmartArray<AbstractMesh>;
  115276. protected _globalPosition: Vector3;
  115277. /** @hidden */
  115278. _computedViewMatrix: Matrix;
  115279. private _doNotComputeProjectionMatrix;
  115280. private _transformMatrix;
  115281. private _frustumPlanes;
  115282. private _refreshFrustumPlanes;
  115283. private _storedFov;
  115284. private _stateStored;
  115285. /**
  115286. * Instantiates a new camera object.
  115287. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  115288. * @see https://doc.babylonjs.com/features/cameras
  115289. * @param name Defines the name of the camera in the scene
  115290. * @param position Defines the position of the camera
  115291. * @param scene Defines the scene the camera belongs too
  115292. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  115293. */
  115294. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  115295. /**
  115296. * Store current camera state (fov, position, etc..)
  115297. * @returns the camera
  115298. */
  115299. storeState(): Camera;
  115300. /**
  115301. * Restores the camera state values if it has been stored. You must call storeState() first
  115302. */
  115303. protected _restoreStateValues(): boolean;
  115304. /**
  115305. * Restored camera state. You must call storeState() first.
  115306. * @returns true if restored and false otherwise
  115307. */
  115308. restoreState(): boolean;
  115309. /**
  115310. * Gets the class name of the camera.
  115311. * @returns the class name
  115312. */
  115313. getClassName(): string;
  115314. /** @hidden */
  115315. readonly _isCamera: boolean;
  115316. /**
  115317. * Gets a string representation of the camera useful for debug purpose.
  115318. * @param fullDetails Defines that a more verboe level of logging is required
  115319. * @returns the string representation
  115320. */
  115321. toString(fullDetails?: boolean): string;
  115322. /**
  115323. * Gets the current world space position of the camera.
  115324. */
  115325. get globalPosition(): Vector3;
  115326. /**
  115327. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  115328. * @returns the active meshe list
  115329. */
  115330. getActiveMeshes(): SmartArray<AbstractMesh>;
  115331. /**
  115332. * Check whether a mesh is part of the current active mesh list of the camera
  115333. * @param mesh Defines the mesh to check
  115334. * @returns true if active, false otherwise
  115335. */
  115336. isActiveMesh(mesh: Mesh): boolean;
  115337. /**
  115338. * Is this camera ready to be used/rendered
  115339. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  115340. * @return true if the camera is ready
  115341. */
  115342. isReady(completeCheck?: boolean): boolean;
  115343. /** @hidden */
  115344. _initCache(): void;
  115345. /** @hidden */
  115346. _updateCache(ignoreParentClass?: boolean): void;
  115347. /** @hidden */
  115348. _isSynchronized(): boolean;
  115349. /** @hidden */
  115350. _isSynchronizedViewMatrix(): boolean;
  115351. /** @hidden */
  115352. _isSynchronizedProjectionMatrix(): boolean;
  115353. /**
  115354. * Attach the input controls to a specific dom element to get the input from.
  115355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115356. */
  115357. attachControl(noPreventDefault?: boolean): void;
  115358. /**
  115359. * Detach the current controls from the specified dom element.
  115360. */
  115361. detachControl(): void;
  115362. /**
  115363. * Update the camera state according to the different inputs gathered during the frame.
  115364. */
  115365. update(): void;
  115366. /** @hidden */
  115367. _checkInputs(): void;
  115368. /** @hidden */
  115369. get rigCameras(): Camera[];
  115370. /**
  115371. * Gets the post process used by the rig cameras
  115372. */
  115373. get rigPostProcess(): Nullable<PostProcess>;
  115374. /**
  115375. * Internal, gets the first post proces.
  115376. * @returns the first post process to be run on this camera.
  115377. */
  115378. _getFirstPostProcess(): Nullable<PostProcess>;
  115379. private _cascadePostProcessesToRigCams;
  115380. /**
  115381. * Attach a post process to the camera.
  115382. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  115383. * @param postProcess The post process to attach to the camera
  115384. * @param insertAt The position of the post process in case several of them are in use in the scene
  115385. * @returns the position the post process has been inserted at
  115386. */
  115387. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  115388. /**
  115389. * Detach a post process to the camera.
  115390. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  115391. * @param postProcess The post process to detach from the camera
  115392. */
  115393. detachPostProcess(postProcess: PostProcess): void;
  115394. /**
  115395. * Gets the current world matrix of the camera
  115396. */
  115397. getWorldMatrix(): Matrix;
  115398. /** @hidden */
  115399. _getViewMatrix(): Matrix;
  115400. /**
  115401. * Gets the current view matrix of the camera.
  115402. * @param force forces the camera to recompute the matrix without looking at the cached state
  115403. * @returns the view matrix
  115404. */
  115405. getViewMatrix(force?: boolean): Matrix;
  115406. /**
  115407. * Freeze the projection matrix.
  115408. * It will prevent the cache check of the camera projection compute and can speed up perf
  115409. * if no parameter of the camera are meant to change
  115410. * @param projection Defines manually a projection if necessary
  115411. */
  115412. freezeProjectionMatrix(projection?: Matrix): void;
  115413. /**
  115414. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  115415. */
  115416. unfreezeProjectionMatrix(): void;
  115417. /**
  115418. * Gets the current projection matrix of the camera.
  115419. * @param force forces the camera to recompute the matrix without looking at the cached state
  115420. * @returns the projection matrix
  115421. */
  115422. getProjectionMatrix(force?: boolean): Matrix;
  115423. /**
  115424. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  115425. * @returns a Matrix
  115426. */
  115427. getTransformationMatrix(): Matrix;
  115428. private _updateFrustumPlanes;
  115429. /**
  115430. * Checks if a cullable object (mesh...) is in the camera frustum
  115431. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  115432. * @param target The object to check
  115433. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  115434. * @returns true if the object is in frustum otherwise false
  115435. */
  115436. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  115437. /**
  115438. * Checks if a cullable object (mesh...) is in the camera frustum
  115439. * Unlike isInFrustum this cheks the full bounding box
  115440. * @param target The object to check
  115441. * @returns true if the object is in frustum otherwise false
  115442. */
  115443. isCompletelyInFrustum(target: ICullable): boolean;
  115444. /**
  115445. * Gets a ray in the forward direction from the camera.
  115446. * @param length Defines the length of the ray to create
  115447. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  115448. * @param origin Defines the start point of the ray which defaults to the camera position
  115449. * @returns the forward ray
  115450. */
  115451. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  115452. /**
  115453. * Gets a ray in the forward direction from the camera.
  115454. * @param refRay the ray to (re)use when setting the values
  115455. * @param length Defines the length of the ray to create
  115456. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  115457. * @param origin Defines the start point of the ray which defaults to the camera position
  115458. * @returns the forward ray
  115459. */
  115460. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  115461. /**
  115462. * Releases resources associated with this node.
  115463. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115464. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115465. */
  115466. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115467. /** @hidden */
  115468. _isLeftCamera: boolean;
  115469. /**
  115470. * Gets the left camera of a rig setup in case of Rigged Camera
  115471. */
  115472. get isLeftCamera(): boolean;
  115473. /** @hidden */
  115474. _isRightCamera: boolean;
  115475. /**
  115476. * Gets the right camera of a rig setup in case of Rigged Camera
  115477. */
  115478. get isRightCamera(): boolean;
  115479. /**
  115480. * Gets the left camera of a rig setup in case of Rigged Camera
  115481. */
  115482. get leftCamera(): Nullable<FreeCamera>;
  115483. /**
  115484. * Gets the right camera of a rig setup in case of Rigged Camera
  115485. */
  115486. get rightCamera(): Nullable<FreeCamera>;
  115487. /**
  115488. * Gets the left camera target of a rig setup in case of Rigged Camera
  115489. * @returns the target position
  115490. */
  115491. getLeftTarget(): Nullable<Vector3>;
  115492. /**
  115493. * Gets the right camera target of a rig setup in case of Rigged Camera
  115494. * @returns the target position
  115495. */
  115496. getRightTarget(): Nullable<Vector3>;
  115497. /**
  115498. * @hidden
  115499. */
  115500. setCameraRigMode(mode: number, rigParams: any): void;
  115501. /** @hidden */
  115502. static _setStereoscopicRigMode(camera: Camera): void;
  115503. /** @hidden */
  115504. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  115505. /** @hidden */
  115506. static _setVRRigMode(camera: Camera, rigParams: any): void;
  115507. /** @hidden */
  115508. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  115509. /** @hidden */
  115510. _getVRProjectionMatrix(): Matrix;
  115511. protected _updateCameraRotationMatrix(): void;
  115512. protected _updateWebVRCameraRotationMatrix(): void;
  115513. /**
  115514. * This function MUST be overwritten by the different WebVR cameras available.
  115515. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  115516. * @hidden
  115517. */
  115518. _getWebVRProjectionMatrix(): Matrix;
  115519. /**
  115520. * This function MUST be overwritten by the different WebVR cameras available.
  115521. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  115522. * @hidden
  115523. */
  115524. _getWebVRViewMatrix(): Matrix;
  115525. /** @hidden */
  115526. setCameraRigParameter(name: string, value: any): void;
  115527. /**
  115528. * needs to be overridden by children so sub has required properties to be copied
  115529. * @hidden
  115530. */
  115531. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  115532. /**
  115533. * May need to be overridden by children
  115534. * @hidden
  115535. */
  115536. _updateRigCameras(): void;
  115537. /** @hidden */
  115538. _setupInputs(): void;
  115539. /**
  115540. * Serialiaze the camera setup to a json represention
  115541. * @returns the JSON representation
  115542. */
  115543. serialize(): any;
  115544. /**
  115545. * Clones the current camera.
  115546. * @param name The cloned camera name
  115547. * @returns the cloned camera
  115548. */
  115549. clone(name: string): Camera;
  115550. /**
  115551. * Gets the direction of the camera relative to a given local axis.
  115552. * @param localAxis Defines the reference axis to provide a relative direction.
  115553. * @return the direction
  115554. */
  115555. getDirection(localAxis: Vector3): Vector3;
  115556. /**
  115557. * Returns the current camera absolute rotation
  115558. */
  115559. get absoluteRotation(): Quaternion;
  115560. /**
  115561. * Gets the direction of the camera relative to a given local axis into a passed vector.
  115562. * @param localAxis Defines the reference axis to provide a relative direction.
  115563. * @param result Defines the vector to store the result in
  115564. */
  115565. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  115566. /**
  115567. * Gets a camera constructor for a given camera type
  115568. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  115569. * @param name The name of the camera the result will be able to instantiate
  115570. * @param scene The scene the result will construct the camera in
  115571. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  115572. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  115573. * @returns a factory method to construc the camera
  115574. */
  115575. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  115576. /**
  115577. * Compute the world matrix of the camera.
  115578. * @returns the camera world matrix
  115579. */
  115580. computeWorldMatrix(): Matrix;
  115581. /**
  115582. * Parse a JSON and creates the camera from the parsed information
  115583. * @param parsedCamera The JSON to parse
  115584. * @param scene The scene to instantiate the camera in
  115585. * @returns the newly constructed camera
  115586. */
  115587. static Parse(parsedCamera: any, scene: Scene): Camera;
  115588. }
  115589. }
  115590. declare module BABYLON {
  115591. /**
  115592. * Class containing static functions to help procedurally build meshes
  115593. */
  115594. export class DiscBuilder {
  115595. /**
  115596. * Creates a plane polygonal mesh. By default, this is a disc
  115597. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115598. * * 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
  115599. * * 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
  115600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115603. * @param name defines the name of the mesh
  115604. * @param options defines the options used to create the mesh
  115605. * @param scene defines the hosting scene
  115606. * @returns the plane polygonal mesh
  115607. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115608. */
  115609. static CreateDisc(name: string, options: {
  115610. radius?: number;
  115611. tessellation?: number;
  115612. arc?: number;
  115613. updatable?: boolean;
  115614. sideOrientation?: number;
  115615. frontUVs?: Vector4;
  115616. backUVs?: Vector4;
  115617. }, scene?: Nullable<Scene>): Mesh;
  115618. }
  115619. }
  115620. declare module BABYLON {
  115621. /**
  115622. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  115623. *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.
  115624. * The SPS is also a particle system. It provides some methods to manage the particles.
  115625. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  115626. *
  115627. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  115628. */
  115629. export class SolidParticleSystem implements IDisposable {
  115630. /**
  115631. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  115632. * Example : var p = SPS.particles[i];
  115633. */
  115634. particles: SolidParticle[];
  115635. /**
  115636. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  115637. */
  115638. nbParticles: number;
  115639. /**
  115640. * If the particles must ever face the camera (default false). Useful for planar particles.
  115641. */
  115642. billboard: boolean;
  115643. /**
  115644. * Recompute normals when adding a shape
  115645. */
  115646. recomputeNormals: boolean;
  115647. /**
  115648. * This a counter ofr your own usage. It's not set by any SPS functions.
  115649. */
  115650. counter: number;
  115651. /**
  115652. * The SPS name. This name is also given to the underlying mesh.
  115653. */
  115654. name: string;
  115655. /**
  115656. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  115657. */
  115658. mesh: Mesh;
  115659. /**
  115660. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  115661. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  115662. */
  115663. vars: any;
  115664. /**
  115665. * This array is populated when the SPS is set as 'pickable'.
  115666. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  115667. * Each element of this array is an object `{idx: int, faceId: int}`.
  115668. * `idx` is the picked particle index in the `SPS.particles` array
  115669. * `faceId` is the picked face index counted within this particle.
  115670. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  115671. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  115672. * Use the method SPS.pickedParticle(pickingInfo) instead.
  115673. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115674. */
  115675. pickedParticles: {
  115676. idx: number;
  115677. faceId: number;
  115678. }[];
  115679. /**
  115680. * This array is populated when the SPS is set as 'pickable'
  115681. * Each key of this array is a submesh index.
  115682. * Each element of this array is a second array defined like this :
  115683. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  115684. * Each element of this second array is an object `{idx: int, faceId: int}`.
  115685. * `idx` is the picked particle index in the `SPS.particles` array
  115686. * `faceId` is the picked face index counted within this particle.
  115687. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  115688. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115689. */
  115690. pickedBySubMesh: {
  115691. idx: number;
  115692. faceId: number;
  115693. }[][];
  115694. /**
  115695. * This array is populated when `enableDepthSort` is set to true.
  115696. * Each element of this array is an instance of the class DepthSortedParticle.
  115697. */
  115698. depthSortedParticles: DepthSortedParticle[];
  115699. /**
  115700. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  115701. * @hidden
  115702. */
  115703. _bSphereOnly: boolean;
  115704. /**
  115705. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  115706. * @hidden
  115707. */
  115708. _bSphereRadiusFactor: number;
  115709. private _scene;
  115710. private _positions;
  115711. private _indices;
  115712. private _normals;
  115713. private _colors;
  115714. private _uvs;
  115715. private _indices32;
  115716. private _positions32;
  115717. private _normals32;
  115718. private _fixedNormal32;
  115719. private _colors32;
  115720. private _uvs32;
  115721. private _index;
  115722. private _updatable;
  115723. private _pickable;
  115724. private _isVisibilityBoxLocked;
  115725. private _alwaysVisible;
  115726. private _depthSort;
  115727. private _expandable;
  115728. private _shapeCounter;
  115729. private _copy;
  115730. private _color;
  115731. private _computeParticleColor;
  115732. private _computeParticleTexture;
  115733. private _computeParticleRotation;
  115734. private _computeParticleVertex;
  115735. private _computeBoundingBox;
  115736. private _depthSortParticles;
  115737. private _camera;
  115738. private _mustUnrotateFixedNormals;
  115739. private _particlesIntersect;
  115740. private _needs32Bits;
  115741. private _isNotBuilt;
  115742. private _lastParticleId;
  115743. private _idxOfId;
  115744. private _multimaterialEnabled;
  115745. private _useModelMaterial;
  115746. private _indicesByMaterial;
  115747. private _materialIndexes;
  115748. private _depthSortFunction;
  115749. private _materialSortFunction;
  115750. private _materials;
  115751. private _multimaterial;
  115752. private _materialIndexesById;
  115753. private _defaultMaterial;
  115754. private _autoUpdateSubMeshes;
  115755. private _tmpVertex;
  115756. /**
  115757. * Creates a SPS (Solid Particle System) object.
  115758. * @param name (String) is the SPS name, this will be the underlying mesh name.
  115759. * @param scene (Scene) is the scene in which the SPS is added.
  115760. * @param options defines the options of the sps e.g.
  115761. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  115762. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  115763. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  115764. * * 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.
  115765. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  115766. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  115767. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  115768. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  115769. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  115770. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  115771. */
  115772. constructor(name: string, scene: Scene, options?: {
  115773. updatable?: boolean;
  115774. isPickable?: boolean;
  115775. enableDepthSort?: boolean;
  115776. particleIntersection?: boolean;
  115777. boundingSphereOnly?: boolean;
  115778. bSphereRadiusFactor?: number;
  115779. expandable?: boolean;
  115780. useModelMaterial?: boolean;
  115781. enableMultiMaterial?: boolean;
  115782. });
  115783. /**
  115784. * Builds the SPS underlying mesh. Returns a standard Mesh.
  115785. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  115786. * @returns the created mesh
  115787. */
  115788. buildMesh(): Mesh;
  115789. /**
  115790. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  115791. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  115792. * Thus the particles generated from `digest()` have their property `position` set yet.
  115793. * @param mesh ( Mesh ) is the mesh to be digested
  115794. * @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
  115795. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  115796. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  115797. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115798. * @returns the current SPS
  115799. */
  115800. digest(mesh: Mesh, options?: {
  115801. facetNb?: number;
  115802. number?: number;
  115803. delta?: number;
  115804. storage?: [];
  115805. }): SolidParticleSystem;
  115806. /**
  115807. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  115808. * @hidden
  115809. */
  115810. private _unrotateFixedNormals;
  115811. /**
  115812. * Resets the temporary working copy particle
  115813. * @hidden
  115814. */
  115815. private _resetCopy;
  115816. /**
  115817. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  115818. * @param p the current index in the positions array to be updated
  115819. * @param ind the current index in the indices array
  115820. * @param shape a Vector3 array, the shape geometry
  115821. * @param positions the positions array to be updated
  115822. * @param meshInd the shape indices array
  115823. * @param indices the indices array to be updated
  115824. * @param meshUV the shape uv array
  115825. * @param uvs the uv array to be updated
  115826. * @param meshCol the shape color array
  115827. * @param colors the color array to be updated
  115828. * @param meshNor the shape normals array
  115829. * @param normals the normals array to be updated
  115830. * @param idx the particle index
  115831. * @param idxInShape the particle index in its shape
  115832. * @param options the addShape() method passed options
  115833. * @model the particle model
  115834. * @hidden
  115835. */
  115836. private _meshBuilder;
  115837. /**
  115838. * Returns a shape Vector3 array from positions float array
  115839. * @param positions float array
  115840. * @returns a vector3 array
  115841. * @hidden
  115842. */
  115843. private _posToShape;
  115844. /**
  115845. * Returns a shapeUV array from a float uvs (array deep copy)
  115846. * @param uvs as a float array
  115847. * @returns a shapeUV array
  115848. * @hidden
  115849. */
  115850. private _uvsToShapeUV;
  115851. /**
  115852. * Adds a new particle object in the particles array
  115853. * @param idx particle index in particles array
  115854. * @param id particle id
  115855. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  115856. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  115857. * @param model particle ModelShape object
  115858. * @param shapeId model shape identifier
  115859. * @param idxInShape index of the particle in the current model
  115860. * @param bInfo model bounding info object
  115861. * @param storage target storage array, if any
  115862. * @hidden
  115863. */
  115864. private _addParticle;
  115865. /**
  115866. * Adds some particles to the SPS from the model shape. Returns the shape id.
  115867. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  115868. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  115869. * @param nb (positive integer) the number of particles to be created from this model
  115870. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  115871. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  115872. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115873. * @returns the number of shapes in the system
  115874. */
  115875. addShape(mesh: Mesh, nb: number, options?: {
  115876. positionFunction?: any;
  115877. vertexFunction?: any;
  115878. storage?: [];
  115879. }): number;
  115880. /**
  115881. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115882. * @hidden
  115883. */
  115884. private _rebuildParticle;
  115885. /**
  115886. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115887. * @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.
  115888. * @returns the SPS.
  115889. */
  115890. rebuildMesh(reset?: boolean): SolidParticleSystem;
  115891. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  115892. * Returns an array with the removed particles.
  115893. * 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.
  115894. * The SPS can't be empty so at least one particle needs to remain in place.
  115895. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  115896. * @param start index of the first particle to remove
  115897. * @param end index of the last particle to remove (included)
  115898. * @returns an array populated with the removed particles
  115899. */
  115900. removeParticles(start: number, end: number): SolidParticle[];
  115901. /**
  115902. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  115903. * @param solidParticleArray an array populated with Solid Particles objects
  115904. * @returns the SPS
  115905. */
  115906. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  115907. /**
  115908. * Creates a new particle and modifies the SPS mesh geometry :
  115909. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  115910. * - calls _addParticle() to populate the particle array
  115911. * factorized code from addShape() and insertParticlesFromArray()
  115912. * @param idx particle index in the particles array
  115913. * @param i particle index in its shape
  115914. * @param modelShape particle ModelShape object
  115915. * @param shape shape vertex array
  115916. * @param meshInd shape indices array
  115917. * @param meshUV shape uv array
  115918. * @param meshCol shape color array
  115919. * @param meshNor shape normals array
  115920. * @param bbInfo shape bounding info
  115921. * @param storage target particle storage
  115922. * @options addShape() passed options
  115923. * @hidden
  115924. */
  115925. private _insertNewParticle;
  115926. /**
  115927. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  115928. * This method calls `updateParticle()` for each particle of the SPS.
  115929. * For an animated SPS, it is usually called within the render loop.
  115930. * 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.
  115931. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  115932. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  115933. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  115934. * @returns the SPS.
  115935. */
  115936. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  115937. /**
  115938. * Disposes the SPS.
  115939. */
  115940. dispose(): void;
  115941. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  115942. * idx is the particle index in the SPS
  115943. * faceId is the picked face index counted within this particle.
  115944. * Returns null if the pickInfo can't identify a picked particle.
  115945. * @param pickingInfo (PickingInfo object)
  115946. * @returns {idx: number, faceId: number} or null
  115947. */
  115948. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  115949. idx: number;
  115950. faceId: number;
  115951. }>;
  115952. /**
  115953. * Returns a SolidParticle object from its identifier : particle.id
  115954. * @param id (integer) the particle Id
  115955. * @returns the searched particle or null if not found in the SPS.
  115956. */
  115957. getParticleById(id: number): Nullable<SolidParticle>;
  115958. /**
  115959. * Returns a new array populated with the particles having the passed shapeId.
  115960. * @param shapeId (integer) the shape identifier
  115961. * @returns a new solid particle array
  115962. */
  115963. getParticlesByShapeId(shapeId: number): SolidParticle[];
  115964. /**
  115965. * Populates the passed array "ref" with the particles having the passed shapeId.
  115966. * @param shapeId the shape identifier
  115967. * @returns the SPS
  115968. * @param ref
  115969. */
  115970. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  115971. /**
  115972. * Computes the required SubMeshes according the materials assigned to the particles.
  115973. * @returns the solid particle system.
  115974. * Does nothing if called before the SPS mesh is built.
  115975. */
  115976. computeSubMeshes(): SolidParticleSystem;
  115977. /**
  115978. * Sorts the solid particles by material when MultiMaterial is enabled.
  115979. * Updates the indices32 array.
  115980. * Updates the indicesByMaterial array.
  115981. * Updates the mesh indices array.
  115982. * @returns the SPS
  115983. * @hidden
  115984. */
  115985. private _sortParticlesByMaterial;
  115986. /**
  115987. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  115988. * @hidden
  115989. */
  115990. private _setMaterialIndexesById;
  115991. /**
  115992. * Returns an array with unique values of Materials from the passed array
  115993. * @param array the material array to be checked and filtered
  115994. * @hidden
  115995. */
  115996. private _filterUniqueMaterialId;
  115997. /**
  115998. * Sets a new Standard Material as _defaultMaterial if not already set.
  115999. * @hidden
  116000. */
  116001. private _setDefaultMaterial;
  116002. /**
  116003. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  116004. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116005. * @returns the SPS.
  116006. */
  116007. refreshVisibleSize(): SolidParticleSystem;
  116008. /**
  116009. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  116010. * @param size the size (float) of the visibility box
  116011. * note : this doesn't lock the SPS mesh bounding box.
  116012. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116013. */
  116014. setVisibilityBox(size: number): void;
  116015. /**
  116016. * Gets whether the SPS as always visible or not
  116017. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116018. */
  116019. get isAlwaysVisible(): boolean;
  116020. /**
  116021. * Sets the SPS as always visible or not
  116022. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116023. */
  116024. set isAlwaysVisible(val: boolean);
  116025. /**
  116026. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116027. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116028. */
  116029. set isVisibilityBoxLocked(val: boolean);
  116030. /**
  116031. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116032. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116033. */
  116034. get isVisibilityBoxLocked(): boolean;
  116035. /**
  116036. * Tells to `setParticles()` to compute the particle rotations or not.
  116037. * Default value : true. The SPS is faster when it's set to false.
  116038. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116039. */
  116040. set computeParticleRotation(val: boolean);
  116041. /**
  116042. * Tells to `setParticles()` to compute the particle colors or not.
  116043. * Default value : true. The SPS is faster when it's set to false.
  116044. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116045. */
  116046. set computeParticleColor(val: boolean);
  116047. set computeParticleTexture(val: boolean);
  116048. /**
  116049. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  116050. * Default value : false. The SPS is faster when it's set to false.
  116051. * Note : the particle custom vertex positions aren't stored values.
  116052. */
  116053. set computeParticleVertex(val: boolean);
  116054. /**
  116055. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  116056. */
  116057. set computeBoundingBox(val: boolean);
  116058. /**
  116059. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  116060. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116061. * Default : `true`
  116062. */
  116063. set depthSortParticles(val: boolean);
  116064. /**
  116065. * Gets if `setParticles()` computes the particle rotations or not.
  116066. * Default value : true. The SPS is faster when it's set to false.
  116067. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116068. */
  116069. get computeParticleRotation(): boolean;
  116070. /**
  116071. * Gets if `setParticles()` computes the particle colors or not.
  116072. * Default value : true. The SPS is faster when it's set to false.
  116073. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116074. */
  116075. get computeParticleColor(): boolean;
  116076. /**
  116077. * Gets if `setParticles()` computes the particle textures or not.
  116078. * Default value : true. The SPS is faster when it's set to false.
  116079. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  116080. */
  116081. get computeParticleTexture(): boolean;
  116082. /**
  116083. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  116084. * Default value : false. The SPS is faster when it's set to false.
  116085. * Note : the particle custom vertex positions aren't stored values.
  116086. */
  116087. get computeParticleVertex(): boolean;
  116088. /**
  116089. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  116090. */
  116091. get computeBoundingBox(): boolean;
  116092. /**
  116093. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  116094. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116095. * Default : `true`
  116096. */
  116097. get depthSortParticles(): boolean;
  116098. /**
  116099. * Gets if the SPS is created as expandable at construction time.
  116100. * Default : `false`
  116101. */
  116102. get expandable(): boolean;
  116103. /**
  116104. * Gets if the SPS supports the Multi Materials
  116105. */
  116106. get multimaterialEnabled(): boolean;
  116107. /**
  116108. * Gets if the SPS uses the model materials for its own multimaterial.
  116109. */
  116110. get useModelMaterial(): boolean;
  116111. /**
  116112. * The SPS used material array.
  116113. */
  116114. get materials(): Material[];
  116115. /**
  116116. * Sets the SPS MultiMaterial from the passed materials.
  116117. * Note : the passed array is internally copied and not used then by reference.
  116118. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  116119. */
  116120. setMultiMaterial(materials: Material[]): void;
  116121. /**
  116122. * The SPS computed multimaterial object
  116123. */
  116124. get multimaterial(): MultiMaterial;
  116125. set multimaterial(mm: MultiMaterial);
  116126. /**
  116127. * If the subMeshes must be updated on the next call to setParticles()
  116128. */
  116129. get autoUpdateSubMeshes(): boolean;
  116130. set autoUpdateSubMeshes(val: boolean);
  116131. /**
  116132. * This function does nothing. It may be overwritten to set all the particle first values.
  116133. * The SPS doesn't call this function, you may have to call it by your own.
  116134. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116135. */
  116136. initParticles(): void;
  116137. /**
  116138. * This function does nothing. It may be overwritten to recycle a particle.
  116139. * The SPS doesn't call this function, you may have to call it by your own.
  116140. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116141. * @param particle The particle to recycle
  116142. * @returns the recycled particle
  116143. */
  116144. recycleParticle(particle: SolidParticle): SolidParticle;
  116145. /**
  116146. * Updates a particle : this function should be overwritten by the user.
  116147. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  116148. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116149. * @example : just set a particle position or velocity and recycle conditions
  116150. * @param particle The particle to update
  116151. * @returns the updated particle
  116152. */
  116153. updateParticle(particle: SolidParticle): SolidParticle;
  116154. /**
  116155. * Updates a vertex of a particle : it can be overwritten by the user.
  116156. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  116157. * @param particle the current particle
  116158. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  116159. * @param pt the index of the current vertex in the particle shape
  116160. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  116161. * @example : just set a vertex particle position or color
  116162. * @returns the sps
  116163. */
  116164. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  116165. /**
  116166. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  116167. * This does nothing and may be overwritten by the user.
  116168. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116169. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116170. * @param update the boolean update value actually passed to setParticles()
  116171. */
  116172. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116173. /**
  116174. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  116175. * This will be passed three parameters.
  116176. * This does nothing and may be overwritten by the user.
  116177. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116178. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116179. * @param update the boolean update value actually passed to setParticles()
  116180. */
  116181. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116182. }
  116183. }
  116184. declare module BABYLON {
  116185. /**
  116186. * Represents one particle of a solid particle system.
  116187. */
  116188. export class SolidParticle {
  116189. /**
  116190. * particle global index
  116191. */
  116192. idx: number;
  116193. /**
  116194. * particle identifier
  116195. */
  116196. id: number;
  116197. /**
  116198. * The color of the particle
  116199. */
  116200. color: Nullable<Color4>;
  116201. /**
  116202. * The world space position of the particle.
  116203. */
  116204. position: Vector3;
  116205. /**
  116206. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  116207. */
  116208. rotation: Vector3;
  116209. /**
  116210. * The world space rotation quaternion of the particle.
  116211. */
  116212. rotationQuaternion: Nullable<Quaternion>;
  116213. /**
  116214. * The scaling of the particle.
  116215. */
  116216. scaling: Vector3;
  116217. /**
  116218. * The uvs of the particle.
  116219. */
  116220. uvs: Vector4;
  116221. /**
  116222. * The current speed of the particle.
  116223. */
  116224. velocity: Vector3;
  116225. /**
  116226. * The pivot point in the particle local space.
  116227. */
  116228. pivot: Vector3;
  116229. /**
  116230. * Must the particle be translated from its pivot point in its local space ?
  116231. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  116232. * Default : false
  116233. */
  116234. translateFromPivot: boolean;
  116235. /**
  116236. * Is the particle active or not ?
  116237. */
  116238. alive: boolean;
  116239. /**
  116240. * Is the particle visible or not ?
  116241. */
  116242. isVisible: boolean;
  116243. /**
  116244. * Index of this particle in the global "positions" array (Internal use)
  116245. * @hidden
  116246. */
  116247. _pos: number;
  116248. /**
  116249. * @hidden Index of this particle in the global "indices" array (Internal use)
  116250. */
  116251. _ind: number;
  116252. /**
  116253. * @hidden ModelShape of this particle (Internal use)
  116254. */
  116255. _model: ModelShape;
  116256. /**
  116257. * ModelShape id of this particle
  116258. */
  116259. shapeId: number;
  116260. /**
  116261. * Index of the particle in its shape id
  116262. */
  116263. idxInShape: number;
  116264. /**
  116265. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  116266. */
  116267. _modelBoundingInfo: BoundingInfo;
  116268. /**
  116269. * @hidden Particle BoundingInfo object (Internal use)
  116270. */
  116271. _boundingInfo: BoundingInfo;
  116272. /**
  116273. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  116274. */
  116275. _sps: SolidParticleSystem;
  116276. /**
  116277. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  116278. */
  116279. _stillInvisible: boolean;
  116280. /**
  116281. * @hidden Last computed particle rotation matrix
  116282. */
  116283. _rotationMatrix: number[];
  116284. /**
  116285. * Parent particle Id, if any.
  116286. * Default null.
  116287. */
  116288. parentId: Nullable<number>;
  116289. /**
  116290. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  116291. */
  116292. materialIndex: Nullable<number>;
  116293. /**
  116294. * Custom object or properties.
  116295. */
  116296. props: Nullable<any>;
  116297. /**
  116298. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  116299. * The possible values are :
  116300. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116301. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116302. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116303. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116304. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116305. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  116306. * */
  116307. cullingStrategy: number;
  116308. /**
  116309. * @hidden Internal global position in the SPS.
  116310. */
  116311. _globalPosition: Vector3;
  116312. /**
  116313. * Creates a Solid Particle object.
  116314. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  116315. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  116316. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  116317. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  116318. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  116319. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  116320. * @param shapeId (integer) is the model shape identifier in the SPS.
  116321. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  116322. * @param sps defines the sps it is associated to
  116323. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  116324. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  116325. */
  116326. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  116327. /**
  116328. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  116329. * @param target the particle target
  116330. * @returns the current particle
  116331. */
  116332. copyToRef(target: SolidParticle): SolidParticle;
  116333. /**
  116334. * Legacy support, changed scale to scaling
  116335. */
  116336. get scale(): Vector3;
  116337. /**
  116338. * Legacy support, changed scale to scaling
  116339. */
  116340. set scale(scale: Vector3);
  116341. /**
  116342. * Legacy support, changed quaternion to rotationQuaternion
  116343. */
  116344. get quaternion(): Nullable<Quaternion>;
  116345. /**
  116346. * Legacy support, changed quaternion to rotationQuaternion
  116347. */
  116348. set quaternion(q: Nullable<Quaternion>);
  116349. /**
  116350. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  116351. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  116352. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  116353. * @returns true if it intersects
  116354. */
  116355. intersectsMesh(target: Mesh | SolidParticle): boolean;
  116356. /**
  116357. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  116358. * A particle is in the frustum if its bounding box intersects the frustum
  116359. * @param frustumPlanes defines the frustum to test
  116360. * @returns true if the particle is in the frustum planes
  116361. */
  116362. isInFrustum(frustumPlanes: Plane[]): boolean;
  116363. /**
  116364. * get the rotation matrix of the particle
  116365. * @hidden
  116366. */
  116367. getRotationMatrix(m: Matrix): void;
  116368. }
  116369. /**
  116370. * Represents the shape of the model used by one particle of a solid particle system.
  116371. * SPS internal tool, don't use it manually.
  116372. */
  116373. export class ModelShape {
  116374. /**
  116375. * The shape id
  116376. * @hidden
  116377. */
  116378. shapeID: number;
  116379. /**
  116380. * flat array of model positions (internal use)
  116381. * @hidden
  116382. */
  116383. _shape: Vector3[];
  116384. /**
  116385. * flat array of model UVs (internal use)
  116386. * @hidden
  116387. */
  116388. _shapeUV: number[];
  116389. /**
  116390. * color array of the model
  116391. * @hidden
  116392. */
  116393. _shapeColors: number[];
  116394. /**
  116395. * indices array of the model
  116396. * @hidden
  116397. */
  116398. _indices: number[];
  116399. /**
  116400. * normals array of the model
  116401. * @hidden
  116402. */
  116403. _normals: number[];
  116404. /**
  116405. * length of the shape in the model indices array (internal use)
  116406. * @hidden
  116407. */
  116408. _indicesLength: number;
  116409. /**
  116410. * Custom position function (internal use)
  116411. * @hidden
  116412. */
  116413. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  116414. /**
  116415. * Custom vertex function (internal use)
  116416. * @hidden
  116417. */
  116418. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  116419. /**
  116420. * Model material (internal use)
  116421. * @hidden
  116422. */
  116423. _material: Nullable<Material>;
  116424. /**
  116425. * 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.
  116426. * SPS internal tool, don't use it manually.
  116427. * @hidden
  116428. */
  116429. 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>);
  116430. }
  116431. /**
  116432. * Represents a Depth Sorted Particle in the solid particle system.
  116433. * @hidden
  116434. */
  116435. export class DepthSortedParticle {
  116436. /**
  116437. * Particle index
  116438. */
  116439. idx: number;
  116440. /**
  116441. * Index of the particle in the "indices" array
  116442. */
  116443. ind: number;
  116444. /**
  116445. * Length of the particle shape in the "indices" array
  116446. */
  116447. indicesLength: number;
  116448. /**
  116449. * Squared distance from the particle to the camera
  116450. */
  116451. sqDistance: number;
  116452. /**
  116453. * Material index when used with MultiMaterials
  116454. */
  116455. materialIndex: number;
  116456. /**
  116457. * Creates a new sorted particle
  116458. * @param materialIndex
  116459. */
  116460. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  116461. }
  116462. /**
  116463. * Represents a solid particle vertex
  116464. */
  116465. export class SolidParticleVertex {
  116466. /**
  116467. * Vertex position
  116468. */
  116469. position: Vector3;
  116470. /**
  116471. * Vertex color
  116472. */
  116473. color: Color4;
  116474. /**
  116475. * Vertex UV
  116476. */
  116477. uv: Vector2;
  116478. /**
  116479. * Creates a new solid particle vertex
  116480. */
  116481. constructor();
  116482. /** Vertex x coordinate */
  116483. get x(): number;
  116484. set x(val: number);
  116485. /** Vertex y coordinate */
  116486. get y(): number;
  116487. set y(val: number);
  116488. /** Vertex z coordinate */
  116489. get z(): number;
  116490. set z(val: number);
  116491. }
  116492. }
  116493. declare module BABYLON {
  116494. /**
  116495. * @hidden
  116496. */
  116497. export class _MeshCollisionData {
  116498. _checkCollisions: boolean;
  116499. _collisionMask: number;
  116500. _collisionGroup: number;
  116501. _surroundingMeshes: Nullable<AbstractMesh[]>;
  116502. _collider: Nullable<Collider>;
  116503. _oldPositionForCollisions: Vector3;
  116504. _diffPositionForCollisions: Vector3;
  116505. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  116506. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  116507. _collisionResponse: boolean;
  116508. }
  116509. }
  116510. declare module BABYLON {
  116511. /** @hidden */
  116512. class _FacetDataStorage {
  116513. facetPositions: Vector3[];
  116514. facetNormals: Vector3[];
  116515. facetPartitioning: number[][];
  116516. facetNb: number;
  116517. partitioningSubdivisions: number;
  116518. partitioningBBoxRatio: number;
  116519. facetDataEnabled: boolean;
  116520. facetParameters: any;
  116521. bbSize: Vector3;
  116522. subDiv: {
  116523. max: number;
  116524. X: number;
  116525. Y: number;
  116526. Z: number;
  116527. };
  116528. facetDepthSort: boolean;
  116529. facetDepthSortEnabled: boolean;
  116530. depthSortedIndices: IndicesArray;
  116531. depthSortedFacets: {
  116532. ind: number;
  116533. sqDistance: number;
  116534. }[];
  116535. facetDepthSortFunction: (f1: {
  116536. ind: number;
  116537. sqDistance: number;
  116538. }, f2: {
  116539. ind: number;
  116540. sqDistance: number;
  116541. }) => number;
  116542. facetDepthSortFrom: Vector3;
  116543. facetDepthSortOrigin: Vector3;
  116544. invertedMatrix: Matrix;
  116545. }
  116546. /**
  116547. * @hidden
  116548. **/
  116549. class _InternalAbstractMeshDataInfo {
  116550. _hasVertexAlpha: boolean;
  116551. _useVertexColors: boolean;
  116552. _numBoneInfluencers: number;
  116553. _applyFog: boolean;
  116554. _receiveShadows: boolean;
  116555. _facetData: _FacetDataStorage;
  116556. _visibility: number;
  116557. _skeleton: Nullable<Skeleton>;
  116558. _layerMask: number;
  116559. _computeBonesUsingShaders: boolean;
  116560. _isActive: boolean;
  116561. _onlyForInstances: boolean;
  116562. _isActiveIntermediate: boolean;
  116563. _onlyForInstancesIntermediate: boolean;
  116564. _actAsRegularMesh: boolean;
  116565. _currentLOD: Nullable<AbstractMesh>;
  116566. }
  116567. /**
  116568. * Class used to store all common mesh properties
  116569. */
  116570. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  116571. /** No occlusion */
  116572. static OCCLUSION_TYPE_NONE: number;
  116573. /** Occlusion set to optimisitic */
  116574. static OCCLUSION_TYPE_OPTIMISTIC: number;
  116575. /** Occlusion set to strict */
  116576. static OCCLUSION_TYPE_STRICT: number;
  116577. /** Use an accurante occlusion algorithm */
  116578. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  116579. /** Use a conservative occlusion algorithm */
  116580. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  116581. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  116582. * Test order :
  116583. * Is the bounding sphere outside the frustum ?
  116584. * If not, are the bounding box vertices outside the frustum ?
  116585. * It not, then the cullable object is in the frustum.
  116586. */
  116587. static readonly CULLINGSTRATEGY_STANDARD: number;
  116588. /** Culling strategy : Bounding Sphere Only.
  116589. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  116590. * It's also less accurate than the standard because some not visible objects can still be selected.
  116591. * Test : is the bounding sphere outside the frustum ?
  116592. * If not, then the cullable object is in the frustum.
  116593. */
  116594. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  116595. /** Culling strategy : Optimistic Inclusion.
  116596. * This in an inclusion test first, then the standard exclusion test.
  116597. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  116598. * 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.
  116599. * Anyway, it's as accurate as the standard strategy.
  116600. * Test :
  116601. * Is the cullable object bounding sphere center in the frustum ?
  116602. * If not, apply the default culling strategy.
  116603. */
  116604. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  116605. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  116606. * This in an inclusion test first, then the bounding sphere only exclusion test.
  116607. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  116608. * 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.
  116609. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  116610. * Test :
  116611. * Is the cullable object bounding sphere center in the frustum ?
  116612. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  116613. */
  116614. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  116615. /**
  116616. * No billboard
  116617. */
  116618. static get BILLBOARDMODE_NONE(): number;
  116619. /** Billboard on X axis */
  116620. static get BILLBOARDMODE_X(): number;
  116621. /** Billboard on Y axis */
  116622. static get BILLBOARDMODE_Y(): number;
  116623. /** Billboard on Z axis */
  116624. static get BILLBOARDMODE_Z(): number;
  116625. /** Billboard on all axes */
  116626. static get BILLBOARDMODE_ALL(): number;
  116627. /** Billboard on using position instead of orientation */
  116628. static get BILLBOARDMODE_USE_POSITION(): number;
  116629. /** @hidden */
  116630. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  116631. /**
  116632. * The culling strategy to use to check whether the mesh must be rendered or not.
  116633. * This value can be changed at any time and will be used on the next render mesh selection.
  116634. * The possible values are :
  116635. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116636. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116637. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116638. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116639. * Please read each static variable documentation to get details about the culling process.
  116640. * */
  116641. cullingStrategy: number;
  116642. /**
  116643. * Gets the number of facets in the mesh
  116644. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116645. */
  116646. get facetNb(): number;
  116647. /**
  116648. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  116649. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116650. */
  116651. get partitioningSubdivisions(): number;
  116652. set partitioningSubdivisions(nb: number);
  116653. /**
  116654. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  116655. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  116656. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116657. */
  116658. get partitioningBBoxRatio(): number;
  116659. set partitioningBBoxRatio(ratio: number);
  116660. /**
  116661. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  116662. * Works only for updatable meshes.
  116663. * Doesn't work with multi-materials
  116664. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116665. */
  116666. get mustDepthSortFacets(): boolean;
  116667. set mustDepthSortFacets(sort: boolean);
  116668. /**
  116669. * The location (Vector3) where the facet depth sort must be computed from.
  116670. * By default, the active camera position.
  116671. * Used only when facet depth sort is enabled
  116672. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116673. */
  116674. get facetDepthSortFrom(): Vector3;
  116675. set facetDepthSortFrom(location: Vector3);
  116676. /**
  116677. * gets a boolean indicating if facetData is enabled
  116678. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116679. */
  116680. get isFacetDataEnabled(): boolean;
  116681. /** @hidden */
  116682. _updateNonUniformScalingState(value: boolean): boolean;
  116683. /**
  116684. * An event triggered when this mesh collides with another one
  116685. */
  116686. onCollideObservable: Observable<AbstractMesh>;
  116687. /** Set a function to call when this mesh collides with another one */
  116688. set onCollide(callback: () => void);
  116689. /**
  116690. * An event triggered when the collision's position changes
  116691. */
  116692. onCollisionPositionChangeObservable: Observable<Vector3>;
  116693. /** Set a function to call when the collision's position changes */
  116694. set onCollisionPositionChange(callback: () => void);
  116695. /**
  116696. * An event triggered when material is changed
  116697. */
  116698. onMaterialChangedObservable: Observable<AbstractMesh>;
  116699. /**
  116700. * Gets or sets the orientation for POV movement & rotation
  116701. */
  116702. definedFacingForward: boolean;
  116703. /** @hidden */
  116704. _occlusionQuery: Nullable<WebGLQuery>;
  116705. /** @hidden */
  116706. _renderingGroup: Nullable<RenderingGroup>;
  116707. /**
  116708. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116709. */
  116710. get visibility(): number;
  116711. /**
  116712. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116713. */
  116714. set visibility(value: number);
  116715. /** Gets or sets the alpha index used to sort transparent meshes
  116716. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  116717. */
  116718. alphaIndex: number;
  116719. /**
  116720. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  116721. */
  116722. isVisible: boolean;
  116723. /**
  116724. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  116725. */
  116726. isPickable: boolean;
  116727. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  116728. showSubMeshesBoundingBox: boolean;
  116729. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  116730. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116731. */
  116732. isBlocker: boolean;
  116733. /**
  116734. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  116735. */
  116736. enablePointerMoveEvents: boolean;
  116737. private _renderingGroupId;
  116738. /**
  116739. * Specifies the rendering group id for this mesh (0 by default)
  116740. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  116741. */
  116742. get renderingGroupId(): number;
  116743. set renderingGroupId(value: number);
  116744. private _material;
  116745. /** Gets or sets current material */
  116746. get material(): Nullable<Material>;
  116747. set material(value: Nullable<Material>);
  116748. /**
  116749. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  116750. * @see https://doc.babylonjs.com/babylon101/shadows
  116751. */
  116752. get receiveShadows(): boolean;
  116753. set receiveShadows(value: boolean);
  116754. /** Defines color to use when rendering outline */
  116755. outlineColor: Color3;
  116756. /** Define width to use when rendering outline */
  116757. outlineWidth: number;
  116758. /** Defines color to use when rendering overlay */
  116759. overlayColor: Color3;
  116760. /** Defines alpha to use when rendering overlay */
  116761. overlayAlpha: number;
  116762. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  116763. get hasVertexAlpha(): boolean;
  116764. set hasVertexAlpha(value: boolean);
  116765. /** 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) */
  116766. get useVertexColors(): boolean;
  116767. set useVertexColors(value: boolean);
  116768. /**
  116769. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  116770. */
  116771. get computeBonesUsingShaders(): boolean;
  116772. set computeBonesUsingShaders(value: boolean);
  116773. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  116774. get numBoneInfluencers(): number;
  116775. set numBoneInfluencers(value: number);
  116776. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  116777. get applyFog(): boolean;
  116778. set applyFog(value: boolean);
  116779. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  116780. useOctreeForRenderingSelection: boolean;
  116781. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  116782. useOctreeForPicking: boolean;
  116783. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  116784. useOctreeForCollisions: boolean;
  116785. /**
  116786. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  116787. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  116788. */
  116789. get layerMask(): number;
  116790. set layerMask(value: number);
  116791. /**
  116792. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  116793. */
  116794. alwaysSelectAsActiveMesh: boolean;
  116795. /**
  116796. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  116797. */
  116798. doNotSyncBoundingInfo: boolean;
  116799. /**
  116800. * Gets or sets the current action manager
  116801. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116802. */
  116803. actionManager: Nullable<AbstractActionManager>;
  116804. private _meshCollisionData;
  116805. /**
  116806. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  116807. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116808. */
  116809. ellipsoid: Vector3;
  116810. /**
  116811. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  116812. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116813. */
  116814. ellipsoidOffset: Vector3;
  116815. /**
  116816. * Gets or sets a collision mask used to mask collisions (default is -1).
  116817. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116818. */
  116819. get collisionMask(): number;
  116820. set collisionMask(mask: number);
  116821. /**
  116822. * Gets or sets a collision response flag (default is true).
  116823. * when collisionResponse is false, events are still triggered but colliding entity has no response
  116824. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  116825. * to respond to the collision.
  116826. */
  116827. get collisionResponse(): boolean;
  116828. set collisionResponse(response: boolean);
  116829. /**
  116830. * Gets or sets the current collision group mask (-1 by default).
  116831. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116832. */
  116833. get collisionGroup(): number;
  116834. set collisionGroup(mask: number);
  116835. /**
  116836. * Gets or sets current surrounding meshes (null by default).
  116837. *
  116838. * By default collision detection is tested against every mesh in the scene.
  116839. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  116840. * meshes will be tested for the collision.
  116841. *
  116842. * Note: if set to an empty array no collision will happen when this mesh is moved.
  116843. */
  116844. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  116845. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  116846. /**
  116847. * Defines edge width used when edgesRenderer is enabled
  116848. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116849. */
  116850. edgesWidth: number;
  116851. /**
  116852. * Defines edge color used when edgesRenderer is enabled
  116853. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116854. */
  116855. edgesColor: Color4;
  116856. /** @hidden */
  116857. _edgesRenderer: Nullable<IEdgesRenderer>;
  116858. /** @hidden */
  116859. _masterMesh: Nullable<AbstractMesh>;
  116860. /** @hidden */
  116861. _boundingInfo: Nullable<BoundingInfo>;
  116862. /** @hidden */
  116863. _renderId: number;
  116864. /**
  116865. * Gets or sets the list of subMeshes
  116866. * @see https://doc.babylonjs.com/how_to/multi_materials
  116867. */
  116868. subMeshes: SubMesh[];
  116869. /** @hidden */
  116870. _intersectionsInProgress: AbstractMesh[];
  116871. /** @hidden */
  116872. _unIndexed: boolean;
  116873. /** @hidden */
  116874. _lightSources: Light[];
  116875. /** Gets the list of lights affecting that mesh */
  116876. get lightSources(): Light[];
  116877. /** @hidden */
  116878. get _positions(): Nullable<Vector3[]>;
  116879. /** @hidden */
  116880. _waitingData: {
  116881. lods: Nullable<any>;
  116882. actions: Nullable<any>;
  116883. freezeWorldMatrix: Nullable<boolean>;
  116884. };
  116885. /** @hidden */
  116886. _bonesTransformMatrices: Nullable<Float32Array>;
  116887. /** @hidden */
  116888. _transformMatrixTexture: Nullable<RawTexture>;
  116889. /**
  116890. * Gets or sets a skeleton to apply skining transformations
  116891. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  116892. */
  116893. set skeleton(value: Nullable<Skeleton>);
  116894. get skeleton(): Nullable<Skeleton>;
  116895. /**
  116896. * An event triggered when the mesh is rebuilt.
  116897. */
  116898. onRebuildObservable: Observable<AbstractMesh>;
  116899. /**
  116900. * Creates a new AbstractMesh
  116901. * @param name defines the name of the mesh
  116902. * @param scene defines the hosting scene
  116903. */
  116904. constructor(name: string, scene?: Nullable<Scene>);
  116905. /**
  116906. * Returns the string "AbstractMesh"
  116907. * @returns "AbstractMesh"
  116908. */
  116909. getClassName(): string;
  116910. /**
  116911. * Gets a string representation of the current mesh
  116912. * @param fullDetails defines a boolean indicating if full details must be included
  116913. * @returns a string representation of the current mesh
  116914. */
  116915. toString(fullDetails?: boolean): string;
  116916. /**
  116917. * @hidden
  116918. */
  116919. protected _getEffectiveParent(): Nullable<Node>;
  116920. /** @hidden */
  116921. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116922. /** @hidden */
  116923. _rebuild(): void;
  116924. /** @hidden */
  116925. _resyncLightSources(): void;
  116926. /** @hidden */
  116927. _resyncLightSource(light: Light): void;
  116928. /** @hidden */
  116929. _unBindEffect(): void;
  116930. /** @hidden */
  116931. _removeLightSource(light: Light, dispose: boolean): void;
  116932. private _markSubMeshesAsDirty;
  116933. /** @hidden */
  116934. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  116935. /** @hidden */
  116936. _markSubMeshesAsAttributesDirty(): void;
  116937. /** @hidden */
  116938. _markSubMeshesAsMiscDirty(): void;
  116939. /**
  116940. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  116941. */
  116942. get scaling(): Vector3;
  116943. set scaling(newScaling: Vector3);
  116944. /**
  116945. * Returns true if the mesh is blocked. Implemented by child classes
  116946. */
  116947. get isBlocked(): boolean;
  116948. /**
  116949. * Returns the mesh itself by default. Implemented by child classes
  116950. * @param camera defines the camera to use to pick the right LOD level
  116951. * @returns the currentAbstractMesh
  116952. */
  116953. getLOD(camera: Camera): Nullable<AbstractMesh>;
  116954. /**
  116955. * Returns 0 by default. Implemented by child classes
  116956. * @returns an integer
  116957. */
  116958. getTotalVertices(): number;
  116959. /**
  116960. * Returns a positive integer : the total number of indices in this mesh geometry.
  116961. * @returns the numner of indices or zero if the mesh has no geometry.
  116962. */
  116963. getTotalIndices(): number;
  116964. /**
  116965. * Returns null by default. Implemented by child classes
  116966. * @returns null
  116967. */
  116968. getIndices(): Nullable<IndicesArray>;
  116969. /**
  116970. * Returns the array of the requested vertex data kind. Implemented by child classes
  116971. * @param kind defines the vertex data kind to use
  116972. * @returns null
  116973. */
  116974. getVerticesData(kind: string): Nullable<FloatArray>;
  116975. /**
  116976. * Sets the vertex data of the mesh geometry for the requested `kind`.
  116977. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  116978. * Note that a new underlying VertexBuffer object is created each call.
  116979. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  116980. * @param kind defines vertex data kind:
  116981. * * VertexBuffer.PositionKind
  116982. * * VertexBuffer.UVKind
  116983. * * VertexBuffer.UV2Kind
  116984. * * VertexBuffer.UV3Kind
  116985. * * VertexBuffer.UV4Kind
  116986. * * VertexBuffer.UV5Kind
  116987. * * VertexBuffer.UV6Kind
  116988. * * VertexBuffer.ColorKind
  116989. * * VertexBuffer.MatricesIndicesKind
  116990. * * VertexBuffer.MatricesIndicesExtraKind
  116991. * * VertexBuffer.MatricesWeightsKind
  116992. * * VertexBuffer.MatricesWeightsExtraKind
  116993. * @param data defines the data source
  116994. * @param updatable defines if the data must be flagged as updatable (or static)
  116995. * @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
  116996. * @returns the current mesh
  116997. */
  116998. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  116999. /**
  117000. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  117001. * If the mesh has no geometry, it is simply returned as it is.
  117002. * @param kind defines vertex data kind:
  117003. * * VertexBuffer.PositionKind
  117004. * * VertexBuffer.UVKind
  117005. * * VertexBuffer.UV2Kind
  117006. * * VertexBuffer.UV3Kind
  117007. * * VertexBuffer.UV4Kind
  117008. * * VertexBuffer.UV5Kind
  117009. * * VertexBuffer.UV6Kind
  117010. * * VertexBuffer.ColorKind
  117011. * * VertexBuffer.MatricesIndicesKind
  117012. * * VertexBuffer.MatricesIndicesExtraKind
  117013. * * VertexBuffer.MatricesWeightsKind
  117014. * * VertexBuffer.MatricesWeightsExtraKind
  117015. * @param data defines the data source
  117016. * @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
  117017. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  117018. * @returns the current mesh
  117019. */
  117020. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  117021. /**
  117022. * Sets the mesh indices,
  117023. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  117024. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  117025. * @param totalVertices Defines the total number of vertices
  117026. * @returns the current mesh
  117027. */
  117028. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  117029. /**
  117030. * Gets a boolean indicating if specific vertex data is present
  117031. * @param kind defines the vertex data kind to use
  117032. * @returns true is data kind is present
  117033. */
  117034. isVerticesDataPresent(kind: string): boolean;
  117035. /**
  117036. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  117037. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  117038. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  117039. * @returns a BoundingInfo
  117040. */
  117041. getBoundingInfo(): BoundingInfo;
  117042. /**
  117043. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  117044. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  117045. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  117046. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  117047. * @returns the current mesh
  117048. */
  117049. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  117050. /**
  117051. * Overwrite the current bounding info
  117052. * @param boundingInfo defines the new bounding info
  117053. * @returns the current mesh
  117054. */
  117055. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  117056. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  117057. get useBones(): boolean;
  117058. /** @hidden */
  117059. _preActivate(): void;
  117060. /** @hidden */
  117061. _preActivateForIntermediateRendering(renderId: number): void;
  117062. /** @hidden */
  117063. _activate(renderId: number, intermediateRendering: boolean): boolean;
  117064. /** @hidden */
  117065. _postActivate(): void;
  117066. /** @hidden */
  117067. _freeze(): void;
  117068. /** @hidden */
  117069. _unFreeze(): void;
  117070. /**
  117071. * Gets the current world matrix
  117072. * @returns a Matrix
  117073. */
  117074. getWorldMatrix(): Matrix;
  117075. /** @hidden */
  117076. _getWorldMatrixDeterminant(): number;
  117077. /**
  117078. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  117079. */
  117080. get isAnInstance(): boolean;
  117081. /**
  117082. * Gets a boolean indicating if this mesh has instances
  117083. */
  117084. get hasInstances(): boolean;
  117085. /**
  117086. * Gets a boolean indicating if this mesh has thin instances
  117087. */
  117088. get hasThinInstances(): boolean;
  117089. /**
  117090. * Perform relative position change from the point of view of behind the front of the mesh.
  117091. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117092. * Supports definition of mesh facing forward or backward
  117093. * @param amountRight defines the distance on the right axis
  117094. * @param amountUp defines the distance on the up axis
  117095. * @param amountForward defines the distance on the forward axis
  117096. * @returns the current mesh
  117097. */
  117098. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  117099. /**
  117100. * Calculate relative position change from the point of view of behind the front of the mesh.
  117101. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117102. * Supports definition of mesh facing forward or backward
  117103. * @param amountRight defines the distance on the right axis
  117104. * @param amountUp defines the distance on the up axis
  117105. * @param amountForward defines the distance on the forward axis
  117106. * @returns the new displacement vector
  117107. */
  117108. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  117109. /**
  117110. * Perform relative rotation change from the point of view of behind the front of the mesh.
  117111. * Supports definition of mesh facing forward or backward
  117112. * @param flipBack defines the flip
  117113. * @param twirlClockwise defines the twirl
  117114. * @param tiltRight defines the tilt
  117115. * @returns the current mesh
  117116. */
  117117. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  117118. /**
  117119. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  117120. * Supports definition of mesh facing forward or backward.
  117121. * @param flipBack defines the flip
  117122. * @param twirlClockwise defines the twirl
  117123. * @param tiltRight defines the tilt
  117124. * @returns the new rotation vector
  117125. */
  117126. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  117127. /**
  117128. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  117129. * This means the mesh underlying bounding box and sphere are recomputed.
  117130. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  117131. * @returns the current mesh
  117132. */
  117133. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  117134. /** @hidden */
  117135. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  117136. /** @hidden */
  117137. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  117138. /** @hidden */
  117139. _updateBoundingInfo(): AbstractMesh;
  117140. /** @hidden */
  117141. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  117142. /** @hidden */
  117143. protected _afterComputeWorldMatrix(): void;
  117144. /** @hidden */
  117145. get _effectiveMesh(): AbstractMesh;
  117146. /**
  117147. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  117148. * A mesh is in the frustum if its bounding box intersects the frustum
  117149. * @param frustumPlanes defines the frustum to test
  117150. * @returns true if the mesh is in the frustum planes
  117151. */
  117152. isInFrustum(frustumPlanes: Plane[]): boolean;
  117153. /**
  117154. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  117155. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  117156. * @param frustumPlanes defines the frustum to test
  117157. * @returns true if the mesh is completely in the frustum planes
  117158. */
  117159. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  117160. /**
  117161. * True if the mesh intersects another mesh or a SolidParticle object
  117162. * @param mesh defines a target mesh or SolidParticle to test
  117163. * @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)
  117164. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  117165. * @returns true if there is an intersection
  117166. */
  117167. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  117168. /**
  117169. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  117170. * @param point defines the point to test
  117171. * @returns true if there is an intersection
  117172. */
  117173. intersectsPoint(point: Vector3): boolean;
  117174. /**
  117175. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  117176. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117177. */
  117178. get checkCollisions(): boolean;
  117179. set checkCollisions(collisionEnabled: boolean);
  117180. /**
  117181. * Gets Collider object used to compute collisions (not physics)
  117182. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117183. */
  117184. get collider(): Nullable<Collider>;
  117185. /**
  117186. * Move the mesh using collision engine
  117187. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117188. * @param displacement defines the requested displacement vector
  117189. * @returns the current mesh
  117190. */
  117191. moveWithCollisions(displacement: Vector3): AbstractMesh;
  117192. private _onCollisionPositionChange;
  117193. /** @hidden */
  117194. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  117195. /** @hidden */
  117196. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  117197. /** @hidden */
  117198. _checkCollision(collider: Collider): AbstractMesh;
  117199. /** @hidden */
  117200. _generatePointsArray(): boolean;
  117201. /**
  117202. * Checks if the passed Ray intersects with the mesh
  117203. * @param ray defines the ray to use
  117204. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  117205. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117206. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  117207. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  117208. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  117209. * @returns the picking info
  117210. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  117211. */
  117212. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  117213. /**
  117214. * Clones the current mesh
  117215. * @param name defines the mesh name
  117216. * @param newParent defines the new mesh parent
  117217. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  117218. * @returns the new mesh
  117219. */
  117220. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  117221. /**
  117222. * Disposes all the submeshes of the current meshnp
  117223. * @returns the current mesh
  117224. */
  117225. releaseSubMeshes(): AbstractMesh;
  117226. /**
  117227. * Releases resources associated with this abstract mesh.
  117228. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117229. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117230. */
  117231. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117232. /**
  117233. * Adds the passed mesh as a child to the current mesh
  117234. * @param mesh defines the child mesh
  117235. * @returns the current mesh
  117236. */
  117237. addChild(mesh: AbstractMesh): AbstractMesh;
  117238. /**
  117239. * Removes the passed mesh from the current mesh children list
  117240. * @param mesh defines the child mesh
  117241. * @returns the current mesh
  117242. */
  117243. removeChild(mesh: AbstractMesh): AbstractMesh;
  117244. /** @hidden */
  117245. private _initFacetData;
  117246. /**
  117247. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  117248. * This method can be called within the render loop.
  117249. * 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
  117250. * @returns the current mesh
  117251. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117252. */
  117253. updateFacetData(): AbstractMesh;
  117254. /**
  117255. * Returns the facetLocalNormals array.
  117256. * The normals are expressed in the mesh local spac
  117257. * @returns an array of Vector3
  117258. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117259. */
  117260. getFacetLocalNormals(): Vector3[];
  117261. /**
  117262. * Returns the facetLocalPositions array.
  117263. * The facet positions are expressed in the mesh local space
  117264. * @returns an array of Vector3
  117265. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117266. */
  117267. getFacetLocalPositions(): Vector3[];
  117268. /**
  117269. * Returns the facetLocalPartioning array
  117270. * @returns an array of array of numbers
  117271. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117272. */
  117273. getFacetLocalPartitioning(): number[][];
  117274. /**
  117275. * Returns the i-th facet position in the world system.
  117276. * This method allocates a new Vector3 per call
  117277. * @param i defines the facet index
  117278. * @returns a new Vector3
  117279. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117280. */
  117281. getFacetPosition(i: number): Vector3;
  117282. /**
  117283. * Sets the reference Vector3 with the i-th facet position in the world system
  117284. * @param i defines the facet index
  117285. * @param ref defines the target vector
  117286. * @returns the current mesh
  117287. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117288. */
  117289. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  117290. /**
  117291. * Returns the i-th facet normal in the world system.
  117292. * This method allocates a new Vector3 per call
  117293. * @param i defines the facet index
  117294. * @returns a new Vector3
  117295. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117296. */
  117297. getFacetNormal(i: number): Vector3;
  117298. /**
  117299. * Sets the reference Vector3 with the i-th facet normal in the world system
  117300. * @param i defines the facet index
  117301. * @param ref defines the target vector
  117302. * @returns the current mesh
  117303. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117304. */
  117305. getFacetNormalToRef(i: number, ref: Vector3): this;
  117306. /**
  117307. * 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)
  117308. * @param x defines x coordinate
  117309. * @param y defines y coordinate
  117310. * @param z defines z coordinate
  117311. * @returns the array of facet indexes
  117312. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117313. */
  117314. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  117315. /**
  117316. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  117317. * @param projected sets as the (x,y,z) world projection on the facet
  117318. * @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
  117319. * @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
  117320. * @param x defines x coordinate
  117321. * @param y defines y coordinate
  117322. * @param z defines z coordinate
  117323. * @returns the face index if found (or null instead)
  117324. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117325. */
  117326. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117327. /**
  117328. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  117329. * @param projected sets as the (x,y,z) local projection on the facet
  117330. * @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
  117331. * @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
  117332. * @param x defines x coordinate
  117333. * @param y defines y coordinate
  117334. * @param z defines z coordinate
  117335. * @returns the face index if found (or null instead)
  117336. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117337. */
  117338. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117339. /**
  117340. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  117341. * @returns the parameters
  117342. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117343. */
  117344. getFacetDataParameters(): any;
  117345. /**
  117346. * Disables the feature FacetData and frees the related memory
  117347. * @returns the current mesh
  117348. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117349. */
  117350. disableFacetData(): AbstractMesh;
  117351. /**
  117352. * Updates the AbstractMesh indices array
  117353. * @param indices defines the data source
  117354. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  117355. * @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)
  117356. * @returns the current mesh
  117357. */
  117358. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  117359. /**
  117360. * Creates new normals data for the mesh
  117361. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  117362. * @returns the current mesh
  117363. */
  117364. createNormals(updatable: boolean): AbstractMesh;
  117365. /**
  117366. * Align the mesh with a normal
  117367. * @param normal defines the normal to use
  117368. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  117369. * @returns the current mesh
  117370. */
  117371. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  117372. /** @hidden */
  117373. _checkOcclusionQuery(): boolean;
  117374. /**
  117375. * Disables the mesh edge rendering mode
  117376. * @returns the currentAbstractMesh
  117377. */
  117378. disableEdgesRendering(): AbstractMesh;
  117379. /**
  117380. * Enables the edge rendering mode on the mesh.
  117381. * This mode makes the mesh edges visible
  117382. * @param epsilon defines the maximal distance between two angles to detect a face
  117383. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  117384. * @returns the currentAbstractMesh
  117385. * @see https://www.babylonjs-playground.com/#19O9TU#0
  117386. */
  117387. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  117388. /**
  117389. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  117390. * @returns an array of particle systems in the scene that use the mesh as an emitter
  117391. */
  117392. getConnectedParticleSystems(): IParticleSystem[];
  117393. }
  117394. }
  117395. declare module BABYLON {
  117396. /**
  117397. * Interface used to define ActionEvent
  117398. */
  117399. export interface IActionEvent {
  117400. /** The mesh or sprite that triggered the action */
  117401. source: any;
  117402. /** The X mouse cursor position at the time of the event */
  117403. pointerX: number;
  117404. /** The Y mouse cursor position at the time of the event */
  117405. pointerY: number;
  117406. /** The mesh that is currently pointed at (can be null) */
  117407. meshUnderPointer: Nullable<AbstractMesh>;
  117408. /** the original (browser) event that triggered the ActionEvent */
  117409. sourceEvent?: any;
  117410. /** additional data for the event */
  117411. additionalData?: any;
  117412. }
  117413. /**
  117414. * ActionEvent is the event being sent when an action is triggered.
  117415. */
  117416. export class ActionEvent implements IActionEvent {
  117417. /** The mesh or sprite that triggered the action */
  117418. source: any;
  117419. /** The X mouse cursor position at the time of the event */
  117420. pointerX: number;
  117421. /** The Y mouse cursor position at the time of the event */
  117422. pointerY: number;
  117423. /** The mesh that is currently pointed at (can be null) */
  117424. meshUnderPointer: Nullable<AbstractMesh>;
  117425. /** the original (browser) event that triggered the ActionEvent */
  117426. sourceEvent?: any;
  117427. /** additional data for the event */
  117428. additionalData?: any;
  117429. /**
  117430. * Creates a new ActionEvent
  117431. * @param source The mesh or sprite that triggered the action
  117432. * @param pointerX The X mouse cursor position at the time of the event
  117433. * @param pointerY The Y mouse cursor position at the time of the event
  117434. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  117435. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  117436. * @param additionalData additional data for the event
  117437. */
  117438. constructor(
  117439. /** The mesh or sprite that triggered the action */
  117440. source: any,
  117441. /** The X mouse cursor position at the time of the event */
  117442. pointerX: number,
  117443. /** The Y mouse cursor position at the time of the event */
  117444. pointerY: number,
  117445. /** The mesh that is currently pointed at (can be null) */
  117446. meshUnderPointer: Nullable<AbstractMesh>,
  117447. /** the original (browser) event that triggered the ActionEvent */
  117448. sourceEvent?: any,
  117449. /** additional data for the event */
  117450. additionalData?: any);
  117451. /**
  117452. * Helper function to auto-create an ActionEvent from a source mesh.
  117453. * @param source The source mesh that triggered the event
  117454. * @param evt The original (browser) event
  117455. * @param additionalData additional data for the event
  117456. * @returns the new ActionEvent
  117457. */
  117458. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  117459. /**
  117460. * Helper function to auto-create an ActionEvent from a source sprite
  117461. * @param source The source sprite that triggered the event
  117462. * @param scene Scene associated with the sprite
  117463. * @param evt The original (browser) event
  117464. * @param additionalData additional data for the event
  117465. * @returns the new ActionEvent
  117466. */
  117467. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  117468. /**
  117469. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  117470. * @param scene the scene where the event occurred
  117471. * @param evt The original (browser) event
  117472. * @returns the new ActionEvent
  117473. */
  117474. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  117475. /**
  117476. * Helper function to auto-create an ActionEvent from a primitive
  117477. * @param prim defines the target primitive
  117478. * @param pointerPos defines the pointer position
  117479. * @param evt The original (browser) event
  117480. * @param additionalData additional data for the event
  117481. * @returns the new ActionEvent
  117482. */
  117483. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  117484. }
  117485. }
  117486. declare module BABYLON {
  117487. /**
  117488. * Abstract class used to decouple action Manager from scene and meshes.
  117489. * Do not instantiate.
  117490. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117491. */
  117492. export abstract class AbstractActionManager implements IDisposable {
  117493. /** Gets the list of active triggers */
  117494. static Triggers: {
  117495. [key: string]: number;
  117496. };
  117497. /** Gets the cursor to use when hovering items */
  117498. hoverCursor: string;
  117499. /** Gets the list of actions */
  117500. actions: IAction[];
  117501. /**
  117502. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  117503. */
  117504. isRecursive: boolean;
  117505. /**
  117506. * Releases all associated resources
  117507. */
  117508. abstract dispose(): void;
  117509. /**
  117510. * Does this action manager has pointer triggers
  117511. */
  117512. abstract get hasPointerTriggers(): boolean;
  117513. /**
  117514. * Does this action manager has pick triggers
  117515. */
  117516. abstract get hasPickTriggers(): boolean;
  117517. /**
  117518. * Process a specific trigger
  117519. * @param trigger defines the trigger to process
  117520. * @param evt defines the event details to be processed
  117521. */
  117522. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  117523. /**
  117524. * Does this action manager handles actions of any of the given triggers
  117525. * @param triggers defines the triggers to be tested
  117526. * @return a boolean indicating whether one (or more) of the triggers is handled
  117527. */
  117528. abstract hasSpecificTriggers(triggers: number[]): boolean;
  117529. /**
  117530. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  117531. * speed.
  117532. * @param triggerA defines the trigger to be tested
  117533. * @param triggerB defines the trigger to be tested
  117534. * @return a boolean indicating whether one (or more) of the triggers is handled
  117535. */
  117536. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  117537. /**
  117538. * Does this action manager handles actions of a given trigger
  117539. * @param trigger defines the trigger to be tested
  117540. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  117541. * @return whether the trigger is handled
  117542. */
  117543. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  117544. /**
  117545. * Serialize this manager to a JSON object
  117546. * @param name defines the property name to store this manager
  117547. * @returns a JSON representation of this manager
  117548. */
  117549. abstract serialize(name: string): any;
  117550. /**
  117551. * Registers an action to this action manager
  117552. * @param action defines the action to be registered
  117553. * @return the action amended (prepared) after registration
  117554. */
  117555. abstract registerAction(action: IAction): Nullable<IAction>;
  117556. /**
  117557. * Unregisters an action to this action manager
  117558. * @param action defines the action to be unregistered
  117559. * @return a boolean indicating whether the action has been unregistered
  117560. */
  117561. abstract unregisterAction(action: IAction): Boolean;
  117562. /**
  117563. * Does exist one action manager with at least one trigger
  117564. **/
  117565. static get HasTriggers(): boolean;
  117566. /**
  117567. * Does exist one action manager with at least one pick trigger
  117568. **/
  117569. static get HasPickTriggers(): boolean;
  117570. /**
  117571. * Does exist one action manager that handles actions of a given trigger
  117572. * @param trigger defines the trigger to be tested
  117573. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  117574. **/
  117575. static HasSpecificTrigger(trigger: number): boolean;
  117576. }
  117577. }
  117578. declare module BABYLON {
  117579. /**
  117580. * Defines how a node can be built from a string name.
  117581. */
  117582. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  117583. /**
  117584. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  117585. */
  117586. export class Node implements IBehaviorAware<Node> {
  117587. /** @hidden */
  117588. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  117589. private static _NodeConstructors;
  117590. /**
  117591. * Add a new node constructor
  117592. * @param type defines the type name of the node to construct
  117593. * @param constructorFunc defines the constructor function
  117594. */
  117595. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  117596. /**
  117597. * Returns a node constructor based on type name
  117598. * @param type defines the type name
  117599. * @param name defines the new node name
  117600. * @param scene defines the hosting scene
  117601. * @param options defines optional options to transmit to constructors
  117602. * @returns the new constructor or null
  117603. */
  117604. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  117605. /**
  117606. * Gets or sets the name of the node
  117607. */
  117608. name: string;
  117609. /**
  117610. * Gets or sets the id of the node
  117611. */
  117612. id: string;
  117613. /**
  117614. * Gets or sets the unique id of the node
  117615. */
  117616. uniqueId: number;
  117617. /**
  117618. * Gets or sets a string used to store user defined state for the node
  117619. */
  117620. state: string;
  117621. /**
  117622. * Gets or sets an object used to store user defined information for the node
  117623. */
  117624. metadata: any;
  117625. /**
  117626. * For internal use only. Please do not use.
  117627. */
  117628. reservedDataStore: any;
  117629. /**
  117630. * List of inspectable custom properties (used by the Inspector)
  117631. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117632. */
  117633. inspectableCustomProperties: IInspectable[];
  117634. private _doNotSerialize;
  117635. /**
  117636. * Gets or sets a boolean used to define if the node must be serialized
  117637. */
  117638. get doNotSerialize(): boolean;
  117639. set doNotSerialize(value: boolean);
  117640. /** @hidden */
  117641. _isDisposed: boolean;
  117642. /**
  117643. * Gets a list of Animations associated with the node
  117644. */
  117645. animations: Animation[];
  117646. protected _ranges: {
  117647. [name: string]: Nullable<AnimationRange>;
  117648. };
  117649. /**
  117650. * Callback raised when the node is ready to be used
  117651. */
  117652. onReady: Nullable<(node: Node) => void>;
  117653. private _isEnabled;
  117654. private _isParentEnabled;
  117655. private _isReady;
  117656. /** @hidden */
  117657. _currentRenderId: number;
  117658. private _parentUpdateId;
  117659. /** @hidden */
  117660. _childUpdateId: number;
  117661. /** @hidden */
  117662. _waitingParentId: Nullable<string>;
  117663. /** @hidden */
  117664. _scene: Scene;
  117665. /** @hidden */
  117666. _cache: any;
  117667. private _parentNode;
  117668. private _children;
  117669. /** @hidden */
  117670. _worldMatrix: Matrix;
  117671. /** @hidden */
  117672. _worldMatrixDeterminant: number;
  117673. /** @hidden */
  117674. _worldMatrixDeterminantIsDirty: boolean;
  117675. /** @hidden */
  117676. private _sceneRootNodesIndex;
  117677. /**
  117678. * Gets a boolean indicating if the node has been disposed
  117679. * @returns true if the node was disposed
  117680. */
  117681. isDisposed(): boolean;
  117682. /**
  117683. * Gets or sets the parent of the node (without keeping the current position in the scene)
  117684. * @see https://doc.babylonjs.com/how_to/parenting
  117685. */
  117686. set parent(parent: Nullable<Node>);
  117687. get parent(): Nullable<Node>;
  117688. /** @hidden */
  117689. _addToSceneRootNodes(): void;
  117690. /** @hidden */
  117691. _removeFromSceneRootNodes(): void;
  117692. private _animationPropertiesOverride;
  117693. /**
  117694. * Gets or sets the animation properties override
  117695. */
  117696. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117697. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117698. /**
  117699. * Gets a string identifying the name of the class
  117700. * @returns "Node" string
  117701. */
  117702. getClassName(): string;
  117703. /** @hidden */
  117704. readonly _isNode: boolean;
  117705. /**
  117706. * An event triggered when the mesh is disposed
  117707. */
  117708. onDisposeObservable: Observable<Node>;
  117709. private _onDisposeObserver;
  117710. /**
  117711. * Sets a callback that will be raised when the node will be disposed
  117712. */
  117713. set onDispose(callback: () => void);
  117714. /**
  117715. * Creates a new Node
  117716. * @param name the name and id to be given to this node
  117717. * @param scene the scene this node will be added to
  117718. */
  117719. constructor(name: string, scene?: Nullable<Scene>);
  117720. /**
  117721. * Gets the scene of the node
  117722. * @returns a scene
  117723. */
  117724. getScene(): Scene;
  117725. /**
  117726. * Gets the engine of the node
  117727. * @returns a Engine
  117728. */
  117729. getEngine(): Engine;
  117730. private _behaviors;
  117731. /**
  117732. * Attach a behavior to the node
  117733. * @see https://doc.babylonjs.com/features/behaviour
  117734. * @param behavior defines the behavior to attach
  117735. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  117736. * @returns the current Node
  117737. */
  117738. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  117739. /**
  117740. * Remove an attached behavior
  117741. * @see https://doc.babylonjs.com/features/behaviour
  117742. * @param behavior defines the behavior to attach
  117743. * @returns the current Node
  117744. */
  117745. removeBehavior(behavior: Behavior<Node>): Node;
  117746. /**
  117747. * Gets the list of attached behaviors
  117748. * @see https://doc.babylonjs.com/features/behaviour
  117749. */
  117750. get behaviors(): Behavior<Node>[];
  117751. /**
  117752. * Gets an attached behavior by name
  117753. * @param name defines the name of the behavior to look for
  117754. * @see https://doc.babylonjs.com/features/behaviour
  117755. * @returns null if behavior was not found else the requested behavior
  117756. */
  117757. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  117758. /**
  117759. * Returns the latest update of the World matrix
  117760. * @returns a Matrix
  117761. */
  117762. getWorldMatrix(): Matrix;
  117763. /** @hidden */
  117764. _getWorldMatrixDeterminant(): number;
  117765. /**
  117766. * Returns directly the latest state of the mesh World matrix.
  117767. * A Matrix is returned.
  117768. */
  117769. get worldMatrixFromCache(): Matrix;
  117770. /** @hidden */
  117771. _initCache(): void;
  117772. /** @hidden */
  117773. updateCache(force?: boolean): void;
  117774. /** @hidden */
  117775. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117776. /** @hidden */
  117777. _updateCache(ignoreParentClass?: boolean): void;
  117778. /** @hidden */
  117779. _isSynchronized(): boolean;
  117780. /** @hidden */
  117781. _markSyncedWithParent(): void;
  117782. /** @hidden */
  117783. isSynchronizedWithParent(): boolean;
  117784. /** @hidden */
  117785. isSynchronized(): boolean;
  117786. /**
  117787. * Is this node ready to be used/rendered
  117788. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117789. * @return true if the node is ready
  117790. */
  117791. isReady(completeCheck?: boolean): boolean;
  117792. /**
  117793. * Is this node enabled?
  117794. * 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
  117795. * @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
  117796. * @return whether this node (and its parent) is enabled
  117797. */
  117798. isEnabled(checkAncestors?: boolean): boolean;
  117799. /** @hidden */
  117800. protected _syncParentEnabledState(): void;
  117801. /**
  117802. * Set the enabled state of this node
  117803. * @param value defines the new enabled state
  117804. */
  117805. setEnabled(value: boolean): void;
  117806. /**
  117807. * Is this node a descendant of the given node?
  117808. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  117809. * @param ancestor defines the parent node to inspect
  117810. * @returns a boolean indicating if this node is a descendant of the given node
  117811. */
  117812. isDescendantOf(ancestor: Node): boolean;
  117813. /** @hidden */
  117814. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  117815. /**
  117816. * Will return all nodes that have this node as ascendant
  117817. * @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
  117818. * @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
  117819. * @return all children nodes of all types
  117820. */
  117821. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  117822. /**
  117823. * Get all child-meshes of this node
  117824. * @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)
  117825. * @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
  117826. * @returns an array of AbstractMesh
  117827. */
  117828. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  117829. /**
  117830. * Get all direct children of this node
  117831. * @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
  117832. * @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)
  117833. * @returns an array of Node
  117834. */
  117835. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  117836. /** @hidden */
  117837. _setReady(state: boolean): void;
  117838. /**
  117839. * Get an animation by name
  117840. * @param name defines the name of the animation to look for
  117841. * @returns null if not found else the requested animation
  117842. */
  117843. getAnimationByName(name: string): Nullable<Animation>;
  117844. /**
  117845. * Creates an animation range for this node
  117846. * @param name defines the name of the range
  117847. * @param from defines the starting key
  117848. * @param to defines the end key
  117849. */
  117850. createAnimationRange(name: string, from: number, to: number): void;
  117851. /**
  117852. * Delete a specific animation range
  117853. * @param name defines the name of the range to delete
  117854. * @param deleteFrames defines if animation frames from the range must be deleted as well
  117855. */
  117856. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  117857. /**
  117858. * Get an animation range by name
  117859. * @param name defines the name of the animation range to look for
  117860. * @returns null if not found else the requested animation range
  117861. */
  117862. getAnimationRange(name: string): Nullable<AnimationRange>;
  117863. /**
  117864. * Gets the list of all animation ranges defined on this node
  117865. * @returns an array
  117866. */
  117867. getAnimationRanges(): Nullable<AnimationRange>[];
  117868. /**
  117869. * Will start the animation sequence
  117870. * @param name defines the range frames for animation sequence
  117871. * @param loop defines if the animation should loop (false by default)
  117872. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  117873. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  117874. * @returns the object created for this animation. If range does not exist, it will return null
  117875. */
  117876. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  117877. /**
  117878. * Serialize animation ranges into a JSON compatible object
  117879. * @returns serialization object
  117880. */
  117881. serializeAnimationRanges(): any;
  117882. /**
  117883. * Computes the world matrix of the node
  117884. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  117885. * @returns the world matrix
  117886. */
  117887. computeWorldMatrix(force?: boolean): Matrix;
  117888. /**
  117889. * Releases resources associated with this node.
  117890. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117891. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117892. */
  117893. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117894. /**
  117895. * Parse animation range data from a serialization object and store them into a given node
  117896. * @param node defines where to store the animation ranges
  117897. * @param parsedNode defines the serialization object to read data from
  117898. * @param scene defines the hosting scene
  117899. */
  117900. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  117901. /**
  117902. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  117903. * @param includeDescendants Include bounding info from descendants as well (true by default)
  117904. * @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
  117905. * @returns the new bounding vectors
  117906. */
  117907. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  117908. min: Vector3;
  117909. max: Vector3;
  117910. };
  117911. }
  117912. }
  117913. declare module BABYLON {
  117914. /**
  117915. * @hidden
  117916. */
  117917. export class _IAnimationState {
  117918. key: number;
  117919. repeatCount: number;
  117920. workValue?: any;
  117921. loopMode?: number;
  117922. offsetValue?: any;
  117923. highLimitValue?: any;
  117924. }
  117925. /**
  117926. * Class used to store any kind of animation
  117927. */
  117928. export class Animation {
  117929. /**Name of the animation */
  117930. name: string;
  117931. /**Property to animate */
  117932. targetProperty: string;
  117933. /**The frames per second of the animation */
  117934. framePerSecond: number;
  117935. /**The data type of the animation */
  117936. dataType: number;
  117937. /**The loop mode of the animation */
  117938. loopMode?: number | undefined;
  117939. /**Specifies if blending should be enabled */
  117940. enableBlending?: boolean | undefined;
  117941. /**
  117942. * Use matrix interpolation instead of using direct key value when animating matrices
  117943. */
  117944. static AllowMatricesInterpolation: boolean;
  117945. /**
  117946. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  117947. */
  117948. static AllowMatrixDecomposeForInterpolation: boolean;
  117949. /** Define the Url to load snippets */
  117950. static SnippetUrl: string;
  117951. /** Snippet ID if the animation was created from the snippet server */
  117952. snippetId: string;
  117953. /**
  117954. * Stores the key frames of the animation
  117955. */
  117956. private _keys;
  117957. /**
  117958. * Stores the easing function of the animation
  117959. */
  117960. private _easingFunction;
  117961. /**
  117962. * @hidden Internal use only
  117963. */
  117964. _runtimeAnimations: RuntimeAnimation[];
  117965. /**
  117966. * The set of event that will be linked to this animation
  117967. */
  117968. private _events;
  117969. /**
  117970. * Stores an array of target property paths
  117971. */
  117972. targetPropertyPath: string[];
  117973. /**
  117974. * Stores the blending speed of the animation
  117975. */
  117976. blendingSpeed: number;
  117977. /**
  117978. * Stores the animation ranges for the animation
  117979. */
  117980. private _ranges;
  117981. /**
  117982. * @hidden Internal use
  117983. */
  117984. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  117985. /**
  117986. * Sets up an animation
  117987. * @param property The property to animate
  117988. * @param animationType The animation type to apply
  117989. * @param framePerSecond The frames per second of the animation
  117990. * @param easingFunction The easing function used in the animation
  117991. * @returns The created animation
  117992. */
  117993. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  117994. /**
  117995. * Create and start an animation on a node
  117996. * @param name defines the name of the global animation that will be run on all nodes
  117997. * @param node defines the root node where the animation will take place
  117998. * @param targetProperty defines property to animate
  117999. * @param framePerSecond defines the number of frame per second yo use
  118000. * @param totalFrame defines the number of frames in total
  118001. * @param from defines the initial value
  118002. * @param to defines the final value
  118003. * @param loopMode defines which loop mode you want to use (off by default)
  118004. * @param easingFunction defines the easing function to use (linear by default)
  118005. * @param onAnimationEnd defines the callback to call when animation end
  118006. * @returns the animatable created for this animation
  118007. */
  118008. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118009. /**
  118010. * Create and start an animation on a node and its descendants
  118011. * @param name defines the name of the global animation that will be run on all nodes
  118012. * @param node defines the root node where the animation will take place
  118013. * @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
  118014. * @param targetProperty defines property to animate
  118015. * @param framePerSecond defines the number of frame per second to use
  118016. * @param totalFrame defines the number of frames in total
  118017. * @param from defines the initial value
  118018. * @param to defines the final value
  118019. * @param loopMode defines which loop mode you want to use (off by default)
  118020. * @param easingFunction defines the easing function to use (linear by default)
  118021. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  118022. * @returns the list of animatables created for all nodes
  118023. * @example https://www.babylonjs-playground.com/#MH0VLI
  118024. */
  118025. 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[]>;
  118026. /**
  118027. * Creates a new animation, merges it with the existing animations and starts it
  118028. * @param name Name of the animation
  118029. * @param node Node which contains the scene that begins the animations
  118030. * @param targetProperty Specifies which property to animate
  118031. * @param framePerSecond The frames per second of the animation
  118032. * @param totalFrame The total number of frames
  118033. * @param from The frame at the beginning of the animation
  118034. * @param to The frame at the end of the animation
  118035. * @param loopMode Specifies the loop mode of the animation
  118036. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  118037. * @param onAnimationEnd Callback to run once the animation is complete
  118038. * @returns Nullable animation
  118039. */
  118040. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118041. /**
  118042. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  118043. * @param sourceAnimation defines the Animation containing keyframes to convert
  118044. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  118045. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  118046. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  118047. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  118048. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  118049. */
  118050. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  118051. /**
  118052. * Transition property of an host to the target Value
  118053. * @param property The property to transition
  118054. * @param targetValue The target Value of the property
  118055. * @param host The object where the property to animate belongs
  118056. * @param scene Scene used to run the animation
  118057. * @param frameRate Framerate (in frame/s) to use
  118058. * @param transition The transition type we want to use
  118059. * @param duration The duration of the animation, in milliseconds
  118060. * @param onAnimationEnd Callback trigger at the end of the animation
  118061. * @returns Nullable animation
  118062. */
  118063. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  118064. /**
  118065. * Return the array of runtime animations currently using this animation
  118066. */
  118067. get runtimeAnimations(): RuntimeAnimation[];
  118068. /**
  118069. * Specifies if any of the runtime animations are currently running
  118070. */
  118071. get hasRunningRuntimeAnimations(): boolean;
  118072. /**
  118073. * Initializes the animation
  118074. * @param name Name of the animation
  118075. * @param targetProperty Property to animate
  118076. * @param framePerSecond The frames per second of the animation
  118077. * @param dataType The data type of the animation
  118078. * @param loopMode The loop mode of the animation
  118079. * @param enableBlending Specifies if blending should be enabled
  118080. */
  118081. constructor(
  118082. /**Name of the animation */
  118083. name: string,
  118084. /**Property to animate */
  118085. targetProperty: string,
  118086. /**The frames per second of the animation */
  118087. framePerSecond: number,
  118088. /**The data type of the animation */
  118089. dataType: number,
  118090. /**The loop mode of the animation */
  118091. loopMode?: number | undefined,
  118092. /**Specifies if blending should be enabled */
  118093. enableBlending?: boolean | undefined);
  118094. /**
  118095. * Converts the animation to a string
  118096. * @param fullDetails support for multiple levels of logging within scene loading
  118097. * @returns String form of the animation
  118098. */
  118099. toString(fullDetails?: boolean): string;
  118100. /**
  118101. * Add an event to this animation
  118102. * @param event Event to add
  118103. */
  118104. addEvent(event: AnimationEvent): void;
  118105. /**
  118106. * Remove all events found at the given frame
  118107. * @param frame The frame to remove events from
  118108. */
  118109. removeEvents(frame: number): void;
  118110. /**
  118111. * Retrieves all the events from the animation
  118112. * @returns Events from the animation
  118113. */
  118114. getEvents(): AnimationEvent[];
  118115. /**
  118116. * Creates an animation range
  118117. * @param name Name of the animation range
  118118. * @param from Starting frame of the animation range
  118119. * @param to Ending frame of the animation
  118120. */
  118121. createRange(name: string, from: number, to: number): void;
  118122. /**
  118123. * Deletes an animation range by name
  118124. * @param name Name of the animation range to delete
  118125. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  118126. */
  118127. deleteRange(name: string, deleteFrames?: boolean): void;
  118128. /**
  118129. * Gets the animation range by name, or null if not defined
  118130. * @param name Name of the animation range
  118131. * @returns Nullable animation range
  118132. */
  118133. getRange(name: string): Nullable<AnimationRange>;
  118134. /**
  118135. * Gets the key frames from the animation
  118136. * @returns The key frames of the animation
  118137. */
  118138. getKeys(): Array<IAnimationKey>;
  118139. /**
  118140. * Gets the highest frame rate of the animation
  118141. * @returns Highest frame rate of the animation
  118142. */
  118143. getHighestFrame(): number;
  118144. /**
  118145. * Gets the easing function of the animation
  118146. * @returns Easing function of the animation
  118147. */
  118148. getEasingFunction(): IEasingFunction;
  118149. /**
  118150. * Sets the easing function of the animation
  118151. * @param easingFunction A custom mathematical formula for animation
  118152. */
  118153. setEasingFunction(easingFunction: EasingFunction): void;
  118154. /**
  118155. * Interpolates a scalar linearly
  118156. * @param startValue Start value of the animation curve
  118157. * @param endValue End value of the animation curve
  118158. * @param gradient Scalar amount to interpolate
  118159. * @returns Interpolated scalar value
  118160. */
  118161. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  118162. /**
  118163. * Interpolates a scalar cubically
  118164. * @param startValue Start value of the animation curve
  118165. * @param outTangent End tangent of the animation
  118166. * @param endValue End value of the animation curve
  118167. * @param inTangent Start tangent of the animation curve
  118168. * @param gradient Scalar amount to interpolate
  118169. * @returns Interpolated scalar value
  118170. */
  118171. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  118172. /**
  118173. * Interpolates a quaternion using a spherical linear interpolation
  118174. * @param startValue Start value of the animation curve
  118175. * @param endValue End value of the animation curve
  118176. * @param gradient Scalar amount to interpolate
  118177. * @returns Interpolated quaternion value
  118178. */
  118179. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  118180. /**
  118181. * Interpolates a quaternion cubically
  118182. * @param startValue Start value of the animation curve
  118183. * @param outTangent End tangent of the animation curve
  118184. * @param endValue End value of the animation curve
  118185. * @param inTangent Start tangent of the animation curve
  118186. * @param gradient Scalar amount to interpolate
  118187. * @returns Interpolated quaternion value
  118188. */
  118189. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  118190. /**
  118191. * Interpolates a Vector3 linearl
  118192. * @param startValue Start value of the animation curve
  118193. * @param endValue End value of the animation curve
  118194. * @param gradient Scalar amount to interpolate
  118195. * @returns Interpolated scalar value
  118196. */
  118197. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  118198. /**
  118199. * Interpolates a Vector3 cubically
  118200. * @param startValue Start value of the animation curve
  118201. * @param outTangent End tangent of the animation
  118202. * @param endValue End value of the animation curve
  118203. * @param inTangent Start tangent of the animation curve
  118204. * @param gradient Scalar amount to interpolate
  118205. * @returns InterpolatedVector3 value
  118206. */
  118207. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  118208. /**
  118209. * Interpolates a Vector2 linearly
  118210. * @param startValue Start value of the animation curve
  118211. * @param endValue End value of the animation curve
  118212. * @param gradient Scalar amount to interpolate
  118213. * @returns Interpolated Vector2 value
  118214. */
  118215. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  118216. /**
  118217. * Interpolates a Vector2 cubically
  118218. * @param startValue Start value of the animation curve
  118219. * @param outTangent End tangent of the animation
  118220. * @param endValue End value of the animation curve
  118221. * @param inTangent Start tangent of the animation curve
  118222. * @param gradient Scalar amount to interpolate
  118223. * @returns Interpolated Vector2 value
  118224. */
  118225. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  118226. /**
  118227. * Interpolates a size linearly
  118228. * @param startValue Start value of the animation curve
  118229. * @param endValue End value of the animation curve
  118230. * @param gradient Scalar amount to interpolate
  118231. * @returns Interpolated Size value
  118232. */
  118233. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  118234. /**
  118235. * Interpolates a Color3 linearly
  118236. * @param startValue Start value of the animation curve
  118237. * @param endValue End value of the animation curve
  118238. * @param gradient Scalar amount to interpolate
  118239. * @returns Interpolated Color3 value
  118240. */
  118241. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  118242. /**
  118243. * Interpolates a Color4 linearly
  118244. * @param startValue Start value of the animation curve
  118245. * @param endValue End value of the animation curve
  118246. * @param gradient Scalar amount to interpolate
  118247. * @returns Interpolated Color3 value
  118248. */
  118249. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  118250. /**
  118251. * @hidden Internal use only
  118252. */
  118253. _getKeyValue(value: any): any;
  118254. /**
  118255. * @hidden Internal use only
  118256. */
  118257. _interpolate(currentFrame: number, state: _IAnimationState): any;
  118258. /**
  118259. * Defines the function to use to interpolate matrices
  118260. * @param startValue defines the start matrix
  118261. * @param endValue defines the end matrix
  118262. * @param gradient defines the gradient between both matrices
  118263. * @param result defines an optional target matrix where to store the interpolation
  118264. * @returns the interpolated matrix
  118265. */
  118266. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  118267. /**
  118268. * Makes a copy of the animation
  118269. * @returns Cloned animation
  118270. */
  118271. clone(): Animation;
  118272. /**
  118273. * Sets the key frames of the animation
  118274. * @param values The animation key frames to set
  118275. */
  118276. setKeys(values: Array<IAnimationKey>): void;
  118277. /**
  118278. * Serializes the animation to an object
  118279. * @returns Serialized object
  118280. */
  118281. serialize(): any;
  118282. /**
  118283. * Float animation type
  118284. */
  118285. static readonly ANIMATIONTYPE_FLOAT: number;
  118286. /**
  118287. * Vector3 animation type
  118288. */
  118289. static readonly ANIMATIONTYPE_VECTOR3: number;
  118290. /**
  118291. * Quaternion animation type
  118292. */
  118293. static readonly ANIMATIONTYPE_QUATERNION: number;
  118294. /**
  118295. * Matrix animation type
  118296. */
  118297. static readonly ANIMATIONTYPE_MATRIX: number;
  118298. /**
  118299. * Color3 animation type
  118300. */
  118301. static readonly ANIMATIONTYPE_COLOR3: number;
  118302. /**
  118303. * Color3 animation type
  118304. */
  118305. static readonly ANIMATIONTYPE_COLOR4: number;
  118306. /**
  118307. * Vector2 animation type
  118308. */
  118309. static readonly ANIMATIONTYPE_VECTOR2: number;
  118310. /**
  118311. * Size animation type
  118312. */
  118313. static readonly ANIMATIONTYPE_SIZE: number;
  118314. /**
  118315. * Relative Loop Mode
  118316. */
  118317. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  118318. /**
  118319. * Cycle Loop Mode
  118320. */
  118321. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  118322. /**
  118323. * Constant Loop Mode
  118324. */
  118325. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  118326. /** @hidden */
  118327. static _UniversalLerp(left: any, right: any, amount: number): any;
  118328. /**
  118329. * Parses an animation object and creates an animation
  118330. * @param parsedAnimation Parsed animation object
  118331. * @returns Animation object
  118332. */
  118333. static Parse(parsedAnimation: any): Animation;
  118334. /**
  118335. * Appends the serialized animations from the source animations
  118336. * @param source Source containing the animations
  118337. * @param destination Target to store the animations
  118338. */
  118339. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118340. /**
  118341. * Creates a new animation or an array of animations from a snippet saved in a remote file
  118342. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  118343. * @param url defines the url to load from
  118344. * @returns a promise that will resolve to the new animation or an array of animations
  118345. */
  118346. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  118347. /**
  118348. * Creates an animation or an array of animations from a snippet saved by the Inspector
  118349. * @param snippetId defines the snippet to load
  118350. * @returns a promise that will resolve to the new animation or a new array of animations
  118351. */
  118352. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  118353. }
  118354. }
  118355. declare module BABYLON {
  118356. /**
  118357. * Interface containing an array of animations
  118358. */
  118359. export interface IAnimatable {
  118360. /**
  118361. * Array of animations
  118362. */
  118363. animations: Nullable<Array<Animation>>;
  118364. }
  118365. }
  118366. declare module BABYLON {
  118367. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  118368. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118369. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118370. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118371. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118372. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118373. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118374. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118375. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118376. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118377. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118378. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118379. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118380. /**
  118381. * Decorator used to define property that can be serialized as reference to a camera
  118382. * @param sourceName defines the name of the property to decorate
  118383. */
  118384. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118385. /**
  118386. * Class used to help serialization objects
  118387. */
  118388. export class SerializationHelper {
  118389. /** @hidden */
  118390. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  118391. /** @hidden */
  118392. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  118393. /** @hidden */
  118394. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  118395. /** @hidden */
  118396. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  118397. /**
  118398. * Appends the serialized animations from the source animations
  118399. * @param source Source containing the animations
  118400. * @param destination Target to store the animations
  118401. */
  118402. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118403. /**
  118404. * Static function used to serialized a specific entity
  118405. * @param entity defines the entity to serialize
  118406. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  118407. * @returns a JSON compatible object representing the serialization of the entity
  118408. */
  118409. static Serialize<T>(entity: T, serializationObject?: any): any;
  118410. /**
  118411. * Creates a new entity from a serialization data object
  118412. * @param creationFunction defines a function used to instanciated the new entity
  118413. * @param source defines the source serialization data
  118414. * @param scene defines the hosting scene
  118415. * @param rootUrl defines the root url for resources
  118416. * @returns a new entity
  118417. */
  118418. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  118419. /**
  118420. * Clones an object
  118421. * @param creationFunction defines the function used to instanciate the new object
  118422. * @param source defines the source object
  118423. * @returns the cloned object
  118424. */
  118425. static Clone<T>(creationFunction: () => T, source: T): T;
  118426. /**
  118427. * Instanciates a new object based on a source one (some data will be shared between both object)
  118428. * @param creationFunction defines the function used to instanciate the new object
  118429. * @param source defines the source object
  118430. * @returns the new object
  118431. */
  118432. static Instanciate<T>(creationFunction: () => T, source: T): T;
  118433. }
  118434. }
  118435. declare module BABYLON {
  118436. /**
  118437. * Base class of all the textures in babylon.
  118438. * It groups all the common properties the materials, post process, lights... might need
  118439. * in order to make a correct use of the texture.
  118440. */
  118441. export class BaseTexture implements IAnimatable {
  118442. /**
  118443. * Default anisotropic filtering level for the application.
  118444. * It is set to 4 as a good tradeoff between perf and quality.
  118445. */
  118446. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  118447. /**
  118448. * Gets or sets the unique id of the texture
  118449. */
  118450. uniqueId: number;
  118451. /**
  118452. * Define the name of the texture.
  118453. */
  118454. name: string;
  118455. /**
  118456. * Gets or sets an object used to store user defined information.
  118457. */
  118458. metadata: any;
  118459. /**
  118460. * For internal use only. Please do not use.
  118461. */
  118462. reservedDataStore: any;
  118463. private _hasAlpha;
  118464. /**
  118465. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  118466. */
  118467. set hasAlpha(value: boolean);
  118468. get hasAlpha(): boolean;
  118469. /**
  118470. * Defines if the alpha value should be determined via the rgb values.
  118471. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  118472. */
  118473. getAlphaFromRGB: boolean;
  118474. /**
  118475. * Intensity or strength of the texture.
  118476. * It is commonly used by materials to fine tune the intensity of the texture
  118477. */
  118478. level: number;
  118479. /**
  118480. * Define the UV chanel to use starting from 0 and defaulting to 0.
  118481. * This is part of the texture as textures usually maps to one uv set.
  118482. */
  118483. coordinatesIndex: number;
  118484. protected _coordinatesMode: number;
  118485. /**
  118486. * How a texture is mapped.
  118487. *
  118488. * | Value | Type | Description |
  118489. * | ----- | ----------------------------------- | ----------- |
  118490. * | 0 | EXPLICIT_MODE | |
  118491. * | 1 | SPHERICAL_MODE | |
  118492. * | 2 | PLANAR_MODE | |
  118493. * | 3 | CUBIC_MODE | |
  118494. * | 4 | PROJECTION_MODE | |
  118495. * | 5 | SKYBOX_MODE | |
  118496. * | 6 | INVCUBIC_MODE | |
  118497. * | 7 | EQUIRECTANGULAR_MODE | |
  118498. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  118499. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  118500. */
  118501. set coordinatesMode(value: number);
  118502. get coordinatesMode(): number;
  118503. private _wrapU;
  118504. /**
  118505. * | Value | Type | Description |
  118506. * | ----- | ------------------ | ----------- |
  118507. * | 0 | CLAMP_ADDRESSMODE | |
  118508. * | 1 | WRAP_ADDRESSMODE | |
  118509. * | 2 | MIRROR_ADDRESSMODE | |
  118510. */
  118511. get wrapU(): number;
  118512. set wrapU(value: number);
  118513. private _wrapV;
  118514. /**
  118515. * | Value | Type | Description |
  118516. * | ----- | ------------------ | ----------- |
  118517. * | 0 | CLAMP_ADDRESSMODE | |
  118518. * | 1 | WRAP_ADDRESSMODE | |
  118519. * | 2 | MIRROR_ADDRESSMODE | |
  118520. */
  118521. get wrapV(): number;
  118522. set wrapV(value: number);
  118523. /**
  118524. * | Value | Type | Description |
  118525. * | ----- | ------------------ | ----------- |
  118526. * | 0 | CLAMP_ADDRESSMODE | |
  118527. * | 1 | WRAP_ADDRESSMODE | |
  118528. * | 2 | MIRROR_ADDRESSMODE | |
  118529. */
  118530. wrapR: number;
  118531. /**
  118532. * With compliant hardware and browser (supporting anisotropic filtering)
  118533. * this defines the level of anisotropic filtering in the texture.
  118534. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  118535. */
  118536. anisotropicFilteringLevel: number;
  118537. /**
  118538. * Define if the texture is a cube texture or if false a 2d texture.
  118539. */
  118540. get isCube(): boolean;
  118541. set isCube(value: boolean);
  118542. /**
  118543. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  118544. */
  118545. get is3D(): boolean;
  118546. set is3D(value: boolean);
  118547. /**
  118548. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  118549. */
  118550. get is2DArray(): boolean;
  118551. set is2DArray(value: boolean);
  118552. private _gammaSpace;
  118553. /**
  118554. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  118555. * HDR texture are usually stored in linear space.
  118556. * This only impacts the PBR and Background materials
  118557. */
  118558. get gammaSpace(): boolean;
  118559. set gammaSpace(gamma: boolean);
  118560. /**
  118561. * Gets or sets whether or not the texture contains RGBD data.
  118562. */
  118563. get isRGBD(): boolean;
  118564. set isRGBD(value: boolean);
  118565. /**
  118566. * Is Z inverted in the texture (useful in a cube texture).
  118567. */
  118568. invertZ: boolean;
  118569. /**
  118570. * Are mip maps generated for this texture or not.
  118571. */
  118572. get noMipmap(): boolean;
  118573. /**
  118574. * @hidden
  118575. */
  118576. lodLevelInAlpha: boolean;
  118577. /**
  118578. * With prefiltered texture, defined the offset used during the prefiltering steps.
  118579. */
  118580. get lodGenerationOffset(): number;
  118581. set lodGenerationOffset(value: number);
  118582. /**
  118583. * With prefiltered texture, defined the scale used during the prefiltering steps.
  118584. */
  118585. get lodGenerationScale(): number;
  118586. set lodGenerationScale(value: number);
  118587. /**
  118588. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  118589. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  118590. * average roughness values.
  118591. */
  118592. get linearSpecularLOD(): boolean;
  118593. set linearSpecularLOD(value: boolean);
  118594. /**
  118595. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  118596. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  118597. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  118598. */
  118599. get irradianceTexture(): Nullable<BaseTexture>;
  118600. set irradianceTexture(value: Nullable<BaseTexture>);
  118601. /**
  118602. * Define if the texture is a render target.
  118603. */
  118604. isRenderTarget: boolean;
  118605. /**
  118606. * Define the unique id of the texture in the scene.
  118607. */
  118608. get uid(): string;
  118609. /** @hidden */
  118610. _prefiltered: boolean;
  118611. /**
  118612. * Return a string representation of the texture.
  118613. * @returns the texture as a string
  118614. */
  118615. toString(): string;
  118616. /**
  118617. * Get the class name of the texture.
  118618. * @returns "BaseTexture"
  118619. */
  118620. getClassName(): string;
  118621. /**
  118622. * Define the list of animation attached to the texture.
  118623. */
  118624. animations: Animation[];
  118625. /**
  118626. * An event triggered when the texture is disposed.
  118627. */
  118628. onDisposeObservable: Observable<BaseTexture>;
  118629. private _onDisposeObserver;
  118630. /**
  118631. * Callback triggered when the texture has been disposed.
  118632. * Kept for back compatibility, you can use the onDisposeObservable instead.
  118633. */
  118634. set onDispose(callback: () => void);
  118635. /**
  118636. * Define the current state of the loading sequence when in delayed load mode.
  118637. */
  118638. delayLoadState: number;
  118639. protected _scene: Nullable<Scene>;
  118640. protected _engine: Nullable<ThinEngine>;
  118641. /** @hidden */
  118642. _texture: Nullable<InternalTexture>;
  118643. private _uid;
  118644. /**
  118645. * Define if the texture is preventinga material to render or not.
  118646. * If not and the texture is not ready, the engine will use a default black texture instead.
  118647. */
  118648. get isBlocking(): boolean;
  118649. /**
  118650. * Instantiates a new BaseTexture.
  118651. * Base class of all the textures in babylon.
  118652. * It groups all the common properties the materials, post process, lights... might need
  118653. * in order to make a correct use of the texture.
  118654. * @param sceneOrEngine Define the scene or engine the texture blongs to
  118655. */
  118656. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  118657. /**
  118658. * Get the scene the texture belongs to.
  118659. * @returns the scene or null if undefined
  118660. */
  118661. getScene(): Nullable<Scene>;
  118662. /** @hidden */
  118663. protected _getEngine(): Nullable<ThinEngine>;
  118664. /**
  118665. * Checks if the texture has the same transform matrix than another texture
  118666. * @param texture texture to check against
  118667. * @returns true if the transforms are the same, else false
  118668. */
  118669. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  118670. /**
  118671. * Get the texture transform matrix used to offset tile the texture for istance.
  118672. * @returns the transformation matrix
  118673. */
  118674. getTextureMatrix(): Matrix;
  118675. /**
  118676. * Get the texture reflection matrix used to rotate/transform the reflection.
  118677. * @returns the reflection matrix
  118678. */
  118679. getReflectionTextureMatrix(): Matrix;
  118680. /**
  118681. * Get the underlying lower level texture from Babylon.
  118682. * @returns the insternal texture
  118683. */
  118684. getInternalTexture(): Nullable<InternalTexture>;
  118685. /**
  118686. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  118687. * @returns true if ready or not blocking
  118688. */
  118689. isReadyOrNotBlocking(): boolean;
  118690. /**
  118691. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  118692. * @returns true if fully ready
  118693. */
  118694. isReady(): boolean;
  118695. private _cachedSize;
  118696. /**
  118697. * Get the size of the texture.
  118698. * @returns the texture size.
  118699. */
  118700. getSize(): ISize;
  118701. /**
  118702. * Get the base size of the texture.
  118703. * It can be different from the size if the texture has been resized for POT for instance
  118704. * @returns the base size
  118705. */
  118706. getBaseSize(): ISize;
  118707. /**
  118708. * Update the sampling mode of the texture.
  118709. * Default is Trilinear mode.
  118710. *
  118711. * | Value | Type | Description |
  118712. * | ----- | ------------------ | ----------- |
  118713. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  118714. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  118715. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  118716. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  118717. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  118718. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  118719. * | 7 | NEAREST_LINEAR | |
  118720. * | 8 | NEAREST_NEAREST | |
  118721. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  118722. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  118723. * | 11 | LINEAR_LINEAR | |
  118724. * | 12 | LINEAR_NEAREST | |
  118725. *
  118726. * > _mag_: magnification filter (close to the viewer)
  118727. * > _min_: minification filter (far from the viewer)
  118728. * > _mip_: filter used between mip map levels
  118729. *@param samplingMode Define the new sampling mode of the texture
  118730. */
  118731. updateSamplingMode(samplingMode: number): void;
  118732. /**
  118733. * Scales the texture if is `canRescale()`
  118734. * @param ratio the resize factor we want to use to rescale
  118735. */
  118736. scale(ratio: number): void;
  118737. /**
  118738. * Get if the texture can rescale.
  118739. */
  118740. get canRescale(): boolean;
  118741. /** @hidden */
  118742. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  118743. /** @hidden */
  118744. _rebuild(): void;
  118745. /**
  118746. * Triggers the load sequence in delayed load mode.
  118747. */
  118748. delayLoad(): void;
  118749. /**
  118750. * Clones the texture.
  118751. * @returns the cloned texture
  118752. */
  118753. clone(): Nullable<BaseTexture>;
  118754. /**
  118755. * Get the texture underlying type (INT, FLOAT...)
  118756. */
  118757. get textureType(): number;
  118758. /**
  118759. * Get the texture underlying format (RGB, RGBA...)
  118760. */
  118761. get textureFormat(): number;
  118762. /**
  118763. * Indicates that textures need to be re-calculated for all materials
  118764. */
  118765. protected _markAllSubMeshesAsTexturesDirty(): void;
  118766. /**
  118767. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  118768. * This will returns an RGBA array buffer containing either in values (0-255) or
  118769. * float values (0-1) depending of the underlying buffer type.
  118770. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  118771. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  118772. * @param buffer defines a user defined buffer to fill with data (can be null)
  118773. * @returns The Array buffer containing the pixels data.
  118774. */
  118775. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  118776. /**
  118777. * Release and destroy the underlying lower level texture aka internalTexture.
  118778. */
  118779. releaseInternalTexture(): void;
  118780. /** @hidden */
  118781. get _lodTextureHigh(): Nullable<BaseTexture>;
  118782. /** @hidden */
  118783. get _lodTextureMid(): Nullable<BaseTexture>;
  118784. /** @hidden */
  118785. get _lodTextureLow(): Nullable<BaseTexture>;
  118786. /**
  118787. * Dispose the texture and release its associated resources.
  118788. */
  118789. dispose(): void;
  118790. /**
  118791. * Serialize the texture into a JSON representation that can be parsed later on.
  118792. * @returns the JSON representation of the texture
  118793. */
  118794. serialize(): any;
  118795. /**
  118796. * Helper function to be called back once a list of texture contains only ready textures.
  118797. * @param textures Define the list of textures to wait for
  118798. * @param callback Define the callback triggered once the entire list will be ready
  118799. */
  118800. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  118801. private static _isScene;
  118802. }
  118803. }
  118804. declare module BABYLON {
  118805. /**
  118806. * Options to be used when creating an effect.
  118807. */
  118808. export interface IEffectCreationOptions {
  118809. /**
  118810. * Atrributes that will be used in the shader.
  118811. */
  118812. attributes: string[];
  118813. /**
  118814. * Uniform varible names that will be set in the shader.
  118815. */
  118816. uniformsNames: string[];
  118817. /**
  118818. * Uniform buffer variable names that will be set in the shader.
  118819. */
  118820. uniformBuffersNames: string[];
  118821. /**
  118822. * Sampler texture variable names that will be set in the shader.
  118823. */
  118824. samplers: string[];
  118825. /**
  118826. * Define statements that will be set in the shader.
  118827. */
  118828. defines: any;
  118829. /**
  118830. * Possible fallbacks for this effect to improve performance when needed.
  118831. */
  118832. fallbacks: Nullable<IEffectFallbacks>;
  118833. /**
  118834. * Callback that will be called when the shader is compiled.
  118835. */
  118836. onCompiled: Nullable<(effect: Effect) => void>;
  118837. /**
  118838. * Callback that will be called if an error occurs during shader compilation.
  118839. */
  118840. onError: Nullable<(effect: Effect, errors: string) => void>;
  118841. /**
  118842. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118843. */
  118844. indexParameters?: any;
  118845. /**
  118846. * Max number of lights that can be used in the shader.
  118847. */
  118848. maxSimultaneousLights?: number;
  118849. /**
  118850. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  118851. */
  118852. transformFeedbackVaryings?: Nullable<string[]>;
  118853. /**
  118854. * 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
  118855. */
  118856. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  118857. /**
  118858. * Is this effect rendering to several color attachments ?
  118859. */
  118860. multiTarget?: boolean;
  118861. }
  118862. /**
  118863. * Effect containing vertex and fragment shader that can be executed on an object.
  118864. */
  118865. export class Effect implements IDisposable {
  118866. /**
  118867. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  118868. */
  118869. static ShadersRepository: string;
  118870. /**
  118871. * Enable logging of the shader code when a compilation error occurs
  118872. */
  118873. static LogShaderCodeOnCompilationError: boolean;
  118874. /**
  118875. * Name of the effect.
  118876. */
  118877. name: any;
  118878. /**
  118879. * String container all the define statements that should be set on the shader.
  118880. */
  118881. defines: string;
  118882. /**
  118883. * Callback that will be called when the shader is compiled.
  118884. */
  118885. onCompiled: Nullable<(effect: Effect) => void>;
  118886. /**
  118887. * Callback that will be called if an error occurs during shader compilation.
  118888. */
  118889. onError: Nullable<(effect: Effect, errors: string) => void>;
  118890. /**
  118891. * Callback that will be called when effect is bound.
  118892. */
  118893. onBind: Nullable<(effect: Effect) => void>;
  118894. /**
  118895. * Unique ID of the effect.
  118896. */
  118897. uniqueId: number;
  118898. /**
  118899. * Observable that will be called when the shader is compiled.
  118900. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  118901. */
  118902. onCompileObservable: Observable<Effect>;
  118903. /**
  118904. * Observable that will be called if an error occurs during shader compilation.
  118905. */
  118906. onErrorObservable: Observable<Effect>;
  118907. /** @hidden */
  118908. _onBindObservable: Nullable<Observable<Effect>>;
  118909. /**
  118910. * @hidden
  118911. * Specifies if the effect was previously ready
  118912. */
  118913. _wasPreviouslyReady: boolean;
  118914. /**
  118915. * Observable that will be called when effect is bound.
  118916. */
  118917. get onBindObservable(): Observable<Effect>;
  118918. /** @hidden */
  118919. _bonesComputationForcedToCPU: boolean;
  118920. /** @hidden */
  118921. _multiTarget: boolean;
  118922. private static _uniqueIdSeed;
  118923. private _engine;
  118924. private _uniformBuffersNames;
  118925. private _uniformBuffersNamesList;
  118926. private _uniformsNames;
  118927. private _samplerList;
  118928. private _samplers;
  118929. private _isReady;
  118930. private _compilationError;
  118931. private _allFallbacksProcessed;
  118932. private _attributesNames;
  118933. private _attributes;
  118934. private _attributeLocationByName;
  118935. private _uniforms;
  118936. /**
  118937. * Key for the effect.
  118938. * @hidden
  118939. */
  118940. _key: string;
  118941. private _indexParameters;
  118942. private _fallbacks;
  118943. private _vertexSourceCode;
  118944. private _fragmentSourceCode;
  118945. private _vertexSourceCodeOverride;
  118946. private _fragmentSourceCodeOverride;
  118947. private _transformFeedbackVaryings;
  118948. /**
  118949. * Compiled shader to webGL program.
  118950. * @hidden
  118951. */
  118952. _pipelineContext: Nullable<IPipelineContext>;
  118953. private _valueCache;
  118954. private static _baseCache;
  118955. /**
  118956. * Instantiates an effect.
  118957. * An effect can be used to create/manage/execute vertex and fragment shaders.
  118958. * @param baseName Name of the effect.
  118959. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  118960. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  118961. * @param samplers List of sampler variables that will be passed to the shader.
  118962. * @param engine Engine to be used to render the effect
  118963. * @param defines Define statements to be added to the shader.
  118964. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  118965. * @param onCompiled Callback that will be called when the shader is compiled.
  118966. * @param onError Callback that will be called if an error occurs during shader compilation.
  118967. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118968. */
  118969. 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);
  118970. private _useFinalCode;
  118971. /**
  118972. * Unique key for this effect
  118973. */
  118974. get key(): string;
  118975. /**
  118976. * If the effect has been compiled and prepared.
  118977. * @returns if the effect is compiled and prepared.
  118978. */
  118979. isReady(): boolean;
  118980. private _isReadyInternal;
  118981. /**
  118982. * The engine the effect was initialized with.
  118983. * @returns the engine.
  118984. */
  118985. getEngine(): Engine;
  118986. /**
  118987. * The pipeline context for this effect
  118988. * @returns the associated pipeline context
  118989. */
  118990. getPipelineContext(): Nullable<IPipelineContext>;
  118991. /**
  118992. * The set of names of attribute variables for the shader.
  118993. * @returns An array of attribute names.
  118994. */
  118995. getAttributesNames(): string[];
  118996. /**
  118997. * Returns the attribute at the given index.
  118998. * @param index The index of the attribute.
  118999. * @returns The location of the attribute.
  119000. */
  119001. getAttributeLocation(index: number): number;
  119002. /**
  119003. * Returns the attribute based on the name of the variable.
  119004. * @param name of the attribute to look up.
  119005. * @returns the attribute location.
  119006. */
  119007. getAttributeLocationByName(name: string): number;
  119008. /**
  119009. * The number of attributes.
  119010. * @returns the numnber of attributes.
  119011. */
  119012. getAttributesCount(): number;
  119013. /**
  119014. * Gets the index of a uniform variable.
  119015. * @param uniformName of the uniform to look up.
  119016. * @returns the index.
  119017. */
  119018. getUniformIndex(uniformName: string): number;
  119019. /**
  119020. * Returns the attribute based on the name of the variable.
  119021. * @param uniformName of the uniform to look up.
  119022. * @returns the location of the uniform.
  119023. */
  119024. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  119025. /**
  119026. * Returns an array of sampler variable names
  119027. * @returns The array of sampler variable names.
  119028. */
  119029. getSamplers(): string[];
  119030. /**
  119031. * Returns an array of uniform variable names
  119032. * @returns The array of uniform variable names.
  119033. */
  119034. getUniformNames(): string[];
  119035. /**
  119036. * Returns an array of uniform buffer variable names
  119037. * @returns The array of uniform buffer variable names.
  119038. */
  119039. getUniformBuffersNames(): string[];
  119040. /**
  119041. * Returns the index parameters used to create the effect
  119042. * @returns The index parameters object
  119043. */
  119044. getIndexParameters(): any;
  119045. /**
  119046. * The error from the last compilation.
  119047. * @returns the error string.
  119048. */
  119049. getCompilationError(): string;
  119050. /**
  119051. * Gets a boolean indicating that all fallbacks were used during compilation
  119052. * @returns true if all fallbacks were used
  119053. */
  119054. allFallbacksProcessed(): boolean;
  119055. /**
  119056. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  119057. * @param func The callback to be used.
  119058. */
  119059. executeWhenCompiled(func: (effect: Effect) => void): void;
  119060. private _checkIsReady;
  119061. private _loadShader;
  119062. /**
  119063. * Gets the vertex shader source code of this effect
  119064. */
  119065. get vertexSourceCode(): string;
  119066. /**
  119067. * Gets the fragment shader source code of this effect
  119068. */
  119069. get fragmentSourceCode(): string;
  119070. /**
  119071. * Recompiles the webGL program
  119072. * @param vertexSourceCode The source code for the vertex shader.
  119073. * @param fragmentSourceCode The source code for the fragment shader.
  119074. * @param onCompiled Callback called when completed.
  119075. * @param onError Callback called on error.
  119076. * @hidden
  119077. */
  119078. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  119079. /**
  119080. * Prepares the effect
  119081. * @hidden
  119082. */
  119083. _prepareEffect(): void;
  119084. private _getShaderCodeAndErrorLine;
  119085. private _processCompilationErrors;
  119086. /**
  119087. * Checks if the effect is supported. (Must be called after compilation)
  119088. */
  119089. get isSupported(): boolean;
  119090. /**
  119091. * Binds a texture to the engine to be used as output of the shader.
  119092. * @param channel Name of the output variable.
  119093. * @param texture Texture to bind.
  119094. * @hidden
  119095. */
  119096. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  119097. /**
  119098. * Sets a texture on the engine to be used in the shader.
  119099. * @param channel Name of the sampler variable.
  119100. * @param texture Texture to set.
  119101. */
  119102. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  119103. /**
  119104. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  119105. * @param channel Name of the sampler variable.
  119106. * @param texture Texture to set.
  119107. */
  119108. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  119109. /**
  119110. * Sets an array of textures on the engine to be used in the shader.
  119111. * @param channel Name of the variable.
  119112. * @param textures Textures to set.
  119113. */
  119114. setTextureArray(channel: string, textures: BaseTexture[]): void;
  119115. /**
  119116. * 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)
  119117. * @param channel Name of the sampler variable.
  119118. * @param postProcess Post process to get the input texture from.
  119119. */
  119120. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  119121. /**
  119122. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  119123. * 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)
  119124. * @param channel Name of the sampler variable.
  119125. * @param postProcess Post process to get the output texture from.
  119126. */
  119127. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  119128. /** @hidden */
  119129. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  119130. /** @hidden */
  119131. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  119132. /** @hidden */
  119133. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  119134. /** @hidden */
  119135. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  119136. /**
  119137. * Binds a buffer to a uniform.
  119138. * @param buffer Buffer to bind.
  119139. * @param name Name of the uniform variable to bind to.
  119140. */
  119141. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  119142. /**
  119143. * Binds block to a uniform.
  119144. * @param blockName Name of the block to bind.
  119145. * @param index Index to bind.
  119146. */
  119147. bindUniformBlock(blockName: string, index: number): void;
  119148. /**
  119149. * Sets an interger value on a uniform variable.
  119150. * @param uniformName Name of the variable.
  119151. * @param value Value to be set.
  119152. * @returns this effect.
  119153. */
  119154. setInt(uniformName: string, value: number): Effect;
  119155. /**
  119156. * Sets an int array on a uniform variable.
  119157. * @param uniformName Name of the variable.
  119158. * @param array array to be set.
  119159. * @returns this effect.
  119160. */
  119161. setIntArray(uniformName: string, array: Int32Array): Effect;
  119162. /**
  119163. * 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)
  119164. * @param uniformName Name of the variable.
  119165. * @param array array to be set.
  119166. * @returns this effect.
  119167. */
  119168. setIntArray2(uniformName: string, array: Int32Array): Effect;
  119169. /**
  119170. * 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)
  119171. * @param uniformName Name of the variable.
  119172. * @param array array to be set.
  119173. * @returns this effect.
  119174. */
  119175. setIntArray3(uniformName: string, array: Int32Array): Effect;
  119176. /**
  119177. * 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)
  119178. * @param uniformName Name of the variable.
  119179. * @param array array to be set.
  119180. * @returns this effect.
  119181. */
  119182. setIntArray4(uniformName: string, array: Int32Array): Effect;
  119183. /**
  119184. * Sets an float array on a uniform variable.
  119185. * @param uniformName Name of the variable.
  119186. * @param array array to be set.
  119187. * @returns this effect.
  119188. */
  119189. setFloatArray(uniformName: string, array: Float32Array): Effect;
  119190. /**
  119191. * 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)
  119192. * @param uniformName Name of the variable.
  119193. * @param array array to be set.
  119194. * @returns this effect.
  119195. */
  119196. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  119197. /**
  119198. * 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)
  119199. * @param uniformName Name of the variable.
  119200. * @param array array to be set.
  119201. * @returns this effect.
  119202. */
  119203. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  119204. /**
  119205. * 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)
  119206. * @param uniformName Name of the variable.
  119207. * @param array array to be set.
  119208. * @returns this effect.
  119209. */
  119210. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  119211. /**
  119212. * Sets an array on a uniform variable.
  119213. * @param uniformName Name of the variable.
  119214. * @param array array to be set.
  119215. * @returns this effect.
  119216. */
  119217. setArray(uniformName: string, array: number[]): Effect;
  119218. /**
  119219. * 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)
  119220. * @param uniformName Name of the variable.
  119221. * @param array array to be set.
  119222. * @returns this effect.
  119223. */
  119224. setArray2(uniformName: string, array: number[]): Effect;
  119225. /**
  119226. * 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)
  119227. * @param uniformName Name of the variable.
  119228. * @param array array to be set.
  119229. * @returns this effect.
  119230. */
  119231. setArray3(uniformName: string, array: number[]): Effect;
  119232. /**
  119233. * 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)
  119234. * @param uniformName Name of the variable.
  119235. * @param array array to be set.
  119236. * @returns this effect.
  119237. */
  119238. setArray4(uniformName: string, array: number[]): Effect;
  119239. /**
  119240. * Sets matrices on a uniform variable.
  119241. * @param uniformName Name of the variable.
  119242. * @param matrices matrices to be set.
  119243. * @returns this effect.
  119244. */
  119245. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  119246. /**
  119247. * Sets matrix on a uniform variable.
  119248. * @param uniformName Name of the variable.
  119249. * @param matrix matrix to be set.
  119250. * @returns this effect.
  119251. */
  119252. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  119253. /**
  119254. * 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)
  119255. * @param uniformName Name of the variable.
  119256. * @param matrix matrix to be set.
  119257. * @returns this effect.
  119258. */
  119259. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  119260. /**
  119261. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  119262. * @param uniformName Name of the variable.
  119263. * @param matrix matrix to be set.
  119264. * @returns this effect.
  119265. */
  119266. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  119267. /**
  119268. * Sets a float on a uniform variable.
  119269. * @param uniformName Name of the variable.
  119270. * @param value value to be set.
  119271. * @returns this effect.
  119272. */
  119273. setFloat(uniformName: string, value: number): Effect;
  119274. /**
  119275. * Sets a boolean on a uniform variable.
  119276. * @param uniformName Name of the variable.
  119277. * @param bool value to be set.
  119278. * @returns this effect.
  119279. */
  119280. setBool(uniformName: string, bool: boolean): Effect;
  119281. /**
  119282. * Sets a Vector2 on a uniform variable.
  119283. * @param uniformName Name of the variable.
  119284. * @param vector2 vector2 to be set.
  119285. * @returns this effect.
  119286. */
  119287. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  119288. /**
  119289. * Sets a float2 on a uniform variable.
  119290. * @param uniformName Name of the variable.
  119291. * @param x First float in float2.
  119292. * @param y Second float in float2.
  119293. * @returns this effect.
  119294. */
  119295. setFloat2(uniformName: string, x: number, y: number): Effect;
  119296. /**
  119297. * Sets a Vector3 on a uniform variable.
  119298. * @param uniformName Name of the variable.
  119299. * @param vector3 Value to be set.
  119300. * @returns this effect.
  119301. */
  119302. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  119303. /**
  119304. * Sets a float3 on a uniform variable.
  119305. * @param uniformName Name of the variable.
  119306. * @param x First float in float3.
  119307. * @param y Second float in float3.
  119308. * @param z Third float in float3.
  119309. * @returns this effect.
  119310. */
  119311. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  119312. /**
  119313. * Sets a Vector4 on a uniform variable.
  119314. * @param uniformName Name of the variable.
  119315. * @param vector4 Value to be set.
  119316. * @returns this effect.
  119317. */
  119318. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  119319. /**
  119320. * Sets a float4 on a uniform variable.
  119321. * @param uniformName Name of the variable.
  119322. * @param x First float in float4.
  119323. * @param y Second float in float4.
  119324. * @param z Third float in float4.
  119325. * @param w Fourth float in float4.
  119326. * @returns this effect.
  119327. */
  119328. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  119329. /**
  119330. * Sets a Color3 on a uniform variable.
  119331. * @param uniformName Name of the variable.
  119332. * @param color3 Value to be set.
  119333. * @returns this effect.
  119334. */
  119335. setColor3(uniformName: string, color3: IColor3Like): Effect;
  119336. /**
  119337. * Sets a Color4 on a uniform variable.
  119338. * @param uniformName Name of the variable.
  119339. * @param color3 Value to be set.
  119340. * @param alpha Alpha value to be set.
  119341. * @returns this effect.
  119342. */
  119343. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  119344. /**
  119345. * Sets a Color4 on a uniform variable
  119346. * @param uniformName defines the name of the variable
  119347. * @param color4 defines the value to be set
  119348. * @returns this effect.
  119349. */
  119350. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  119351. /** Release all associated resources */
  119352. dispose(): void;
  119353. /**
  119354. * This function will add a new shader to the shader store
  119355. * @param name the name of the shader
  119356. * @param pixelShader optional pixel shader content
  119357. * @param vertexShader optional vertex shader content
  119358. */
  119359. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  119360. /**
  119361. * Store of each shader (The can be looked up using effect.key)
  119362. */
  119363. static ShadersStore: {
  119364. [key: string]: string;
  119365. };
  119366. /**
  119367. * Store of each included file for a shader (The can be looked up using effect.key)
  119368. */
  119369. static IncludesShadersStore: {
  119370. [key: string]: string;
  119371. };
  119372. /**
  119373. * Resets the cache of effects.
  119374. */
  119375. static ResetCache(): void;
  119376. }
  119377. }
  119378. declare module BABYLON {
  119379. /**
  119380. * Interface used to describe the capabilities of the engine relatively to the current browser
  119381. */
  119382. export interface EngineCapabilities {
  119383. /** Maximum textures units per fragment shader */
  119384. maxTexturesImageUnits: number;
  119385. /** Maximum texture units per vertex shader */
  119386. maxVertexTextureImageUnits: number;
  119387. /** Maximum textures units in the entire pipeline */
  119388. maxCombinedTexturesImageUnits: number;
  119389. /** Maximum texture size */
  119390. maxTextureSize: number;
  119391. /** Maximum texture samples */
  119392. maxSamples?: number;
  119393. /** Maximum cube texture size */
  119394. maxCubemapTextureSize: number;
  119395. /** Maximum render texture size */
  119396. maxRenderTextureSize: number;
  119397. /** Maximum number of vertex attributes */
  119398. maxVertexAttribs: number;
  119399. /** Maximum number of varyings */
  119400. maxVaryingVectors: number;
  119401. /** Maximum number of uniforms per vertex shader */
  119402. maxVertexUniformVectors: number;
  119403. /** Maximum number of uniforms per fragment shader */
  119404. maxFragmentUniformVectors: number;
  119405. /** Defines if standard derivates (dx/dy) are supported */
  119406. standardDerivatives: boolean;
  119407. /** Defines if s3tc texture compression is supported */
  119408. s3tc?: WEBGL_compressed_texture_s3tc;
  119409. /** Defines if pvrtc texture compression is supported */
  119410. pvrtc: any;
  119411. /** Defines if etc1 texture compression is supported */
  119412. etc1: any;
  119413. /** Defines if etc2 texture compression is supported */
  119414. etc2: any;
  119415. /** Defines if astc texture compression is supported */
  119416. astc: any;
  119417. /** Defines if bptc texture compression is supported */
  119418. bptc: any;
  119419. /** Defines if float textures are supported */
  119420. textureFloat: boolean;
  119421. /** Defines if vertex array objects are supported */
  119422. vertexArrayObject: boolean;
  119423. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  119424. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  119425. /** Gets the maximum level of anisotropy supported */
  119426. maxAnisotropy: number;
  119427. /** Defines if instancing is supported */
  119428. instancedArrays: boolean;
  119429. /** Defines if 32 bits indices are supported */
  119430. uintIndices: boolean;
  119431. /** Defines if high precision shaders are supported */
  119432. highPrecisionShaderSupported: boolean;
  119433. /** Defines if depth reading in the fragment shader is supported */
  119434. fragmentDepthSupported: boolean;
  119435. /** Defines if float texture linear filtering is supported*/
  119436. textureFloatLinearFiltering: boolean;
  119437. /** Defines if rendering to float textures is supported */
  119438. textureFloatRender: boolean;
  119439. /** Defines if half float textures are supported*/
  119440. textureHalfFloat: boolean;
  119441. /** Defines if half float texture linear filtering is supported*/
  119442. textureHalfFloatLinearFiltering: boolean;
  119443. /** Defines if rendering to half float textures is supported */
  119444. textureHalfFloatRender: boolean;
  119445. /** Defines if textureLOD shader command is supported */
  119446. textureLOD: boolean;
  119447. /** Defines if draw buffers extension is supported */
  119448. drawBuffersExtension: boolean;
  119449. /** Defines if depth textures are supported */
  119450. depthTextureExtension: boolean;
  119451. /** Defines if float color buffer are supported */
  119452. colorBufferFloat: boolean;
  119453. /** Gets disjoint timer query extension (null if not supported) */
  119454. timerQuery?: EXT_disjoint_timer_query;
  119455. /** Defines if timestamp can be used with timer query */
  119456. canUseTimestampForTimerQuery: boolean;
  119457. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  119458. multiview?: any;
  119459. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  119460. oculusMultiview?: any;
  119461. /** Function used to let the system compiles shaders in background */
  119462. parallelShaderCompile?: {
  119463. COMPLETION_STATUS_KHR: number;
  119464. };
  119465. /** Max number of texture samples for MSAA */
  119466. maxMSAASamples: number;
  119467. /** Defines if the blend min max extension is supported */
  119468. blendMinMax: boolean;
  119469. }
  119470. }
  119471. declare module BABYLON {
  119472. /**
  119473. * @hidden
  119474. **/
  119475. export class DepthCullingState {
  119476. private _isDepthTestDirty;
  119477. private _isDepthMaskDirty;
  119478. private _isDepthFuncDirty;
  119479. private _isCullFaceDirty;
  119480. private _isCullDirty;
  119481. private _isZOffsetDirty;
  119482. private _isFrontFaceDirty;
  119483. private _depthTest;
  119484. private _depthMask;
  119485. private _depthFunc;
  119486. private _cull;
  119487. private _cullFace;
  119488. private _zOffset;
  119489. private _frontFace;
  119490. /**
  119491. * Initializes the state.
  119492. */
  119493. constructor();
  119494. get isDirty(): boolean;
  119495. get zOffset(): number;
  119496. set zOffset(value: number);
  119497. get cullFace(): Nullable<number>;
  119498. set cullFace(value: Nullable<number>);
  119499. get cull(): Nullable<boolean>;
  119500. set cull(value: Nullable<boolean>);
  119501. get depthFunc(): Nullable<number>;
  119502. set depthFunc(value: Nullable<number>);
  119503. get depthMask(): boolean;
  119504. set depthMask(value: boolean);
  119505. get depthTest(): boolean;
  119506. set depthTest(value: boolean);
  119507. get frontFace(): Nullable<number>;
  119508. set frontFace(value: Nullable<number>);
  119509. reset(): void;
  119510. apply(gl: WebGLRenderingContext): void;
  119511. }
  119512. }
  119513. declare module BABYLON {
  119514. /**
  119515. * @hidden
  119516. **/
  119517. export class StencilState {
  119518. /** 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 */
  119519. static readonly ALWAYS: number;
  119520. /** Passed to stencilOperation to specify that stencil value must be kept */
  119521. static readonly KEEP: number;
  119522. /** Passed to stencilOperation to specify that stencil value must be replaced */
  119523. static readonly REPLACE: number;
  119524. private _isStencilTestDirty;
  119525. private _isStencilMaskDirty;
  119526. private _isStencilFuncDirty;
  119527. private _isStencilOpDirty;
  119528. private _stencilTest;
  119529. private _stencilMask;
  119530. private _stencilFunc;
  119531. private _stencilFuncRef;
  119532. private _stencilFuncMask;
  119533. private _stencilOpStencilFail;
  119534. private _stencilOpDepthFail;
  119535. private _stencilOpStencilDepthPass;
  119536. get isDirty(): boolean;
  119537. get stencilFunc(): number;
  119538. set stencilFunc(value: number);
  119539. get stencilFuncRef(): number;
  119540. set stencilFuncRef(value: number);
  119541. get stencilFuncMask(): number;
  119542. set stencilFuncMask(value: number);
  119543. get stencilOpStencilFail(): number;
  119544. set stencilOpStencilFail(value: number);
  119545. get stencilOpDepthFail(): number;
  119546. set stencilOpDepthFail(value: number);
  119547. get stencilOpStencilDepthPass(): number;
  119548. set stencilOpStencilDepthPass(value: number);
  119549. get stencilMask(): number;
  119550. set stencilMask(value: number);
  119551. get stencilTest(): boolean;
  119552. set stencilTest(value: boolean);
  119553. constructor();
  119554. reset(): void;
  119555. apply(gl: WebGLRenderingContext): void;
  119556. }
  119557. }
  119558. declare module BABYLON {
  119559. /**
  119560. * @hidden
  119561. **/
  119562. export class AlphaState {
  119563. private _isAlphaBlendDirty;
  119564. private _isBlendFunctionParametersDirty;
  119565. private _isBlendEquationParametersDirty;
  119566. private _isBlendConstantsDirty;
  119567. private _alphaBlend;
  119568. private _blendFunctionParameters;
  119569. private _blendEquationParameters;
  119570. private _blendConstants;
  119571. /**
  119572. * Initializes the state.
  119573. */
  119574. constructor();
  119575. get isDirty(): boolean;
  119576. get alphaBlend(): boolean;
  119577. set alphaBlend(value: boolean);
  119578. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  119579. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  119580. setAlphaEquationParameters(rgb: number, alpha: number): void;
  119581. reset(): void;
  119582. apply(gl: WebGLRenderingContext): void;
  119583. }
  119584. }
  119585. declare module BABYLON {
  119586. /** @hidden */
  119587. export class WebGLShaderProcessor implements IShaderProcessor {
  119588. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  119589. }
  119590. }
  119591. declare module BABYLON {
  119592. /** @hidden */
  119593. export class WebGL2ShaderProcessor implements IShaderProcessor {
  119594. attributeProcessor(attribute: string): string;
  119595. varyingProcessor(varying: string, isFragment: boolean): string;
  119596. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  119597. }
  119598. }
  119599. declare module BABYLON {
  119600. /**
  119601. * Interface for attribute information associated with buffer instanciation
  119602. */
  119603. export interface InstancingAttributeInfo {
  119604. /**
  119605. * Name of the GLSL attribute
  119606. * if attribute index is not specified, this is used to retrieve the index from the effect
  119607. */
  119608. attributeName: string;
  119609. /**
  119610. * Index/offset of the attribute in the vertex shader
  119611. * if not specified, this will be computes from the name.
  119612. */
  119613. index?: number;
  119614. /**
  119615. * size of the attribute, 1, 2, 3 or 4
  119616. */
  119617. attributeSize: number;
  119618. /**
  119619. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  119620. */
  119621. offset: number;
  119622. /**
  119623. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  119624. * default to 1
  119625. */
  119626. divisor?: number;
  119627. /**
  119628. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  119629. * default is FLOAT
  119630. */
  119631. attributeType?: number;
  119632. /**
  119633. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  119634. */
  119635. normalized?: boolean;
  119636. }
  119637. }
  119638. declare module BABYLON {
  119639. interface ThinEngine {
  119640. /**
  119641. * Update a video texture
  119642. * @param texture defines the texture to update
  119643. * @param video defines the video element to use
  119644. * @param invertY defines if data must be stored with Y axis inverted
  119645. */
  119646. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  119647. }
  119648. }
  119649. declare module BABYLON {
  119650. interface ThinEngine {
  119651. /**
  119652. * Creates a dynamic texture
  119653. * @param width defines the width of the texture
  119654. * @param height defines the height of the texture
  119655. * @param generateMipMaps defines if the engine should generate the mip levels
  119656. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  119657. * @returns the dynamic texture inside an InternalTexture
  119658. */
  119659. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  119660. /**
  119661. * Update the content of a dynamic texture
  119662. * @param texture defines the texture to update
  119663. * @param canvas defines the canvas containing the source
  119664. * @param invertY defines if data must be stored with Y axis inverted
  119665. * @param premulAlpha defines if alpha is stored as premultiplied
  119666. * @param format defines the format of the data
  119667. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119668. */
  119669. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  119670. }
  119671. }
  119672. declare module BABYLON {
  119673. /**
  119674. * Settings for finer control over video usage
  119675. */
  119676. export interface VideoTextureSettings {
  119677. /**
  119678. * Applies `autoplay` to video, if specified
  119679. */
  119680. autoPlay?: boolean;
  119681. /**
  119682. * Applies `muted` to video, if specified
  119683. */
  119684. muted?: boolean;
  119685. /**
  119686. * Applies `loop` to video, if specified
  119687. */
  119688. loop?: boolean;
  119689. /**
  119690. * Automatically updates internal texture from video at every frame in the render loop
  119691. */
  119692. autoUpdateTexture: boolean;
  119693. /**
  119694. * Image src displayed during the video loading or until the user interacts with the video.
  119695. */
  119696. poster?: string;
  119697. }
  119698. /**
  119699. * If you want to display a video in your scene, this is the special texture for that.
  119700. * This special texture works similar to other textures, with the exception of a few parameters.
  119701. * @see https://doc.babylonjs.com/how_to/video_texture
  119702. */
  119703. export class VideoTexture extends Texture {
  119704. /**
  119705. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  119706. */
  119707. readonly autoUpdateTexture: boolean;
  119708. /**
  119709. * The video instance used by the texture internally
  119710. */
  119711. readonly video: HTMLVideoElement;
  119712. private _onUserActionRequestedObservable;
  119713. /**
  119714. * Event triggerd when a dom action is required by the user to play the video.
  119715. * This happens due to recent changes in browser policies preventing video to auto start.
  119716. */
  119717. get onUserActionRequestedObservable(): Observable<Texture>;
  119718. private _generateMipMaps;
  119719. private _stillImageCaptured;
  119720. private _displayingPosterTexture;
  119721. private _settings;
  119722. private _createInternalTextureOnEvent;
  119723. private _frameId;
  119724. private _currentSrc;
  119725. /**
  119726. * Creates a video texture.
  119727. * If you want to display a video in your scene, this is the special texture for that.
  119728. * This special texture works similar to other textures, with the exception of a few parameters.
  119729. * @see https://doc.babylonjs.com/how_to/video_texture
  119730. * @param name optional name, will detect from video source, if not defined
  119731. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  119732. * @param scene is obviously the current scene.
  119733. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  119734. * @param invertY is false by default but can be used to invert video on Y axis
  119735. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  119736. * @param settings allows finer control over video usage
  119737. */
  119738. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  119739. private _getName;
  119740. private _getVideo;
  119741. private _createInternalTexture;
  119742. private reset;
  119743. /**
  119744. * @hidden Internal method to initiate `update`.
  119745. */
  119746. _rebuild(): void;
  119747. /**
  119748. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  119749. */
  119750. update(): void;
  119751. /**
  119752. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  119753. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  119754. */
  119755. updateTexture(isVisible: boolean): void;
  119756. protected _updateInternalTexture: () => void;
  119757. /**
  119758. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  119759. * @param url New url.
  119760. */
  119761. updateURL(url: string): void;
  119762. /**
  119763. * Clones the texture.
  119764. * @returns the cloned texture
  119765. */
  119766. clone(): VideoTexture;
  119767. /**
  119768. * Dispose the texture and release its associated resources.
  119769. */
  119770. dispose(): void;
  119771. /**
  119772. * Creates a video texture straight from a stream.
  119773. * @param scene Define the scene the texture should be created in
  119774. * @param stream Define the stream the texture should be created from
  119775. * @returns The created video texture as a promise
  119776. */
  119777. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  119778. /**
  119779. * Creates a video texture straight from your WebCam video feed.
  119780. * @param scene Define the scene the texture should be created in
  119781. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119782. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119783. * @returns The created video texture as a promise
  119784. */
  119785. static CreateFromWebCamAsync(scene: Scene, constraints: {
  119786. minWidth: number;
  119787. maxWidth: number;
  119788. minHeight: number;
  119789. maxHeight: number;
  119790. deviceId: string;
  119791. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  119792. /**
  119793. * Creates a video texture straight from your WebCam video feed.
  119794. * @param scene Define the scene the texture should be created in
  119795. * @param onReady Define a callback to triggered once the texture will be ready
  119796. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119797. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119798. */
  119799. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  119800. minWidth: number;
  119801. maxWidth: number;
  119802. minHeight: number;
  119803. maxHeight: number;
  119804. deviceId: string;
  119805. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  119806. }
  119807. }
  119808. declare module BABYLON {
  119809. /**
  119810. * Defines the interface used by objects working like Scene
  119811. * @hidden
  119812. */
  119813. export interface ISceneLike {
  119814. _addPendingData(data: any): void;
  119815. _removePendingData(data: any): void;
  119816. offlineProvider: IOfflineProvider;
  119817. }
  119818. /**
  119819. * Information about the current host
  119820. */
  119821. export interface HostInformation {
  119822. /**
  119823. * Defines if the current host is a mobile
  119824. */
  119825. isMobile: boolean;
  119826. }
  119827. /** Interface defining initialization parameters for Engine class */
  119828. export interface EngineOptions extends WebGLContextAttributes {
  119829. /**
  119830. * Defines if the engine should no exceed a specified device ratio
  119831. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  119832. */
  119833. limitDeviceRatio?: number;
  119834. /**
  119835. * Defines if webvr should be enabled automatically
  119836. * @see https://doc.babylonjs.com/how_to/webvr_camera
  119837. */
  119838. autoEnableWebVR?: boolean;
  119839. /**
  119840. * Defines if webgl2 should be turned off even if supported
  119841. * @see https://doc.babylonjs.com/features/webgl2
  119842. */
  119843. disableWebGL2Support?: boolean;
  119844. /**
  119845. * Defines if webaudio should be initialized as well
  119846. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119847. */
  119848. audioEngine?: boolean;
  119849. /**
  119850. * Defines if animations should run using a deterministic lock step
  119851. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119852. */
  119853. deterministicLockstep?: boolean;
  119854. /** Defines the maximum steps to use with deterministic lock step mode */
  119855. lockstepMaxSteps?: number;
  119856. /** Defines the seconds between each deterministic lock step */
  119857. timeStep?: number;
  119858. /**
  119859. * Defines that engine should ignore context lost events
  119860. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  119861. */
  119862. doNotHandleContextLost?: boolean;
  119863. /**
  119864. * Defines that engine should ignore modifying touch action attribute and style
  119865. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  119866. */
  119867. doNotHandleTouchAction?: boolean;
  119868. /**
  119869. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  119870. */
  119871. useHighPrecisionFloats?: boolean;
  119872. /**
  119873. * Make the canvas XR Compatible for XR sessions
  119874. */
  119875. xrCompatible?: boolean;
  119876. /**
  119877. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  119878. */
  119879. useHighPrecisionMatrix?: boolean;
  119880. /**
  119881. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  119882. */
  119883. failIfMajorPerformanceCaveat?: boolean;
  119884. }
  119885. /**
  119886. * The base engine class (root of all engines)
  119887. */
  119888. export class ThinEngine {
  119889. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  119890. static ExceptionList: ({
  119891. key: string;
  119892. capture: string;
  119893. captureConstraint: number;
  119894. targets: string[];
  119895. } | {
  119896. key: string;
  119897. capture: null;
  119898. captureConstraint: null;
  119899. targets: string[];
  119900. })[];
  119901. /** @hidden */
  119902. static _TextureLoaders: IInternalTextureLoader[];
  119903. /**
  119904. * Returns the current npm package of the sdk
  119905. */
  119906. static get NpmPackage(): string;
  119907. /**
  119908. * Returns the current version of the framework
  119909. */
  119910. static get Version(): string;
  119911. /**
  119912. * Returns a string describing the current engine
  119913. */
  119914. get description(): string;
  119915. /**
  119916. * Gets or sets the epsilon value used by collision engine
  119917. */
  119918. static CollisionsEpsilon: number;
  119919. /**
  119920. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119921. */
  119922. static get ShadersRepository(): string;
  119923. static set ShadersRepository(value: string);
  119924. /** @hidden */
  119925. _shaderProcessor: IShaderProcessor;
  119926. /**
  119927. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  119928. */
  119929. forcePOTTextures: boolean;
  119930. /**
  119931. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  119932. */
  119933. isFullscreen: boolean;
  119934. /**
  119935. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  119936. */
  119937. cullBackFaces: boolean;
  119938. /**
  119939. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  119940. */
  119941. renderEvenInBackground: boolean;
  119942. /**
  119943. * Gets or sets a boolean indicating that cache can be kept between frames
  119944. */
  119945. preventCacheWipeBetweenFrames: boolean;
  119946. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  119947. validateShaderPrograms: boolean;
  119948. /**
  119949. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  119950. * This can provide greater z depth for distant objects.
  119951. */
  119952. useReverseDepthBuffer: boolean;
  119953. /**
  119954. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  119955. */
  119956. disableUniformBuffers: boolean;
  119957. /** @hidden */
  119958. _uniformBuffers: UniformBuffer[];
  119959. /**
  119960. * Gets a boolean indicating that the engine supports uniform buffers
  119961. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  119962. */
  119963. get supportsUniformBuffers(): boolean;
  119964. /** @hidden */
  119965. _gl: WebGLRenderingContext;
  119966. /** @hidden */
  119967. _webGLVersion: number;
  119968. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  119969. protected _windowIsBackground: boolean;
  119970. protected _creationOptions: EngineOptions;
  119971. protected _highPrecisionShadersAllowed: boolean;
  119972. /** @hidden */
  119973. get _shouldUseHighPrecisionShader(): boolean;
  119974. /**
  119975. * Gets a boolean indicating that only power of 2 textures are supported
  119976. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  119977. */
  119978. get needPOTTextures(): boolean;
  119979. /** @hidden */
  119980. _badOS: boolean;
  119981. /** @hidden */
  119982. _badDesktopOS: boolean;
  119983. private _hardwareScalingLevel;
  119984. /** @hidden */
  119985. _caps: EngineCapabilities;
  119986. private _isStencilEnable;
  119987. private _glVersion;
  119988. private _glRenderer;
  119989. private _glVendor;
  119990. /** @hidden */
  119991. _videoTextureSupported: boolean;
  119992. protected _renderingQueueLaunched: boolean;
  119993. protected _activeRenderLoops: (() => void)[];
  119994. /**
  119995. * Observable signaled when a context lost event is raised
  119996. */
  119997. onContextLostObservable: Observable<ThinEngine>;
  119998. /**
  119999. * Observable signaled when a context restored event is raised
  120000. */
  120001. onContextRestoredObservable: Observable<ThinEngine>;
  120002. private _onContextLost;
  120003. private _onContextRestored;
  120004. protected _contextWasLost: boolean;
  120005. /** @hidden */
  120006. _doNotHandleContextLost: boolean;
  120007. /**
  120008. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  120009. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  120010. */
  120011. get doNotHandleContextLost(): boolean;
  120012. set doNotHandleContextLost(value: boolean);
  120013. /**
  120014. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  120015. */
  120016. disableVertexArrayObjects: boolean;
  120017. /** @hidden */
  120018. protected _colorWrite: boolean;
  120019. /** @hidden */
  120020. protected _colorWriteChanged: boolean;
  120021. /** @hidden */
  120022. protected _depthCullingState: DepthCullingState;
  120023. /** @hidden */
  120024. protected _stencilState: StencilState;
  120025. /** @hidden */
  120026. _alphaState: AlphaState;
  120027. /** @hidden */
  120028. _alphaMode: number;
  120029. /** @hidden */
  120030. _alphaEquation: number;
  120031. /** @hidden */
  120032. _internalTexturesCache: InternalTexture[];
  120033. /** @hidden */
  120034. protected _activeChannel: number;
  120035. private _currentTextureChannel;
  120036. /** @hidden */
  120037. protected _boundTexturesCache: {
  120038. [key: string]: Nullable<InternalTexture>;
  120039. };
  120040. /** @hidden */
  120041. protected _currentEffect: Nullable<Effect>;
  120042. /** @hidden */
  120043. protected _currentProgram: Nullable<WebGLProgram>;
  120044. private _compiledEffects;
  120045. private _vertexAttribArraysEnabled;
  120046. /** @hidden */
  120047. protected _cachedViewport: Nullable<IViewportLike>;
  120048. private _cachedVertexArrayObject;
  120049. /** @hidden */
  120050. protected _cachedVertexBuffers: any;
  120051. /** @hidden */
  120052. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  120053. /** @hidden */
  120054. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  120055. /** @hidden */
  120056. _currentRenderTarget: Nullable<InternalTexture>;
  120057. private _uintIndicesCurrentlySet;
  120058. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  120059. /** @hidden */
  120060. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  120061. /** @hidden */
  120062. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  120063. private _currentBufferPointers;
  120064. private _currentInstanceLocations;
  120065. private _currentInstanceBuffers;
  120066. private _textureUnits;
  120067. /** @hidden */
  120068. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120069. /** @hidden */
  120070. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120071. /** @hidden */
  120072. _boundRenderFunction: any;
  120073. private _vaoRecordInProgress;
  120074. private _mustWipeVertexAttributes;
  120075. private _emptyTexture;
  120076. private _emptyCubeTexture;
  120077. private _emptyTexture3D;
  120078. private _emptyTexture2DArray;
  120079. /** @hidden */
  120080. _frameHandler: number;
  120081. private _nextFreeTextureSlots;
  120082. private _maxSimultaneousTextures;
  120083. private _activeRequests;
  120084. /** @hidden */
  120085. _transformTextureUrl: Nullable<(url: string) => string>;
  120086. /**
  120087. * Gets information about the current host
  120088. */
  120089. hostInformation: HostInformation;
  120090. protected get _supportsHardwareTextureRescaling(): boolean;
  120091. private _framebufferDimensionsObject;
  120092. /**
  120093. * sets the object from which width and height will be taken from when getting render width and height
  120094. * Will fallback to the gl object
  120095. * @param dimensions the framebuffer width and height that will be used.
  120096. */
  120097. set framebufferDimensionsObject(dimensions: Nullable<{
  120098. framebufferWidth: number;
  120099. framebufferHeight: number;
  120100. }>);
  120101. /**
  120102. * Gets the current viewport
  120103. */
  120104. get currentViewport(): Nullable<IViewportLike>;
  120105. /**
  120106. * Gets the default empty texture
  120107. */
  120108. get emptyTexture(): InternalTexture;
  120109. /**
  120110. * Gets the default empty 3D texture
  120111. */
  120112. get emptyTexture3D(): InternalTexture;
  120113. /**
  120114. * Gets the default empty 2D array texture
  120115. */
  120116. get emptyTexture2DArray(): InternalTexture;
  120117. /**
  120118. * Gets the default empty cube texture
  120119. */
  120120. get emptyCubeTexture(): InternalTexture;
  120121. /**
  120122. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  120123. */
  120124. readonly premultipliedAlpha: boolean;
  120125. /**
  120126. * Observable event triggered before each texture is initialized
  120127. */
  120128. onBeforeTextureInitObservable: Observable<Texture>;
  120129. /**
  120130. * Creates a new engine
  120131. * @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
  120132. * @param antialias defines enable antialiasing (default: false)
  120133. * @param options defines further options to be sent to the getContext() function
  120134. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  120135. */
  120136. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  120137. private _rebuildInternalTextures;
  120138. private _rebuildEffects;
  120139. /**
  120140. * Gets a boolean indicating if all created effects are ready
  120141. * @returns true if all effects are ready
  120142. */
  120143. areAllEffectsReady(): boolean;
  120144. protected _rebuildBuffers(): void;
  120145. protected _initGLContext(): void;
  120146. /**
  120147. * Gets version of the current webGL context
  120148. */
  120149. get webGLVersion(): number;
  120150. /**
  120151. * Gets a string identifying the name of the class
  120152. * @returns "Engine" string
  120153. */
  120154. getClassName(): string;
  120155. /**
  120156. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  120157. */
  120158. get isStencilEnable(): boolean;
  120159. /** @hidden */
  120160. _prepareWorkingCanvas(): void;
  120161. /**
  120162. * Reset the texture cache to empty state
  120163. */
  120164. resetTextureCache(): void;
  120165. /**
  120166. * Gets an object containing information about the current webGL context
  120167. * @returns an object containing the vender, the renderer and the version of the current webGL context
  120168. */
  120169. getGlInfo(): {
  120170. vendor: string;
  120171. renderer: string;
  120172. version: string;
  120173. };
  120174. /**
  120175. * Defines the hardware scaling level.
  120176. * By default the hardware scaling level is computed from the window device ratio.
  120177. * 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.
  120178. * @param level defines the level to use
  120179. */
  120180. setHardwareScalingLevel(level: number): void;
  120181. /**
  120182. * Gets the current hardware scaling level.
  120183. * By default the hardware scaling level is computed from the window device ratio.
  120184. * 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.
  120185. * @returns a number indicating the current hardware scaling level
  120186. */
  120187. getHardwareScalingLevel(): number;
  120188. /**
  120189. * Gets the list of loaded textures
  120190. * @returns an array containing all loaded textures
  120191. */
  120192. getLoadedTexturesCache(): InternalTexture[];
  120193. /**
  120194. * Gets the object containing all engine capabilities
  120195. * @returns the EngineCapabilities object
  120196. */
  120197. getCaps(): EngineCapabilities;
  120198. /**
  120199. * stop executing a render loop function and remove it from the execution array
  120200. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  120201. */
  120202. stopRenderLoop(renderFunction?: () => void): void;
  120203. /** @hidden */
  120204. _renderLoop(): void;
  120205. /**
  120206. * Gets the HTML canvas attached with the current webGL context
  120207. * @returns a HTML canvas
  120208. */
  120209. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  120210. /**
  120211. * Gets host window
  120212. * @returns the host window object
  120213. */
  120214. getHostWindow(): Nullable<Window>;
  120215. /**
  120216. * Gets the current render width
  120217. * @param useScreen defines if screen size must be used (or the current render target if any)
  120218. * @returns a number defining the current render width
  120219. */
  120220. getRenderWidth(useScreen?: boolean): number;
  120221. /**
  120222. * Gets the current render height
  120223. * @param useScreen defines if screen size must be used (or the current render target if any)
  120224. * @returns a number defining the current render height
  120225. */
  120226. getRenderHeight(useScreen?: boolean): number;
  120227. /**
  120228. * Can be used to override the current requestAnimationFrame requester.
  120229. * @hidden
  120230. */
  120231. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120232. /**
  120233. * Register and execute a render loop. The engine can have more than one render function
  120234. * @param renderFunction defines the function to continuously execute
  120235. */
  120236. runRenderLoop(renderFunction: () => void): void;
  120237. /**
  120238. * Clear the current render buffer or the current render target (if any is set up)
  120239. * @param color defines the color to use
  120240. * @param backBuffer defines if the back buffer must be cleared
  120241. * @param depth defines if the depth buffer must be cleared
  120242. * @param stencil defines if the stencil buffer must be cleared
  120243. */
  120244. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120245. private _viewportCached;
  120246. /** @hidden */
  120247. _viewport(x: number, y: number, width: number, height: number): void;
  120248. /**
  120249. * Set the WebGL's viewport
  120250. * @param viewport defines the viewport element to be used
  120251. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  120252. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  120253. */
  120254. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  120255. /**
  120256. * Begin a new frame
  120257. */
  120258. beginFrame(): void;
  120259. /**
  120260. * Enf the current frame
  120261. */
  120262. endFrame(): void;
  120263. /**
  120264. * Resize the view according to the canvas' size
  120265. */
  120266. resize(): void;
  120267. /**
  120268. * Force a specific size of the canvas
  120269. * @param width defines the new canvas' width
  120270. * @param height defines the new canvas' height
  120271. * @returns true if the size was changed
  120272. */
  120273. setSize(width: number, height: number): boolean;
  120274. /**
  120275. * Binds the frame buffer to the specified texture.
  120276. * @param texture The texture to render to or null for the default canvas
  120277. * @param faceIndex The face of the texture to render to in case of cube texture
  120278. * @param requiredWidth The width of the target to render to
  120279. * @param requiredHeight The height of the target to render to
  120280. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120281. * @param lodLevel defines the lod level to bind to the frame buffer
  120282. * @param layer defines the 2d array index to bind to frame buffer to
  120283. */
  120284. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  120285. /** @hidden */
  120286. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120287. /**
  120288. * Unbind the current render target texture from the webGL context
  120289. * @param texture defines the render target texture to unbind
  120290. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120291. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120292. */
  120293. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120294. /**
  120295. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  120296. */
  120297. flushFramebuffer(): void;
  120298. /**
  120299. * Unbind the current render target and bind the default framebuffer
  120300. */
  120301. restoreDefaultFramebuffer(): void;
  120302. /** @hidden */
  120303. protected _resetVertexBufferBinding(): void;
  120304. /**
  120305. * Creates a vertex buffer
  120306. * @param data the data for the vertex buffer
  120307. * @returns the new WebGL static buffer
  120308. */
  120309. createVertexBuffer(data: DataArray): DataBuffer;
  120310. private _createVertexBuffer;
  120311. /**
  120312. * Creates a dynamic vertex buffer
  120313. * @param data the data for the dynamic vertex buffer
  120314. * @returns the new WebGL dynamic buffer
  120315. */
  120316. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120317. protected _resetIndexBufferBinding(): void;
  120318. /**
  120319. * Creates a new index buffer
  120320. * @param indices defines the content of the index buffer
  120321. * @param updatable defines if the index buffer must be updatable
  120322. * @returns a new webGL buffer
  120323. */
  120324. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  120325. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  120326. /**
  120327. * Bind a webGL buffer to the webGL context
  120328. * @param buffer defines the buffer to bind
  120329. */
  120330. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  120331. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  120332. private bindBuffer;
  120333. /**
  120334. * update the bound buffer with the given data
  120335. * @param data defines the data to update
  120336. */
  120337. updateArrayBuffer(data: Float32Array): void;
  120338. private _vertexAttribPointer;
  120339. /** @hidden */
  120340. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  120341. private _bindVertexBuffersAttributes;
  120342. /**
  120343. * Records a vertex array object
  120344. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  120345. * @param vertexBuffers defines the list of vertex buffers to store
  120346. * @param indexBuffer defines the index buffer to store
  120347. * @param effect defines the effect to store
  120348. * @returns the new vertex array object
  120349. */
  120350. recordVertexArrayObject(vertexBuffers: {
  120351. [key: string]: VertexBuffer;
  120352. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120353. /**
  120354. * Bind a specific vertex array object
  120355. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  120356. * @param vertexArrayObject defines the vertex array object to bind
  120357. * @param indexBuffer defines the index buffer to bind
  120358. */
  120359. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  120360. /**
  120361. * Bind webGl buffers directly to the webGL context
  120362. * @param vertexBuffer defines the vertex buffer to bind
  120363. * @param indexBuffer defines the index buffer to bind
  120364. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  120365. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  120366. * @param effect defines the effect associated with the vertex buffer
  120367. */
  120368. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  120369. private _unbindVertexArrayObject;
  120370. /**
  120371. * Bind a list of vertex buffers to the webGL context
  120372. * @param vertexBuffers defines the list of vertex buffers to bind
  120373. * @param indexBuffer defines the index buffer to bind
  120374. * @param effect defines the effect associated with the vertex buffers
  120375. */
  120376. bindBuffers(vertexBuffers: {
  120377. [key: string]: Nullable<VertexBuffer>;
  120378. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  120379. /**
  120380. * Unbind all instance attributes
  120381. */
  120382. unbindInstanceAttributes(): void;
  120383. /**
  120384. * Release and free the memory of a vertex array object
  120385. * @param vao defines the vertex array object to delete
  120386. */
  120387. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  120388. /** @hidden */
  120389. _releaseBuffer(buffer: DataBuffer): boolean;
  120390. protected _deleteBuffer(buffer: DataBuffer): void;
  120391. /**
  120392. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  120393. * @param instancesBuffer defines the webGL buffer to update and bind
  120394. * @param data defines the data to store in the buffer
  120395. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  120396. */
  120397. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  120398. /**
  120399. * Bind the content of a webGL buffer used with instantiation
  120400. * @param instancesBuffer defines the webGL buffer to bind
  120401. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  120402. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  120403. */
  120404. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  120405. /**
  120406. * Disable the instance attribute corresponding to the name in parameter
  120407. * @param name defines the name of the attribute to disable
  120408. */
  120409. disableInstanceAttributeByName(name: string): void;
  120410. /**
  120411. * Disable the instance attribute corresponding to the location in parameter
  120412. * @param attributeLocation defines the attribute location of the attribute to disable
  120413. */
  120414. disableInstanceAttribute(attributeLocation: number): void;
  120415. /**
  120416. * Disable the attribute corresponding to the location in parameter
  120417. * @param attributeLocation defines the attribute location of the attribute to disable
  120418. */
  120419. disableAttributeByIndex(attributeLocation: number): void;
  120420. /**
  120421. * Send a draw order
  120422. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120423. * @param indexStart defines the starting index
  120424. * @param indexCount defines the number of index to draw
  120425. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120426. */
  120427. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120428. /**
  120429. * Draw a list of points
  120430. * @param verticesStart defines the index of first vertex to draw
  120431. * @param verticesCount defines the count of vertices to draw
  120432. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120433. */
  120434. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120435. /**
  120436. * Draw a list of unindexed primitives
  120437. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120438. * @param verticesStart defines the index of first vertex to draw
  120439. * @param verticesCount defines the count of vertices to draw
  120440. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120441. */
  120442. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120443. /**
  120444. * Draw a list of indexed primitives
  120445. * @param fillMode defines the primitive to use
  120446. * @param indexStart defines the starting index
  120447. * @param indexCount defines the number of index to draw
  120448. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120449. */
  120450. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120451. /**
  120452. * Draw a list of unindexed primitives
  120453. * @param fillMode defines the primitive to use
  120454. * @param verticesStart defines the index of first vertex to draw
  120455. * @param verticesCount defines the count of vertices to draw
  120456. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120457. */
  120458. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120459. private _drawMode;
  120460. /** @hidden */
  120461. protected _reportDrawCall(): void;
  120462. /** @hidden */
  120463. _releaseEffect(effect: Effect): void;
  120464. /** @hidden */
  120465. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120466. /**
  120467. * Create a new effect (used to store vertex/fragment shaders)
  120468. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  120469. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  120470. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  120471. * @param samplers defines an array of string used to represent textures
  120472. * @param defines defines the string containing the defines to use to compile the shaders
  120473. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  120474. * @param onCompiled defines a function to call when the effect creation is successful
  120475. * @param onError defines a function to call when the effect creation has failed
  120476. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  120477. * @returns the new Effect
  120478. */
  120479. 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;
  120480. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  120481. private _compileShader;
  120482. private _compileRawShader;
  120483. /** @hidden */
  120484. _getShaderSource(shader: WebGLShader): Nullable<string>;
  120485. /**
  120486. * Directly creates a webGL program
  120487. * @param pipelineContext defines the pipeline context to attach to
  120488. * @param vertexCode defines the vertex shader code to use
  120489. * @param fragmentCode defines the fragment shader code to use
  120490. * @param context defines the webGL context to use (if not set, the current one will be used)
  120491. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  120492. * @returns the new webGL program
  120493. */
  120494. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  120495. /**
  120496. * Creates a webGL program
  120497. * @param pipelineContext defines the pipeline context to attach to
  120498. * @param vertexCode defines the vertex shader code to use
  120499. * @param fragmentCode defines the fragment shader code to use
  120500. * @param defines defines the string containing the defines to use to compile the shaders
  120501. * @param context defines the webGL context to use (if not set, the current one will be used)
  120502. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  120503. * @returns the new webGL program
  120504. */
  120505. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  120506. /**
  120507. * Creates a new pipeline context
  120508. * @returns the new pipeline
  120509. */
  120510. createPipelineContext(): IPipelineContext;
  120511. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  120512. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  120513. /** @hidden */
  120514. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120515. /** @hidden */
  120516. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120517. /** @hidden */
  120518. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120519. /**
  120520. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  120521. * @param pipelineContext defines the pipeline context to use
  120522. * @param uniformsNames defines the list of uniform names
  120523. * @returns an array of webGL uniform locations
  120524. */
  120525. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  120526. /**
  120527. * Gets the lsit of active attributes for a given webGL program
  120528. * @param pipelineContext defines the pipeline context to use
  120529. * @param attributesNames defines the list of attribute names to get
  120530. * @returns an array of indices indicating the offset of each attribute
  120531. */
  120532. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120533. /**
  120534. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  120535. * @param effect defines the effect to activate
  120536. */
  120537. enableEffect(effect: Nullable<Effect>): void;
  120538. /**
  120539. * Set the value of an uniform to a number (int)
  120540. * @param uniform defines the webGL uniform location where to store the value
  120541. * @param value defines the int number to store
  120542. * @returns true if the value was set
  120543. */
  120544. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  120545. /**
  120546. * Set the value of an uniform to an array of int32
  120547. * @param uniform defines the webGL uniform location where to store the value
  120548. * @param array defines the array of int32 to store
  120549. * @returns true if the value was set
  120550. */
  120551. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120552. /**
  120553. * Set the value of an uniform to an array of int32 (stored as vec2)
  120554. * @param uniform defines the webGL uniform location where to store the value
  120555. * @param array defines the array of int32 to store
  120556. * @returns true if the value was set
  120557. */
  120558. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120559. /**
  120560. * Set the value of an uniform to an array of int32 (stored as vec3)
  120561. * @param uniform defines the webGL uniform location where to store the value
  120562. * @param array defines the array of int32 to store
  120563. * @returns true if the value was set
  120564. */
  120565. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120566. /**
  120567. * Set the value of an uniform to an array of int32 (stored as vec4)
  120568. * @param uniform defines the webGL uniform location where to store the value
  120569. * @param array defines the array of int32 to store
  120570. * @returns true if the value was set
  120571. */
  120572. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120573. /**
  120574. * Set the value of an uniform to an array of number
  120575. * @param uniform defines the webGL uniform location where to store the value
  120576. * @param array defines the array of number to store
  120577. * @returns true if the value was set
  120578. */
  120579. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120580. /**
  120581. * Set the value of an uniform to an array of number (stored as vec2)
  120582. * @param uniform defines the webGL uniform location where to store the value
  120583. * @param array defines the array of number to store
  120584. * @returns true if the value was set
  120585. */
  120586. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120587. /**
  120588. * Set the value of an uniform to an array of number (stored as vec3)
  120589. * @param uniform defines the webGL uniform location where to store the value
  120590. * @param array defines the array of number to store
  120591. * @returns true if the value was set
  120592. */
  120593. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120594. /**
  120595. * Set the value of an uniform to an array of number (stored as vec4)
  120596. * @param uniform defines the webGL uniform location where to store the value
  120597. * @param array defines the array of number to store
  120598. * @returns true if the value was set
  120599. */
  120600. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120601. /**
  120602. * Set the value of an uniform to an array of float32 (stored as matrices)
  120603. * @param uniform defines the webGL uniform location where to store the value
  120604. * @param matrices defines the array of float32 to store
  120605. * @returns true if the value was set
  120606. */
  120607. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  120608. /**
  120609. * Set the value of an uniform to a matrix (3x3)
  120610. * @param uniform defines the webGL uniform location where to store the value
  120611. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  120612. * @returns true if the value was set
  120613. */
  120614. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  120615. /**
  120616. * Set the value of an uniform to a matrix (2x2)
  120617. * @param uniform defines the webGL uniform location where to store the value
  120618. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  120619. * @returns true if the value was set
  120620. */
  120621. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  120622. /**
  120623. * Set the value of an uniform to a number (float)
  120624. * @param uniform defines the webGL uniform location where to store the value
  120625. * @param value defines the float number to store
  120626. * @returns true if the value was transfered
  120627. */
  120628. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  120629. /**
  120630. * Set the value of an uniform to a vec2
  120631. * @param uniform defines the webGL uniform location where to store the value
  120632. * @param x defines the 1st component of the value
  120633. * @param y defines the 2nd component of the value
  120634. * @returns true if the value was set
  120635. */
  120636. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  120637. /**
  120638. * Set the value of an uniform to a vec3
  120639. * @param uniform defines the webGL uniform location where to store the value
  120640. * @param x defines the 1st component of the value
  120641. * @param y defines the 2nd component of the value
  120642. * @param z defines the 3rd component of the value
  120643. * @returns true if the value was set
  120644. */
  120645. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  120646. /**
  120647. * Set the value of an uniform to a vec4
  120648. * @param uniform defines the webGL uniform location where to store the value
  120649. * @param x defines the 1st component of the value
  120650. * @param y defines the 2nd component of the value
  120651. * @param z defines the 3rd component of the value
  120652. * @param w defines the 4th component of the value
  120653. * @returns true if the value was set
  120654. */
  120655. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  120656. /**
  120657. * Apply all cached states (depth, culling, stencil and alpha)
  120658. */
  120659. applyStates(): void;
  120660. /**
  120661. * Enable or disable color writing
  120662. * @param enable defines the state to set
  120663. */
  120664. setColorWrite(enable: boolean): void;
  120665. /**
  120666. * Gets a boolean indicating if color writing is enabled
  120667. * @returns the current color writing state
  120668. */
  120669. getColorWrite(): boolean;
  120670. /**
  120671. * Gets the depth culling state manager
  120672. */
  120673. get depthCullingState(): DepthCullingState;
  120674. /**
  120675. * Gets the alpha state manager
  120676. */
  120677. get alphaState(): AlphaState;
  120678. /**
  120679. * Gets the stencil state manager
  120680. */
  120681. get stencilState(): StencilState;
  120682. /**
  120683. * Clears the list of texture accessible through engine.
  120684. * This can help preventing texture load conflict due to name collision.
  120685. */
  120686. clearInternalTexturesCache(): void;
  120687. /**
  120688. * Force the entire cache to be cleared
  120689. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120690. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120691. */
  120692. wipeCaches(bruteForce?: boolean): void;
  120693. /** @hidden */
  120694. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  120695. min: number;
  120696. mag: number;
  120697. };
  120698. /** @hidden */
  120699. _createTexture(): WebGLTexture;
  120700. /**
  120701. * Usually called from Texture.ts.
  120702. * Passed information to create a WebGLTexture
  120703. * @param url defines a value which contains one of the following:
  120704. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120705. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120706. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120707. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120708. * @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)
  120709. * @param scene needed for loading to the correct scene
  120710. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120711. * @param onLoad optional callback to be called upon successful completion
  120712. * @param onError optional callback to be called upon failure
  120713. * @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
  120714. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120715. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120716. * @param forcedExtension defines the extension to use to pick the right loader
  120717. * @param mimeType defines an optional mime type
  120718. * @param loaderOptions options to be passed to the loader
  120719. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120720. */
  120721. 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;
  120722. /**
  120723. * Loads an image as an HTMLImageElement.
  120724. * @param input url string, ArrayBuffer, or Blob to load
  120725. * @param onLoad callback called when the image successfully loads
  120726. * @param onError callback called when the image fails to load
  120727. * @param offlineProvider offline provider for caching
  120728. * @param mimeType optional mime type
  120729. * @returns the HTMLImageElement of the loaded image
  120730. * @hidden
  120731. */
  120732. 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>;
  120733. /**
  120734. * @hidden
  120735. */
  120736. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  120737. private _unpackFlipYCached;
  120738. /**
  120739. * In case you are sharing the context with other applications, it might
  120740. * be interested to not cache the unpack flip y state to ensure a consistent
  120741. * value would be set.
  120742. */
  120743. enableUnpackFlipYCached: boolean;
  120744. /** @hidden */
  120745. _unpackFlipY(value: boolean): void;
  120746. /** @hidden */
  120747. _getUnpackAlignement(): number;
  120748. private _getTextureTarget;
  120749. /**
  120750. * Update the sampling mode of a given texture
  120751. * @param samplingMode defines the required sampling mode
  120752. * @param texture defines the texture to update
  120753. * @param generateMipMaps defines whether to generate mipmaps for the texture
  120754. */
  120755. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  120756. /**
  120757. * Update the sampling mode of a given texture
  120758. * @param texture defines the texture to update
  120759. * @param wrapU defines the texture wrap mode of the u coordinates
  120760. * @param wrapV defines the texture wrap mode of the v coordinates
  120761. * @param wrapR defines the texture wrap mode of the r coordinates
  120762. */
  120763. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  120764. /** @hidden */
  120765. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  120766. width: number;
  120767. height: number;
  120768. layers?: number;
  120769. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  120770. /** @hidden */
  120771. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120772. /** @hidden */
  120773. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  120774. /**
  120775. * Update a portion of an internal texture
  120776. * @param texture defines the texture to update
  120777. * @param imageData defines the data to store into the texture
  120778. * @param xOffset defines the x coordinates of the update rectangle
  120779. * @param yOffset defines the y coordinates of the update rectangle
  120780. * @param width defines the width of the update rectangle
  120781. * @param height defines the height of the update rectangle
  120782. * @param faceIndex defines the face index if texture is a cube (0 by default)
  120783. * @param lod defines the lod level to update (0 by default)
  120784. */
  120785. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  120786. /** @hidden */
  120787. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120788. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  120789. private _prepareWebGLTexture;
  120790. /** @hidden */
  120791. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  120792. private _getDepthStencilBuffer;
  120793. /** @hidden */
  120794. _releaseFramebufferObjects(texture: InternalTexture): void;
  120795. /** @hidden */
  120796. _releaseTexture(texture: InternalTexture): void;
  120797. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120798. protected _setProgram(program: WebGLProgram): void;
  120799. protected _boundUniforms: {
  120800. [key: number]: WebGLUniformLocation;
  120801. };
  120802. /**
  120803. * Binds an effect to the webGL context
  120804. * @param effect defines the effect to bind
  120805. */
  120806. bindSamplers(effect: Effect): void;
  120807. private _activateCurrentTexture;
  120808. /** @hidden */
  120809. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  120810. /** @hidden */
  120811. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  120812. /**
  120813. * Unbind all textures from the webGL context
  120814. */
  120815. unbindAllTextures(): void;
  120816. /**
  120817. * Sets a texture to the according uniform.
  120818. * @param channel The texture channel
  120819. * @param uniform The uniform to set
  120820. * @param texture The texture to apply
  120821. */
  120822. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  120823. private _bindSamplerUniformToChannel;
  120824. private _getTextureWrapMode;
  120825. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120826. /**
  120827. * Sets an array of texture to the webGL context
  120828. * @param channel defines the channel where the texture array must be set
  120829. * @param uniform defines the associated uniform location
  120830. * @param textures defines the array of textures to bind
  120831. */
  120832. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  120833. /** @hidden */
  120834. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  120835. private _setTextureParameterFloat;
  120836. private _setTextureParameterInteger;
  120837. /**
  120838. * Unbind all vertex attributes from the webGL context
  120839. */
  120840. unbindAllAttributes(): void;
  120841. /**
  120842. * 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
  120843. */
  120844. releaseEffects(): void;
  120845. /**
  120846. * Dispose and release all associated resources
  120847. */
  120848. dispose(): void;
  120849. /**
  120850. * Attach a new callback raised when context lost event is fired
  120851. * @param callback defines the callback to call
  120852. */
  120853. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120854. /**
  120855. * Attach a new callback raised when context restored event is fired
  120856. * @param callback defines the callback to call
  120857. */
  120858. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120859. /**
  120860. * Get the current error code of the webGL context
  120861. * @returns the error code
  120862. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120863. */
  120864. getError(): number;
  120865. private _canRenderToFloatFramebuffer;
  120866. private _canRenderToHalfFloatFramebuffer;
  120867. private _canRenderToFramebuffer;
  120868. /** @hidden */
  120869. _getWebGLTextureType(type: number): number;
  120870. /** @hidden */
  120871. _getInternalFormat(format: number): number;
  120872. /** @hidden */
  120873. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  120874. /** @hidden */
  120875. _getRGBAMultiSampleBufferFormat(type: number): number;
  120876. /** @hidden */
  120877. _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;
  120878. /**
  120879. * Loads a file from a url
  120880. * @param url url to load
  120881. * @param onSuccess callback called when the file successfully loads
  120882. * @param onProgress callback called while file is loading (if the server supports this mode)
  120883. * @param offlineProvider defines the offline provider for caching
  120884. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  120885. * @param onError callback called when the file fails to load
  120886. * @returns a file request object
  120887. * @hidden
  120888. */
  120889. 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;
  120890. /**
  120891. * Reads pixels from the current frame buffer. Please note that this function can be slow
  120892. * @param x defines the x coordinate of the rectangle where pixels must be read
  120893. * @param y defines the y coordinate of the rectangle where pixels must be read
  120894. * @param width defines the width of the rectangle where pixels must be read
  120895. * @param height defines the height of the rectangle where pixels must be read
  120896. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  120897. * @returns a Uint8Array containing RGBA colors
  120898. */
  120899. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  120900. private static _IsSupported;
  120901. private static _HasMajorPerformanceCaveat;
  120902. /**
  120903. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120904. */
  120905. static get IsSupported(): boolean;
  120906. /**
  120907. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120908. * @returns true if the engine can be created
  120909. * @ignorenaming
  120910. */
  120911. static isSupported(): boolean;
  120912. /**
  120913. * 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)
  120914. */
  120915. static get HasMajorPerformanceCaveat(): boolean;
  120916. /**
  120917. * Find the next highest power of two.
  120918. * @param x Number to start search from.
  120919. * @return Next highest power of two.
  120920. */
  120921. static CeilingPOT(x: number): number;
  120922. /**
  120923. * Find the next lowest power of two.
  120924. * @param x Number to start search from.
  120925. * @return Next lowest power of two.
  120926. */
  120927. static FloorPOT(x: number): number;
  120928. /**
  120929. * Find the nearest power of two.
  120930. * @param x Number to start search from.
  120931. * @return Next nearest power of two.
  120932. */
  120933. static NearestPOT(x: number): number;
  120934. /**
  120935. * Get the closest exponent of two
  120936. * @param value defines the value to approximate
  120937. * @param max defines the maximum value to return
  120938. * @param mode defines how to define the closest value
  120939. * @returns closest exponent of two of the given value
  120940. */
  120941. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  120942. /**
  120943. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  120944. * @param func - the function to be called
  120945. * @param requester - the object that will request the next frame. Falls back to window.
  120946. * @returns frame number
  120947. */
  120948. static QueueNewFrame(func: () => void, requester?: any): number;
  120949. /**
  120950. * Gets host document
  120951. * @returns the host document object
  120952. */
  120953. getHostDocument(): Nullable<Document>;
  120954. }
  120955. }
  120956. declare module BABYLON {
  120957. /**
  120958. * Defines the source of the internal texture
  120959. */
  120960. export enum InternalTextureSource {
  120961. /**
  120962. * The source of the texture data is unknown
  120963. */
  120964. Unknown = 0,
  120965. /**
  120966. * Texture data comes from an URL
  120967. */
  120968. Url = 1,
  120969. /**
  120970. * Texture data is only used for temporary storage
  120971. */
  120972. Temp = 2,
  120973. /**
  120974. * Texture data comes from raw data (ArrayBuffer)
  120975. */
  120976. Raw = 3,
  120977. /**
  120978. * Texture content is dynamic (video or dynamic texture)
  120979. */
  120980. Dynamic = 4,
  120981. /**
  120982. * Texture content is generated by rendering to it
  120983. */
  120984. RenderTarget = 5,
  120985. /**
  120986. * Texture content is part of a multi render target process
  120987. */
  120988. MultiRenderTarget = 6,
  120989. /**
  120990. * Texture data comes from a cube data file
  120991. */
  120992. Cube = 7,
  120993. /**
  120994. * Texture data comes from a raw cube data
  120995. */
  120996. CubeRaw = 8,
  120997. /**
  120998. * Texture data come from a prefiltered cube data file
  120999. */
  121000. CubePrefiltered = 9,
  121001. /**
  121002. * Texture content is raw 3D data
  121003. */
  121004. Raw3D = 10,
  121005. /**
  121006. * Texture content is raw 2D array data
  121007. */
  121008. Raw2DArray = 11,
  121009. /**
  121010. * Texture content is a depth texture
  121011. */
  121012. Depth = 12,
  121013. /**
  121014. * Texture data comes from a raw cube data encoded with RGBD
  121015. */
  121016. CubeRawRGBD = 13
  121017. }
  121018. /**
  121019. * Class used to store data associated with WebGL texture data for the engine
  121020. * This class should not be used directly
  121021. */
  121022. export class InternalTexture {
  121023. /** @hidden */
  121024. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  121025. /**
  121026. * Defines if the texture is ready
  121027. */
  121028. isReady: boolean;
  121029. /**
  121030. * Defines if the texture is a cube texture
  121031. */
  121032. isCube: boolean;
  121033. /**
  121034. * Defines if the texture contains 3D data
  121035. */
  121036. is3D: boolean;
  121037. /**
  121038. * Defines if the texture contains 2D array data
  121039. */
  121040. is2DArray: boolean;
  121041. /**
  121042. * Defines if the texture contains multiview data
  121043. */
  121044. isMultiview: boolean;
  121045. /**
  121046. * Gets the URL used to load this texture
  121047. */
  121048. url: string;
  121049. /**
  121050. * Gets the sampling mode of the texture
  121051. */
  121052. samplingMode: number;
  121053. /**
  121054. * Gets a boolean indicating if the texture needs mipmaps generation
  121055. */
  121056. generateMipMaps: boolean;
  121057. /**
  121058. * Gets the number of samples used by the texture (WebGL2+ only)
  121059. */
  121060. samples: number;
  121061. /**
  121062. * Gets the type of the texture (int, float...)
  121063. */
  121064. type: number;
  121065. /**
  121066. * Gets the format of the texture (RGB, RGBA...)
  121067. */
  121068. format: number;
  121069. /**
  121070. * Observable called when the texture is loaded
  121071. */
  121072. onLoadedObservable: Observable<InternalTexture>;
  121073. /**
  121074. * Gets the width of the texture
  121075. */
  121076. width: number;
  121077. /**
  121078. * Gets the height of the texture
  121079. */
  121080. height: number;
  121081. /**
  121082. * Gets the depth of the texture
  121083. */
  121084. depth: number;
  121085. /**
  121086. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  121087. */
  121088. baseWidth: number;
  121089. /**
  121090. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  121091. */
  121092. baseHeight: number;
  121093. /**
  121094. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  121095. */
  121096. baseDepth: number;
  121097. /**
  121098. * Gets a boolean indicating if the texture is inverted on Y axis
  121099. */
  121100. invertY: boolean;
  121101. /** @hidden */
  121102. _invertVScale: boolean;
  121103. /** @hidden */
  121104. _associatedChannel: number;
  121105. /** @hidden */
  121106. _source: InternalTextureSource;
  121107. /** @hidden */
  121108. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  121109. /** @hidden */
  121110. _bufferView: Nullable<ArrayBufferView>;
  121111. /** @hidden */
  121112. _bufferViewArray: Nullable<ArrayBufferView[]>;
  121113. /** @hidden */
  121114. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  121115. /** @hidden */
  121116. _size: number;
  121117. /** @hidden */
  121118. _extension: string;
  121119. /** @hidden */
  121120. _files: Nullable<string[]>;
  121121. /** @hidden */
  121122. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  121123. /** @hidden */
  121124. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  121125. /** @hidden */
  121126. _framebuffer: Nullable<WebGLFramebuffer>;
  121127. /** @hidden */
  121128. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  121129. /** @hidden */
  121130. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  121131. /** @hidden */
  121132. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  121133. /** @hidden */
  121134. _attachments: Nullable<number[]>;
  121135. /** @hidden */
  121136. _textureArray: Nullable<InternalTexture[]>;
  121137. /** @hidden */
  121138. _cachedCoordinatesMode: Nullable<number>;
  121139. /** @hidden */
  121140. _cachedWrapU: Nullable<number>;
  121141. /** @hidden */
  121142. _cachedWrapV: Nullable<number>;
  121143. /** @hidden */
  121144. _cachedWrapR: Nullable<number>;
  121145. /** @hidden */
  121146. _cachedAnisotropicFilteringLevel: Nullable<number>;
  121147. /** @hidden */
  121148. _isDisabled: boolean;
  121149. /** @hidden */
  121150. _compression: Nullable<string>;
  121151. /** @hidden */
  121152. _generateStencilBuffer: boolean;
  121153. /** @hidden */
  121154. _generateDepthBuffer: boolean;
  121155. /** @hidden */
  121156. _comparisonFunction: number;
  121157. /** @hidden */
  121158. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  121159. /** @hidden */
  121160. _lodGenerationScale: number;
  121161. /** @hidden */
  121162. _lodGenerationOffset: number;
  121163. /** @hidden */
  121164. _depthStencilTexture: Nullable<InternalTexture>;
  121165. /** @hidden */
  121166. _colorTextureArray: Nullable<WebGLTexture>;
  121167. /** @hidden */
  121168. _depthStencilTextureArray: Nullable<WebGLTexture>;
  121169. /** @hidden */
  121170. _lodTextureHigh: Nullable<BaseTexture>;
  121171. /** @hidden */
  121172. _lodTextureMid: Nullable<BaseTexture>;
  121173. /** @hidden */
  121174. _lodTextureLow: Nullable<BaseTexture>;
  121175. /** @hidden */
  121176. _isRGBD: boolean;
  121177. /** @hidden */
  121178. _linearSpecularLOD: boolean;
  121179. /** @hidden */
  121180. _irradianceTexture: Nullable<BaseTexture>;
  121181. /** @hidden */
  121182. _webGLTexture: Nullable<WebGLTexture>;
  121183. /** @hidden */
  121184. _references: number;
  121185. /** @hidden */
  121186. _gammaSpace: Nullable<boolean>;
  121187. private _engine;
  121188. /**
  121189. * Gets the Engine the texture belongs to.
  121190. * @returns The babylon engine
  121191. */
  121192. getEngine(): ThinEngine;
  121193. /**
  121194. * Gets the data source type of the texture
  121195. */
  121196. get source(): InternalTextureSource;
  121197. /**
  121198. * Creates a new InternalTexture
  121199. * @param engine defines the engine to use
  121200. * @param source defines the type of data that will be used
  121201. * @param delayAllocation if the texture allocation should be delayed (default: false)
  121202. */
  121203. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  121204. /**
  121205. * Increments the number of references (ie. the number of Texture that point to it)
  121206. */
  121207. incrementReferences(): void;
  121208. /**
  121209. * Change the size of the texture (not the size of the content)
  121210. * @param width defines the new width
  121211. * @param height defines the new height
  121212. * @param depth defines the new depth (1 by default)
  121213. */
  121214. updateSize(width: int, height: int, depth?: int): void;
  121215. /** @hidden */
  121216. _rebuild(): void;
  121217. /** @hidden */
  121218. _swapAndDie(target: InternalTexture): void;
  121219. /**
  121220. * Dispose the current allocated resources
  121221. */
  121222. dispose(): void;
  121223. }
  121224. }
  121225. declare module BABYLON {
  121226. /**
  121227. * Interface used to present a loading screen while loading a scene
  121228. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121229. */
  121230. export interface ILoadingScreen {
  121231. /**
  121232. * Function called to display the loading screen
  121233. */
  121234. displayLoadingUI: () => void;
  121235. /**
  121236. * Function called to hide the loading screen
  121237. */
  121238. hideLoadingUI: () => void;
  121239. /**
  121240. * Gets or sets the color to use for the background
  121241. */
  121242. loadingUIBackgroundColor: string;
  121243. /**
  121244. * Gets or sets the text to display while loading
  121245. */
  121246. loadingUIText: string;
  121247. }
  121248. /**
  121249. * Class used for the default loading screen
  121250. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121251. */
  121252. export class DefaultLoadingScreen implements ILoadingScreen {
  121253. private _renderingCanvas;
  121254. private _loadingText;
  121255. private _loadingDivBackgroundColor;
  121256. private _loadingDiv;
  121257. private _loadingTextDiv;
  121258. /** Gets or sets the logo url to use for the default loading screen */
  121259. static DefaultLogoUrl: string;
  121260. /** Gets or sets the spinner url to use for the default loading screen */
  121261. static DefaultSpinnerUrl: string;
  121262. /**
  121263. * Creates a new default loading screen
  121264. * @param _renderingCanvas defines the canvas used to render the scene
  121265. * @param _loadingText defines the default text to display
  121266. * @param _loadingDivBackgroundColor defines the default background color
  121267. */
  121268. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  121269. /**
  121270. * Function called to display the loading screen
  121271. */
  121272. displayLoadingUI(): void;
  121273. /**
  121274. * Function called to hide the loading screen
  121275. */
  121276. hideLoadingUI(): void;
  121277. /**
  121278. * Gets or sets the text to display while loading
  121279. */
  121280. set loadingUIText(text: string);
  121281. get loadingUIText(): string;
  121282. /**
  121283. * Gets or sets the color to use for the background
  121284. */
  121285. get loadingUIBackgroundColor(): string;
  121286. set loadingUIBackgroundColor(color: string);
  121287. private _resizeLoadingUI;
  121288. }
  121289. }
  121290. declare module BABYLON {
  121291. /**
  121292. * Interface for any object that can request an animation frame
  121293. */
  121294. export interface ICustomAnimationFrameRequester {
  121295. /**
  121296. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  121297. */
  121298. renderFunction?: Function;
  121299. /**
  121300. * Called to request the next frame to render to
  121301. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  121302. */
  121303. requestAnimationFrame: Function;
  121304. /**
  121305. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  121306. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  121307. */
  121308. requestID?: number;
  121309. }
  121310. }
  121311. declare module BABYLON {
  121312. /**
  121313. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  121314. */
  121315. export class PerformanceMonitor {
  121316. private _enabled;
  121317. private _rollingFrameTime;
  121318. private _lastFrameTimeMs;
  121319. /**
  121320. * constructor
  121321. * @param frameSampleSize The number of samples required to saturate the sliding window
  121322. */
  121323. constructor(frameSampleSize?: number);
  121324. /**
  121325. * Samples current frame
  121326. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  121327. */
  121328. sampleFrame(timeMs?: number): void;
  121329. /**
  121330. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121331. */
  121332. get averageFrameTime(): number;
  121333. /**
  121334. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121335. */
  121336. get averageFrameTimeVariance(): number;
  121337. /**
  121338. * Returns the frame time of the most recent frame
  121339. */
  121340. get instantaneousFrameTime(): number;
  121341. /**
  121342. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  121343. */
  121344. get averageFPS(): number;
  121345. /**
  121346. * Returns the average framerate in frames per second using the most recent frame time
  121347. */
  121348. get instantaneousFPS(): number;
  121349. /**
  121350. * Returns true if enough samples have been taken to completely fill the sliding window
  121351. */
  121352. get isSaturated(): boolean;
  121353. /**
  121354. * Enables contributions to the sliding window sample set
  121355. */
  121356. enable(): void;
  121357. /**
  121358. * Disables contributions to the sliding window sample set
  121359. * Samples will not be interpolated over the disabled period
  121360. */
  121361. disable(): void;
  121362. /**
  121363. * Returns true if sampling is enabled
  121364. */
  121365. get isEnabled(): boolean;
  121366. /**
  121367. * Resets performance monitor
  121368. */
  121369. reset(): void;
  121370. }
  121371. /**
  121372. * RollingAverage
  121373. *
  121374. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  121375. */
  121376. export class RollingAverage {
  121377. /**
  121378. * Current average
  121379. */
  121380. average: number;
  121381. /**
  121382. * Current variance
  121383. */
  121384. variance: number;
  121385. protected _samples: Array<number>;
  121386. protected _sampleCount: number;
  121387. protected _pos: number;
  121388. protected _m2: number;
  121389. /**
  121390. * constructor
  121391. * @param length The number of samples required to saturate the sliding window
  121392. */
  121393. constructor(length: number);
  121394. /**
  121395. * Adds a sample to the sample set
  121396. * @param v The sample value
  121397. */
  121398. add(v: number): void;
  121399. /**
  121400. * Returns previously added values or null if outside of history or outside the sliding window domain
  121401. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  121402. * @return Value previously recorded with add() or null if outside of range
  121403. */
  121404. history(i: number): number;
  121405. /**
  121406. * Returns true if enough samples have been taken to completely fill the sliding window
  121407. * @return true if sample-set saturated
  121408. */
  121409. isSaturated(): boolean;
  121410. /**
  121411. * Resets the rolling average (equivalent to 0 samples taken so far)
  121412. */
  121413. reset(): void;
  121414. /**
  121415. * Wraps a value around the sample range boundaries
  121416. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  121417. * @return Wrapped position in sample range
  121418. */
  121419. protected _wrapPosition(i: number): number;
  121420. }
  121421. }
  121422. declare module BABYLON {
  121423. /**
  121424. * This class is used to track a performance counter which is number based.
  121425. * The user has access to many properties which give statistics of different nature.
  121426. *
  121427. * The implementer can track two kinds of Performance Counter: time and count.
  121428. * 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.
  121429. * 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.
  121430. */
  121431. export class PerfCounter {
  121432. /**
  121433. * Gets or sets a global boolean to turn on and off all the counters
  121434. */
  121435. static Enabled: boolean;
  121436. /**
  121437. * Returns the smallest value ever
  121438. */
  121439. get min(): number;
  121440. /**
  121441. * Returns the biggest value ever
  121442. */
  121443. get max(): number;
  121444. /**
  121445. * Returns the average value since the performance counter is running
  121446. */
  121447. get average(): number;
  121448. /**
  121449. * Returns the average value of the last second the counter was monitored
  121450. */
  121451. get lastSecAverage(): number;
  121452. /**
  121453. * Returns the current value
  121454. */
  121455. get current(): number;
  121456. /**
  121457. * Gets the accumulated total
  121458. */
  121459. get total(): number;
  121460. /**
  121461. * Gets the total value count
  121462. */
  121463. get count(): number;
  121464. /**
  121465. * Creates a new counter
  121466. */
  121467. constructor();
  121468. /**
  121469. * Call this method to start monitoring a new frame.
  121470. * 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.
  121471. */
  121472. fetchNewFrame(): void;
  121473. /**
  121474. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  121475. * @param newCount the count value to add to the monitored count
  121476. * @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.
  121477. */
  121478. addCount(newCount: number, fetchResult: boolean): void;
  121479. /**
  121480. * Start monitoring this performance counter
  121481. */
  121482. beginMonitoring(): void;
  121483. /**
  121484. * Compute the time lapsed since the previous beginMonitoring() call.
  121485. * @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
  121486. */
  121487. endMonitoring(newFrame?: boolean): void;
  121488. private _fetchResult;
  121489. private _startMonitoringTime;
  121490. private _min;
  121491. private _max;
  121492. private _average;
  121493. private _current;
  121494. private _totalValueCount;
  121495. private _totalAccumulated;
  121496. private _lastSecAverage;
  121497. private _lastSecAccumulated;
  121498. private _lastSecTime;
  121499. private _lastSecValueCount;
  121500. }
  121501. }
  121502. declare module BABYLON {
  121503. interface ThinEngine {
  121504. /** @hidden */
  121505. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  121506. }
  121507. }
  121508. declare module BABYLON {
  121509. /**
  121510. * Class used to work with sound analyzer using fast fourier transform (FFT)
  121511. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121512. */
  121513. export class Analyser {
  121514. /**
  121515. * Gets or sets the smoothing
  121516. * @ignorenaming
  121517. */
  121518. SMOOTHING: number;
  121519. /**
  121520. * Gets or sets the FFT table size
  121521. * @ignorenaming
  121522. */
  121523. FFT_SIZE: number;
  121524. /**
  121525. * Gets or sets the bar graph amplitude
  121526. * @ignorenaming
  121527. */
  121528. BARGRAPHAMPLITUDE: number;
  121529. /**
  121530. * Gets or sets the position of the debug canvas
  121531. * @ignorenaming
  121532. */
  121533. DEBUGCANVASPOS: {
  121534. x: number;
  121535. y: number;
  121536. };
  121537. /**
  121538. * Gets or sets the debug canvas size
  121539. * @ignorenaming
  121540. */
  121541. DEBUGCANVASSIZE: {
  121542. width: number;
  121543. height: number;
  121544. };
  121545. private _byteFreqs;
  121546. private _byteTime;
  121547. private _floatFreqs;
  121548. private _webAudioAnalyser;
  121549. private _debugCanvas;
  121550. private _debugCanvasContext;
  121551. private _scene;
  121552. private _registerFunc;
  121553. private _audioEngine;
  121554. /**
  121555. * Creates a new analyser
  121556. * @param scene defines hosting scene
  121557. */
  121558. constructor(scene: Scene);
  121559. /**
  121560. * Get the number of data values you will have to play with for the visualization
  121561. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  121562. * @returns a number
  121563. */
  121564. getFrequencyBinCount(): number;
  121565. /**
  121566. * Gets the current frequency data as a byte array
  121567. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  121568. * @returns a Uint8Array
  121569. */
  121570. getByteFrequencyData(): Uint8Array;
  121571. /**
  121572. * Gets the current waveform as a byte array
  121573. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  121574. * @returns a Uint8Array
  121575. */
  121576. getByteTimeDomainData(): Uint8Array;
  121577. /**
  121578. * Gets the current frequency data as a float array
  121579. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  121580. * @returns a Float32Array
  121581. */
  121582. getFloatFrequencyData(): Float32Array;
  121583. /**
  121584. * Renders the debug canvas
  121585. */
  121586. drawDebugCanvas(): void;
  121587. /**
  121588. * Stops rendering the debug canvas and removes it
  121589. */
  121590. stopDebugCanvas(): void;
  121591. /**
  121592. * Connects two audio nodes
  121593. * @param inputAudioNode defines first node to connect
  121594. * @param outputAudioNode defines second node to connect
  121595. */
  121596. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  121597. /**
  121598. * Releases all associated resources
  121599. */
  121600. dispose(): void;
  121601. }
  121602. }
  121603. declare module BABYLON {
  121604. /**
  121605. * This represents an audio engine and it is responsible
  121606. * to play, synchronize and analyse sounds throughout the application.
  121607. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121608. */
  121609. export interface IAudioEngine extends IDisposable {
  121610. /**
  121611. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  121612. */
  121613. readonly canUseWebAudio: boolean;
  121614. /**
  121615. * Gets the current AudioContext if available.
  121616. */
  121617. readonly audioContext: Nullable<AudioContext>;
  121618. /**
  121619. * The master gain node defines the global audio volume of your audio engine.
  121620. */
  121621. readonly masterGain: GainNode;
  121622. /**
  121623. * Gets whether or not mp3 are supported by your browser.
  121624. */
  121625. readonly isMP3supported: boolean;
  121626. /**
  121627. * Gets whether or not ogg are supported by your browser.
  121628. */
  121629. readonly isOGGsupported: boolean;
  121630. /**
  121631. * Defines if Babylon should emit a warning if WebAudio is not supported.
  121632. * @ignoreNaming
  121633. */
  121634. WarnedWebAudioUnsupported: boolean;
  121635. /**
  121636. * Defines if the audio engine relies on a custom unlocked button.
  121637. * In this case, the embedded button will not be displayed.
  121638. */
  121639. useCustomUnlockedButton: boolean;
  121640. /**
  121641. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  121642. */
  121643. readonly unlocked: boolean;
  121644. /**
  121645. * Event raised when audio has been unlocked on the browser.
  121646. */
  121647. onAudioUnlockedObservable: Observable<IAudioEngine>;
  121648. /**
  121649. * Event raised when audio has been locked on the browser.
  121650. */
  121651. onAudioLockedObservable: Observable<IAudioEngine>;
  121652. /**
  121653. * Flags the audio engine in Locked state.
  121654. * This happens due to new browser policies preventing audio to autoplay.
  121655. */
  121656. lock(): void;
  121657. /**
  121658. * Unlocks the audio engine once a user action has been done on the dom.
  121659. * This is helpful to resume play once browser policies have been satisfied.
  121660. */
  121661. unlock(): void;
  121662. /**
  121663. * Gets the global volume sets on the master gain.
  121664. * @returns the global volume if set or -1 otherwise
  121665. */
  121666. getGlobalVolume(): number;
  121667. /**
  121668. * Sets the global volume of your experience (sets on the master gain).
  121669. * @param newVolume Defines the new global volume of the application
  121670. */
  121671. setGlobalVolume(newVolume: number): void;
  121672. /**
  121673. * Connect the audio engine to an audio analyser allowing some amazing
  121674. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  121675. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  121676. * @param analyser The analyser to connect to the engine
  121677. */
  121678. connectToAnalyser(analyser: Analyser): void;
  121679. }
  121680. }
  121681. declare module BABYLON {
  121682. /**
  121683. * Defines the interface used by display changed events
  121684. */
  121685. export interface IDisplayChangedEventArgs {
  121686. /** Gets the vrDisplay object (if any) */
  121687. vrDisplay: Nullable<any>;
  121688. /** Gets a boolean indicating if webVR is supported */
  121689. vrSupported: boolean;
  121690. }
  121691. /**
  121692. * Defines the interface used by objects containing a viewport (like a camera)
  121693. */
  121694. interface IViewportOwnerLike {
  121695. /**
  121696. * Gets or sets the viewport
  121697. */
  121698. viewport: IViewportLike;
  121699. }
  121700. /**
  121701. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  121702. */
  121703. export class Engine extends ThinEngine {
  121704. /** Defines that alpha blending is disabled */
  121705. static readonly ALPHA_DISABLE: number;
  121706. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  121707. static readonly ALPHA_ADD: number;
  121708. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  121709. static readonly ALPHA_COMBINE: number;
  121710. /** Defines that alpha blending to DEST - SRC * DEST */
  121711. static readonly ALPHA_SUBTRACT: number;
  121712. /** Defines that alpha blending to SRC * DEST */
  121713. static readonly ALPHA_MULTIPLY: number;
  121714. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  121715. static readonly ALPHA_MAXIMIZED: number;
  121716. /** Defines that alpha blending to SRC + DEST */
  121717. static readonly ALPHA_ONEONE: number;
  121718. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  121719. static readonly ALPHA_PREMULTIPLIED: number;
  121720. /**
  121721. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  121722. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  121723. */
  121724. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  121725. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  121726. static readonly ALPHA_INTERPOLATE: number;
  121727. /**
  121728. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  121729. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  121730. */
  121731. static readonly ALPHA_SCREENMODE: number;
  121732. /** Defines that the ressource is not delayed*/
  121733. static readonly DELAYLOADSTATE_NONE: number;
  121734. /** Defines that the ressource was successfully delay loaded */
  121735. static readonly DELAYLOADSTATE_LOADED: number;
  121736. /** Defines that the ressource is currently delay loading */
  121737. static readonly DELAYLOADSTATE_LOADING: number;
  121738. /** Defines that the ressource is delayed and has not started loading */
  121739. static readonly DELAYLOADSTATE_NOTLOADED: number;
  121740. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  121741. static readonly NEVER: number;
  121742. /** 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 */
  121743. static readonly ALWAYS: number;
  121744. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  121745. static readonly LESS: number;
  121746. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  121747. static readonly EQUAL: number;
  121748. /** 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 */
  121749. static readonly LEQUAL: number;
  121750. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  121751. static readonly GREATER: number;
  121752. /** 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 */
  121753. static readonly GEQUAL: number;
  121754. /** 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 */
  121755. static readonly NOTEQUAL: number;
  121756. /** Passed to stencilOperation to specify that stencil value must be kept */
  121757. static readonly KEEP: number;
  121758. /** Passed to stencilOperation to specify that stencil value must be replaced */
  121759. static readonly REPLACE: number;
  121760. /** Passed to stencilOperation to specify that stencil value must be incremented */
  121761. static readonly INCR: number;
  121762. /** Passed to stencilOperation to specify that stencil value must be decremented */
  121763. static readonly DECR: number;
  121764. /** Passed to stencilOperation to specify that stencil value must be inverted */
  121765. static readonly INVERT: number;
  121766. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  121767. static readonly INCR_WRAP: number;
  121768. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  121769. static readonly DECR_WRAP: number;
  121770. /** Texture is not repeating outside of 0..1 UVs */
  121771. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  121772. /** Texture is repeating outside of 0..1 UVs */
  121773. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  121774. /** Texture is repeating and mirrored */
  121775. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  121776. /** ALPHA */
  121777. static readonly TEXTUREFORMAT_ALPHA: number;
  121778. /** LUMINANCE */
  121779. static readonly TEXTUREFORMAT_LUMINANCE: number;
  121780. /** LUMINANCE_ALPHA */
  121781. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  121782. /** RGB */
  121783. static readonly TEXTUREFORMAT_RGB: number;
  121784. /** RGBA */
  121785. static readonly TEXTUREFORMAT_RGBA: number;
  121786. /** RED */
  121787. static readonly TEXTUREFORMAT_RED: number;
  121788. /** RED (2nd reference) */
  121789. static readonly TEXTUREFORMAT_R: number;
  121790. /** RG */
  121791. static readonly TEXTUREFORMAT_RG: number;
  121792. /** RED_INTEGER */
  121793. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  121794. /** RED_INTEGER (2nd reference) */
  121795. static readonly TEXTUREFORMAT_R_INTEGER: number;
  121796. /** RG_INTEGER */
  121797. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  121798. /** RGB_INTEGER */
  121799. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  121800. /** RGBA_INTEGER */
  121801. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  121802. /** UNSIGNED_BYTE */
  121803. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  121804. /** UNSIGNED_BYTE (2nd reference) */
  121805. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  121806. /** FLOAT */
  121807. static readonly TEXTURETYPE_FLOAT: number;
  121808. /** HALF_FLOAT */
  121809. static readonly TEXTURETYPE_HALF_FLOAT: number;
  121810. /** BYTE */
  121811. static readonly TEXTURETYPE_BYTE: number;
  121812. /** SHORT */
  121813. static readonly TEXTURETYPE_SHORT: number;
  121814. /** UNSIGNED_SHORT */
  121815. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  121816. /** INT */
  121817. static readonly TEXTURETYPE_INT: number;
  121818. /** UNSIGNED_INT */
  121819. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  121820. /** UNSIGNED_SHORT_4_4_4_4 */
  121821. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  121822. /** UNSIGNED_SHORT_5_5_5_1 */
  121823. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  121824. /** UNSIGNED_SHORT_5_6_5 */
  121825. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  121826. /** UNSIGNED_INT_2_10_10_10_REV */
  121827. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  121828. /** UNSIGNED_INT_24_8 */
  121829. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  121830. /** UNSIGNED_INT_10F_11F_11F_REV */
  121831. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  121832. /** UNSIGNED_INT_5_9_9_9_REV */
  121833. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  121834. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  121835. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121836. /** nearest is mag = nearest and min = nearest and mip = linear */
  121837. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  121838. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121839. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  121840. /** Trilinear is mag = linear and min = linear and mip = linear */
  121841. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  121842. /** nearest is mag = nearest and min = nearest and mip = linear */
  121843. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  121844. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121845. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  121846. /** Trilinear is mag = linear and min = linear and mip = linear */
  121847. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  121848. /** mag = nearest and min = nearest and mip = nearest */
  121849. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  121850. /** mag = nearest and min = linear and mip = nearest */
  121851. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  121852. /** mag = nearest and min = linear and mip = linear */
  121853. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  121854. /** mag = nearest and min = linear and mip = none */
  121855. static readonly TEXTURE_NEAREST_LINEAR: number;
  121856. /** mag = nearest and min = nearest and mip = none */
  121857. static readonly TEXTURE_NEAREST_NEAREST: number;
  121858. /** mag = linear and min = nearest and mip = nearest */
  121859. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  121860. /** mag = linear and min = nearest and mip = linear */
  121861. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  121862. /** mag = linear and min = linear and mip = none */
  121863. static readonly TEXTURE_LINEAR_LINEAR: number;
  121864. /** mag = linear and min = nearest and mip = none */
  121865. static readonly TEXTURE_LINEAR_NEAREST: number;
  121866. /** Explicit coordinates mode */
  121867. static readonly TEXTURE_EXPLICIT_MODE: number;
  121868. /** Spherical coordinates mode */
  121869. static readonly TEXTURE_SPHERICAL_MODE: number;
  121870. /** Planar coordinates mode */
  121871. static readonly TEXTURE_PLANAR_MODE: number;
  121872. /** Cubic coordinates mode */
  121873. static readonly TEXTURE_CUBIC_MODE: number;
  121874. /** Projection coordinates mode */
  121875. static readonly TEXTURE_PROJECTION_MODE: number;
  121876. /** Skybox coordinates mode */
  121877. static readonly TEXTURE_SKYBOX_MODE: number;
  121878. /** Inverse Cubic coordinates mode */
  121879. static readonly TEXTURE_INVCUBIC_MODE: number;
  121880. /** Equirectangular coordinates mode */
  121881. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  121882. /** Equirectangular Fixed coordinates mode */
  121883. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  121884. /** Equirectangular Fixed Mirrored coordinates mode */
  121885. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  121886. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  121887. static readonly SCALEMODE_FLOOR: number;
  121888. /** Defines that texture rescaling will look for the nearest power of 2 size */
  121889. static readonly SCALEMODE_NEAREST: number;
  121890. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  121891. static readonly SCALEMODE_CEILING: number;
  121892. /**
  121893. * Returns the current npm package of the sdk
  121894. */
  121895. static get NpmPackage(): string;
  121896. /**
  121897. * Returns the current version of the framework
  121898. */
  121899. static get Version(): string;
  121900. /** Gets the list of created engines */
  121901. static get Instances(): Engine[];
  121902. /**
  121903. * Gets the latest created engine
  121904. */
  121905. static get LastCreatedEngine(): Nullable<Engine>;
  121906. /**
  121907. * Gets the latest created scene
  121908. */
  121909. static get LastCreatedScene(): Nullable<Scene>;
  121910. /**
  121911. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  121912. * @param flag defines which part of the materials must be marked as dirty
  121913. * @param predicate defines a predicate used to filter which materials should be affected
  121914. */
  121915. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121916. /**
  121917. * Method called to create the default loading screen.
  121918. * This can be overriden in your own app.
  121919. * @param canvas The rendering canvas element
  121920. * @returns The loading screen
  121921. */
  121922. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  121923. /**
  121924. * Method called to create the default rescale post process on each engine.
  121925. */
  121926. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  121927. /**
  121928. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  121929. **/
  121930. enableOfflineSupport: boolean;
  121931. /**
  121932. * 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)
  121933. **/
  121934. disableManifestCheck: boolean;
  121935. /**
  121936. * Gets the list of created scenes
  121937. */
  121938. scenes: Scene[];
  121939. /**
  121940. * Event raised when a new scene is created
  121941. */
  121942. onNewSceneAddedObservable: Observable<Scene>;
  121943. /**
  121944. * Gets the list of created postprocesses
  121945. */
  121946. postProcesses: PostProcess[];
  121947. /**
  121948. * Gets a boolean indicating if the pointer is currently locked
  121949. */
  121950. isPointerLock: boolean;
  121951. /**
  121952. * Observable event triggered each time the rendering canvas is resized
  121953. */
  121954. onResizeObservable: Observable<Engine>;
  121955. /**
  121956. * Observable event triggered each time the canvas loses focus
  121957. */
  121958. onCanvasBlurObservable: Observable<Engine>;
  121959. /**
  121960. * Observable event triggered each time the canvas gains focus
  121961. */
  121962. onCanvasFocusObservable: Observable<Engine>;
  121963. /**
  121964. * Observable event triggered each time the canvas receives pointerout event
  121965. */
  121966. onCanvasPointerOutObservable: Observable<PointerEvent>;
  121967. /**
  121968. * Observable raised when the engine begins a new frame
  121969. */
  121970. onBeginFrameObservable: Observable<Engine>;
  121971. /**
  121972. * If set, will be used to request the next animation frame for the render loop
  121973. */
  121974. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  121975. /**
  121976. * Observable raised when the engine ends the current frame
  121977. */
  121978. onEndFrameObservable: Observable<Engine>;
  121979. /**
  121980. * Observable raised when the engine is about to compile a shader
  121981. */
  121982. onBeforeShaderCompilationObservable: Observable<Engine>;
  121983. /**
  121984. * Observable raised when the engine has jsut compiled a shader
  121985. */
  121986. onAfterShaderCompilationObservable: Observable<Engine>;
  121987. /**
  121988. * Gets the audio engine
  121989. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121990. * @ignorenaming
  121991. */
  121992. static audioEngine: IAudioEngine;
  121993. /**
  121994. * Default AudioEngine factory responsible of creating the Audio Engine.
  121995. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  121996. */
  121997. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  121998. /**
  121999. * Default offline support factory responsible of creating a tool used to store data locally.
  122000. * By default, this will create a Database object if the workload has been embedded.
  122001. */
  122002. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  122003. private _loadingScreen;
  122004. private _pointerLockRequested;
  122005. private _rescalePostProcess;
  122006. private _deterministicLockstep;
  122007. private _lockstepMaxSteps;
  122008. private _timeStep;
  122009. protected get _supportsHardwareTextureRescaling(): boolean;
  122010. private _fps;
  122011. private _deltaTime;
  122012. /** @hidden */
  122013. _drawCalls: PerfCounter;
  122014. /** 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 */
  122015. canvasTabIndex: number;
  122016. /**
  122017. * Turn this value on if you want to pause FPS computation when in background
  122018. */
  122019. disablePerformanceMonitorInBackground: boolean;
  122020. private _performanceMonitor;
  122021. /**
  122022. * Gets the performance monitor attached to this engine
  122023. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122024. */
  122025. get performanceMonitor(): PerformanceMonitor;
  122026. private _onFocus;
  122027. private _onBlur;
  122028. private _onCanvasPointerOut;
  122029. private _onCanvasBlur;
  122030. private _onCanvasFocus;
  122031. private _onFullscreenChange;
  122032. private _onPointerLockChange;
  122033. /**
  122034. * Gets the HTML element used to attach event listeners
  122035. * @returns a HTML element
  122036. */
  122037. getInputElement(): Nullable<HTMLElement>;
  122038. /**
  122039. * Creates a new engine
  122040. * @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
  122041. * @param antialias defines enable antialiasing (default: false)
  122042. * @param options defines further options to be sent to the getContext() function
  122043. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  122044. */
  122045. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  122046. /**
  122047. * Gets current aspect ratio
  122048. * @param viewportOwner defines the camera to use to get the aspect ratio
  122049. * @param useScreen defines if screen size must be used (or the current render target if any)
  122050. * @returns a number defining the aspect ratio
  122051. */
  122052. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  122053. /**
  122054. * Gets current screen aspect ratio
  122055. * @returns a number defining the aspect ratio
  122056. */
  122057. getScreenAspectRatio(): number;
  122058. /**
  122059. * Gets the client rect of the HTML canvas attached with the current webGL context
  122060. * @returns a client rectanglee
  122061. */
  122062. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  122063. /**
  122064. * Gets the client rect of the HTML element used for events
  122065. * @returns a client rectanglee
  122066. */
  122067. getInputElementClientRect(): Nullable<ClientRect>;
  122068. /**
  122069. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  122070. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122071. * @returns true if engine is in deterministic lock step mode
  122072. */
  122073. isDeterministicLockStep(): boolean;
  122074. /**
  122075. * Gets the max steps when engine is running in deterministic lock step
  122076. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122077. * @returns the max steps
  122078. */
  122079. getLockstepMaxSteps(): number;
  122080. /**
  122081. * Returns the time in ms between steps when using deterministic lock step.
  122082. * @returns time step in (ms)
  122083. */
  122084. getTimeStep(): number;
  122085. /**
  122086. * Force the mipmap generation for the given render target texture
  122087. * @param texture defines the render target texture to use
  122088. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  122089. */
  122090. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  122091. /** States */
  122092. /**
  122093. * Set various states to the webGL context
  122094. * @param culling defines backface culling state
  122095. * @param zOffset defines the value to apply to zOffset (0 by default)
  122096. * @param force defines if states must be applied even if cache is up to date
  122097. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  122098. */
  122099. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122100. /**
  122101. * Set the z offset to apply to current rendering
  122102. * @param value defines the offset to apply
  122103. */
  122104. setZOffset(value: number): void;
  122105. /**
  122106. * Gets the current value of the zOffset
  122107. * @returns the current zOffset state
  122108. */
  122109. getZOffset(): number;
  122110. /**
  122111. * Enable or disable depth buffering
  122112. * @param enable defines the state to set
  122113. */
  122114. setDepthBuffer(enable: boolean): void;
  122115. /**
  122116. * Gets a boolean indicating if depth writing is enabled
  122117. * @returns the current depth writing state
  122118. */
  122119. getDepthWrite(): boolean;
  122120. /**
  122121. * Enable or disable depth writing
  122122. * @param enable defines the state to set
  122123. */
  122124. setDepthWrite(enable: boolean): void;
  122125. /**
  122126. * Gets a boolean indicating if stencil buffer is enabled
  122127. * @returns the current stencil buffer state
  122128. */
  122129. getStencilBuffer(): boolean;
  122130. /**
  122131. * Enable or disable the stencil buffer
  122132. * @param enable defines if the stencil buffer must be enabled or disabled
  122133. */
  122134. setStencilBuffer(enable: boolean): void;
  122135. /**
  122136. * Gets the current stencil mask
  122137. * @returns a number defining the new stencil mask to use
  122138. */
  122139. getStencilMask(): number;
  122140. /**
  122141. * Sets the current stencil mask
  122142. * @param mask defines the new stencil mask to use
  122143. */
  122144. setStencilMask(mask: number): void;
  122145. /**
  122146. * Gets the current stencil function
  122147. * @returns a number defining the stencil function to use
  122148. */
  122149. getStencilFunction(): number;
  122150. /**
  122151. * Gets the current stencil reference value
  122152. * @returns a number defining the stencil reference value to use
  122153. */
  122154. getStencilFunctionReference(): number;
  122155. /**
  122156. * Gets the current stencil mask
  122157. * @returns a number defining the stencil mask to use
  122158. */
  122159. getStencilFunctionMask(): number;
  122160. /**
  122161. * Sets the current stencil function
  122162. * @param stencilFunc defines the new stencil function to use
  122163. */
  122164. setStencilFunction(stencilFunc: number): void;
  122165. /**
  122166. * Sets the current stencil reference
  122167. * @param reference defines the new stencil reference to use
  122168. */
  122169. setStencilFunctionReference(reference: number): void;
  122170. /**
  122171. * Sets the current stencil mask
  122172. * @param mask defines the new stencil mask to use
  122173. */
  122174. setStencilFunctionMask(mask: number): void;
  122175. /**
  122176. * Gets the current stencil operation when stencil fails
  122177. * @returns a number defining stencil operation to use when stencil fails
  122178. */
  122179. getStencilOperationFail(): number;
  122180. /**
  122181. * Gets the current stencil operation when depth fails
  122182. * @returns a number defining stencil operation to use when depth fails
  122183. */
  122184. getStencilOperationDepthFail(): number;
  122185. /**
  122186. * Gets the current stencil operation when stencil passes
  122187. * @returns a number defining stencil operation to use when stencil passes
  122188. */
  122189. getStencilOperationPass(): number;
  122190. /**
  122191. * Sets the stencil operation to use when stencil fails
  122192. * @param operation defines the stencil operation to use when stencil fails
  122193. */
  122194. setStencilOperationFail(operation: number): void;
  122195. /**
  122196. * Sets the stencil operation to use when depth fails
  122197. * @param operation defines the stencil operation to use when depth fails
  122198. */
  122199. setStencilOperationDepthFail(operation: number): void;
  122200. /**
  122201. * Sets the stencil operation to use when stencil passes
  122202. * @param operation defines the stencil operation to use when stencil passes
  122203. */
  122204. setStencilOperationPass(operation: number): void;
  122205. /**
  122206. * Sets a boolean indicating if the dithering state is enabled or disabled
  122207. * @param value defines the dithering state
  122208. */
  122209. setDitheringState(value: boolean): void;
  122210. /**
  122211. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  122212. * @param value defines the rasterizer state
  122213. */
  122214. setRasterizerState(value: boolean): void;
  122215. /**
  122216. * Gets the current depth function
  122217. * @returns a number defining the depth function
  122218. */
  122219. getDepthFunction(): Nullable<number>;
  122220. /**
  122221. * Sets the current depth function
  122222. * @param depthFunc defines the function to use
  122223. */
  122224. setDepthFunction(depthFunc: number): void;
  122225. /**
  122226. * Sets the current depth function to GREATER
  122227. */
  122228. setDepthFunctionToGreater(): void;
  122229. /**
  122230. * Sets the current depth function to GEQUAL
  122231. */
  122232. setDepthFunctionToGreaterOrEqual(): void;
  122233. /**
  122234. * Sets the current depth function to LESS
  122235. */
  122236. setDepthFunctionToLess(): void;
  122237. /**
  122238. * Sets the current depth function to LEQUAL
  122239. */
  122240. setDepthFunctionToLessOrEqual(): void;
  122241. private _cachedStencilBuffer;
  122242. private _cachedStencilFunction;
  122243. private _cachedStencilMask;
  122244. private _cachedStencilOperationPass;
  122245. private _cachedStencilOperationFail;
  122246. private _cachedStencilOperationDepthFail;
  122247. private _cachedStencilReference;
  122248. /**
  122249. * Caches the the state of the stencil buffer
  122250. */
  122251. cacheStencilState(): void;
  122252. /**
  122253. * Restores the state of the stencil buffer
  122254. */
  122255. restoreStencilState(): void;
  122256. /**
  122257. * Directly set the WebGL Viewport
  122258. * @param x defines the x coordinate of the viewport (in screen space)
  122259. * @param y defines the y coordinate of the viewport (in screen space)
  122260. * @param width defines the width of the viewport (in screen space)
  122261. * @param height defines the height of the viewport (in screen space)
  122262. * @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
  122263. */
  122264. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  122265. /**
  122266. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  122267. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  122268. * @param y defines the y-coordinate of the corner of the clear rectangle
  122269. * @param width defines the width of the clear rectangle
  122270. * @param height defines the height of the clear rectangle
  122271. * @param clearColor defines the clear color
  122272. */
  122273. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  122274. /**
  122275. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  122276. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  122277. * @param y defines the y-coordinate of the corner of the clear rectangle
  122278. * @param width defines the width of the clear rectangle
  122279. * @param height defines the height of the clear rectangle
  122280. */
  122281. enableScissor(x: number, y: number, width: number, height: number): void;
  122282. /**
  122283. * Disable previously set scissor test rectangle
  122284. */
  122285. disableScissor(): void;
  122286. protected _reportDrawCall(): void;
  122287. /**
  122288. * Initializes a webVR display and starts listening to display change events
  122289. * The onVRDisplayChangedObservable will be notified upon these changes
  122290. * @returns The onVRDisplayChangedObservable
  122291. */
  122292. initWebVR(): Observable<IDisplayChangedEventArgs>;
  122293. /** @hidden */
  122294. _prepareVRComponent(): void;
  122295. /** @hidden */
  122296. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  122297. /** @hidden */
  122298. _submitVRFrame(): void;
  122299. /**
  122300. * Call this function to leave webVR mode
  122301. * Will do nothing if webVR is not supported or if there is no webVR device
  122302. * @see https://doc.babylonjs.com/how_to/webvr_camera
  122303. */
  122304. disableVR(): void;
  122305. /**
  122306. * Gets a boolean indicating that the system is in VR mode and is presenting
  122307. * @returns true if VR mode is engaged
  122308. */
  122309. isVRPresenting(): boolean;
  122310. /** @hidden */
  122311. _requestVRFrame(): void;
  122312. /** @hidden */
  122313. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  122314. /**
  122315. * Gets the source code of the vertex shader associated with a specific webGL program
  122316. * @param program defines the program to use
  122317. * @returns a string containing the source code of the vertex shader associated with the program
  122318. */
  122319. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  122320. /**
  122321. * Gets the source code of the fragment shader associated with a specific webGL program
  122322. * @param program defines the program to use
  122323. * @returns a string containing the source code of the fragment shader associated with the program
  122324. */
  122325. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  122326. /**
  122327. * Sets a depth stencil texture from a render target to the according uniform.
  122328. * @param channel The texture channel
  122329. * @param uniform The uniform to set
  122330. * @param texture The render target texture containing the depth stencil texture to apply
  122331. */
  122332. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  122333. /**
  122334. * Sets a texture to the webGL context from a postprocess
  122335. * @param channel defines the channel to use
  122336. * @param postProcess defines the source postprocess
  122337. */
  122338. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  122339. /**
  122340. * Binds the output of the passed in post process to the texture channel specified
  122341. * @param channel The channel the texture should be bound to
  122342. * @param postProcess The post process which's output should be bound
  122343. */
  122344. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  122345. protected _rebuildBuffers(): void;
  122346. /** @hidden */
  122347. _renderFrame(): void;
  122348. _renderLoop(): void;
  122349. /** @hidden */
  122350. _renderViews(): boolean;
  122351. /**
  122352. * Toggle full screen mode
  122353. * @param requestPointerLock defines if a pointer lock should be requested from the user
  122354. */
  122355. switchFullscreen(requestPointerLock: boolean): void;
  122356. /**
  122357. * Enters full screen mode
  122358. * @param requestPointerLock defines if a pointer lock should be requested from the user
  122359. */
  122360. enterFullscreen(requestPointerLock: boolean): void;
  122361. /**
  122362. * Exits full screen mode
  122363. */
  122364. exitFullscreen(): void;
  122365. /**
  122366. * Enters Pointerlock mode
  122367. */
  122368. enterPointerlock(): void;
  122369. /**
  122370. * Exits Pointerlock mode
  122371. */
  122372. exitPointerlock(): void;
  122373. /**
  122374. * Begin a new frame
  122375. */
  122376. beginFrame(): void;
  122377. /**
  122378. * Enf the current frame
  122379. */
  122380. endFrame(): void;
  122381. resize(): void;
  122382. /**
  122383. * Force a specific size of the canvas
  122384. * @param width defines the new canvas' width
  122385. * @param height defines the new canvas' height
  122386. * @returns true if the size was changed
  122387. */
  122388. setSize(width: number, height: number): boolean;
  122389. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  122390. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  122391. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  122392. _releaseTexture(texture: InternalTexture): void;
  122393. /**
  122394. * @hidden
  122395. * Rescales a texture
  122396. * @param source input texutre
  122397. * @param destination destination texture
  122398. * @param scene scene to use to render the resize
  122399. * @param internalFormat format to use when resizing
  122400. * @param onComplete callback to be called when resize has completed
  122401. */
  122402. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  122403. /**
  122404. * Gets the current framerate
  122405. * @returns a number representing the framerate
  122406. */
  122407. getFps(): number;
  122408. /**
  122409. * Gets the time spent between current and previous frame
  122410. * @returns a number representing the delta time in ms
  122411. */
  122412. getDeltaTime(): number;
  122413. private _measureFps;
  122414. /** @hidden */
  122415. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  122416. /**
  122417. * Updates the sample count of a render target texture
  122418. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  122419. * @param texture defines the texture to update
  122420. * @param samples defines the sample count to set
  122421. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  122422. */
  122423. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  122424. /**
  122425. * Updates a depth texture Comparison Mode and Function.
  122426. * If the comparison Function is equal to 0, the mode will be set to none.
  122427. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  122428. * @param texture The texture to set the comparison function for
  122429. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  122430. */
  122431. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  122432. /**
  122433. * Creates a webGL buffer to use with instanciation
  122434. * @param capacity defines the size of the buffer
  122435. * @returns the webGL buffer
  122436. */
  122437. createInstancesBuffer(capacity: number): DataBuffer;
  122438. /**
  122439. * Delete a webGL buffer used with instanciation
  122440. * @param buffer defines the webGL buffer to delete
  122441. */
  122442. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  122443. private _clientWaitAsync;
  122444. /** @hidden */
  122445. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  122446. dispose(): void;
  122447. private _disableTouchAction;
  122448. /**
  122449. * Display the loading screen
  122450. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122451. */
  122452. displayLoadingUI(): void;
  122453. /**
  122454. * Hide the loading screen
  122455. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122456. */
  122457. hideLoadingUI(): void;
  122458. /**
  122459. * Gets the current loading screen object
  122460. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122461. */
  122462. get loadingScreen(): ILoadingScreen;
  122463. /**
  122464. * Sets the current loading screen object
  122465. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122466. */
  122467. set loadingScreen(loadingScreen: ILoadingScreen);
  122468. /**
  122469. * Sets the current loading screen text
  122470. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122471. */
  122472. set loadingUIText(text: string);
  122473. /**
  122474. * Sets the current loading screen background color
  122475. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122476. */
  122477. set loadingUIBackgroundColor(color: string);
  122478. /** Pointerlock and fullscreen */
  122479. /**
  122480. * Ask the browser to promote the current element to pointerlock mode
  122481. * @param element defines the DOM element to promote
  122482. */
  122483. static _RequestPointerlock(element: HTMLElement): void;
  122484. /**
  122485. * Asks the browser to exit pointerlock mode
  122486. */
  122487. static _ExitPointerlock(): void;
  122488. /**
  122489. * Ask the browser to promote the current element to fullscreen rendering mode
  122490. * @param element defines the DOM element to promote
  122491. */
  122492. static _RequestFullscreen(element: HTMLElement): void;
  122493. /**
  122494. * Asks the browser to exit fullscreen mode
  122495. */
  122496. static _ExitFullscreen(): void;
  122497. }
  122498. }
  122499. declare module BABYLON {
  122500. /**
  122501. * The engine store class is responsible to hold all the instances of Engine and Scene created
  122502. * during the life time of the application.
  122503. */
  122504. export class EngineStore {
  122505. /** Gets the list of created engines */
  122506. static Instances: Engine[];
  122507. /** @hidden */
  122508. static _LastCreatedScene: Nullable<Scene>;
  122509. /**
  122510. * Gets the latest created engine
  122511. */
  122512. static get LastCreatedEngine(): Nullable<Engine>;
  122513. /**
  122514. * Gets the latest created scene
  122515. */
  122516. static get LastCreatedScene(): Nullable<Scene>;
  122517. /**
  122518. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  122519. * @ignorenaming
  122520. */
  122521. static UseFallbackTexture: boolean;
  122522. /**
  122523. * Texture content used if a texture cannot loaded
  122524. * @ignorenaming
  122525. */
  122526. static FallbackTexture: string;
  122527. }
  122528. }
  122529. declare module BABYLON {
  122530. /**
  122531. * Helper class that provides a small promise polyfill
  122532. */
  122533. export class PromisePolyfill {
  122534. /**
  122535. * Static function used to check if the polyfill is required
  122536. * If this is the case then the function will inject the polyfill to window.Promise
  122537. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  122538. */
  122539. static Apply(force?: boolean): void;
  122540. }
  122541. }
  122542. declare module BABYLON {
  122543. /**
  122544. * Interface for screenshot methods with describe argument called `size` as object with options
  122545. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  122546. */
  122547. export interface IScreenshotSize {
  122548. /**
  122549. * number in pixels for canvas height
  122550. */
  122551. height?: number;
  122552. /**
  122553. * multiplier allowing render at a higher or lower resolution
  122554. * If value is defined then height and width will be ignored and taken from camera
  122555. */
  122556. precision?: number;
  122557. /**
  122558. * number in pixels for canvas width
  122559. */
  122560. width?: number;
  122561. }
  122562. }
  122563. declare module BABYLON {
  122564. interface IColor4Like {
  122565. r: float;
  122566. g: float;
  122567. b: float;
  122568. a: float;
  122569. }
  122570. /**
  122571. * Class containing a set of static utilities functions
  122572. */
  122573. export class Tools {
  122574. /**
  122575. * Gets or sets the base URL to use to load assets
  122576. */
  122577. static get BaseUrl(): string;
  122578. static set BaseUrl(value: string);
  122579. /**
  122580. * Enable/Disable Custom HTTP Request Headers globally.
  122581. * default = false
  122582. * @see CustomRequestHeaders
  122583. */
  122584. static UseCustomRequestHeaders: boolean;
  122585. /**
  122586. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  122587. * i.e. when loading files, where the server/service expects an Authorization header
  122588. */
  122589. static CustomRequestHeaders: {
  122590. [key: string]: string;
  122591. };
  122592. /**
  122593. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  122594. */
  122595. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  122596. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  122597. /**
  122598. * Default behaviour for cors in the application.
  122599. * It can be a string if the expected behavior is identical in the entire app.
  122600. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  122601. */
  122602. static get CorsBehavior(): string | ((url: string | string[]) => string);
  122603. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  122604. /**
  122605. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  122606. * @ignorenaming
  122607. */
  122608. static get UseFallbackTexture(): boolean;
  122609. static set UseFallbackTexture(value: boolean);
  122610. /**
  122611. * Use this object to register external classes like custom textures or material
  122612. * to allow the laoders to instantiate them
  122613. */
  122614. static get RegisteredExternalClasses(): {
  122615. [key: string]: Object;
  122616. };
  122617. static set RegisteredExternalClasses(classes: {
  122618. [key: string]: Object;
  122619. });
  122620. /**
  122621. * Texture content used if a texture cannot loaded
  122622. * @ignorenaming
  122623. */
  122624. static get fallbackTexture(): string;
  122625. static set fallbackTexture(value: string);
  122626. /**
  122627. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  122628. * @param u defines the coordinate on X axis
  122629. * @param v defines the coordinate on Y axis
  122630. * @param width defines the width of the source data
  122631. * @param height defines the height of the source data
  122632. * @param pixels defines the source byte array
  122633. * @param color defines the output color
  122634. */
  122635. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  122636. /**
  122637. * Interpolates between a and b via alpha
  122638. * @param a The lower value (returned when alpha = 0)
  122639. * @param b The upper value (returned when alpha = 1)
  122640. * @param alpha The interpolation-factor
  122641. * @return The mixed value
  122642. */
  122643. static Mix(a: number, b: number, alpha: number): number;
  122644. /**
  122645. * Tries to instantiate a new object from a given class name
  122646. * @param className defines the class name to instantiate
  122647. * @returns the new object or null if the system was not able to do the instantiation
  122648. */
  122649. static Instantiate(className: string): any;
  122650. /**
  122651. * Provides a slice function that will work even on IE
  122652. * @param data defines the array to slice
  122653. * @param start defines the start of the data (optional)
  122654. * @param end defines the end of the data (optional)
  122655. * @returns the new sliced array
  122656. */
  122657. static Slice<T>(data: T, start?: number, end?: number): T;
  122658. /**
  122659. * Provides a slice function that will work even on IE
  122660. * The difference between this and Slice is that this will force-convert to array
  122661. * @param data defines the array to slice
  122662. * @param start defines the start of the data (optional)
  122663. * @param end defines the end of the data (optional)
  122664. * @returns the new sliced array
  122665. */
  122666. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  122667. /**
  122668. * Polyfill for setImmediate
  122669. * @param action defines the action to execute after the current execution block
  122670. */
  122671. static SetImmediate(action: () => void): void;
  122672. /**
  122673. * Function indicating if a number is an exponent of 2
  122674. * @param value defines the value to test
  122675. * @returns true if the value is an exponent of 2
  122676. */
  122677. static IsExponentOfTwo(value: number): boolean;
  122678. private static _tmpFloatArray;
  122679. /**
  122680. * Returns the nearest 32-bit single precision float representation of a Number
  122681. * @param value A Number. If the parameter is of a different type, it will get converted
  122682. * to a number or to NaN if it cannot be converted
  122683. * @returns number
  122684. */
  122685. static FloatRound(value: number): number;
  122686. /**
  122687. * Extracts the filename from a path
  122688. * @param path defines the path to use
  122689. * @returns the filename
  122690. */
  122691. static GetFilename(path: string): string;
  122692. /**
  122693. * Extracts the "folder" part of a path (everything before the filename).
  122694. * @param uri The URI to extract the info from
  122695. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  122696. * @returns The "folder" part of the path
  122697. */
  122698. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  122699. /**
  122700. * Extracts text content from a DOM element hierarchy
  122701. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  122702. */
  122703. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  122704. /**
  122705. * Convert an angle in radians to degrees
  122706. * @param angle defines the angle to convert
  122707. * @returns the angle in degrees
  122708. */
  122709. static ToDegrees(angle: number): number;
  122710. /**
  122711. * Convert an angle in degrees to radians
  122712. * @param angle defines the angle to convert
  122713. * @returns the angle in radians
  122714. */
  122715. static ToRadians(angle: number): number;
  122716. /**
  122717. * Returns an array if obj is not an array
  122718. * @param obj defines the object to evaluate as an array
  122719. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  122720. * @returns either obj directly if obj is an array or a new array containing obj
  122721. */
  122722. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  122723. /**
  122724. * Gets the pointer prefix to use
  122725. * @param engine defines the engine we are finding the prefix for
  122726. * @returns "pointer" if touch is enabled. Else returns "mouse"
  122727. */
  122728. static GetPointerPrefix(engine: Engine): string;
  122729. /**
  122730. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  122731. * @param url define the url we are trying
  122732. * @param element define the dom element where to configure the cors policy
  122733. */
  122734. static SetCorsBehavior(url: string | string[], element: {
  122735. crossOrigin: string | null;
  122736. }): void;
  122737. /**
  122738. * Removes unwanted characters from an url
  122739. * @param url defines the url to clean
  122740. * @returns the cleaned url
  122741. */
  122742. static CleanUrl(url: string): string;
  122743. /**
  122744. * Gets or sets a function used to pre-process url before using them to load assets
  122745. */
  122746. static get PreprocessUrl(): (url: string) => string;
  122747. static set PreprocessUrl(processor: (url: string) => string);
  122748. /**
  122749. * Loads an image as an HTMLImageElement.
  122750. * @param input url string, ArrayBuffer, or Blob to load
  122751. * @param onLoad callback called when the image successfully loads
  122752. * @param onError callback called when the image fails to load
  122753. * @param offlineProvider offline provider for caching
  122754. * @param mimeType optional mime type
  122755. * @returns the HTMLImageElement of the loaded image
  122756. */
  122757. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  122758. /**
  122759. * Loads a file from a url
  122760. * @param url url string, ArrayBuffer, or Blob to load
  122761. * @param onSuccess callback called when the file successfully loads
  122762. * @param onProgress callback called while file is loading (if the server supports this mode)
  122763. * @param offlineProvider defines the offline provider for caching
  122764. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122765. * @param onError callback called when the file fails to load
  122766. * @returns a file request object
  122767. */
  122768. 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;
  122769. /**
  122770. * Loads a file from a url
  122771. * @param url the file url to load
  122772. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122773. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  122774. */
  122775. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  122776. /**
  122777. * Load a script (identified by an url). When the url returns, the
  122778. * content of this file is added into a new script element, attached to the DOM (body element)
  122779. * @param scriptUrl defines the url of the script to laod
  122780. * @param onSuccess defines the callback called when the script is loaded
  122781. * @param onError defines the callback to call if an error occurs
  122782. * @param scriptId defines the id of the script element
  122783. */
  122784. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  122785. /**
  122786. * Load an asynchronous script (identified by an url). When the url returns, the
  122787. * content of this file is added into a new script element, attached to the DOM (body element)
  122788. * @param scriptUrl defines the url of the script to laod
  122789. * @param scriptId defines the id of the script element
  122790. * @returns a promise request object
  122791. */
  122792. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  122793. /**
  122794. * Loads a file from a blob
  122795. * @param fileToLoad defines the blob to use
  122796. * @param callback defines the callback to call when data is loaded
  122797. * @param progressCallback defines the callback to call during loading process
  122798. * @returns a file request object
  122799. */
  122800. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  122801. /**
  122802. * Reads a file from a File object
  122803. * @param file defines the file to load
  122804. * @param onSuccess defines the callback to call when data is loaded
  122805. * @param onProgress defines the callback to call during loading process
  122806. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  122807. * @param onError defines the callback to call when an error occurs
  122808. * @returns a file request object
  122809. */
  122810. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  122811. /**
  122812. * Creates a data url from a given string content
  122813. * @param content defines the content to convert
  122814. * @returns the new data url link
  122815. */
  122816. static FileAsURL(content: string): string;
  122817. /**
  122818. * Format the given number to a specific decimal format
  122819. * @param value defines the number to format
  122820. * @param decimals defines the number of decimals to use
  122821. * @returns the formatted string
  122822. */
  122823. static Format(value: number, decimals?: number): string;
  122824. /**
  122825. * Tries to copy an object by duplicating every property
  122826. * @param source defines the source object
  122827. * @param destination defines the target object
  122828. * @param doNotCopyList defines a list of properties to avoid
  122829. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  122830. */
  122831. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  122832. /**
  122833. * Gets a boolean indicating if the given object has no own property
  122834. * @param obj defines the object to test
  122835. * @returns true if object has no own property
  122836. */
  122837. static IsEmpty(obj: any): boolean;
  122838. /**
  122839. * Function used to register events at window level
  122840. * @param windowElement defines the Window object to use
  122841. * @param events defines the events to register
  122842. */
  122843. static RegisterTopRootEvents(windowElement: Window, events: {
  122844. name: string;
  122845. handler: Nullable<(e: FocusEvent) => any>;
  122846. }[]): void;
  122847. /**
  122848. * Function used to unregister events from window level
  122849. * @param windowElement defines the Window object to use
  122850. * @param events defines the events to unregister
  122851. */
  122852. static UnregisterTopRootEvents(windowElement: Window, events: {
  122853. name: string;
  122854. handler: Nullable<(e: FocusEvent) => any>;
  122855. }[]): void;
  122856. /**
  122857. * @ignore
  122858. */
  122859. static _ScreenshotCanvas: HTMLCanvasElement;
  122860. /**
  122861. * Dumps the current bound framebuffer
  122862. * @param width defines the rendering width
  122863. * @param height defines the rendering height
  122864. * @param engine defines the hosting engine
  122865. * @param successCallback defines the callback triggered once the data are available
  122866. * @param mimeType defines the mime type of the result
  122867. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  122868. */
  122869. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122870. /**
  122871. * Converts the canvas data to blob.
  122872. * This acts as a polyfill for browsers not supporting the to blob function.
  122873. * @param canvas Defines the canvas to extract the data from
  122874. * @param successCallback Defines the callback triggered once the data are available
  122875. * @param mimeType Defines the mime type of the result
  122876. */
  122877. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  122878. /**
  122879. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  122880. * @param successCallback defines the callback triggered once the data are available
  122881. * @param mimeType defines the mime type of the result
  122882. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  122883. */
  122884. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122885. /**
  122886. * Downloads a blob in the browser
  122887. * @param blob defines the blob to download
  122888. * @param fileName defines the name of the downloaded file
  122889. */
  122890. static Download(blob: Blob, fileName: string): void;
  122891. /**
  122892. * Will return the right value of the noPreventDefault variable
  122893. * Needed to keep backwards compatibility to the old API.
  122894. *
  122895. * @param args arguments passed to the attachControl function
  122896. * @returns the correct value for noPreventDefault
  122897. */
  122898. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  122899. /**
  122900. * Captures a screenshot of the current rendering
  122901. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122902. * @param engine defines the rendering engine
  122903. * @param camera defines the source camera
  122904. * @param size This parameter can be set to a single number or to an object with the
  122905. * following (optional) properties: precision, width, height. If a single number is passed,
  122906. * it will be used for both width and height. If an object is passed, the screenshot size
  122907. * will be derived from the parameters. The precision property is a multiplier allowing
  122908. * rendering at a higher or lower resolution
  122909. * @param successCallback defines the callback receives a single parameter which contains the
  122910. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122911. * src parameter of an <img> to display it
  122912. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122913. * Check your browser for supported MIME types
  122914. */
  122915. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  122916. /**
  122917. * Captures a screenshot of the current rendering
  122918. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122919. * @param engine defines the rendering engine
  122920. * @param camera defines the source camera
  122921. * @param size This parameter can be set to a single number or to an object with the
  122922. * following (optional) properties: precision, width, height. If a single number is passed,
  122923. * it will be used for both width and height. If an object is passed, the screenshot size
  122924. * will be derived from the parameters. The precision property is a multiplier allowing
  122925. * rendering at a higher or lower resolution
  122926. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122927. * Check your browser for supported MIME types
  122928. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122929. * to the src parameter of an <img> to display it
  122930. */
  122931. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  122932. /**
  122933. * Generates an image screenshot from the specified camera.
  122934. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122935. * @param engine The engine to use for rendering
  122936. * @param camera The camera to use for rendering
  122937. * @param size This parameter can be set to a single number or to an object with the
  122938. * following (optional) properties: precision, width, height. If a single number is passed,
  122939. * it will be used for both width and height. If an object is passed, the screenshot size
  122940. * will be derived from the parameters. The precision property is a multiplier allowing
  122941. * rendering at a higher or lower resolution
  122942. * @param successCallback The callback receives a single parameter which contains the
  122943. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122944. * src parameter of an <img> to display it
  122945. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122946. * Check your browser for supported MIME types
  122947. * @param samples Texture samples (default: 1)
  122948. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122949. * @param fileName A name for for the downloaded file.
  122950. */
  122951. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122952. /**
  122953. * Generates an image screenshot from the specified camera.
  122954. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122955. * @param engine The engine to use for rendering
  122956. * @param camera The camera to use for rendering
  122957. * @param size This parameter can be set to a single number or to an object with the
  122958. * following (optional) properties: precision, width, height. If a single number is passed,
  122959. * it will be used for both width and height. If an object is passed, the screenshot size
  122960. * will be derived from the parameters. The precision property is a multiplier allowing
  122961. * rendering at a higher or lower resolution
  122962. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122963. * Check your browser for supported MIME types
  122964. * @param samples Texture samples (default: 1)
  122965. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122966. * @param fileName A name for for the downloaded file.
  122967. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122968. * to the src parameter of an <img> to display it
  122969. */
  122970. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  122971. /**
  122972. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  122973. * Be aware Math.random() could cause collisions, but:
  122974. * "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"
  122975. * @returns a pseudo random id
  122976. */
  122977. static RandomId(): string;
  122978. /**
  122979. * Test if the given uri is a base64 string
  122980. * @param uri The uri to test
  122981. * @return True if the uri is a base64 string or false otherwise
  122982. */
  122983. static IsBase64(uri: string): boolean;
  122984. /**
  122985. * Decode the given base64 uri.
  122986. * @param uri The uri to decode
  122987. * @return The decoded base64 data.
  122988. */
  122989. static DecodeBase64(uri: string): ArrayBuffer;
  122990. /**
  122991. * Gets the absolute url.
  122992. * @param url the input url
  122993. * @return the absolute url
  122994. */
  122995. static GetAbsoluteUrl(url: string): string;
  122996. /**
  122997. * No log
  122998. */
  122999. static readonly NoneLogLevel: number;
  123000. /**
  123001. * Only message logs
  123002. */
  123003. static readonly MessageLogLevel: number;
  123004. /**
  123005. * Only warning logs
  123006. */
  123007. static readonly WarningLogLevel: number;
  123008. /**
  123009. * Only error logs
  123010. */
  123011. static readonly ErrorLogLevel: number;
  123012. /**
  123013. * All logs
  123014. */
  123015. static readonly AllLogLevel: number;
  123016. /**
  123017. * Gets a value indicating the number of loading errors
  123018. * @ignorenaming
  123019. */
  123020. static get errorsCount(): number;
  123021. /**
  123022. * Callback called when a new log is added
  123023. */
  123024. static OnNewCacheEntry: (entry: string) => void;
  123025. /**
  123026. * Log a message to the console
  123027. * @param message defines the message to log
  123028. */
  123029. static Log(message: string): void;
  123030. /**
  123031. * Write a warning message to the console
  123032. * @param message defines the message to log
  123033. */
  123034. static Warn(message: string): void;
  123035. /**
  123036. * Write an error message to the console
  123037. * @param message defines the message to log
  123038. */
  123039. static Error(message: string): void;
  123040. /**
  123041. * Gets current log cache (list of logs)
  123042. */
  123043. static get LogCache(): string;
  123044. /**
  123045. * Clears the log cache
  123046. */
  123047. static ClearLogCache(): void;
  123048. /**
  123049. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  123050. */
  123051. static set LogLevels(level: number);
  123052. /**
  123053. * Checks if the window object exists
  123054. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  123055. */
  123056. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  123057. /**
  123058. * No performance log
  123059. */
  123060. static readonly PerformanceNoneLogLevel: number;
  123061. /**
  123062. * Use user marks to log performance
  123063. */
  123064. static readonly PerformanceUserMarkLogLevel: number;
  123065. /**
  123066. * Log performance to the console
  123067. */
  123068. static readonly PerformanceConsoleLogLevel: number;
  123069. private static _performance;
  123070. /**
  123071. * Sets the current performance log level
  123072. */
  123073. static set PerformanceLogLevel(level: number);
  123074. private static _StartPerformanceCounterDisabled;
  123075. private static _EndPerformanceCounterDisabled;
  123076. private static _StartUserMark;
  123077. private static _EndUserMark;
  123078. private static _StartPerformanceConsole;
  123079. private static _EndPerformanceConsole;
  123080. /**
  123081. * Starts a performance counter
  123082. */
  123083. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123084. /**
  123085. * Ends a specific performance coutner
  123086. */
  123087. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123088. /**
  123089. * Gets either window.performance.now() if supported or Date.now() else
  123090. */
  123091. static get Now(): number;
  123092. /**
  123093. * This method will return the name of the class used to create the instance of the given object.
  123094. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  123095. * @param object the object to get the class name from
  123096. * @param isType defines if the object is actually a type
  123097. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  123098. */
  123099. static GetClassName(object: any, isType?: boolean): string;
  123100. /**
  123101. * Gets the first element of an array satisfying a given predicate
  123102. * @param array defines the array to browse
  123103. * @param predicate defines the predicate to use
  123104. * @returns null if not found or the element
  123105. */
  123106. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  123107. /**
  123108. * This method will return the name of the full name of the class, including its owning module (if any).
  123109. * 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).
  123110. * @param object the object to get the class name from
  123111. * @param isType defines if the object is actually a type
  123112. * @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.
  123113. * @ignorenaming
  123114. */
  123115. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  123116. /**
  123117. * Returns a promise that resolves after the given amount of time.
  123118. * @param delay Number of milliseconds to delay
  123119. * @returns Promise that resolves after the given amount of time
  123120. */
  123121. static DelayAsync(delay: number): Promise<void>;
  123122. /**
  123123. * Utility function to detect if the current user agent is Safari
  123124. * @returns whether or not the current user agent is safari
  123125. */
  123126. static IsSafari(): boolean;
  123127. }
  123128. /**
  123129. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  123130. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  123131. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  123132. * @param name The name of the class, case should be preserved
  123133. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  123134. */
  123135. export function className(name: string, module?: string): (target: Object) => void;
  123136. /**
  123137. * An implementation of a loop for asynchronous functions.
  123138. */
  123139. export class AsyncLoop {
  123140. /**
  123141. * Defines the number of iterations for the loop
  123142. */
  123143. iterations: number;
  123144. /**
  123145. * Defines the current index of the loop.
  123146. */
  123147. index: number;
  123148. private _done;
  123149. private _fn;
  123150. private _successCallback;
  123151. /**
  123152. * Constructor.
  123153. * @param iterations the number of iterations.
  123154. * @param func the function to run each iteration
  123155. * @param successCallback the callback that will be called upon succesful execution
  123156. * @param offset starting offset.
  123157. */
  123158. constructor(
  123159. /**
  123160. * Defines the number of iterations for the loop
  123161. */
  123162. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  123163. /**
  123164. * Execute the next iteration. Must be called after the last iteration was finished.
  123165. */
  123166. executeNext(): void;
  123167. /**
  123168. * Break the loop and run the success callback.
  123169. */
  123170. breakLoop(): void;
  123171. /**
  123172. * Create and run an async loop.
  123173. * @param iterations the number of iterations.
  123174. * @param fn the function to run each iteration
  123175. * @param successCallback the callback that will be called upon succesful execution
  123176. * @param offset starting offset.
  123177. * @returns the created async loop object
  123178. */
  123179. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  123180. /**
  123181. * A for-loop that will run a given number of iterations synchronous and the rest async.
  123182. * @param iterations total number of iterations
  123183. * @param syncedIterations number of synchronous iterations in each async iteration.
  123184. * @param fn the function to call each iteration.
  123185. * @param callback a success call back that will be called when iterating stops.
  123186. * @param breakFunction a break condition (optional)
  123187. * @param timeout timeout settings for the setTimeout function. default - 0.
  123188. * @returns the created async loop object
  123189. */
  123190. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  123191. }
  123192. }
  123193. declare module BABYLON {
  123194. /**
  123195. * This class implement a typical dictionary using a string as key and the generic type T as value.
  123196. * The underlying implementation relies on an associative array to ensure the best performances.
  123197. * The value can be anything including 'null' but except 'undefined'
  123198. */
  123199. export class StringDictionary<T> {
  123200. /**
  123201. * This will clear this dictionary and copy the content from the 'source' one.
  123202. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  123203. * @param source the dictionary to take the content from and copy to this dictionary
  123204. */
  123205. copyFrom(source: StringDictionary<T>): void;
  123206. /**
  123207. * Get a value based from its key
  123208. * @param key the given key to get the matching value from
  123209. * @return the value if found, otherwise undefined is returned
  123210. */
  123211. get(key: string): T | undefined;
  123212. /**
  123213. * Get a value from its key or add it if it doesn't exist.
  123214. * This method will ensure you that a given key/data will be present in the dictionary.
  123215. * @param key the given key to get the matching value from
  123216. * @param factory the factory that will create the value if the key is not present in the dictionary.
  123217. * The factory will only be invoked if there's no data for the given key.
  123218. * @return the value corresponding to the key.
  123219. */
  123220. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  123221. /**
  123222. * Get a value from its key if present in the dictionary otherwise add it
  123223. * @param key the key to get the value from
  123224. * @param val if there's no such key/value pair in the dictionary add it with this value
  123225. * @return the value corresponding to the key
  123226. */
  123227. getOrAdd(key: string, val: T): T;
  123228. /**
  123229. * Check if there's a given key in the dictionary
  123230. * @param key the key to check for
  123231. * @return true if the key is present, false otherwise
  123232. */
  123233. contains(key: string): boolean;
  123234. /**
  123235. * Add a new key and its corresponding value
  123236. * @param key the key to add
  123237. * @param value the value corresponding to the key
  123238. * @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
  123239. */
  123240. add(key: string, value: T): boolean;
  123241. /**
  123242. * Update a specific value associated to a key
  123243. * @param key defines the key to use
  123244. * @param value defines the value to store
  123245. * @returns true if the value was updated (or false if the key was not found)
  123246. */
  123247. set(key: string, value: T): boolean;
  123248. /**
  123249. * Get the element of the given key and remove it from the dictionary
  123250. * @param key defines the key to search
  123251. * @returns the value associated with the key or null if not found
  123252. */
  123253. getAndRemove(key: string): Nullable<T>;
  123254. /**
  123255. * Remove a key/value from the dictionary.
  123256. * @param key the key to remove
  123257. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  123258. */
  123259. remove(key: string): boolean;
  123260. /**
  123261. * Clear the whole content of the dictionary
  123262. */
  123263. clear(): void;
  123264. /**
  123265. * Gets the current count
  123266. */
  123267. get count(): number;
  123268. /**
  123269. * Execute a callback on each key/val of the dictionary.
  123270. * Note that you can remove any element in this dictionary in the callback implementation
  123271. * @param callback the callback to execute on a given key/value pair
  123272. */
  123273. forEach(callback: (key: string, val: T) => void): void;
  123274. /**
  123275. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  123276. * If the callback returns null or undefined the method will iterate to the next key/value pair
  123277. * Note that you can remove any element in this dictionary in the callback implementation
  123278. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  123279. * @returns the first item
  123280. */
  123281. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  123282. private _count;
  123283. private _data;
  123284. }
  123285. }
  123286. declare module BABYLON {
  123287. /** @hidden */
  123288. export interface ICollisionCoordinator {
  123289. createCollider(): Collider;
  123290. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  123291. init(scene: Scene): void;
  123292. }
  123293. /** @hidden */
  123294. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  123295. private _scene;
  123296. private _scaledPosition;
  123297. private _scaledVelocity;
  123298. private _finalPosition;
  123299. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  123300. createCollider(): Collider;
  123301. init(scene: Scene): void;
  123302. private _collideWithWorld;
  123303. }
  123304. }
  123305. declare module BABYLON {
  123306. /**
  123307. * Class used to manage all inputs for the scene.
  123308. */
  123309. export class InputManager {
  123310. /** The distance in pixel that you have to move to prevent some events */
  123311. static DragMovementThreshold: number;
  123312. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  123313. static LongPressDelay: number;
  123314. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  123315. static DoubleClickDelay: number;
  123316. /** If you need to check double click without raising a single click at first click, enable this flag */
  123317. static ExclusiveDoubleClickMode: boolean;
  123318. /** 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. */
  123319. private _alreadyAttached;
  123320. private _alreadyAttachedTo;
  123321. private _wheelEventName;
  123322. private _onPointerMove;
  123323. private _onPointerDown;
  123324. private _onPointerUp;
  123325. private _initClickEvent;
  123326. private _initActionManager;
  123327. private _delayedSimpleClick;
  123328. private _delayedSimpleClickTimeout;
  123329. private _previousDelayedSimpleClickTimeout;
  123330. private _meshPickProceed;
  123331. private _previousButtonPressed;
  123332. private _currentPickResult;
  123333. private _previousPickResult;
  123334. private _totalPointersPressed;
  123335. private _doubleClickOccured;
  123336. private _pointerOverMesh;
  123337. private _pickedDownMesh;
  123338. private _pickedUpMesh;
  123339. private _pointerX;
  123340. private _pointerY;
  123341. private _unTranslatedPointerX;
  123342. private _unTranslatedPointerY;
  123343. private _startingPointerPosition;
  123344. private _previousStartingPointerPosition;
  123345. private _startingPointerTime;
  123346. private _previousStartingPointerTime;
  123347. private _pointerCaptures;
  123348. private _meshUnderPointerId;
  123349. private _onKeyDown;
  123350. private _onKeyUp;
  123351. private _keyboardIsAttached;
  123352. private _onCanvasFocusObserver;
  123353. private _onCanvasBlurObserver;
  123354. private _scene;
  123355. /**
  123356. * Creates a new InputManager
  123357. * @param scene defines the hosting scene
  123358. */
  123359. constructor(scene: Scene);
  123360. /**
  123361. * Gets the mesh that is currently under the pointer
  123362. */
  123363. get meshUnderPointer(): Nullable<AbstractMesh>;
  123364. /**
  123365. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  123366. * @param pointerId the pointer id to use
  123367. * @returns The mesh under this pointer id or null if not found
  123368. */
  123369. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  123370. /**
  123371. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  123372. */
  123373. get unTranslatedPointer(): Vector2;
  123374. /**
  123375. * Gets or sets the current on-screen X position of the pointer
  123376. */
  123377. get pointerX(): number;
  123378. set pointerX(value: number);
  123379. /**
  123380. * Gets or sets the current on-screen Y position of the pointer
  123381. */
  123382. get pointerY(): number;
  123383. set pointerY(value: number);
  123384. private _updatePointerPosition;
  123385. private _processPointerMove;
  123386. private _setRayOnPointerInfo;
  123387. private _checkPrePointerObservable;
  123388. /**
  123389. * Use this method to simulate a pointer move on a mesh
  123390. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123391. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123392. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123393. */
  123394. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  123395. /**
  123396. * Use this method to simulate a pointer down on a mesh
  123397. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123398. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123399. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123400. */
  123401. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  123402. private _processPointerDown;
  123403. /** @hidden */
  123404. _isPointerSwiping(): boolean;
  123405. /**
  123406. * Use this method to simulate a pointer up on a mesh
  123407. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123408. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123409. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123410. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  123411. */
  123412. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  123413. private _processPointerUp;
  123414. /**
  123415. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  123416. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  123417. * @returns true if the pointer was captured
  123418. */
  123419. isPointerCaptured(pointerId?: number): boolean;
  123420. /**
  123421. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  123422. * @param attachUp defines if you want to attach events to pointerup
  123423. * @param attachDown defines if you want to attach events to pointerdown
  123424. * @param attachMove defines if you want to attach events to pointermove
  123425. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  123426. */
  123427. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  123428. /**
  123429. * Detaches all event handlers
  123430. */
  123431. detachControl(): void;
  123432. /**
  123433. * Force the value of meshUnderPointer
  123434. * @param mesh defines the mesh to use
  123435. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  123436. */
  123437. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  123438. /**
  123439. * Gets the mesh under the pointer
  123440. * @returns a Mesh or null if no mesh is under the pointer
  123441. */
  123442. getPointerOverMesh(): Nullable<AbstractMesh>;
  123443. }
  123444. }
  123445. declare module BABYLON {
  123446. /**
  123447. * This class defines the direct association between an animation and a target
  123448. */
  123449. export class TargetedAnimation {
  123450. /**
  123451. * Animation to perform
  123452. */
  123453. animation: Animation;
  123454. /**
  123455. * Target to animate
  123456. */
  123457. target: any;
  123458. /**
  123459. * Returns the string "TargetedAnimation"
  123460. * @returns "TargetedAnimation"
  123461. */
  123462. getClassName(): string;
  123463. /**
  123464. * Serialize the object
  123465. * @returns the JSON object representing the current entity
  123466. */
  123467. serialize(): any;
  123468. }
  123469. /**
  123470. * Use this class to create coordinated animations on multiple targets
  123471. */
  123472. export class AnimationGroup implements IDisposable {
  123473. /** The name of the animation group */
  123474. name: string;
  123475. private _scene;
  123476. private _targetedAnimations;
  123477. private _animatables;
  123478. private _from;
  123479. private _to;
  123480. private _isStarted;
  123481. private _isPaused;
  123482. private _speedRatio;
  123483. private _loopAnimation;
  123484. private _isAdditive;
  123485. /**
  123486. * Gets or sets the unique id of the node
  123487. */
  123488. uniqueId: number;
  123489. /**
  123490. * This observable will notify when one animation have ended
  123491. */
  123492. onAnimationEndObservable: Observable<TargetedAnimation>;
  123493. /**
  123494. * Observer raised when one animation loops
  123495. */
  123496. onAnimationLoopObservable: Observable<TargetedAnimation>;
  123497. /**
  123498. * Observer raised when all animations have looped
  123499. */
  123500. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  123501. /**
  123502. * This observable will notify when all animations have ended.
  123503. */
  123504. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  123505. /**
  123506. * This observable will notify when all animations have paused.
  123507. */
  123508. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  123509. /**
  123510. * This observable will notify when all animations are playing.
  123511. */
  123512. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  123513. /**
  123514. * Gets the first frame
  123515. */
  123516. get from(): number;
  123517. /**
  123518. * Gets the last frame
  123519. */
  123520. get to(): number;
  123521. /**
  123522. * Define if the animations are started
  123523. */
  123524. get isStarted(): boolean;
  123525. /**
  123526. * Gets a value indicating that the current group is playing
  123527. */
  123528. get isPlaying(): boolean;
  123529. /**
  123530. * Gets or sets the speed ratio to use for all animations
  123531. */
  123532. get speedRatio(): number;
  123533. /**
  123534. * Gets or sets the speed ratio to use for all animations
  123535. */
  123536. set speedRatio(value: number);
  123537. /**
  123538. * Gets or sets if all animations should loop or not
  123539. */
  123540. get loopAnimation(): boolean;
  123541. set loopAnimation(value: boolean);
  123542. /**
  123543. * Gets or sets if all animations should be evaluated additively
  123544. */
  123545. get isAdditive(): boolean;
  123546. set isAdditive(value: boolean);
  123547. /**
  123548. * Gets the targeted animations for this animation group
  123549. */
  123550. get targetedAnimations(): Array<TargetedAnimation>;
  123551. /**
  123552. * returning the list of animatables controlled by this animation group.
  123553. */
  123554. get animatables(): Array<Animatable>;
  123555. /**
  123556. * Gets the list of target animations
  123557. */
  123558. get children(): TargetedAnimation[];
  123559. /**
  123560. * Instantiates a new Animation Group.
  123561. * This helps managing several animations at once.
  123562. * @see https://doc.babylonjs.com/how_to/group
  123563. * @param name Defines the name of the group
  123564. * @param scene Defines the scene the group belongs to
  123565. */
  123566. constructor(
  123567. /** The name of the animation group */
  123568. name: string, scene?: Nullable<Scene>);
  123569. /**
  123570. * Add an animation (with its target) in the group
  123571. * @param animation defines the animation we want to add
  123572. * @param target defines the target of the animation
  123573. * @returns the TargetedAnimation object
  123574. */
  123575. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  123576. /**
  123577. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  123578. * It can add constant keys at begin or end
  123579. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  123580. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  123581. * @returns the animation group
  123582. */
  123583. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  123584. private _animationLoopCount;
  123585. private _animationLoopFlags;
  123586. private _processLoop;
  123587. /**
  123588. * Start all animations on given targets
  123589. * @param loop defines if animations must loop
  123590. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  123591. * @param from defines the from key (optional)
  123592. * @param to defines the to key (optional)
  123593. * @param isAdditive defines the additive state for the resulting animatables (optional)
  123594. * @returns the current animation group
  123595. */
  123596. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  123597. /**
  123598. * Pause all animations
  123599. * @returns the animation group
  123600. */
  123601. pause(): AnimationGroup;
  123602. /**
  123603. * Play all animations to initial state
  123604. * This function will start() the animations if they were not started or will restart() them if they were paused
  123605. * @param loop defines if animations must loop
  123606. * @returns the animation group
  123607. */
  123608. play(loop?: boolean): AnimationGroup;
  123609. /**
  123610. * Reset all animations to initial state
  123611. * @returns the animation group
  123612. */
  123613. reset(): AnimationGroup;
  123614. /**
  123615. * Restart animations from key 0
  123616. * @returns the animation group
  123617. */
  123618. restart(): AnimationGroup;
  123619. /**
  123620. * Stop all animations
  123621. * @returns the animation group
  123622. */
  123623. stop(): AnimationGroup;
  123624. /**
  123625. * Set animation weight for all animatables
  123626. * @param weight defines the weight to use
  123627. * @return the animationGroup
  123628. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  123629. */
  123630. setWeightForAllAnimatables(weight: number): AnimationGroup;
  123631. /**
  123632. * Synchronize and normalize all animatables with a source animatable
  123633. * @param root defines the root animatable to synchronize with
  123634. * @return the animationGroup
  123635. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  123636. */
  123637. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  123638. /**
  123639. * Goes to a specific frame in this animation group
  123640. * @param frame the frame number to go to
  123641. * @return the animationGroup
  123642. */
  123643. goToFrame(frame: number): AnimationGroup;
  123644. /**
  123645. * Dispose all associated resources
  123646. */
  123647. dispose(): void;
  123648. private _checkAnimationGroupEnded;
  123649. /**
  123650. * Clone the current animation group and returns a copy
  123651. * @param newName defines the name of the new group
  123652. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  123653. * @returns the new aniamtion group
  123654. */
  123655. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  123656. /**
  123657. * Serializes the animationGroup to an object
  123658. * @returns Serialized object
  123659. */
  123660. serialize(): any;
  123661. /**
  123662. * Returns a new AnimationGroup object parsed from the source provided.
  123663. * @param parsedAnimationGroup defines the source
  123664. * @param scene defines the scene that will receive the animationGroup
  123665. * @returns a new AnimationGroup
  123666. */
  123667. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  123668. /**
  123669. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  123670. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  123671. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  123672. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  123673. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  123674. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  123675. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  123676. */
  123677. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  123678. /**
  123679. * Returns the string "AnimationGroup"
  123680. * @returns "AnimationGroup"
  123681. */
  123682. getClassName(): string;
  123683. /**
  123684. * Creates a detailled string about the object
  123685. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  123686. * @returns a string representing the object
  123687. */
  123688. toString(fullDetails?: boolean): string;
  123689. }
  123690. }
  123691. declare module BABYLON {
  123692. /**
  123693. * Define an interface for all classes that will hold resources
  123694. */
  123695. export interface IDisposable {
  123696. /**
  123697. * Releases all held resources
  123698. */
  123699. dispose(): void;
  123700. }
  123701. /** Interface defining initialization parameters for Scene class */
  123702. export interface SceneOptions {
  123703. /**
  123704. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  123705. * It will improve performance when the number of geometries becomes important.
  123706. */
  123707. useGeometryUniqueIdsMap?: boolean;
  123708. /**
  123709. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  123710. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123711. */
  123712. useMaterialMeshMap?: boolean;
  123713. /**
  123714. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  123715. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123716. */
  123717. useClonedMeshMap?: boolean;
  123718. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  123719. virtual?: boolean;
  123720. }
  123721. /**
  123722. * Represents a scene to be rendered by the engine.
  123723. * @see https://doc.babylonjs.com/features/scene
  123724. */
  123725. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  123726. /** The fog is deactivated */
  123727. static readonly FOGMODE_NONE: number;
  123728. /** The fog density is following an exponential function */
  123729. static readonly FOGMODE_EXP: number;
  123730. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  123731. static readonly FOGMODE_EXP2: number;
  123732. /** The fog density is following a linear function. */
  123733. static readonly FOGMODE_LINEAR: number;
  123734. /**
  123735. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  123736. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123737. */
  123738. static MinDeltaTime: number;
  123739. /**
  123740. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  123741. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123742. */
  123743. static MaxDeltaTime: number;
  123744. /**
  123745. * Factory used to create the default material.
  123746. * @param name The name of the material to create
  123747. * @param scene The scene to create the material for
  123748. * @returns The default material
  123749. */
  123750. static DefaultMaterialFactory(scene: Scene): Material;
  123751. /**
  123752. * Factory used to create the a collision coordinator.
  123753. * @returns The collision coordinator
  123754. */
  123755. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  123756. /** @hidden */
  123757. _inputManager: InputManager;
  123758. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  123759. cameraToUseForPointers: Nullable<Camera>;
  123760. /** @hidden */
  123761. readonly _isScene: boolean;
  123762. /** @hidden */
  123763. _blockEntityCollection: boolean;
  123764. /**
  123765. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  123766. */
  123767. autoClear: boolean;
  123768. /**
  123769. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  123770. */
  123771. autoClearDepthAndStencil: boolean;
  123772. /**
  123773. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  123774. */
  123775. clearColor: Color4;
  123776. /**
  123777. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  123778. */
  123779. ambientColor: Color3;
  123780. /**
  123781. * This is use to store the default BRDF lookup for PBR materials in your scene.
  123782. * It should only be one of the following (if not the default embedded one):
  123783. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  123784. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  123785. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  123786. * The material properties need to be setup according to the type of texture in use.
  123787. */
  123788. environmentBRDFTexture: BaseTexture;
  123789. /**
  123790. * Texture used in all pbr material as the reflection texture.
  123791. * As in the majority of the scene they are the same (exception for multi room and so on),
  123792. * this is easier to reference from here than from all the materials.
  123793. */
  123794. get environmentTexture(): Nullable<BaseTexture>;
  123795. /**
  123796. * Texture used in all pbr material as the reflection texture.
  123797. * As in the majority of the scene they are the same (exception for multi room and so on),
  123798. * this is easier to set here than in all the materials.
  123799. */
  123800. set environmentTexture(value: Nullable<BaseTexture>);
  123801. /** @hidden */
  123802. protected _environmentIntensity: number;
  123803. /**
  123804. * Intensity of the environment in all pbr material.
  123805. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123806. * As in the majority of the scene they are the same (exception for multi room and so on),
  123807. * this is easier to reference from here than from all the materials.
  123808. */
  123809. get environmentIntensity(): number;
  123810. /**
  123811. * Intensity of the environment in all pbr material.
  123812. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123813. * As in the majority of the scene they are the same (exception for multi room and so on),
  123814. * this is easier to set here than in all the materials.
  123815. */
  123816. set environmentIntensity(value: number);
  123817. /** @hidden */
  123818. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123819. /**
  123820. * Default image processing configuration used either in the rendering
  123821. * Forward main pass or through the imageProcessingPostProcess if present.
  123822. * As in the majority of the scene they are the same (exception for multi camera),
  123823. * this is easier to reference from here than from all the materials and post process.
  123824. *
  123825. * No setter as we it is a shared configuration, you can set the values instead.
  123826. */
  123827. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123828. private _forceWireframe;
  123829. /**
  123830. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  123831. */
  123832. set forceWireframe(value: boolean);
  123833. get forceWireframe(): boolean;
  123834. private _skipFrustumClipping;
  123835. /**
  123836. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  123837. */
  123838. set skipFrustumClipping(value: boolean);
  123839. get skipFrustumClipping(): boolean;
  123840. private _forcePointsCloud;
  123841. /**
  123842. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  123843. */
  123844. set forcePointsCloud(value: boolean);
  123845. get forcePointsCloud(): boolean;
  123846. /**
  123847. * Gets or sets the active clipplane 1
  123848. */
  123849. clipPlane: Nullable<Plane>;
  123850. /**
  123851. * Gets or sets the active clipplane 2
  123852. */
  123853. clipPlane2: Nullable<Plane>;
  123854. /**
  123855. * Gets or sets the active clipplane 3
  123856. */
  123857. clipPlane3: Nullable<Plane>;
  123858. /**
  123859. * Gets or sets the active clipplane 4
  123860. */
  123861. clipPlane4: Nullable<Plane>;
  123862. /**
  123863. * Gets or sets the active clipplane 5
  123864. */
  123865. clipPlane5: Nullable<Plane>;
  123866. /**
  123867. * Gets or sets the active clipplane 6
  123868. */
  123869. clipPlane6: Nullable<Plane>;
  123870. /**
  123871. * Gets or sets a boolean indicating if animations are enabled
  123872. */
  123873. animationsEnabled: boolean;
  123874. private _animationPropertiesOverride;
  123875. /**
  123876. * Gets or sets the animation properties override
  123877. */
  123878. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  123879. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  123880. /**
  123881. * Gets or sets a boolean indicating if a constant deltatime has to be used
  123882. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  123883. */
  123884. useConstantAnimationDeltaTime: boolean;
  123885. /**
  123886. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  123887. * Please note that it requires to run a ray cast through the scene on every frame
  123888. */
  123889. constantlyUpdateMeshUnderPointer: boolean;
  123890. /**
  123891. * Defines the HTML cursor to use when hovering over interactive elements
  123892. */
  123893. hoverCursor: string;
  123894. /**
  123895. * Defines the HTML default cursor to use (empty by default)
  123896. */
  123897. defaultCursor: string;
  123898. /**
  123899. * Defines whether cursors are handled by the scene.
  123900. */
  123901. doNotHandleCursors: boolean;
  123902. /**
  123903. * This is used to call preventDefault() on pointer down
  123904. * in order to block unwanted artifacts like system double clicks
  123905. */
  123906. preventDefaultOnPointerDown: boolean;
  123907. /**
  123908. * This is used to call preventDefault() on pointer up
  123909. * in order to block unwanted artifacts like system double clicks
  123910. */
  123911. preventDefaultOnPointerUp: boolean;
  123912. /**
  123913. * Gets or sets user defined metadata
  123914. */
  123915. metadata: any;
  123916. /**
  123917. * For internal use only. Please do not use.
  123918. */
  123919. reservedDataStore: any;
  123920. /**
  123921. * Gets the name of the plugin used to load this scene (null by default)
  123922. */
  123923. loadingPluginName: string;
  123924. /**
  123925. * Use this array to add regular expressions used to disable offline support for specific urls
  123926. */
  123927. disableOfflineSupportExceptionRules: RegExp[];
  123928. /**
  123929. * An event triggered when the scene is disposed.
  123930. */
  123931. onDisposeObservable: Observable<Scene>;
  123932. private _onDisposeObserver;
  123933. /** Sets a function to be executed when this scene is disposed. */
  123934. set onDispose(callback: () => void);
  123935. /**
  123936. * An event triggered before rendering the scene (right after animations and physics)
  123937. */
  123938. onBeforeRenderObservable: Observable<Scene>;
  123939. private _onBeforeRenderObserver;
  123940. /** Sets a function to be executed before rendering this scene */
  123941. set beforeRender(callback: Nullable<() => void>);
  123942. /**
  123943. * An event triggered after rendering the scene
  123944. */
  123945. onAfterRenderObservable: Observable<Scene>;
  123946. /**
  123947. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  123948. */
  123949. onAfterRenderCameraObservable: Observable<Camera>;
  123950. private _onAfterRenderObserver;
  123951. /** Sets a function to be executed after rendering this scene */
  123952. set afterRender(callback: Nullable<() => void>);
  123953. /**
  123954. * An event triggered before animating the scene
  123955. */
  123956. onBeforeAnimationsObservable: Observable<Scene>;
  123957. /**
  123958. * An event triggered after animations processing
  123959. */
  123960. onAfterAnimationsObservable: Observable<Scene>;
  123961. /**
  123962. * An event triggered before draw calls are ready to be sent
  123963. */
  123964. onBeforeDrawPhaseObservable: Observable<Scene>;
  123965. /**
  123966. * An event triggered after draw calls have been sent
  123967. */
  123968. onAfterDrawPhaseObservable: Observable<Scene>;
  123969. /**
  123970. * An event triggered when the scene is ready
  123971. */
  123972. onReadyObservable: Observable<Scene>;
  123973. /**
  123974. * An event triggered before rendering a camera
  123975. */
  123976. onBeforeCameraRenderObservable: Observable<Camera>;
  123977. private _onBeforeCameraRenderObserver;
  123978. /** Sets a function to be executed before rendering a camera*/
  123979. set beforeCameraRender(callback: () => void);
  123980. /**
  123981. * An event triggered after rendering a camera
  123982. */
  123983. onAfterCameraRenderObservable: Observable<Camera>;
  123984. private _onAfterCameraRenderObserver;
  123985. /** Sets a function to be executed after rendering a camera*/
  123986. set afterCameraRender(callback: () => void);
  123987. /**
  123988. * An event triggered when active meshes evaluation is about to start
  123989. */
  123990. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  123991. /**
  123992. * An event triggered when active meshes evaluation is done
  123993. */
  123994. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  123995. /**
  123996. * An event triggered when particles rendering is about to start
  123997. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123998. */
  123999. onBeforeParticlesRenderingObservable: Observable<Scene>;
  124000. /**
  124001. * An event triggered when particles rendering is done
  124002. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124003. */
  124004. onAfterParticlesRenderingObservable: Observable<Scene>;
  124005. /**
  124006. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  124007. */
  124008. onDataLoadedObservable: Observable<Scene>;
  124009. /**
  124010. * An event triggered when a camera is created
  124011. */
  124012. onNewCameraAddedObservable: Observable<Camera>;
  124013. /**
  124014. * An event triggered when a camera is removed
  124015. */
  124016. onCameraRemovedObservable: Observable<Camera>;
  124017. /**
  124018. * An event triggered when a light is created
  124019. */
  124020. onNewLightAddedObservable: Observable<Light>;
  124021. /**
  124022. * An event triggered when a light is removed
  124023. */
  124024. onLightRemovedObservable: Observable<Light>;
  124025. /**
  124026. * An event triggered when a geometry is created
  124027. */
  124028. onNewGeometryAddedObservable: Observable<Geometry>;
  124029. /**
  124030. * An event triggered when a geometry is removed
  124031. */
  124032. onGeometryRemovedObservable: Observable<Geometry>;
  124033. /**
  124034. * An event triggered when a transform node is created
  124035. */
  124036. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  124037. /**
  124038. * An event triggered when a transform node is removed
  124039. */
  124040. onTransformNodeRemovedObservable: Observable<TransformNode>;
  124041. /**
  124042. * An event triggered when a mesh is created
  124043. */
  124044. onNewMeshAddedObservable: Observable<AbstractMesh>;
  124045. /**
  124046. * An event triggered when a mesh is removed
  124047. */
  124048. onMeshRemovedObservable: Observable<AbstractMesh>;
  124049. /**
  124050. * An event triggered when a skeleton is created
  124051. */
  124052. onNewSkeletonAddedObservable: Observable<Skeleton>;
  124053. /**
  124054. * An event triggered when a skeleton is removed
  124055. */
  124056. onSkeletonRemovedObservable: Observable<Skeleton>;
  124057. /**
  124058. * An event triggered when a material is created
  124059. */
  124060. onNewMaterialAddedObservable: Observable<Material>;
  124061. /**
  124062. * An event triggered when a material is removed
  124063. */
  124064. onMaterialRemovedObservable: Observable<Material>;
  124065. /**
  124066. * An event triggered when a texture is created
  124067. */
  124068. onNewTextureAddedObservable: Observable<BaseTexture>;
  124069. /**
  124070. * An event triggered when a texture is removed
  124071. */
  124072. onTextureRemovedObservable: Observable<BaseTexture>;
  124073. /**
  124074. * An event triggered when render targets are about to be rendered
  124075. * Can happen multiple times per frame.
  124076. */
  124077. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  124078. /**
  124079. * An event triggered when render targets were rendered.
  124080. * Can happen multiple times per frame.
  124081. */
  124082. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  124083. /**
  124084. * An event triggered before calculating deterministic simulation step
  124085. */
  124086. onBeforeStepObservable: Observable<Scene>;
  124087. /**
  124088. * An event triggered after calculating deterministic simulation step
  124089. */
  124090. onAfterStepObservable: Observable<Scene>;
  124091. /**
  124092. * An event triggered when the activeCamera property is updated
  124093. */
  124094. onActiveCameraChanged: Observable<Scene>;
  124095. /**
  124096. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  124097. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124098. * 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)
  124099. */
  124100. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124101. /**
  124102. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  124103. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124104. * 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)
  124105. */
  124106. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124107. /**
  124108. * This Observable will when a mesh has been imported into the scene.
  124109. */
  124110. onMeshImportedObservable: Observable<AbstractMesh>;
  124111. /**
  124112. * This Observable will when an animation file has been imported into the scene.
  124113. */
  124114. onAnimationFileImportedObservable: Observable<Scene>;
  124115. /**
  124116. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  124117. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  124118. */
  124119. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  124120. /** @hidden */
  124121. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  124122. /**
  124123. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  124124. */
  124125. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  124126. /**
  124127. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  124128. */
  124129. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  124130. /**
  124131. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  124132. */
  124133. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  124134. /** Callback called when a pointer move is detected */
  124135. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124136. /** Callback called when a pointer down is detected */
  124137. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124138. /** Callback called when a pointer up is detected */
  124139. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  124140. /** Callback called when a pointer pick is detected */
  124141. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  124142. /**
  124143. * 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).
  124144. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  124145. */
  124146. onPrePointerObservable: Observable<PointerInfoPre>;
  124147. /**
  124148. * Observable event triggered each time an input event is received from the rendering canvas
  124149. */
  124150. onPointerObservable: Observable<PointerInfo>;
  124151. /**
  124152. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  124153. */
  124154. get unTranslatedPointer(): Vector2;
  124155. /**
  124156. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  124157. */
  124158. static get DragMovementThreshold(): number;
  124159. static set DragMovementThreshold(value: number);
  124160. /**
  124161. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  124162. */
  124163. static get LongPressDelay(): number;
  124164. static set LongPressDelay(value: number);
  124165. /**
  124166. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  124167. */
  124168. static get DoubleClickDelay(): number;
  124169. static set DoubleClickDelay(value: number);
  124170. /** If you need to check double click without raising a single click at first click, enable this flag */
  124171. static get ExclusiveDoubleClickMode(): boolean;
  124172. static set ExclusiveDoubleClickMode(value: boolean);
  124173. /** @hidden */
  124174. _mirroredCameraPosition: Nullable<Vector3>;
  124175. /**
  124176. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  124177. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  124178. */
  124179. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  124180. /**
  124181. * Observable event triggered each time an keyboard event is received from the hosting window
  124182. */
  124183. onKeyboardObservable: Observable<KeyboardInfo>;
  124184. private _useRightHandedSystem;
  124185. /**
  124186. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  124187. */
  124188. set useRightHandedSystem(value: boolean);
  124189. get useRightHandedSystem(): boolean;
  124190. private _timeAccumulator;
  124191. private _currentStepId;
  124192. private _currentInternalStep;
  124193. /**
  124194. * Sets the step Id used by deterministic lock step
  124195. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124196. * @param newStepId defines the step Id
  124197. */
  124198. setStepId(newStepId: number): void;
  124199. /**
  124200. * Gets the step Id used by deterministic lock step
  124201. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124202. * @returns the step Id
  124203. */
  124204. getStepId(): number;
  124205. /**
  124206. * Gets the internal step used by deterministic lock step
  124207. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124208. * @returns the internal step
  124209. */
  124210. getInternalStep(): number;
  124211. private _fogEnabled;
  124212. /**
  124213. * Gets or sets a boolean indicating if fog is enabled on this scene
  124214. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124215. * (Default is true)
  124216. */
  124217. set fogEnabled(value: boolean);
  124218. get fogEnabled(): boolean;
  124219. private _fogMode;
  124220. /**
  124221. * Gets or sets the fog mode to use
  124222. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124223. * | mode | value |
  124224. * | --- | --- |
  124225. * | FOGMODE_NONE | 0 |
  124226. * | FOGMODE_EXP | 1 |
  124227. * | FOGMODE_EXP2 | 2 |
  124228. * | FOGMODE_LINEAR | 3 |
  124229. */
  124230. set fogMode(value: number);
  124231. get fogMode(): number;
  124232. /**
  124233. * Gets or sets the fog color to use
  124234. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124235. * (Default is Color3(0.2, 0.2, 0.3))
  124236. */
  124237. fogColor: Color3;
  124238. /**
  124239. * Gets or sets the fog density to use
  124240. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124241. * (Default is 0.1)
  124242. */
  124243. fogDensity: number;
  124244. /**
  124245. * Gets or sets the fog start distance to use
  124246. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124247. * (Default is 0)
  124248. */
  124249. fogStart: number;
  124250. /**
  124251. * Gets or sets the fog end distance to use
  124252. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124253. * (Default is 1000)
  124254. */
  124255. fogEnd: number;
  124256. /**
  124257. * Flag indicating that the frame buffer binding is handled by another component
  124258. */
  124259. prePass: boolean;
  124260. private _shadowsEnabled;
  124261. /**
  124262. * Gets or sets a boolean indicating if shadows are enabled on this scene
  124263. */
  124264. set shadowsEnabled(value: boolean);
  124265. get shadowsEnabled(): boolean;
  124266. private _lightsEnabled;
  124267. /**
  124268. * Gets or sets a boolean indicating if lights are enabled on this scene
  124269. */
  124270. set lightsEnabled(value: boolean);
  124271. get lightsEnabled(): boolean;
  124272. /** All of the active cameras added to this scene. */
  124273. activeCameras: Camera[];
  124274. /** @hidden */
  124275. _activeCamera: Nullable<Camera>;
  124276. /** Gets or sets the current active camera */
  124277. get activeCamera(): Nullable<Camera>;
  124278. set activeCamera(value: Nullable<Camera>);
  124279. private _defaultMaterial;
  124280. /** The default material used on meshes when no material is affected */
  124281. get defaultMaterial(): Material;
  124282. /** The default material used on meshes when no material is affected */
  124283. set defaultMaterial(value: Material);
  124284. private _texturesEnabled;
  124285. /**
  124286. * Gets or sets a boolean indicating if textures are enabled on this scene
  124287. */
  124288. set texturesEnabled(value: boolean);
  124289. get texturesEnabled(): boolean;
  124290. /**
  124291. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  124292. */
  124293. physicsEnabled: boolean;
  124294. /**
  124295. * Gets or sets a boolean indicating if particles are enabled on this scene
  124296. */
  124297. particlesEnabled: boolean;
  124298. /**
  124299. * Gets or sets a boolean indicating if sprites are enabled on this scene
  124300. */
  124301. spritesEnabled: boolean;
  124302. private _skeletonsEnabled;
  124303. /**
  124304. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  124305. */
  124306. set skeletonsEnabled(value: boolean);
  124307. get skeletonsEnabled(): boolean;
  124308. /**
  124309. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  124310. */
  124311. lensFlaresEnabled: boolean;
  124312. /**
  124313. * Gets or sets a boolean indicating if collisions are enabled on this scene
  124314. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  124315. */
  124316. collisionsEnabled: boolean;
  124317. private _collisionCoordinator;
  124318. /** @hidden */
  124319. get collisionCoordinator(): ICollisionCoordinator;
  124320. /**
  124321. * Defines the gravity applied to this scene (used only for collisions)
  124322. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  124323. */
  124324. gravity: Vector3;
  124325. /**
  124326. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  124327. */
  124328. postProcessesEnabled: boolean;
  124329. /**
  124330. * Gets the current postprocess manager
  124331. */
  124332. postProcessManager: PostProcessManager;
  124333. /**
  124334. * Gets or sets a boolean indicating if render targets are enabled on this scene
  124335. */
  124336. renderTargetsEnabled: boolean;
  124337. /**
  124338. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  124339. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  124340. */
  124341. dumpNextRenderTargets: boolean;
  124342. /**
  124343. * The list of user defined render targets added to the scene
  124344. */
  124345. customRenderTargets: RenderTargetTexture[];
  124346. /**
  124347. * Defines if texture loading must be delayed
  124348. * If true, textures will only be loaded when they need to be rendered
  124349. */
  124350. useDelayedTextureLoading: boolean;
  124351. /**
  124352. * Gets the list of meshes imported to the scene through SceneLoader
  124353. */
  124354. importedMeshesFiles: String[];
  124355. /**
  124356. * Gets or sets a boolean indicating if probes are enabled on this scene
  124357. */
  124358. probesEnabled: boolean;
  124359. /**
  124360. * Gets or sets the current offline provider to use to store scene data
  124361. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124362. */
  124363. offlineProvider: IOfflineProvider;
  124364. /**
  124365. * Gets or sets the action manager associated with the scene
  124366. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  124367. */
  124368. actionManager: AbstractActionManager;
  124369. private _meshesForIntersections;
  124370. /**
  124371. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  124372. */
  124373. proceduralTexturesEnabled: boolean;
  124374. private _engine;
  124375. private _totalVertices;
  124376. /** @hidden */
  124377. _activeIndices: PerfCounter;
  124378. /** @hidden */
  124379. _activeParticles: PerfCounter;
  124380. /** @hidden */
  124381. _activeBones: PerfCounter;
  124382. private _animationRatio;
  124383. /** @hidden */
  124384. _animationTimeLast: number;
  124385. /** @hidden */
  124386. _animationTime: number;
  124387. /**
  124388. * Gets or sets a general scale for animation speed
  124389. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  124390. */
  124391. animationTimeScale: number;
  124392. /** @hidden */
  124393. _cachedMaterial: Nullable<Material>;
  124394. /** @hidden */
  124395. _cachedEffect: Nullable<Effect>;
  124396. /** @hidden */
  124397. _cachedVisibility: Nullable<number>;
  124398. private _renderId;
  124399. private _frameId;
  124400. private _executeWhenReadyTimeoutId;
  124401. private _intermediateRendering;
  124402. private _viewUpdateFlag;
  124403. private _projectionUpdateFlag;
  124404. /** @hidden */
  124405. _toBeDisposed: Nullable<IDisposable>[];
  124406. private _activeRequests;
  124407. /** @hidden */
  124408. _pendingData: any[];
  124409. private _isDisposed;
  124410. /**
  124411. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  124412. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  124413. */
  124414. dispatchAllSubMeshesOfActiveMeshes: boolean;
  124415. private _activeMeshes;
  124416. private _processedMaterials;
  124417. private _renderTargets;
  124418. /** @hidden */
  124419. _activeParticleSystems: SmartArray<IParticleSystem>;
  124420. private _activeSkeletons;
  124421. private _softwareSkinnedMeshes;
  124422. private _renderingManager;
  124423. /** @hidden */
  124424. _activeAnimatables: Animatable[];
  124425. private _transformMatrix;
  124426. private _sceneUbo;
  124427. /** @hidden */
  124428. _viewMatrix: Matrix;
  124429. private _projectionMatrix;
  124430. /** @hidden */
  124431. _forcedViewPosition: Nullable<Vector3>;
  124432. /** @hidden */
  124433. _frustumPlanes: Plane[];
  124434. /**
  124435. * Gets the list of frustum planes (built from the active camera)
  124436. */
  124437. get frustumPlanes(): Plane[];
  124438. /**
  124439. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  124440. * This is useful if there are more lights that the maximum simulteanous authorized
  124441. */
  124442. requireLightSorting: boolean;
  124443. /** @hidden */
  124444. readonly useMaterialMeshMap: boolean;
  124445. /** @hidden */
  124446. readonly useClonedMeshMap: boolean;
  124447. private _externalData;
  124448. private _uid;
  124449. /**
  124450. * @hidden
  124451. * Backing store of defined scene components.
  124452. */
  124453. _components: ISceneComponent[];
  124454. /**
  124455. * @hidden
  124456. * Backing store of defined scene components.
  124457. */
  124458. _serializableComponents: ISceneSerializableComponent[];
  124459. /**
  124460. * List of components to register on the next registration step.
  124461. */
  124462. private _transientComponents;
  124463. /**
  124464. * Registers the transient components if needed.
  124465. */
  124466. private _registerTransientComponents;
  124467. /**
  124468. * @hidden
  124469. * Add a component to the scene.
  124470. * Note that the ccomponent could be registered on th next frame if this is called after
  124471. * the register component stage.
  124472. * @param component Defines the component to add to the scene
  124473. */
  124474. _addComponent(component: ISceneComponent): void;
  124475. /**
  124476. * @hidden
  124477. * Gets a component from the scene.
  124478. * @param name defines the name of the component to retrieve
  124479. * @returns the component or null if not present
  124480. */
  124481. _getComponent(name: string): Nullable<ISceneComponent>;
  124482. /**
  124483. * @hidden
  124484. * Defines the actions happening before camera updates.
  124485. */
  124486. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  124487. /**
  124488. * @hidden
  124489. * Defines the actions happening before clear the canvas.
  124490. */
  124491. _beforeClearStage: Stage<SimpleStageAction>;
  124492. /**
  124493. * @hidden
  124494. * Defines the actions when collecting render targets for the frame.
  124495. */
  124496. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  124497. /**
  124498. * @hidden
  124499. * Defines the actions happening for one camera in the frame.
  124500. */
  124501. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  124502. /**
  124503. * @hidden
  124504. * Defines the actions happening during the per mesh ready checks.
  124505. */
  124506. _isReadyForMeshStage: Stage<MeshStageAction>;
  124507. /**
  124508. * @hidden
  124509. * Defines the actions happening before evaluate active mesh checks.
  124510. */
  124511. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  124512. /**
  124513. * @hidden
  124514. * Defines the actions happening during the evaluate sub mesh checks.
  124515. */
  124516. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  124517. /**
  124518. * @hidden
  124519. * Defines the actions happening during the active mesh stage.
  124520. */
  124521. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  124522. /**
  124523. * @hidden
  124524. * Defines the actions happening during the per camera render target step.
  124525. */
  124526. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  124527. /**
  124528. * @hidden
  124529. * Defines the actions happening just before the active camera is drawing.
  124530. */
  124531. _beforeCameraDrawStage: Stage<CameraStageAction>;
  124532. /**
  124533. * @hidden
  124534. * Defines the actions happening just before a render target is drawing.
  124535. */
  124536. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  124537. /**
  124538. * @hidden
  124539. * Defines the actions happening just before a rendering group is drawing.
  124540. */
  124541. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  124542. /**
  124543. * @hidden
  124544. * Defines the actions happening just before a mesh is drawing.
  124545. */
  124546. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  124547. /**
  124548. * @hidden
  124549. * Defines the actions happening just after a mesh has been drawn.
  124550. */
  124551. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  124552. /**
  124553. * @hidden
  124554. * Defines the actions happening just after a rendering group has been drawn.
  124555. */
  124556. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  124557. /**
  124558. * @hidden
  124559. * Defines the actions happening just after the active camera has been drawn.
  124560. */
  124561. _afterCameraDrawStage: Stage<CameraStageAction>;
  124562. /**
  124563. * @hidden
  124564. * Defines the actions happening just after a render target has been drawn.
  124565. */
  124566. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  124567. /**
  124568. * @hidden
  124569. * Defines the actions happening just after rendering all cameras and computing intersections.
  124570. */
  124571. _afterRenderStage: Stage<SimpleStageAction>;
  124572. /**
  124573. * @hidden
  124574. * Defines the actions happening when a pointer move event happens.
  124575. */
  124576. _pointerMoveStage: Stage<PointerMoveStageAction>;
  124577. /**
  124578. * @hidden
  124579. * Defines the actions happening when a pointer down event happens.
  124580. */
  124581. _pointerDownStage: Stage<PointerUpDownStageAction>;
  124582. /**
  124583. * @hidden
  124584. * Defines the actions happening when a pointer up event happens.
  124585. */
  124586. _pointerUpStage: Stage<PointerUpDownStageAction>;
  124587. /**
  124588. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  124589. */
  124590. private geometriesByUniqueId;
  124591. /**
  124592. * Creates a new Scene
  124593. * @param engine defines the engine to use to render this scene
  124594. * @param options defines the scene options
  124595. */
  124596. constructor(engine: Engine, options?: SceneOptions);
  124597. /**
  124598. * Gets a string identifying the name of the class
  124599. * @returns "Scene" string
  124600. */
  124601. getClassName(): string;
  124602. private _defaultMeshCandidates;
  124603. /**
  124604. * @hidden
  124605. */
  124606. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  124607. private _defaultSubMeshCandidates;
  124608. /**
  124609. * @hidden
  124610. */
  124611. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  124612. /**
  124613. * Sets the default candidate providers for the scene.
  124614. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  124615. * and getCollidingSubMeshCandidates to their default function
  124616. */
  124617. setDefaultCandidateProviders(): void;
  124618. /**
  124619. * Gets the mesh that is currently under the pointer
  124620. */
  124621. get meshUnderPointer(): Nullable<AbstractMesh>;
  124622. /**
  124623. * Gets or sets the current on-screen X position of the pointer
  124624. */
  124625. get pointerX(): number;
  124626. set pointerX(value: number);
  124627. /**
  124628. * Gets or sets the current on-screen Y position of the pointer
  124629. */
  124630. get pointerY(): number;
  124631. set pointerY(value: number);
  124632. /**
  124633. * Gets the cached material (ie. the latest rendered one)
  124634. * @returns the cached material
  124635. */
  124636. getCachedMaterial(): Nullable<Material>;
  124637. /**
  124638. * Gets the cached effect (ie. the latest rendered one)
  124639. * @returns the cached effect
  124640. */
  124641. getCachedEffect(): Nullable<Effect>;
  124642. /**
  124643. * Gets the cached visibility state (ie. the latest rendered one)
  124644. * @returns the cached visibility state
  124645. */
  124646. getCachedVisibility(): Nullable<number>;
  124647. /**
  124648. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  124649. * @param material defines the current material
  124650. * @param effect defines the current effect
  124651. * @param visibility defines the current visibility state
  124652. * @returns true if one parameter is not cached
  124653. */
  124654. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  124655. /**
  124656. * Gets the engine associated with the scene
  124657. * @returns an Engine
  124658. */
  124659. getEngine(): Engine;
  124660. /**
  124661. * Gets the total number of vertices rendered per frame
  124662. * @returns the total number of vertices rendered per frame
  124663. */
  124664. getTotalVertices(): number;
  124665. /**
  124666. * Gets the performance counter for total vertices
  124667. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124668. */
  124669. get totalVerticesPerfCounter(): PerfCounter;
  124670. /**
  124671. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  124672. * @returns the total number of active indices rendered per frame
  124673. */
  124674. getActiveIndices(): number;
  124675. /**
  124676. * Gets the performance counter for active indices
  124677. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124678. */
  124679. get totalActiveIndicesPerfCounter(): PerfCounter;
  124680. /**
  124681. * Gets the total number of active particles rendered per frame
  124682. * @returns the total number of active particles rendered per frame
  124683. */
  124684. getActiveParticles(): number;
  124685. /**
  124686. * Gets the performance counter for active particles
  124687. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124688. */
  124689. get activeParticlesPerfCounter(): PerfCounter;
  124690. /**
  124691. * Gets the total number of active bones rendered per frame
  124692. * @returns the total number of active bones rendered per frame
  124693. */
  124694. getActiveBones(): number;
  124695. /**
  124696. * Gets the performance counter for active bones
  124697. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124698. */
  124699. get activeBonesPerfCounter(): PerfCounter;
  124700. /**
  124701. * Gets the array of active meshes
  124702. * @returns an array of AbstractMesh
  124703. */
  124704. getActiveMeshes(): SmartArray<AbstractMesh>;
  124705. /**
  124706. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  124707. * @returns a number
  124708. */
  124709. getAnimationRatio(): number;
  124710. /**
  124711. * Gets an unique Id for the current render phase
  124712. * @returns a number
  124713. */
  124714. getRenderId(): number;
  124715. /**
  124716. * Gets an unique Id for the current frame
  124717. * @returns a number
  124718. */
  124719. getFrameId(): number;
  124720. /** Call this function if you want to manually increment the render Id*/
  124721. incrementRenderId(): void;
  124722. private _createUbo;
  124723. /**
  124724. * Use this method to simulate a pointer move on a mesh
  124725. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124726. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124727. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124728. * @returns the current scene
  124729. */
  124730. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124731. /**
  124732. * Use this method to simulate a pointer down on a mesh
  124733. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124734. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124735. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124736. * @returns the current scene
  124737. */
  124738. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124739. /**
  124740. * Use this method to simulate a pointer up on a mesh
  124741. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124742. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124743. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124744. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  124745. * @returns the current scene
  124746. */
  124747. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  124748. /**
  124749. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  124750. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  124751. * @returns true if the pointer was captured
  124752. */
  124753. isPointerCaptured(pointerId?: number): boolean;
  124754. /**
  124755. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  124756. * @param attachUp defines if you want to attach events to pointerup
  124757. * @param attachDown defines if you want to attach events to pointerdown
  124758. * @param attachMove defines if you want to attach events to pointermove
  124759. */
  124760. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  124761. /** Detaches all event handlers*/
  124762. detachControl(): void;
  124763. /**
  124764. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  124765. * Delay loaded resources are not taking in account
  124766. * @return true if all required resources are ready
  124767. */
  124768. isReady(): boolean;
  124769. /** Resets all cached information relative to material (including effect and visibility) */
  124770. resetCachedMaterial(): void;
  124771. /**
  124772. * Registers a function to be called before every frame render
  124773. * @param func defines the function to register
  124774. */
  124775. registerBeforeRender(func: () => void): void;
  124776. /**
  124777. * Unregisters a function called before every frame render
  124778. * @param func defines the function to unregister
  124779. */
  124780. unregisterBeforeRender(func: () => void): void;
  124781. /**
  124782. * Registers a function to be called after every frame render
  124783. * @param func defines the function to register
  124784. */
  124785. registerAfterRender(func: () => void): void;
  124786. /**
  124787. * Unregisters a function called after every frame render
  124788. * @param func defines the function to unregister
  124789. */
  124790. unregisterAfterRender(func: () => void): void;
  124791. private _executeOnceBeforeRender;
  124792. /**
  124793. * The provided function will run before render once and will be disposed afterwards.
  124794. * A timeout delay can be provided so that the function will be executed in N ms.
  124795. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  124796. * @param func The function to be executed.
  124797. * @param timeout optional delay in ms
  124798. */
  124799. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  124800. /** @hidden */
  124801. _addPendingData(data: any): void;
  124802. /** @hidden */
  124803. _removePendingData(data: any): void;
  124804. /**
  124805. * Returns the number of items waiting to be loaded
  124806. * @returns the number of items waiting to be loaded
  124807. */
  124808. getWaitingItemsCount(): number;
  124809. /**
  124810. * Returns a boolean indicating if the scene is still loading data
  124811. */
  124812. get isLoading(): boolean;
  124813. /**
  124814. * Registers a function to be executed when the scene is ready
  124815. * @param {Function} func - the function to be executed
  124816. */
  124817. executeWhenReady(func: () => void): void;
  124818. /**
  124819. * Returns a promise that resolves when the scene is ready
  124820. * @returns A promise that resolves when the scene is ready
  124821. */
  124822. whenReadyAsync(): Promise<void>;
  124823. /** @hidden */
  124824. _checkIsReady(): void;
  124825. /**
  124826. * Gets all animatable attached to the scene
  124827. */
  124828. get animatables(): Animatable[];
  124829. /**
  124830. * Resets the last animation time frame.
  124831. * Useful to override when animations start running when loading a scene for the first time.
  124832. */
  124833. resetLastAnimationTimeFrame(): void;
  124834. /**
  124835. * Gets the current view matrix
  124836. * @returns a Matrix
  124837. */
  124838. getViewMatrix(): Matrix;
  124839. /**
  124840. * Gets the current projection matrix
  124841. * @returns a Matrix
  124842. */
  124843. getProjectionMatrix(): Matrix;
  124844. /**
  124845. * Gets the current transform matrix
  124846. * @returns a Matrix made of View * Projection
  124847. */
  124848. getTransformMatrix(): Matrix;
  124849. /**
  124850. * Sets the current transform matrix
  124851. * @param viewL defines the View matrix to use
  124852. * @param projectionL defines the Projection matrix to use
  124853. * @param viewR defines the right View matrix to use (if provided)
  124854. * @param projectionR defines the right Projection matrix to use (if provided)
  124855. */
  124856. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  124857. /**
  124858. * Gets the uniform buffer used to store scene data
  124859. * @returns a UniformBuffer
  124860. */
  124861. getSceneUniformBuffer(): UniformBuffer;
  124862. /**
  124863. * Gets an unique (relatively to the current scene) Id
  124864. * @returns an unique number for the scene
  124865. */
  124866. getUniqueId(): number;
  124867. /**
  124868. * Add a mesh to the list of scene's meshes
  124869. * @param newMesh defines the mesh to add
  124870. * @param recursive if all child meshes should also be added to the scene
  124871. */
  124872. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  124873. /**
  124874. * Remove a mesh for the list of scene's meshes
  124875. * @param toRemove defines the mesh to remove
  124876. * @param recursive if all child meshes should also be removed from the scene
  124877. * @returns the index where the mesh was in the mesh list
  124878. */
  124879. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  124880. /**
  124881. * Add a transform node to the list of scene's transform nodes
  124882. * @param newTransformNode defines the transform node to add
  124883. */
  124884. addTransformNode(newTransformNode: TransformNode): void;
  124885. /**
  124886. * Remove a transform node for the list of scene's transform nodes
  124887. * @param toRemove defines the transform node to remove
  124888. * @returns the index where the transform node was in the transform node list
  124889. */
  124890. removeTransformNode(toRemove: TransformNode): number;
  124891. /**
  124892. * Remove a skeleton for the list of scene's skeletons
  124893. * @param toRemove defines the skeleton to remove
  124894. * @returns the index where the skeleton was in the skeleton list
  124895. */
  124896. removeSkeleton(toRemove: Skeleton): number;
  124897. /**
  124898. * Remove a morph target for the list of scene's morph targets
  124899. * @param toRemove defines the morph target to remove
  124900. * @returns the index where the morph target was in the morph target list
  124901. */
  124902. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  124903. /**
  124904. * Remove a light for the list of scene's lights
  124905. * @param toRemove defines the light to remove
  124906. * @returns the index where the light was in the light list
  124907. */
  124908. removeLight(toRemove: Light): number;
  124909. /**
  124910. * Remove a camera for the list of scene's cameras
  124911. * @param toRemove defines the camera to remove
  124912. * @returns the index where the camera was in the camera list
  124913. */
  124914. removeCamera(toRemove: Camera): number;
  124915. /**
  124916. * Remove a particle system for the list of scene's particle systems
  124917. * @param toRemove defines the particle system to remove
  124918. * @returns the index where the particle system was in the particle system list
  124919. */
  124920. removeParticleSystem(toRemove: IParticleSystem): number;
  124921. /**
  124922. * Remove a animation for the list of scene's animations
  124923. * @param toRemove defines the animation to remove
  124924. * @returns the index where the animation was in the animation list
  124925. */
  124926. removeAnimation(toRemove: Animation): number;
  124927. /**
  124928. * Will stop the animation of the given target
  124929. * @param target - the target
  124930. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  124931. * @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)
  124932. */
  124933. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  124934. /**
  124935. * Removes the given animation group from this scene.
  124936. * @param toRemove The animation group to remove
  124937. * @returns The index of the removed animation group
  124938. */
  124939. removeAnimationGroup(toRemove: AnimationGroup): number;
  124940. /**
  124941. * Removes the given multi-material from this scene.
  124942. * @param toRemove The multi-material to remove
  124943. * @returns The index of the removed multi-material
  124944. */
  124945. removeMultiMaterial(toRemove: MultiMaterial): number;
  124946. /**
  124947. * Removes the given material from this scene.
  124948. * @param toRemove The material to remove
  124949. * @returns The index of the removed material
  124950. */
  124951. removeMaterial(toRemove: Material): number;
  124952. /**
  124953. * Removes the given action manager from this scene.
  124954. * @param toRemove The action manager to remove
  124955. * @returns The index of the removed action manager
  124956. */
  124957. removeActionManager(toRemove: AbstractActionManager): number;
  124958. /**
  124959. * Removes the given texture from this scene.
  124960. * @param toRemove The texture to remove
  124961. * @returns The index of the removed texture
  124962. */
  124963. removeTexture(toRemove: BaseTexture): number;
  124964. /**
  124965. * Adds the given light to this scene
  124966. * @param newLight The light to add
  124967. */
  124968. addLight(newLight: Light): void;
  124969. /**
  124970. * Sorts the list list based on light priorities
  124971. */
  124972. sortLightsByPriority(): void;
  124973. /**
  124974. * Adds the given camera to this scene
  124975. * @param newCamera The camera to add
  124976. */
  124977. addCamera(newCamera: Camera): void;
  124978. /**
  124979. * Adds the given skeleton to this scene
  124980. * @param newSkeleton The skeleton to add
  124981. */
  124982. addSkeleton(newSkeleton: Skeleton): void;
  124983. /**
  124984. * Adds the given particle system to this scene
  124985. * @param newParticleSystem The particle system to add
  124986. */
  124987. addParticleSystem(newParticleSystem: IParticleSystem): void;
  124988. /**
  124989. * Adds the given animation to this scene
  124990. * @param newAnimation The animation to add
  124991. */
  124992. addAnimation(newAnimation: Animation): void;
  124993. /**
  124994. * Adds the given animation group to this scene.
  124995. * @param newAnimationGroup The animation group to add
  124996. */
  124997. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  124998. /**
  124999. * Adds the given multi-material to this scene
  125000. * @param newMultiMaterial The multi-material to add
  125001. */
  125002. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  125003. /**
  125004. * Adds the given material to this scene
  125005. * @param newMaterial The material to add
  125006. */
  125007. addMaterial(newMaterial: Material): void;
  125008. /**
  125009. * Adds the given morph target to this scene
  125010. * @param newMorphTargetManager The morph target to add
  125011. */
  125012. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  125013. /**
  125014. * Adds the given geometry to this scene
  125015. * @param newGeometry The geometry to add
  125016. */
  125017. addGeometry(newGeometry: Geometry): void;
  125018. /**
  125019. * Adds the given action manager to this scene
  125020. * @param newActionManager The action manager to add
  125021. */
  125022. addActionManager(newActionManager: AbstractActionManager): void;
  125023. /**
  125024. * Adds the given texture to this scene.
  125025. * @param newTexture The texture to add
  125026. */
  125027. addTexture(newTexture: BaseTexture): void;
  125028. /**
  125029. * Switch active camera
  125030. * @param newCamera defines the new active camera
  125031. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  125032. */
  125033. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  125034. /**
  125035. * sets the active camera of the scene using its ID
  125036. * @param id defines the camera's ID
  125037. * @return the new active camera or null if none found.
  125038. */
  125039. setActiveCameraByID(id: string): Nullable<Camera>;
  125040. /**
  125041. * sets the active camera of the scene using its name
  125042. * @param name defines the camera's name
  125043. * @returns the new active camera or null if none found.
  125044. */
  125045. setActiveCameraByName(name: string): Nullable<Camera>;
  125046. /**
  125047. * get an animation group using its name
  125048. * @param name defines the material's name
  125049. * @return the animation group or null if none found.
  125050. */
  125051. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  125052. /**
  125053. * Get a material using its unique id
  125054. * @param uniqueId defines the material's unique id
  125055. * @return the material or null if none found.
  125056. */
  125057. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  125058. /**
  125059. * get a material using its id
  125060. * @param id defines the material's ID
  125061. * @return the material or null if none found.
  125062. */
  125063. getMaterialByID(id: string): Nullable<Material>;
  125064. /**
  125065. * Gets a the last added material using a given id
  125066. * @param id defines the material's ID
  125067. * @return the last material with the given id or null if none found.
  125068. */
  125069. getLastMaterialByID(id: string): Nullable<Material>;
  125070. /**
  125071. * Gets a material using its name
  125072. * @param name defines the material's name
  125073. * @return the material or null if none found.
  125074. */
  125075. getMaterialByName(name: string): Nullable<Material>;
  125076. /**
  125077. * Get a texture using its unique id
  125078. * @param uniqueId defines the texture's unique id
  125079. * @return the texture or null if none found.
  125080. */
  125081. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  125082. /**
  125083. * Gets a camera using its id
  125084. * @param id defines the id to look for
  125085. * @returns the camera or null if not found
  125086. */
  125087. getCameraByID(id: string): Nullable<Camera>;
  125088. /**
  125089. * Gets a camera using its unique id
  125090. * @param uniqueId defines the unique id to look for
  125091. * @returns the camera or null if not found
  125092. */
  125093. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  125094. /**
  125095. * Gets a camera using its name
  125096. * @param name defines the camera's name
  125097. * @return the camera or null if none found.
  125098. */
  125099. getCameraByName(name: string): Nullable<Camera>;
  125100. /**
  125101. * Gets a bone using its id
  125102. * @param id defines the bone's id
  125103. * @return the bone or null if not found
  125104. */
  125105. getBoneByID(id: string): Nullable<Bone>;
  125106. /**
  125107. * Gets a bone using its id
  125108. * @param name defines the bone's name
  125109. * @return the bone or null if not found
  125110. */
  125111. getBoneByName(name: string): Nullable<Bone>;
  125112. /**
  125113. * Gets a light node using its name
  125114. * @param name defines the the light's name
  125115. * @return the light or null if none found.
  125116. */
  125117. getLightByName(name: string): Nullable<Light>;
  125118. /**
  125119. * Gets a light node using its id
  125120. * @param id defines the light's id
  125121. * @return the light or null if none found.
  125122. */
  125123. getLightByID(id: string): Nullable<Light>;
  125124. /**
  125125. * Gets a light node using its scene-generated unique ID
  125126. * @param uniqueId defines the light's unique id
  125127. * @return the light or null if none found.
  125128. */
  125129. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  125130. /**
  125131. * Gets a particle system by id
  125132. * @param id defines the particle system id
  125133. * @return the corresponding system or null if none found
  125134. */
  125135. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  125136. /**
  125137. * Gets a geometry using its ID
  125138. * @param id defines the geometry's id
  125139. * @return the geometry or null if none found.
  125140. */
  125141. getGeometryByID(id: string): Nullable<Geometry>;
  125142. private _getGeometryByUniqueID;
  125143. /**
  125144. * Add a new geometry to this scene
  125145. * @param geometry defines the geometry to be added to the scene.
  125146. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  125147. * @return a boolean defining if the geometry was added or not
  125148. */
  125149. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  125150. /**
  125151. * Removes an existing geometry
  125152. * @param geometry defines the geometry to be removed from the scene
  125153. * @return a boolean defining if the geometry was removed or not
  125154. */
  125155. removeGeometry(geometry: Geometry): boolean;
  125156. /**
  125157. * Gets the list of geometries attached to the scene
  125158. * @returns an array of Geometry
  125159. */
  125160. getGeometries(): Geometry[];
  125161. /**
  125162. * Gets the first added mesh found of a given ID
  125163. * @param id defines the id to search for
  125164. * @return the mesh found or null if not found at all
  125165. */
  125166. getMeshByID(id: string): Nullable<AbstractMesh>;
  125167. /**
  125168. * Gets a list of meshes using their id
  125169. * @param id defines the id to search for
  125170. * @returns a list of meshes
  125171. */
  125172. getMeshesByID(id: string): Array<AbstractMesh>;
  125173. /**
  125174. * Gets the first added transform node found of a given ID
  125175. * @param id defines the id to search for
  125176. * @return the found transform node or null if not found at all.
  125177. */
  125178. getTransformNodeByID(id: string): Nullable<TransformNode>;
  125179. /**
  125180. * Gets a transform node with its auto-generated unique id
  125181. * @param uniqueId efines the unique id to search for
  125182. * @return the found transform node or null if not found at all.
  125183. */
  125184. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  125185. /**
  125186. * Gets a list of transform nodes using their id
  125187. * @param id defines the id to search for
  125188. * @returns a list of transform nodes
  125189. */
  125190. getTransformNodesByID(id: string): Array<TransformNode>;
  125191. /**
  125192. * Gets a mesh with its auto-generated unique id
  125193. * @param uniqueId defines the unique id to search for
  125194. * @return the found mesh or null if not found at all.
  125195. */
  125196. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  125197. /**
  125198. * Gets a the last added mesh using a given id
  125199. * @param id defines the id to search for
  125200. * @return the found mesh or null if not found at all.
  125201. */
  125202. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  125203. /**
  125204. * Gets a the last added node (Mesh, Camera, Light) using a given id
  125205. * @param id defines the id to search for
  125206. * @return the found node or null if not found at all
  125207. */
  125208. getLastEntryByID(id: string): Nullable<Node>;
  125209. /**
  125210. * Gets a node (Mesh, Camera, Light) using a given id
  125211. * @param id defines the id to search for
  125212. * @return the found node or null if not found at all
  125213. */
  125214. getNodeByID(id: string): Nullable<Node>;
  125215. /**
  125216. * Gets a node (Mesh, Camera, Light) using a given name
  125217. * @param name defines the name to search for
  125218. * @return the found node or null if not found at all.
  125219. */
  125220. getNodeByName(name: string): Nullable<Node>;
  125221. /**
  125222. * Gets a mesh using a given name
  125223. * @param name defines the name to search for
  125224. * @return the found mesh or null if not found at all.
  125225. */
  125226. getMeshByName(name: string): Nullable<AbstractMesh>;
  125227. /**
  125228. * Gets a transform node using a given name
  125229. * @param name defines the name to search for
  125230. * @return the found transform node or null if not found at all.
  125231. */
  125232. getTransformNodeByName(name: string): Nullable<TransformNode>;
  125233. /**
  125234. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  125235. * @param id defines the id to search for
  125236. * @return the found skeleton or null if not found at all.
  125237. */
  125238. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  125239. /**
  125240. * Gets a skeleton using a given auto generated unique id
  125241. * @param uniqueId defines the unique id to search for
  125242. * @return the found skeleton or null if not found at all.
  125243. */
  125244. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  125245. /**
  125246. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  125247. * @param id defines the id to search for
  125248. * @return the found skeleton or null if not found at all.
  125249. */
  125250. getSkeletonById(id: string): Nullable<Skeleton>;
  125251. /**
  125252. * Gets a skeleton using a given name
  125253. * @param name defines the name to search for
  125254. * @return the found skeleton or null if not found at all.
  125255. */
  125256. getSkeletonByName(name: string): Nullable<Skeleton>;
  125257. /**
  125258. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  125259. * @param id defines the id to search for
  125260. * @return the found morph target manager or null if not found at all.
  125261. */
  125262. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  125263. /**
  125264. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  125265. * @param id defines the id to search for
  125266. * @return the found morph target or null if not found at all.
  125267. */
  125268. getMorphTargetById(id: string): Nullable<MorphTarget>;
  125269. /**
  125270. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  125271. * @param name defines the name to search for
  125272. * @return the found morph target or null if not found at all.
  125273. */
  125274. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  125275. /**
  125276. * Gets a post process using a given name (if many are found, this function will pick the first one)
  125277. * @param name defines the name to search for
  125278. * @return the found post process or null if not found at all.
  125279. */
  125280. getPostProcessByName(name: string): Nullable<PostProcess>;
  125281. /**
  125282. * Gets a boolean indicating if the given mesh is active
  125283. * @param mesh defines the mesh to look for
  125284. * @returns true if the mesh is in the active list
  125285. */
  125286. isActiveMesh(mesh: AbstractMesh): boolean;
  125287. /**
  125288. * Return a unique id as a string which can serve as an identifier for the scene
  125289. */
  125290. get uid(): string;
  125291. /**
  125292. * Add an externaly attached data from its key.
  125293. * This method call will fail and return false, if such key already exists.
  125294. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  125295. * @param key the unique key that identifies the data
  125296. * @param data the data object to associate to the key for this Engine instance
  125297. * @return true if no such key were already present and the data was added successfully, false otherwise
  125298. */
  125299. addExternalData<T>(key: string, data: T): boolean;
  125300. /**
  125301. * Get an externaly attached data from its key
  125302. * @param key the unique key that identifies the data
  125303. * @return the associated data, if present (can be null), or undefined if not present
  125304. */
  125305. getExternalData<T>(key: string): Nullable<T>;
  125306. /**
  125307. * Get an externaly attached data from its key, create it using a factory if it's not already present
  125308. * @param key the unique key that identifies the data
  125309. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  125310. * @return the associated data, can be null if the factory returned null.
  125311. */
  125312. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  125313. /**
  125314. * Remove an externaly attached data from the Engine instance
  125315. * @param key the unique key that identifies the data
  125316. * @return true if the data was successfully removed, false if it doesn't exist
  125317. */
  125318. removeExternalData(key: string): boolean;
  125319. private _evaluateSubMesh;
  125320. /**
  125321. * Clear the processed materials smart array preventing retention point in material dispose.
  125322. */
  125323. freeProcessedMaterials(): void;
  125324. private _preventFreeActiveMeshesAndRenderingGroups;
  125325. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  125326. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  125327. * when disposing several meshes in a row or a hierarchy of meshes.
  125328. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  125329. */
  125330. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  125331. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  125332. /**
  125333. * Clear the active meshes smart array preventing retention point in mesh dispose.
  125334. */
  125335. freeActiveMeshes(): void;
  125336. /**
  125337. * Clear the info related to rendering groups preventing retention points during dispose.
  125338. */
  125339. freeRenderingGroups(): void;
  125340. /** @hidden */
  125341. _isInIntermediateRendering(): boolean;
  125342. /**
  125343. * Lambda returning the list of potentially active meshes.
  125344. */
  125345. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  125346. /**
  125347. * Lambda returning the list of potentially active sub meshes.
  125348. */
  125349. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  125350. /**
  125351. * Lambda returning the list of potentially intersecting sub meshes.
  125352. */
  125353. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  125354. /**
  125355. * Lambda returning the list of potentially colliding sub meshes.
  125356. */
  125357. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  125358. private _activeMeshesFrozen;
  125359. private _skipEvaluateActiveMeshesCompletely;
  125360. /**
  125361. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  125362. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  125363. * @param onSuccess optional success callback
  125364. * @param onError optional error callback
  125365. * @returns the current scene
  125366. */
  125367. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  125368. /**
  125369. * Use this function to restart evaluating active meshes on every frame
  125370. * @returns the current scene
  125371. */
  125372. unfreezeActiveMeshes(): Scene;
  125373. private _evaluateActiveMeshes;
  125374. private _activeMesh;
  125375. /**
  125376. * Update the transform matrix to update from the current active camera
  125377. * @param force defines a boolean used to force the update even if cache is up to date
  125378. */
  125379. updateTransformMatrix(force?: boolean): void;
  125380. private _bindFrameBuffer;
  125381. /** @hidden */
  125382. _allowPostProcessClearColor: boolean;
  125383. /** @hidden */
  125384. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  125385. private _processSubCameras;
  125386. private _checkIntersections;
  125387. /** @hidden */
  125388. _advancePhysicsEngineStep(step: number): void;
  125389. /**
  125390. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  125391. */
  125392. getDeterministicFrameTime: () => number;
  125393. /** @hidden */
  125394. _animate(): void;
  125395. /** Execute all animations (for a frame) */
  125396. animate(): void;
  125397. /**
  125398. * Render the scene
  125399. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  125400. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  125401. */
  125402. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  125403. /**
  125404. * Freeze all materials
  125405. * A frozen material will not be updatable but should be faster to render
  125406. */
  125407. freezeMaterials(): void;
  125408. /**
  125409. * Unfreeze all materials
  125410. * A frozen material will not be updatable but should be faster to render
  125411. */
  125412. unfreezeMaterials(): void;
  125413. /**
  125414. * Releases all held ressources
  125415. */
  125416. dispose(): void;
  125417. /**
  125418. * Gets if the scene is already disposed
  125419. */
  125420. get isDisposed(): boolean;
  125421. /**
  125422. * Call this function to reduce memory footprint of the scene.
  125423. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  125424. */
  125425. clearCachedVertexData(): void;
  125426. /**
  125427. * This function will remove the local cached buffer data from texture.
  125428. * It will save memory but will prevent the texture from being rebuilt
  125429. */
  125430. cleanCachedTextureBuffer(): void;
  125431. /**
  125432. * Get the world extend vectors with an optional filter
  125433. *
  125434. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  125435. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  125436. */
  125437. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  125438. min: Vector3;
  125439. max: Vector3;
  125440. };
  125441. /**
  125442. * Creates a ray that can be used to pick in the scene
  125443. * @param x defines the x coordinate of the origin (on-screen)
  125444. * @param y defines the y coordinate of the origin (on-screen)
  125445. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  125446. * @param camera defines the camera to use for the picking
  125447. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  125448. * @returns a Ray
  125449. */
  125450. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  125451. /**
  125452. * Creates a ray that can be used to pick in the scene
  125453. * @param x defines the x coordinate of the origin (on-screen)
  125454. * @param y defines the y coordinate of the origin (on-screen)
  125455. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  125456. * @param result defines the ray where to store the picking ray
  125457. * @param camera defines the camera to use for the picking
  125458. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  125459. * @returns the current scene
  125460. */
  125461. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  125462. /**
  125463. * Creates a ray that can be used to pick in the scene
  125464. * @param x defines the x coordinate of the origin (on-screen)
  125465. * @param y defines the y coordinate of the origin (on-screen)
  125466. * @param camera defines the camera to use for the picking
  125467. * @returns a Ray
  125468. */
  125469. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  125470. /**
  125471. * Creates a ray that can be used to pick in the scene
  125472. * @param x defines the x coordinate of the origin (on-screen)
  125473. * @param y defines the y coordinate of the origin (on-screen)
  125474. * @param result defines the ray where to store the picking ray
  125475. * @param camera defines the camera to use for the picking
  125476. * @returns the current scene
  125477. */
  125478. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  125479. /** Launch a ray to try to pick a mesh in the scene
  125480. * @param x position on screen
  125481. * @param y position on screen
  125482. * @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
  125483. * @param fastCheck defines if the first intersection will be used (and not the closest)
  125484. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  125485. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125486. * @returns a PickingInfo
  125487. */
  125488. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  125489. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  125490. * @param x position on screen
  125491. * @param y position on screen
  125492. * @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
  125493. * @param fastCheck defines if the first intersection will be used (and not the closest)
  125494. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  125495. * @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)
  125496. */
  125497. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  125498. /** Use the given ray to pick a mesh in the scene
  125499. * @param ray The ray to use to pick meshes
  125500. * @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
  125501. * @param fastCheck defines if the first intersection will be used (and not the closest)
  125502. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125503. * @returns a PickingInfo
  125504. */
  125505. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  125506. /**
  125507. * Launch a ray to try to pick a mesh in the scene
  125508. * @param x X position on screen
  125509. * @param y Y position on screen
  125510. * @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
  125511. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  125512. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125513. * @returns an array of PickingInfo
  125514. */
  125515. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  125516. /**
  125517. * Launch a ray to try to pick a mesh in the scene
  125518. * @param ray Ray to use
  125519. * @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
  125520. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125521. * @returns an array of PickingInfo
  125522. */
  125523. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  125524. /**
  125525. * Force the value of meshUnderPointer
  125526. * @param mesh defines the mesh to use
  125527. * @param pointerId optional pointer id when using more than one pointer
  125528. */
  125529. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  125530. /**
  125531. * Gets the mesh under the pointer
  125532. * @returns a Mesh or null if no mesh is under the pointer
  125533. */
  125534. getPointerOverMesh(): Nullable<AbstractMesh>;
  125535. /** @hidden */
  125536. _rebuildGeometries(): void;
  125537. /** @hidden */
  125538. _rebuildTextures(): void;
  125539. private _getByTags;
  125540. /**
  125541. * Get a list of meshes by tags
  125542. * @param tagsQuery defines the tags query to use
  125543. * @param forEach defines a predicate used to filter results
  125544. * @returns an array of Mesh
  125545. */
  125546. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  125547. /**
  125548. * Get a list of cameras by tags
  125549. * @param tagsQuery defines the tags query to use
  125550. * @param forEach defines a predicate used to filter results
  125551. * @returns an array of Camera
  125552. */
  125553. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  125554. /**
  125555. * Get a list of lights by tags
  125556. * @param tagsQuery defines the tags query to use
  125557. * @param forEach defines a predicate used to filter results
  125558. * @returns an array of Light
  125559. */
  125560. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  125561. /**
  125562. * Get a list of materials by tags
  125563. * @param tagsQuery defines the tags query to use
  125564. * @param forEach defines a predicate used to filter results
  125565. * @returns an array of Material
  125566. */
  125567. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  125568. /**
  125569. * Get a list of transform nodes by tags
  125570. * @param tagsQuery defines the tags query to use
  125571. * @param forEach defines a predicate used to filter results
  125572. * @returns an array of TransformNode
  125573. */
  125574. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  125575. /**
  125576. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  125577. * This allowed control for front to back rendering or reversly depending of the special needs.
  125578. *
  125579. * @param renderingGroupId The rendering group id corresponding to its index
  125580. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  125581. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  125582. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  125583. */
  125584. 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;
  125585. /**
  125586. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  125587. *
  125588. * @param renderingGroupId The rendering group id corresponding to its index
  125589. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  125590. * @param depth Automatically clears depth between groups if true and autoClear is true.
  125591. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  125592. */
  125593. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  125594. /**
  125595. * Gets the current auto clear configuration for one rendering group of the rendering
  125596. * manager.
  125597. * @param index the rendering group index to get the information for
  125598. * @returns The auto clear setup for the requested rendering group
  125599. */
  125600. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  125601. private _blockMaterialDirtyMechanism;
  125602. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  125603. get blockMaterialDirtyMechanism(): boolean;
  125604. set blockMaterialDirtyMechanism(value: boolean);
  125605. /**
  125606. * Will flag all materials as dirty to trigger new shader compilation
  125607. * @param flag defines the flag used to specify which material part must be marked as dirty
  125608. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  125609. */
  125610. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  125611. /** @hidden */
  125612. _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;
  125613. /** @hidden */
  125614. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  125615. /** @hidden */
  125616. _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;
  125617. /** @hidden */
  125618. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  125619. /** @hidden */
  125620. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  125621. /** @hidden */
  125622. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  125623. }
  125624. }
  125625. declare module BABYLON {
  125626. /**
  125627. * Set of assets to keep when moving a scene into an asset container.
  125628. */
  125629. export class KeepAssets extends AbstractScene {
  125630. }
  125631. /**
  125632. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  125633. */
  125634. export class InstantiatedEntries {
  125635. /**
  125636. * List of new root nodes (eg. nodes with no parent)
  125637. */
  125638. rootNodes: TransformNode[];
  125639. /**
  125640. * List of new skeletons
  125641. */
  125642. skeletons: Skeleton[];
  125643. /**
  125644. * List of new animation groups
  125645. */
  125646. animationGroups: AnimationGroup[];
  125647. }
  125648. /**
  125649. * Container with a set of assets that can be added or removed from a scene.
  125650. */
  125651. export class AssetContainer extends AbstractScene {
  125652. private _wasAddedToScene;
  125653. /**
  125654. * The scene the AssetContainer belongs to.
  125655. */
  125656. scene: Scene;
  125657. /**
  125658. * Instantiates an AssetContainer.
  125659. * @param scene The scene the AssetContainer belongs to.
  125660. */
  125661. constructor(scene: Scene);
  125662. /**
  125663. * Instantiate or clone all meshes and add the new ones to the scene.
  125664. * Skeletons and animation groups will all be cloned
  125665. * @param nameFunction defines an optional function used to get new names for clones
  125666. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  125667. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  125668. */
  125669. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  125670. /**
  125671. * Adds all the assets from the container to the scene.
  125672. */
  125673. addAllToScene(): void;
  125674. /**
  125675. * Removes all the assets in the container from the scene
  125676. */
  125677. removeAllFromScene(): void;
  125678. /**
  125679. * Disposes all the assets in the container
  125680. */
  125681. dispose(): void;
  125682. private _moveAssets;
  125683. /**
  125684. * Removes all the assets contained in the scene and adds them to the container.
  125685. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  125686. */
  125687. moveAllFromScene(keepAssets?: KeepAssets): void;
  125688. /**
  125689. * 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.
  125690. * @returns the root mesh
  125691. */
  125692. createRootMesh(): Mesh;
  125693. /**
  125694. * Merge animations (direct and animation groups) from this asset container into a scene
  125695. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125696. * @param animatables set of animatables to retarget to a node from the scene
  125697. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  125698. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  125699. */
  125700. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  125701. }
  125702. }
  125703. declare module BABYLON {
  125704. /**
  125705. * Defines how the parser contract is defined.
  125706. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  125707. */
  125708. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  125709. /**
  125710. * Defines how the individual parser contract is defined.
  125711. * These parser can parse an individual asset
  125712. */
  125713. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  125714. /**
  125715. * Base class of the scene acting as a container for the different elements composing a scene.
  125716. * This class is dynamically extended by the different components of the scene increasing
  125717. * flexibility and reducing coupling
  125718. */
  125719. export abstract class AbstractScene {
  125720. /**
  125721. * Stores the list of available parsers in the application.
  125722. */
  125723. private static _BabylonFileParsers;
  125724. /**
  125725. * Stores the list of available individual parsers in the application.
  125726. */
  125727. private static _IndividualBabylonFileParsers;
  125728. /**
  125729. * Adds a parser in the list of available ones
  125730. * @param name Defines the name of the parser
  125731. * @param parser Defines the parser to add
  125732. */
  125733. static AddParser(name: string, parser: BabylonFileParser): void;
  125734. /**
  125735. * Gets a general parser from the list of avaialble ones
  125736. * @param name Defines the name of the parser
  125737. * @returns the requested parser or null
  125738. */
  125739. static GetParser(name: string): Nullable<BabylonFileParser>;
  125740. /**
  125741. * Adds n individual parser in the list of available ones
  125742. * @param name Defines the name of the parser
  125743. * @param parser Defines the parser to add
  125744. */
  125745. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  125746. /**
  125747. * Gets an individual parser from the list of avaialble ones
  125748. * @param name Defines the name of the parser
  125749. * @returns the requested parser or null
  125750. */
  125751. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  125752. /**
  125753. * Parser json data and populate both a scene and its associated container object
  125754. * @param jsonData Defines the data to parse
  125755. * @param scene Defines the scene to parse the data for
  125756. * @param container Defines the container attached to the parsing sequence
  125757. * @param rootUrl Defines the root url of the data
  125758. */
  125759. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  125760. /**
  125761. * Gets the list of root nodes (ie. nodes with no parent)
  125762. */
  125763. rootNodes: Node[];
  125764. /** All of the cameras added to this scene
  125765. * @see https://doc.babylonjs.com/babylon101/cameras
  125766. */
  125767. cameras: Camera[];
  125768. /**
  125769. * All of the lights added to this scene
  125770. * @see https://doc.babylonjs.com/babylon101/lights
  125771. */
  125772. lights: Light[];
  125773. /**
  125774. * All of the (abstract) meshes added to this scene
  125775. */
  125776. meshes: AbstractMesh[];
  125777. /**
  125778. * The list of skeletons added to the scene
  125779. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  125780. */
  125781. skeletons: Skeleton[];
  125782. /**
  125783. * All of the particle systems added to this scene
  125784. * @see https://doc.babylonjs.com/babylon101/particles
  125785. */
  125786. particleSystems: IParticleSystem[];
  125787. /**
  125788. * Gets a list of Animations associated with the scene
  125789. */
  125790. animations: Animation[];
  125791. /**
  125792. * All of the animation groups added to this scene
  125793. * @see https://doc.babylonjs.com/how_to/group
  125794. */
  125795. animationGroups: AnimationGroup[];
  125796. /**
  125797. * All of the multi-materials added to this scene
  125798. * @see https://doc.babylonjs.com/how_to/multi_materials
  125799. */
  125800. multiMaterials: MultiMaterial[];
  125801. /**
  125802. * All of the materials added to this scene
  125803. * In the context of a Scene, it is not supposed to be modified manually.
  125804. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  125805. * Note also that the order of the Material within the array is not significant and might change.
  125806. * @see https://doc.babylonjs.com/babylon101/materials
  125807. */
  125808. materials: Material[];
  125809. /**
  125810. * The list of morph target managers added to the scene
  125811. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  125812. */
  125813. morphTargetManagers: MorphTargetManager[];
  125814. /**
  125815. * The list of geometries used in the scene.
  125816. */
  125817. geometries: Geometry[];
  125818. /**
  125819. * All of the tranform nodes added to this scene
  125820. * In the context of a Scene, it is not supposed to be modified manually.
  125821. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  125822. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  125823. * @see https://doc.babylonjs.com/how_to/transformnode
  125824. */
  125825. transformNodes: TransformNode[];
  125826. /**
  125827. * ActionManagers available on the scene.
  125828. */
  125829. actionManagers: AbstractActionManager[];
  125830. /**
  125831. * Textures to keep.
  125832. */
  125833. textures: BaseTexture[];
  125834. /** @hidden */
  125835. protected _environmentTexture: Nullable<BaseTexture>;
  125836. /**
  125837. * Texture used in all pbr material as the reflection texture.
  125838. * As in the majority of the scene they are the same (exception for multi room and so on),
  125839. * this is easier to reference from here than from all the materials.
  125840. */
  125841. get environmentTexture(): Nullable<BaseTexture>;
  125842. set environmentTexture(value: Nullable<BaseTexture>);
  125843. /**
  125844. * The list of postprocesses added to the scene
  125845. */
  125846. postProcesses: PostProcess[];
  125847. /**
  125848. * @returns all meshes, lights, cameras, transformNodes and bones
  125849. */
  125850. getNodes(): Array<Node>;
  125851. }
  125852. }
  125853. declare module BABYLON {
  125854. /**
  125855. * Interface used to define options for Sound class
  125856. */
  125857. export interface ISoundOptions {
  125858. /**
  125859. * Does the sound autoplay once loaded.
  125860. */
  125861. autoplay?: boolean;
  125862. /**
  125863. * Does the sound loop after it finishes playing once.
  125864. */
  125865. loop?: boolean;
  125866. /**
  125867. * Sound's volume
  125868. */
  125869. volume?: number;
  125870. /**
  125871. * Is it a spatial sound?
  125872. */
  125873. spatialSound?: boolean;
  125874. /**
  125875. * Maximum distance to hear that sound
  125876. */
  125877. maxDistance?: number;
  125878. /**
  125879. * Uses user defined attenuation function
  125880. */
  125881. useCustomAttenuation?: boolean;
  125882. /**
  125883. * Define the roll off factor of spatial sounds.
  125884. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125885. */
  125886. rolloffFactor?: number;
  125887. /**
  125888. * Define the reference distance the sound should be heard perfectly.
  125889. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125890. */
  125891. refDistance?: number;
  125892. /**
  125893. * Define the distance attenuation model the sound will follow.
  125894. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125895. */
  125896. distanceModel?: string;
  125897. /**
  125898. * Defines the playback speed (1 by default)
  125899. */
  125900. playbackRate?: number;
  125901. /**
  125902. * Defines if the sound is from a streaming source
  125903. */
  125904. streaming?: boolean;
  125905. /**
  125906. * Defines an optional length (in seconds) inside the sound file
  125907. */
  125908. length?: number;
  125909. /**
  125910. * Defines an optional offset (in seconds) inside the sound file
  125911. */
  125912. offset?: number;
  125913. /**
  125914. * If true, URLs will not be required to state the audio file codec to use.
  125915. */
  125916. skipCodecCheck?: boolean;
  125917. }
  125918. }
  125919. declare module BABYLON {
  125920. /**
  125921. * Defines a sound that can be played in the application.
  125922. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  125923. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125924. */
  125925. export class Sound {
  125926. /**
  125927. * The name of the sound in the scene.
  125928. */
  125929. name: string;
  125930. /**
  125931. * Does the sound autoplay once loaded.
  125932. */
  125933. autoplay: boolean;
  125934. /**
  125935. * Does the sound loop after it finishes playing once.
  125936. */
  125937. loop: boolean;
  125938. /**
  125939. * Does the sound use a custom attenuation curve to simulate the falloff
  125940. * happening when the source gets further away from the camera.
  125941. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125942. */
  125943. useCustomAttenuation: boolean;
  125944. /**
  125945. * The sound track id this sound belongs to.
  125946. */
  125947. soundTrackId: number;
  125948. /**
  125949. * Is this sound currently played.
  125950. */
  125951. isPlaying: boolean;
  125952. /**
  125953. * Is this sound currently paused.
  125954. */
  125955. isPaused: boolean;
  125956. /**
  125957. * Does this sound enables spatial sound.
  125958. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125959. */
  125960. spatialSound: boolean;
  125961. /**
  125962. * Define the reference distance the sound should be heard perfectly.
  125963. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125964. */
  125965. refDistance: number;
  125966. /**
  125967. * Define the roll off factor of spatial sounds.
  125968. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125969. */
  125970. rolloffFactor: number;
  125971. /**
  125972. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  125973. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125974. */
  125975. maxDistance: number;
  125976. /**
  125977. * Define the distance attenuation model the sound will follow.
  125978. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125979. */
  125980. distanceModel: string;
  125981. /**
  125982. * @hidden
  125983. * Back Compat
  125984. **/
  125985. onended: () => any;
  125986. /**
  125987. * Gets or sets an object used to store user defined information for the sound.
  125988. */
  125989. metadata: any;
  125990. /**
  125991. * Observable event when the current playing sound finishes.
  125992. */
  125993. onEndedObservable: Observable<Sound>;
  125994. /**
  125995. * Gets the current time for the sound.
  125996. */
  125997. get currentTime(): number;
  125998. private _panningModel;
  125999. private _playbackRate;
  126000. private _streaming;
  126001. private _startTime;
  126002. private _startOffset;
  126003. private _position;
  126004. /** @hidden */
  126005. _positionInEmitterSpace: boolean;
  126006. private _localDirection;
  126007. private _volume;
  126008. private _isReadyToPlay;
  126009. private _isDirectional;
  126010. private _readyToPlayCallback;
  126011. private _audioBuffer;
  126012. private _soundSource;
  126013. private _streamingSource;
  126014. private _soundPanner;
  126015. private _soundGain;
  126016. private _inputAudioNode;
  126017. private _outputAudioNode;
  126018. private _coneInnerAngle;
  126019. private _coneOuterAngle;
  126020. private _coneOuterGain;
  126021. private _scene;
  126022. private _connectedTransformNode;
  126023. private _customAttenuationFunction;
  126024. private _registerFunc;
  126025. private _isOutputConnected;
  126026. private _htmlAudioElement;
  126027. private _urlType;
  126028. private _length?;
  126029. private _offset?;
  126030. /** @hidden */
  126031. static _SceneComponentInitialization: (scene: Scene) => void;
  126032. /**
  126033. * Create a sound and attach it to a scene
  126034. * @param name Name of your sound
  126035. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  126036. * @param scene defines the scene the sound belongs to
  126037. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  126038. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  126039. */
  126040. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  126041. /**
  126042. * Release the sound and its associated resources
  126043. */
  126044. dispose(): void;
  126045. /**
  126046. * Gets if the sounds is ready to be played or not.
  126047. * @returns true if ready, otherwise false
  126048. */
  126049. isReady(): boolean;
  126050. private _soundLoaded;
  126051. /**
  126052. * Sets the data of the sound from an audiobuffer
  126053. * @param audioBuffer The audioBuffer containing the data
  126054. */
  126055. setAudioBuffer(audioBuffer: AudioBuffer): void;
  126056. /**
  126057. * Updates the current sounds options such as maxdistance, loop...
  126058. * @param options A JSON object containing values named as the object properties
  126059. */
  126060. updateOptions(options: ISoundOptions): void;
  126061. private _createSpatialParameters;
  126062. private _updateSpatialParameters;
  126063. /**
  126064. * Switch the panning model to HRTF:
  126065. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  126066. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126067. */
  126068. switchPanningModelToHRTF(): void;
  126069. /**
  126070. * Switch the panning model to Equal Power:
  126071. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  126072. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126073. */
  126074. switchPanningModelToEqualPower(): void;
  126075. private _switchPanningModel;
  126076. /**
  126077. * Connect this sound to a sound track audio node like gain...
  126078. * @param soundTrackAudioNode the sound track audio node to connect to
  126079. */
  126080. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  126081. /**
  126082. * Transform this sound into a directional source
  126083. * @param coneInnerAngle Size of the inner cone in degree
  126084. * @param coneOuterAngle Size of the outer cone in degree
  126085. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  126086. */
  126087. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  126088. /**
  126089. * Gets or sets the inner angle for the directional cone.
  126090. */
  126091. get directionalConeInnerAngle(): number;
  126092. /**
  126093. * Gets or sets the inner angle for the directional cone.
  126094. */
  126095. set directionalConeInnerAngle(value: number);
  126096. /**
  126097. * Gets or sets the outer angle for the directional cone.
  126098. */
  126099. get directionalConeOuterAngle(): number;
  126100. /**
  126101. * Gets or sets the outer angle for the directional cone.
  126102. */
  126103. set directionalConeOuterAngle(value: number);
  126104. /**
  126105. * Sets the position of the emitter if spatial sound is enabled
  126106. * @param newPosition Defines the new posisiton
  126107. */
  126108. setPosition(newPosition: Vector3): void;
  126109. /**
  126110. * Sets the local direction of the emitter if spatial sound is enabled
  126111. * @param newLocalDirection Defines the new local direction
  126112. */
  126113. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  126114. private _updateDirection;
  126115. /** @hidden */
  126116. updateDistanceFromListener(): void;
  126117. /**
  126118. * Sets a new custom attenuation function for the sound.
  126119. * @param callback Defines the function used for the attenuation
  126120. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126121. */
  126122. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  126123. /**
  126124. * Play the sound
  126125. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  126126. * @param offset (optional) Start the sound at a specific time in seconds
  126127. * @param length (optional) Sound duration (in seconds)
  126128. */
  126129. play(time?: number, offset?: number, length?: number): void;
  126130. private _onended;
  126131. /**
  126132. * Stop the sound
  126133. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  126134. */
  126135. stop(time?: number): void;
  126136. /**
  126137. * Put the sound in pause
  126138. */
  126139. pause(): void;
  126140. /**
  126141. * Sets a dedicated volume for this sounds
  126142. * @param newVolume Define the new volume of the sound
  126143. * @param time Define time for gradual change to new volume
  126144. */
  126145. setVolume(newVolume: number, time?: number): void;
  126146. /**
  126147. * Set the sound play back rate
  126148. * @param newPlaybackRate Define the playback rate the sound should be played at
  126149. */
  126150. setPlaybackRate(newPlaybackRate: number): void;
  126151. /**
  126152. * Gets the volume of the sound.
  126153. * @returns the volume of the sound
  126154. */
  126155. getVolume(): number;
  126156. /**
  126157. * Attach the sound to a dedicated mesh
  126158. * @param transformNode The transform node to connect the sound with
  126159. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126160. */
  126161. attachToMesh(transformNode: TransformNode): void;
  126162. /**
  126163. * Detach the sound from the previously attached mesh
  126164. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126165. */
  126166. detachFromMesh(): void;
  126167. private _onRegisterAfterWorldMatrixUpdate;
  126168. /**
  126169. * Clone the current sound in the scene.
  126170. * @returns the new sound clone
  126171. */
  126172. clone(): Nullable<Sound>;
  126173. /**
  126174. * Gets the current underlying audio buffer containing the data
  126175. * @returns the audio buffer
  126176. */
  126177. getAudioBuffer(): Nullable<AudioBuffer>;
  126178. /**
  126179. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  126180. * @returns the source node
  126181. */
  126182. getSoundSource(): Nullable<AudioBufferSourceNode>;
  126183. /**
  126184. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  126185. * @returns the gain node
  126186. */
  126187. getSoundGain(): Nullable<GainNode>;
  126188. /**
  126189. * Serializes the Sound in a JSON representation
  126190. * @returns the JSON representation of the sound
  126191. */
  126192. serialize(): any;
  126193. /**
  126194. * Parse a JSON representation of a sound to innstantiate in a given scene
  126195. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  126196. * @param scene Define the scene the new parsed sound should be created in
  126197. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  126198. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  126199. * @returns the newly parsed sound
  126200. */
  126201. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  126202. }
  126203. }
  126204. declare module BABYLON {
  126205. /**
  126206. * This defines an action helpful to play a defined sound on a triggered action.
  126207. */
  126208. export class PlaySoundAction extends Action {
  126209. private _sound;
  126210. /**
  126211. * Instantiate the action
  126212. * @param triggerOptions defines the trigger options
  126213. * @param sound defines the sound to play
  126214. * @param condition defines the trigger related conditions
  126215. */
  126216. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  126217. /** @hidden */
  126218. _prepare(): void;
  126219. /**
  126220. * Execute the action and play the sound.
  126221. */
  126222. execute(): void;
  126223. /**
  126224. * Serializes the actions and its related information.
  126225. * @param parent defines the object to serialize in
  126226. * @returns the serialized object
  126227. */
  126228. serialize(parent: any): any;
  126229. }
  126230. /**
  126231. * This defines an action helpful to stop a defined sound on a triggered action.
  126232. */
  126233. export class StopSoundAction extends Action {
  126234. private _sound;
  126235. /**
  126236. * Instantiate the action
  126237. * @param triggerOptions defines the trigger options
  126238. * @param sound defines the sound to stop
  126239. * @param condition defines the trigger related conditions
  126240. */
  126241. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  126242. /** @hidden */
  126243. _prepare(): void;
  126244. /**
  126245. * Execute the action and stop the sound.
  126246. */
  126247. execute(): void;
  126248. /**
  126249. * Serializes the actions and its related information.
  126250. * @param parent defines the object to serialize in
  126251. * @returns the serialized object
  126252. */
  126253. serialize(parent: any): any;
  126254. }
  126255. }
  126256. declare module BABYLON {
  126257. /**
  126258. * This defines an action responsible to change the value of a property
  126259. * by interpolating between its current value and the newly set one once triggered.
  126260. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  126261. */
  126262. export class InterpolateValueAction extends Action {
  126263. /**
  126264. * Defines the path of the property where the value should be interpolated
  126265. */
  126266. propertyPath: string;
  126267. /**
  126268. * Defines the target value at the end of the interpolation.
  126269. */
  126270. value: any;
  126271. /**
  126272. * Defines the time it will take for the property to interpolate to the value.
  126273. */
  126274. duration: number;
  126275. /**
  126276. * Defines if the other scene animations should be stopped when the action has been triggered
  126277. */
  126278. stopOtherAnimations?: boolean;
  126279. /**
  126280. * Defines a callback raised once the interpolation animation has been done.
  126281. */
  126282. onInterpolationDone?: () => void;
  126283. /**
  126284. * Observable triggered once the interpolation animation has been done.
  126285. */
  126286. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  126287. private _target;
  126288. private _effectiveTarget;
  126289. private _property;
  126290. /**
  126291. * Instantiate the action
  126292. * @param triggerOptions defines the trigger options
  126293. * @param target defines the object containing the value to interpolate
  126294. * @param propertyPath defines the path to the property in the target object
  126295. * @param value defines the target value at the end of the interpolation
  126296. * @param duration deines the time it will take for the property to interpolate to the value.
  126297. * @param condition defines the trigger related conditions
  126298. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  126299. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  126300. */
  126301. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  126302. /** @hidden */
  126303. _prepare(): void;
  126304. /**
  126305. * Execute the action starts the value interpolation.
  126306. */
  126307. execute(): void;
  126308. /**
  126309. * Serializes the actions and its related information.
  126310. * @param parent defines the object to serialize in
  126311. * @returns the serialized object
  126312. */
  126313. serialize(parent: any): any;
  126314. }
  126315. }
  126316. declare module BABYLON {
  126317. /**
  126318. * This represents the default audio engine used in babylon.
  126319. * It is responsible to play, synchronize and analyse sounds throughout the application.
  126320. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126321. */
  126322. export class AudioEngine implements IAudioEngine {
  126323. private _audioContext;
  126324. private _audioContextInitialized;
  126325. private _muteButton;
  126326. private _hostElement;
  126327. /**
  126328. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  126329. */
  126330. canUseWebAudio: boolean;
  126331. /**
  126332. * The master gain node defines the global audio volume of your audio engine.
  126333. */
  126334. masterGain: GainNode;
  126335. /**
  126336. * Defines if Babylon should emit a warning if WebAudio is not supported.
  126337. * @ignoreNaming
  126338. */
  126339. WarnedWebAudioUnsupported: boolean;
  126340. /**
  126341. * Gets whether or not mp3 are supported by your browser.
  126342. */
  126343. isMP3supported: boolean;
  126344. /**
  126345. * Gets whether or not ogg are supported by your browser.
  126346. */
  126347. isOGGsupported: boolean;
  126348. /**
  126349. * Gets whether audio has been unlocked on the device.
  126350. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  126351. * a user interaction has happened.
  126352. */
  126353. unlocked: boolean;
  126354. /**
  126355. * Defines if the audio engine relies on a custom unlocked button.
  126356. * In this case, the embedded button will not be displayed.
  126357. */
  126358. useCustomUnlockedButton: boolean;
  126359. /**
  126360. * Event raised when audio has been unlocked on the browser.
  126361. */
  126362. onAudioUnlockedObservable: Observable<IAudioEngine>;
  126363. /**
  126364. * Event raised when audio has been locked on the browser.
  126365. */
  126366. onAudioLockedObservable: Observable<IAudioEngine>;
  126367. /**
  126368. * Gets the current AudioContext if available.
  126369. */
  126370. get audioContext(): Nullable<AudioContext>;
  126371. private _connectedAnalyser;
  126372. /**
  126373. * Instantiates a new audio engine.
  126374. *
  126375. * There should be only one per page as some browsers restrict the number
  126376. * of audio contexts you can create.
  126377. * @param hostElement defines the host element where to display the mute icon if necessary
  126378. */
  126379. constructor(hostElement?: Nullable<HTMLElement>);
  126380. /**
  126381. * Flags the audio engine in Locked state.
  126382. * This happens due to new browser policies preventing audio to autoplay.
  126383. */
  126384. lock(): void;
  126385. /**
  126386. * Unlocks the audio engine once a user action has been done on the dom.
  126387. * This is helpful to resume play once browser policies have been satisfied.
  126388. */
  126389. unlock(): void;
  126390. private _resumeAudioContext;
  126391. private _initializeAudioContext;
  126392. private _tryToRun;
  126393. private _triggerRunningState;
  126394. private _triggerSuspendedState;
  126395. private _displayMuteButton;
  126396. private _moveButtonToTopLeft;
  126397. private _onResize;
  126398. private _hideMuteButton;
  126399. /**
  126400. * Destroy and release the resources associated with the audio ccontext.
  126401. */
  126402. dispose(): void;
  126403. /**
  126404. * Gets the global volume sets on the master gain.
  126405. * @returns the global volume if set or -1 otherwise
  126406. */
  126407. getGlobalVolume(): number;
  126408. /**
  126409. * Sets the global volume of your experience (sets on the master gain).
  126410. * @param newVolume Defines the new global volume of the application
  126411. */
  126412. setGlobalVolume(newVolume: number): void;
  126413. /**
  126414. * Connect the audio engine to an audio analyser allowing some amazing
  126415. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  126416. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  126417. * @param analyser The analyser to connect to the engine
  126418. */
  126419. connectToAnalyser(analyser: Analyser): void;
  126420. }
  126421. }
  126422. declare module BABYLON {
  126423. /**
  126424. * Options allowed during the creation of a sound track.
  126425. */
  126426. export interface ISoundTrackOptions {
  126427. /**
  126428. * The volume the sound track should take during creation
  126429. */
  126430. volume?: number;
  126431. /**
  126432. * Define if the sound track is the main sound track of the scene
  126433. */
  126434. mainTrack?: boolean;
  126435. }
  126436. /**
  126437. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  126438. * It will be also used in a future release to apply effects on a specific track.
  126439. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  126440. */
  126441. export class SoundTrack {
  126442. /**
  126443. * The unique identifier of the sound track in the scene.
  126444. */
  126445. id: number;
  126446. /**
  126447. * The list of sounds included in the sound track.
  126448. */
  126449. soundCollection: Array<Sound>;
  126450. private _outputAudioNode;
  126451. private _scene;
  126452. private _connectedAnalyser;
  126453. private _options;
  126454. private _isInitialized;
  126455. /**
  126456. * Creates a new sound track.
  126457. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  126458. * @param scene Define the scene the sound track belongs to
  126459. * @param options
  126460. */
  126461. constructor(scene: Scene, options?: ISoundTrackOptions);
  126462. private _initializeSoundTrackAudioGraph;
  126463. /**
  126464. * Release the sound track and its associated resources
  126465. */
  126466. dispose(): void;
  126467. /**
  126468. * Adds a sound to this sound track
  126469. * @param sound define the cound to add
  126470. * @ignoreNaming
  126471. */
  126472. addSound(sound: Sound): void;
  126473. /**
  126474. * Removes a sound to this sound track
  126475. * @param sound define the cound to remove
  126476. * @ignoreNaming
  126477. */
  126478. removeSound(sound: Sound): void;
  126479. /**
  126480. * Set a global volume for the full sound track.
  126481. * @param newVolume Define the new volume of the sound track
  126482. */
  126483. setVolume(newVolume: number): void;
  126484. /**
  126485. * Switch the panning model to HRTF:
  126486. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  126487. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126488. */
  126489. switchPanningModelToHRTF(): void;
  126490. /**
  126491. * Switch the panning model to Equal Power:
  126492. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  126493. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126494. */
  126495. switchPanningModelToEqualPower(): void;
  126496. /**
  126497. * Connect the sound track to an audio analyser allowing some amazing
  126498. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  126499. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  126500. * @param analyser The analyser to connect to the engine
  126501. */
  126502. connectToAnalyser(analyser: Analyser): void;
  126503. }
  126504. }
  126505. declare module BABYLON {
  126506. interface AbstractScene {
  126507. /**
  126508. * The list of sounds used in the scene.
  126509. */
  126510. sounds: Nullable<Array<Sound>>;
  126511. }
  126512. interface Scene {
  126513. /**
  126514. * @hidden
  126515. * Backing field
  126516. */
  126517. _mainSoundTrack: SoundTrack;
  126518. /**
  126519. * The main sound track played by the scene.
  126520. * It cotains your primary collection of sounds.
  126521. */
  126522. mainSoundTrack: SoundTrack;
  126523. /**
  126524. * The list of sound tracks added to the scene
  126525. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126526. */
  126527. soundTracks: Nullable<Array<SoundTrack>>;
  126528. /**
  126529. * Gets a sound using a given name
  126530. * @param name defines the name to search for
  126531. * @return the found sound or null if not found at all.
  126532. */
  126533. getSoundByName(name: string): Nullable<Sound>;
  126534. /**
  126535. * Gets or sets if audio support is enabled
  126536. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126537. */
  126538. audioEnabled: boolean;
  126539. /**
  126540. * Gets or sets if audio will be output to headphones
  126541. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126542. */
  126543. headphone: boolean;
  126544. /**
  126545. * Gets or sets custom audio listener position provider
  126546. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126547. */
  126548. audioListenerPositionProvider: Nullable<() => Vector3>;
  126549. /**
  126550. * Gets or sets a refresh rate when using 3D audio positioning
  126551. */
  126552. audioPositioningRefreshRate: number;
  126553. }
  126554. /**
  126555. * Defines the sound scene component responsible to manage any sounds
  126556. * in a given scene.
  126557. */
  126558. export class AudioSceneComponent implements ISceneSerializableComponent {
  126559. private static _CameraDirectionLH;
  126560. private static _CameraDirectionRH;
  126561. /**
  126562. * The component name helpfull to identify the component in the list of scene components.
  126563. */
  126564. readonly name: string;
  126565. /**
  126566. * The scene the component belongs to.
  126567. */
  126568. scene: Scene;
  126569. private _audioEnabled;
  126570. /**
  126571. * Gets whether audio is enabled or not.
  126572. * Please use related enable/disable method to switch state.
  126573. */
  126574. get audioEnabled(): boolean;
  126575. private _headphone;
  126576. /**
  126577. * Gets whether audio is outputing to headphone or not.
  126578. * Please use the according Switch methods to change output.
  126579. */
  126580. get headphone(): boolean;
  126581. /**
  126582. * Gets or sets a refresh rate when using 3D audio positioning
  126583. */
  126584. audioPositioningRefreshRate: number;
  126585. private _audioListenerPositionProvider;
  126586. /**
  126587. * Gets the current audio listener position provider
  126588. */
  126589. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  126590. /**
  126591. * Sets a custom listener position for all sounds in the scene
  126592. * By default, this is the position of the first active camera
  126593. */
  126594. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  126595. /**
  126596. * Creates a new instance of the component for the given scene
  126597. * @param scene Defines the scene to register the component in
  126598. */
  126599. constructor(scene: Scene);
  126600. /**
  126601. * Registers the component in a given scene
  126602. */
  126603. register(): void;
  126604. /**
  126605. * Rebuilds the elements related to this component in case of
  126606. * context lost for instance.
  126607. */
  126608. rebuild(): void;
  126609. /**
  126610. * Serializes the component data to the specified json object
  126611. * @param serializationObject The object to serialize to
  126612. */
  126613. serialize(serializationObject: any): void;
  126614. /**
  126615. * Adds all the elements from the container to the scene
  126616. * @param container the container holding the elements
  126617. */
  126618. addFromContainer(container: AbstractScene): void;
  126619. /**
  126620. * Removes all the elements in the container from the scene
  126621. * @param container contains the elements to remove
  126622. * @param dispose if the removed element should be disposed (default: false)
  126623. */
  126624. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126625. /**
  126626. * Disposes the component and the associated ressources.
  126627. */
  126628. dispose(): void;
  126629. /**
  126630. * Disables audio in the associated scene.
  126631. */
  126632. disableAudio(): void;
  126633. /**
  126634. * Enables audio in the associated scene.
  126635. */
  126636. enableAudio(): void;
  126637. /**
  126638. * Switch audio to headphone output.
  126639. */
  126640. switchAudioModeForHeadphones(): void;
  126641. /**
  126642. * Switch audio to normal speakers.
  126643. */
  126644. switchAudioModeForNormalSpeakers(): void;
  126645. private _cachedCameraDirection;
  126646. private _cachedCameraPosition;
  126647. private _lastCheck;
  126648. private _afterRender;
  126649. }
  126650. }
  126651. declare module BABYLON {
  126652. /**
  126653. * Wraps one or more Sound objects and selects one with random weight for playback.
  126654. */
  126655. export class WeightedSound {
  126656. /** When true a Sound will be selected and played when the current playing Sound completes. */
  126657. loop: boolean;
  126658. private _coneInnerAngle;
  126659. private _coneOuterAngle;
  126660. private _volume;
  126661. /** A Sound is currently playing. */
  126662. isPlaying: boolean;
  126663. /** A Sound is currently paused. */
  126664. isPaused: boolean;
  126665. private _sounds;
  126666. private _weights;
  126667. private _currentIndex?;
  126668. /**
  126669. * Creates a new WeightedSound from the list of sounds given.
  126670. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  126671. * @param sounds Array of Sounds that will be selected from.
  126672. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  126673. */
  126674. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  126675. /**
  126676. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  126677. */
  126678. get directionalConeInnerAngle(): number;
  126679. /**
  126680. * The size of cone in degress for a directional sound in which there will be no attenuation.
  126681. */
  126682. set directionalConeInnerAngle(value: number);
  126683. /**
  126684. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  126685. * Listener angles between innerAngle and outerAngle will falloff linearly.
  126686. */
  126687. get directionalConeOuterAngle(): number;
  126688. /**
  126689. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  126690. * Listener angles between innerAngle and outerAngle will falloff linearly.
  126691. */
  126692. set directionalConeOuterAngle(value: number);
  126693. /**
  126694. * Playback volume.
  126695. */
  126696. get volume(): number;
  126697. /**
  126698. * Playback volume.
  126699. */
  126700. set volume(value: number);
  126701. private _onended;
  126702. /**
  126703. * Suspend playback
  126704. */
  126705. pause(): void;
  126706. /**
  126707. * Stop playback
  126708. */
  126709. stop(): void;
  126710. /**
  126711. * Start playback.
  126712. * @param startOffset Position the clip head at a specific time in seconds.
  126713. */
  126714. play(startOffset?: number): void;
  126715. }
  126716. }
  126717. declare module BABYLON {
  126718. /**
  126719. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  126720. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126721. */
  126722. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  126723. /**
  126724. * Gets the name of the behavior.
  126725. */
  126726. get name(): string;
  126727. /**
  126728. * The easing function used by animations
  126729. */
  126730. static EasingFunction: BackEase;
  126731. /**
  126732. * The easing mode used by animations
  126733. */
  126734. static EasingMode: number;
  126735. /**
  126736. * The duration of the animation, in milliseconds
  126737. */
  126738. transitionDuration: number;
  126739. /**
  126740. * Length of the distance animated by the transition when lower radius is reached
  126741. */
  126742. lowerRadiusTransitionRange: number;
  126743. /**
  126744. * Length of the distance animated by the transition when upper radius is reached
  126745. */
  126746. upperRadiusTransitionRange: number;
  126747. private _autoTransitionRange;
  126748. /**
  126749. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  126750. */
  126751. get autoTransitionRange(): boolean;
  126752. /**
  126753. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  126754. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  126755. */
  126756. set autoTransitionRange(value: boolean);
  126757. private _attachedCamera;
  126758. private _onAfterCheckInputsObserver;
  126759. private _onMeshTargetChangedObserver;
  126760. /**
  126761. * Initializes the behavior.
  126762. */
  126763. init(): void;
  126764. /**
  126765. * Attaches the behavior to its arc rotate camera.
  126766. * @param camera Defines the camera to attach the behavior to
  126767. */
  126768. attach(camera: ArcRotateCamera): void;
  126769. /**
  126770. * Detaches the behavior from its current arc rotate camera.
  126771. */
  126772. detach(): void;
  126773. private _radiusIsAnimating;
  126774. private _radiusBounceTransition;
  126775. private _animatables;
  126776. private _cachedWheelPrecision;
  126777. /**
  126778. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  126779. * @param radiusLimit The limit to check against.
  126780. * @return Bool to indicate if at limit.
  126781. */
  126782. private _isRadiusAtLimit;
  126783. /**
  126784. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  126785. * @param radiusDelta The delta by which to animate to. Can be negative.
  126786. */
  126787. private _applyBoundRadiusAnimation;
  126788. /**
  126789. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  126790. */
  126791. protected _clearAnimationLocks(): void;
  126792. /**
  126793. * Stops and removes all animations that have been applied to the camera
  126794. */
  126795. stopAllAnimations(): void;
  126796. }
  126797. }
  126798. declare module BABYLON {
  126799. /**
  126800. * 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.
  126801. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126802. */
  126803. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  126804. /**
  126805. * Gets the name of the behavior.
  126806. */
  126807. get name(): string;
  126808. private _mode;
  126809. private _radiusScale;
  126810. private _positionScale;
  126811. private _defaultElevation;
  126812. private _elevationReturnTime;
  126813. private _elevationReturnWaitTime;
  126814. private _zoomStopsAnimation;
  126815. private _framingTime;
  126816. /**
  126817. * The easing function used by animations
  126818. */
  126819. static EasingFunction: ExponentialEase;
  126820. /**
  126821. * The easing mode used by animations
  126822. */
  126823. static EasingMode: number;
  126824. /**
  126825. * Sets the current mode used by the behavior
  126826. */
  126827. set mode(mode: number);
  126828. /**
  126829. * Gets current mode used by the behavior.
  126830. */
  126831. get mode(): number;
  126832. /**
  126833. * Sets the scale applied to the radius (1 by default)
  126834. */
  126835. set radiusScale(radius: number);
  126836. /**
  126837. * Gets the scale applied to the radius
  126838. */
  126839. get radiusScale(): number;
  126840. /**
  126841. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126842. */
  126843. set positionScale(scale: number);
  126844. /**
  126845. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126846. */
  126847. get positionScale(): number;
  126848. /**
  126849. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126850. * behaviour is triggered, in radians.
  126851. */
  126852. set defaultElevation(elevation: number);
  126853. /**
  126854. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126855. * behaviour is triggered, in radians.
  126856. */
  126857. get defaultElevation(): number;
  126858. /**
  126859. * Sets the time (in milliseconds) taken to return to the default beta position.
  126860. * Negative value indicates camera should not return to default.
  126861. */
  126862. set elevationReturnTime(speed: number);
  126863. /**
  126864. * Gets the time (in milliseconds) taken to return to the default beta position.
  126865. * Negative value indicates camera should not return to default.
  126866. */
  126867. get elevationReturnTime(): number;
  126868. /**
  126869. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126870. */
  126871. set elevationReturnWaitTime(time: number);
  126872. /**
  126873. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126874. */
  126875. get elevationReturnWaitTime(): number;
  126876. /**
  126877. * Sets the flag that indicates if user zooming should stop animation.
  126878. */
  126879. set zoomStopsAnimation(flag: boolean);
  126880. /**
  126881. * Gets the flag that indicates if user zooming should stop animation.
  126882. */
  126883. get zoomStopsAnimation(): boolean;
  126884. /**
  126885. * Sets the transition time when framing the mesh, in milliseconds
  126886. */
  126887. set framingTime(time: number);
  126888. /**
  126889. * Gets the transition time when framing the mesh, in milliseconds
  126890. */
  126891. get framingTime(): number;
  126892. /**
  126893. * Define if the behavior should automatically change the configured
  126894. * camera limits and sensibilities.
  126895. */
  126896. autoCorrectCameraLimitsAndSensibility: boolean;
  126897. private _onPrePointerObservableObserver;
  126898. private _onAfterCheckInputsObserver;
  126899. private _onMeshTargetChangedObserver;
  126900. private _attachedCamera;
  126901. private _isPointerDown;
  126902. private _lastInteractionTime;
  126903. /**
  126904. * Initializes the behavior.
  126905. */
  126906. init(): void;
  126907. /**
  126908. * Attaches the behavior to its arc rotate camera.
  126909. * @param camera Defines the camera to attach the behavior to
  126910. */
  126911. attach(camera: ArcRotateCamera): void;
  126912. /**
  126913. * Detaches the behavior from its current arc rotate camera.
  126914. */
  126915. detach(): void;
  126916. private _animatables;
  126917. private _betaIsAnimating;
  126918. private _betaTransition;
  126919. private _radiusTransition;
  126920. private _vectorTransition;
  126921. /**
  126922. * Targets the given mesh and updates zoom level accordingly.
  126923. * @param mesh The mesh to target.
  126924. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126925. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126926. */
  126927. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126928. /**
  126929. * Targets the given mesh with its children and updates zoom level accordingly.
  126930. * @param mesh The mesh to target.
  126931. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126932. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126933. */
  126934. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126935. /**
  126936. * Targets the given meshes with their children and updates zoom level accordingly.
  126937. * @param meshes The mesh to target.
  126938. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126939. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126940. */
  126941. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126942. /**
  126943. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  126944. * @param minimumWorld Determines the smaller position of the bounding box extend
  126945. * @param maximumWorld Determines the bigger position of the bounding box extend
  126946. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126947. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126948. */
  126949. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126950. /**
  126951. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  126952. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  126953. * frustum width.
  126954. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  126955. * to fully enclose the mesh in the viewing frustum.
  126956. */
  126957. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  126958. /**
  126959. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  126960. * is automatically returned to its default position (expected to be above ground plane).
  126961. */
  126962. private _maintainCameraAboveGround;
  126963. /**
  126964. * Returns the frustum slope based on the canvas ratio and camera FOV
  126965. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  126966. */
  126967. private _getFrustumSlope;
  126968. /**
  126969. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  126970. */
  126971. private _clearAnimationLocks;
  126972. /**
  126973. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  126974. */
  126975. private _applyUserInteraction;
  126976. /**
  126977. * Stops and removes all animations that have been applied to the camera
  126978. */
  126979. stopAllAnimations(): void;
  126980. /**
  126981. * Gets a value indicating if the user is moving the camera
  126982. */
  126983. get isUserIsMoving(): boolean;
  126984. /**
  126985. * The camera can move all the way towards the mesh.
  126986. */
  126987. static IgnoreBoundsSizeMode: number;
  126988. /**
  126989. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  126990. */
  126991. static FitFrustumSidesMode: number;
  126992. }
  126993. }
  126994. declare module BABYLON {
  126995. /**
  126996. * Base class for Camera Pointer Inputs.
  126997. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  126998. * for example usage.
  126999. */
  127000. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  127001. /**
  127002. * Defines the camera the input is attached to.
  127003. */
  127004. abstract camera: Camera;
  127005. /**
  127006. * Whether keyboard modifier keys are pressed at time of last mouse event.
  127007. */
  127008. protected _altKey: boolean;
  127009. protected _ctrlKey: boolean;
  127010. protected _metaKey: boolean;
  127011. protected _shiftKey: boolean;
  127012. /**
  127013. * Which mouse buttons were pressed at time of last mouse event.
  127014. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  127015. */
  127016. protected _buttonsPressed: number;
  127017. /**
  127018. * Defines the buttons associated with the input to handle camera move.
  127019. */
  127020. buttons: number[];
  127021. /**
  127022. * Attach the input controls to a specific dom element to get the input from.
  127023. * @param element Defines the element the controls should be listened from
  127024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127025. */
  127026. attachControl(noPreventDefault?: boolean): void;
  127027. /**
  127028. * Detach the current controls from the specified dom element.
  127029. */
  127030. detachControl(): void;
  127031. /**
  127032. * Gets the class name of the current input.
  127033. * @returns the class name
  127034. */
  127035. getClassName(): string;
  127036. /**
  127037. * Get the friendly name associated with the input class.
  127038. * @returns the input friendly name
  127039. */
  127040. getSimpleName(): string;
  127041. /**
  127042. * Called on pointer POINTERDOUBLETAP event.
  127043. * Override this method to provide functionality on POINTERDOUBLETAP event.
  127044. */
  127045. protected onDoubleTap(type: string): void;
  127046. /**
  127047. * Called on pointer POINTERMOVE event if only a single touch is active.
  127048. * Override this method to provide functionality.
  127049. */
  127050. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127051. /**
  127052. * Called on pointer POINTERMOVE event if multiple touches are active.
  127053. * Override this method to provide functionality.
  127054. */
  127055. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127056. /**
  127057. * Called on JS contextmenu event.
  127058. * Override this method to provide functionality.
  127059. */
  127060. protected onContextMenu(evt: PointerEvent): void;
  127061. /**
  127062. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127063. * press.
  127064. * Override this method to provide functionality.
  127065. */
  127066. protected onButtonDown(evt: PointerEvent): void;
  127067. /**
  127068. * Called each time a new POINTERUP event occurs. Ie, for each button
  127069. * release.
  127070. * Override this method to provide functionality.
  127071. */
  127072. protected onButtonUp(evt: PointerEvent): void;
  127073. /**
  127074. * Called when window becomes inactive.
  127075. * Override this method to provide functionality.
  127076. */
  127077. protected onLostFocus(): void;
  127078. private _pointerInput;
  127079. private _observer;
  127080. private _onLostFocus;
  127081. private pointA;
  127082. private pointB;
  127083. }
  127084. }
  127085. declare module BABYLON {
  127086. /**
  127087. * Manage the pointers inputs to control an arc rotate camera.
  127088. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127089. */
  127090. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  127091. /**
  127092. * Defines the camera the input is attached to.
  127093. */
  127094. camera: ArcRotateCamera;
  127095. /**
  127096. * Gets the class name of the current input.
  127097. * @returns the class name
  127098. */
  127099. getClassName(): string;
  127100. /**
  127101. * Defines the buttons associated with the input to handle camera move.
  127102. */
  127103. buttons: number[];
  127104. /**
  127105. * Defines the pointer angular sensibility along the X axis or how fast is
  127106. * the camera rotating.
  127107. */
  127108. angularSensibilityX: number;
  127109. /**
  127110. * Defines the pointer angular sensibility along the Y axis or how fast is
  127111. * the camera rotating.
  127112. */
  127113. angularSensibilityY: number;
  127114. /**
  127115. * Defines the pointer pinch precision or how fast is the camera zooming.
  127116. */
  127117. pinchPrecision: number;
  127118. /**
  127119. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  127120. * from 0.
  127121. * It defines the percentage of current camera.radius to use as delta when
  127122. * pinch zoom is used.
  127123. */
  127124. pinchDeltaPercentage: number;
  127125. /**
  127126. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  127127. * that any object in the plane at the camera's target point will scale
  127128. * perfectly with finger motion.
  127129. * Overrides pinchDeltaPercentage and pinchPrecision.
  127130. */
  127131. useNaturalPinchZoom: boolean;
  127132. /**
  127133. * Defines the pointer panning sensibility or how fast is the camera moving.
  127134. */
  127135. panningSensibility: number;
  127136. /**
  127137. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  127138. */
  127139. multiTouchPanning: boolean;
  127140. /**
  127141. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  127142. * zoom (pinch) through multitouch.
  127143. */
  127144. multiTouchPanAndZoom: boolean;
  127145. /**
  127146. * Revers pinch action direction.
  127147. */
  127148. pinchInwards: boolean;
  127149. private _isPanClick;
  127150. private _twoFingerActivityCount;
  127151. private _isPinching;
  127152. /**
  127153. * Called on pointer POINTERMOVE event if only a single touch is active.
  127154. */
  127155. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127156. /**
  127157. * Called on pointer POINTERDOUBLETAP event.
  127158. */
  127159. protected onDoubleTap(type: string): void;
  127160. /**
  127161. * Called on pointer POINTERMOVE event if multiple touches are active.
  127162. */
  127163. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127164. /**
  127165. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127166. * press.
  127167. */
  127168. protected onButtonDown(evt: PointerEvent): void;
  127169. /**
  127170. * Called each time a new POINTERUP event occurs. Ie, for each button
  127171. * release.
  127172. */
  127173. protected onButtonUp(evt: PointerEvent): void;
  127174. /**
  127175. * Called when window becomes inactive.
  127176. */
  127177. protected onLostFocus(): void;
  127178. }
  127179. }
  127180. declare module BABYLON {
  127181. /**
  127182. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  127183. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127184. */
  127185. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  127186. /**
  127187. * Defines the camera the input is attached to.
  127188. */
  127189. camera: ArcRotateCamera;
  127190. /**
  127191. * Defines the list of key codes associated with the up action (increase alpha)
  127192. */
  127193. keysUp: number[];
  127194. /**
  127195. * Defines the list of key codes associated with the down action (decrease alpha)
  127196. */
  127197. keysDown: number[];
  127198. /**
  127199. * Defines the list of key codes associated with the left action (increase beta)
  127200. */
  127201. keysLeft: number[];
  127202. /**
  127203. * Defines the list of key codes associated with the right action (decrease beta)
  127204. */
  127205. keysRight: number[];
  127206. /**
  127207. * Defines the list of key codes associated with the reset action.
  127208. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  127209. */
  127210. keysReset: number[];
  127211. /**
  127212. * Defines the panning sensibility of the inputs.
  127213. * (How fast is the camera panning)
  127214. */
  127215. panningSensibility: number;
  127216. /**
  127217. * Defines the zooming sensibility of the inputs.
  127218. * (How fast is the camera zooming)
  127219. */
  127220. zoomingSensibility: number;
  127221. /**
  127222. * Defines whether maintaining the alt key down switch the movement mode from
  127223. * orientation to zoom.
  127224. */
  127225. useAltToZoom: boolean;
  127226. /**
  127227. * Rotation speed of the camera
  127228. */
  127229. angularSpeed: number;
  127230. private _keys;
  127231. private _ctrlPressed;
  127232. private _altPressed;
  127233. private _onCanvasBlurObserver;
  127234. private _onKeyboardObserver;
  127235. private _engine;
  127236. private _scene;
  127237. /**
  127238. * Attach the input controls to a specific dom element to get the input from.
  127239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127240. */
  127241. attachControl(noPreventDefault?: boolean): void;
  127242. /**
  127243. * Detach the current controls from the specified dom element.
  127244. */
  127245. detachControl(): void;
  127246. /**
  127247. * Update the current camera state depending on the inputs that have been used this frame.
  127248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127249. */
  127250. checkInputs(): void;
  127251. /**
  127252. * Gets the class name of the current intput.
  127253. * @returns the class name
  127254. */
  127255. getClassName(): string;
  127256. /**
  127257. * Get the friendly name associated with the input class.
  127258. * @returns the input friendly name
  127259. */
  127260. getSimpleName(): string;
  127261. }
  127262. }
  127263. declare module BABYLON {
  127264. /**
  127265. * Manage the mouse wheel inputs to control an arc rotate camera.
  127266. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127267. */
  127268. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  127269. /**
  127270. * Defines the camera the input is attached to.
  127271. */
  127272. camera: ArcRotateCamera;
  127273. /**
  127274. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  127275. */
  127276. wheelPrecision: number;
  127277. /**
  127278. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  127279. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  127280. */
  127281. wheelDeltaPercentage: number;
  127282. private _wheel;
  127283. private _observer;
  127284. private computeDeltaFromMouseWheelLegacyEvent;
  127285. /**
  127286. * Attach the input controls to a specific dom element to get the input from.
  127287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127288. */
  127289. attachControl(noPreventDefault?: boolean): void;
  127290. /**
  127291. * Detach the current controls from the specified dom element.
  127292. */
  127293. detachControl(): void;
  127294. /**
  127295. * Gets the class name of the current intput.
  127296. * @returns the class name
  127297. */
  127298. getClassName(): string;
  127299. /**
  127300. * Get the friendly name associated with the input class.
  127301. * @returns the input friendly name
  127302. */
  127303. getSimpleName(): string;
  127304. }
  127305. }
  127306. declare module BABYLON {
  127307. /**
  127308. * Default Inputs manager for the ArcRotateCamera.
  127309. * It groups all the default supported inputs for ease of use.
  127310. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127311. */
  127312. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  127313. /**
  127314. * Instantiates a new ArcRotateCameraInputsManager.
  127315. * @param camera Defines the camera the inputs belong to
  127316. */
  127317. constructor(camera: ArcRotateCamera);
  127318. /**
  127319. * Add mouse wheel input support to the input manager.
  127320. * @returns the current input manager
  127321. */
  127322. addMouseWheel(): ArcRotateCameraInputsManager;
  127323. /**
  127324. * Add pointers input support to the input manager.
  127325. * @returns the current input manager
  127326. */
  127327. addPointers(): ArcRotateCameraInputsManager;
  127328. /**
  127329. * Add keyboard input support to the input manager.
  127330. * @returns the current input manager
  127331. */
  127332. addKeyboard(): ArcRotateCameraInputsManager;
  127333. }
  127334. }
  127335. declare module BABYLON {
  127336. /**
  127337. * This represents an orbital type of camera.
  127338. *
  127339. * 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.
  127340. * 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.
  127341. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  127342. */
  127343. export class ArcRotateCamera extends TargetCamera {
  127344. /**
  127345. * Defines the rotation angle of the camera along the longitudinal axis.
  127346. */
  127347. alpha: number;
  127348. /**
  127349. * Defines the rotation angle of the camera along the latitudinal axis.
  127350. */
  127351. beta: number;
  127352. /**
  127353. * Defines the radius of the camera from it s target point.
  127354. */
  127355. radius: number;
  127356. protected _target: Vector3;
  127357. protected _targetHost: Nullable<AbstractMesh>;
  127358. /**
  127359. * Defines the target point of the camera.
  127360. * The camera looks towards it form the radius distance.
  127361. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  127362. */
  127363. get target(): Vector3;
  127364. set target(value: Vector3);
  127365. /**
  127366. * Define the current local position of the camera in the scene
  127367. */
  127368. get position(): Vector3;
  127369. set position(newPosition: Vector3);
  127370. protected _upToYMatrix: Matrix;
  127371. protected _YToUpMatrix: Matrix;
  127372. /**
  127373. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  127374. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  127375. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  127376. */
  127377. set upVector(vec: Vector3);
  127378. get upVector(): Vector3;
  127379. /**
  127380. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  127381. */
  127382. setMatUp(): void;
  127383. /**
  127384. * Current inertia value on the longitudinal axis.
  127385. * The bigger this number the longer it will take for the camera to stop.
  127386. */
  127387. inertialAlphaOffset: number;
  127388. /**
  127389. * Current inertia value on the latitudinal axis.
  127390. * The bigger this number the longer it will take for the camera to stop.
  127391. */
  127392. inertialBetaOffset: number;
  127393. /**
  127394. * Current inertia value on the radius axis.
  127395. * The bigger this number the longer it will take for the camera to stop.
  127396. */
  127397. inertialRadiusOffset: number;
  127398. /**
  127399. * Minimum allowed angle on the longitudinal axis.
  127400. * This can help limiting how the Camera is able to move in the scene.
  127401. */
  127402. lowerAlphaLimit: Nullable<number>;
  127403. /**
  127404. * Maximum allowed angle on the longitudinal axis.
  127405. * This can help limiting how the Camera is able to move in the scene.
  127406. */
  127407. upperAlphaLimit: Nullable<number>;
  127408. /**
  127409. * Minimum allowed angle on the latitudinal axis.
  127410. * This can help limiting how the Camera is able to move in the scene.
  127411. */
  127412. lowerBetaLimit: number;
  127413. /**
  127414. * Maximum allowed angle on the latitudinal axis.
  127415. * This can help limiting how the Camera is able to move in the scene.
  127416. */
  127417. upperBetaLimit: number;
  127418. /**
  127419. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  127420. * This can help limiting how the Camera is able to move in the scene.
  127421. */
  127422. lowerRadiusLimit: Nullable<number>;
  127423. /**
  127424. * Maximum allowed distance of the camera to the target (The camera can not get further).
  127425. * This can help limiting how the Camera is able to move in the scene.
  127426. */
  127427. upperRadiusLimit: Nullable<number>;
  127428. /**
  127429. * Defines the current inertia value used during panning of the camera along the X axis.
  127430. */
  127431. inertialPanningX: number;
  127432. /**
  127433. * Defines the current inertia value used during panning of the camera along the Y axis.
  127434. */
  127435. inertialPanningY: number;
  127436. /**
  127437. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  127438. * Basically if your fingers moves away from more than this distance you will be considered
  127439. * in pinch mode.
  127440. */
  127441. pinchToPanMaxDistance: number;
  127442. /**
  127443. * Defines the maximum distance the camera can pan.
  127444. * This could help keeping the cammera always in your scene.
  127445. */
  127446. panningDistanceLimit: Nullable<number>;
  127447. /**
  127448. * Defines the target of the camera before paning.
  127449. */
  127450. panningOriginTarget: Vector3;
  127451. /**
  127452. * Defines the value of the inertia used during panning.
  127453. * 0 would mean stop inertia and one would mean no decelleration at all.
  127454. */
  127455. panningInertia: number;
  127456. /**
  127457. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  127458. */
  127459. get angularSensibilityX(): number;
  127460. set angularSensibilityX(value: number);
  127461. /**
  127462. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  127463. */
  127464. get angularSensibilityY(): number;
  127465. set angularSensibilityY(value: number);
  127466. /**
  127467. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  127468. */
  127469. get pinchPrecision(): number;
  127470. set pinchPrecision(value: number);
  127471. /**
  127472. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  127473. * It will be used instead of pinchDeltaPrecision if different from 0.
  127474. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  127475. */
  127476. get pinchDeltaPercentage(): number;
  127477. set pinchDeltaPercentage(value: number);
  127478. /**
  127479. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  127480. * and pinch delta percentage.
  127481. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  127482. * that any object in the plane at the camera's target point will scale
  127483. * perfectly with finger motion.
  127484. */
  127485. get useNaturalPinchZoom(): boolean;
  127486. set useNaturalPinchZoom(value: boolean);
  127487. /**
  127488. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  127489. */
  127490. get panningSensibility(): number;
  127491. set panningSensibility(value: number);
  127492. /**
  127493. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  127494. */
  127495. get keysUp(): number[];
  127496. set keysUp(value: number[]);
  127497. /**
  127498. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  127499. */
  127500. get keysDown(): number[];
  127501. set keysDown(value: number[]);
  127502. /**
  127503. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  127504. */
  127505. get keysLeft(): number[];
  127506. set keysLeft(value: number[]);
  127507. /**
  127508. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  127509. */
  127510. get keysRight(): number[];
  127511. set keysRight(value: number[]);
  127512. /**
  127513. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  127514. */
  127515. get wheelPrecision(): number;
  127516. set wheelPrecision(value: number);
  127517. /**
  127518. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  127519. * It will be used instead of pinchDeltaPrecision if different from 0.
  127520. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  127521. */
  127522. get wheelDeltaPercentage(): number;
  127523. set wheelDeltaPercentage(value: number);
  127524. /**
  127525. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  127526. */
  127527. zoomOnFactor: number;
  127528. /**
  127529. * Defines a screen offset for the camera position.
  127530. */
  127531. targetScreenOffset: Vector2;
  127532. /**
  127533. * Allows the camera to be completely reversed.
  127534. * If false the camera can not arrive upside down.
  127535. */
  127536. allowUpsideDown: boolean;
  127537. /**
  127538. * Define if double tap/click is used to restore the previously saved state of the camera.
  127539. */
  127540. useInputToRestoreState: boolean;
  127541. /** @hidden */
  127542. _viewMatrix: Matrix;
  127543. /** @hidden */
  127544. _useCtrlForPanning: boolean;
  127545. /** @hidden */
  127546. _panningMouseButton: number;
  127547. /**
  127548. * Defines the input associated to the camera.
  127549. */
  127550. inputs: ArcRotateCameraInputsManager;
  127551. /** @hidden */
  127552. _reset: () => void;
  127553. /**
  127554. * Defines the allowed panning axis.
  127555. */
  127556. panningAxis: Vector3;
  127557. protected _localDirection: Vector3;
  127558. protected _transformedDirection: Vector3;
  127559. private _bouncingBehavior;
  127560. /**
  127561. * Gets the bouncing behavior of the camera if it has been enabled.
  127562. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  127563. */
  127564. get bouncingBehavior(): Nullable<BouncingBehavior>;
  127565. /**
  127566. * Defines if the bouncing behavior of the camera is enabled on the camera.
  127567. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  127568. */
  127569. get useBouncingBehavior(): boolean;
  127570. set useBouncingBehavior(value: boolean);
  127571. private _framingBehavior;
  127572. /**
  127573. * Gets the framing behavior of the camera if it has been enabled.
  127574. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  127575. */
  127576. get framingBehavior(): Nullable<FramingBehavior>;
  127577. /**
  127578. * Defines if the framing behavior of the camera is enabled on the camera.
  127579. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  127580. */
  127581. get useFramingBehavior(): boolean;
  127582. set useFramingBehavior(value: boolean);
  127583. private _autoRotationBehavior;
  127584. /**
  127585. * Gets the auto rotation behavior of the camera if it has been enabled.
  127586. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127587. */
  127588. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  127589. /**
  127590. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  127591. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127592. */
  127593. get useAutoRotationBehavior(): boolean;
  127594. set useAutoRotationBehavior(value: boolean);
  127595. /**
  127596. * Observable triggered when the mesh target has been changed on the camera.
  127597. */
  127598. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  127599. /**
  127600. * Event raised when the camera is colliding with a mesh.
  127601. */
  127602. onCollide: (collidedMesh: AbstractMesh) => void;
  127603. /**
  127604. * Defines whether the camera should check collision with the objects oh the scene.
  127605. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  127606. */
  127607. checkCollisions: boolean;
  127608. /**
  127609. * Defines the collision radius of the camera.
  127610. * This simulates a sphere around the camera.
  127611. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  127612. */
  127613. collisionRadius: Vector3;
  127614. protected _collider: Collider;
  127615. protected _previousPosition: Vector3;
  127616. protected _collisionVelocity: Vector3;
  127617. protected _newPosition: Vector3;
  127618. protected _previousAlpha: number;
  127619. protected _previousBeta: number;
  127620. protected _previousRadius: number;
  127621. protected _collisionTriggered: boolean;
  127622. protected _targetBoundingCenter: Nullable<Vector3>;
  127623. private _computationVector;
  127624. /**
  127625. * Instantiates a new ArcRotateCamera in a given scene
  127626. * @param name Defines the name of the camera
  127627. * @param alpha Defines the camera rotation along the logitudinal axis
  127628. * @param beta Defines the camera rotation along the latitudinal axis
  127629. * @param radius Defines the camera distance from its target
  127630. * @param target Defines the camera target
  127631. * @param scene Defines the scene the camera belongs to
  127632. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  127633. */
  127634. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  127635. /** @hidden */
  127636. _initCache(): void;
  127637. /** @hidden */
  127638. _updateCache(ignoreParentClass?: boolean): void;
  127639. protected _getTargetPosition(): Vector3;
  127640. private _storedAlpha;
  127641. private _storedBeta;
  127642. private _storedRadius;
  127643. private _storedTarget;
  127644. private _storedTargetScreenOffset;
  127645. /**
  127646. * Stores the current state of the camera (alpha, beta, radius and target)
  127647. * @returns the camera itself
  127648. */
  127649. storeState(): Camera;
  127650. /**
  127651. * @hidden
  127652. * Restored camera state. You must call storeState() first
  127653. */
  127654. _restoreStateValues(): boolean;
  127655. /** @hidden */
  127656. _isSynchronizedViewMatrix(): boolean;
  127657. /**
  127658. * Attached controls to the current camera.
  127659. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127660. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  127661. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  127662. */
  127663. attachControl(noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  127664. /**
  127665. * Detach the current controls from the camera.
  127666. * The camera will stop reacting to inputs.
  127667. */
  127668. detachControl(): void;
  127669. /** @hidden */
  127670. _checkInputs(): void;
  127671. protected _checkLimits(): void;
  127672. /**
  127673. * Rebuilds angles (alpha, beta) and radius from the give position and target
  127674. */
  127675. rebuildAnglesAndRadius(): void;
  127676. /**
  127677. * Use a position to define the current camera related information like alpha, beta and radius
  127678. * @param position Defines the position to set the camera at
  127679. */
  127680. setPosition(position: Vector3): void;
  127681. /**
  127682. * Defines the target the camera should look at.
  127683. * This will automatically adapt alpha beta and radius to fit within the new target.
  127684. * @param target Defines the new target as a Vector or a mesh
  127685. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  127686. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  127687. */
  127688. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  127689. /** @hidden */
  127690. _getViewMatrix(): Matrix;
  127691. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  127692. /**
  127693. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  127694. * @param meshes Defines the mesh to zoom on
  127695. * @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)
  127696. */
  127697. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  127698. /**
  127699. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  127700. * The target will be changed but the radius
  127701. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  127702. * @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)
  127703. */
  127704. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  127705. min: Vector3;
  127706. max: Vector3;
  127707. distance: number;
  127708. }, doNotUpdateMaxZ?: boolean): void;
  127709. /**
  127710. * @override
  127711. * Override Camera.createRigCamera
  127712. */
  127713. createRigCamera(name: string, cameraIndex: number): Camera;
  127714. /**
  127715. * @hidden
  127716. * @override
  127717. * Override Camera._updateRigCameras
  127718. */
  127719. _updateRigCameras(): void;
  127720. /**
  127721. * Destroy the camera and release the current resources hold by it.
  127722. */
  127723. dispose(): void;
  127724. /**
  127725. * Gets the current object class name.
  127726. * @return the class name
  127727. */
  127728. getClassName(): string;
  127729. }
  127730. }
  127731. declare module BABYLON {
  127732. /**
  127733. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  127734. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127735. */
  127736. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  127737. /**
  127738. * Gets the name of the behavior.
  127739. */
  127740. get name(): string;
  127741. private _zoomStopsAnimation;
  127742. private _idleRotationSpeed;
  127743. private _idleRotationWaitTime;
  127744. private _idleRotationSpinupTime;
  127745. /**
  127746. * Sets the flag that indicates if user zooming should stop animation.
  127747. */
  127748. set zoomStopsAnimation(flag: boolean);
  127749. /**
  127750. * Gets the flag that indicates if user zooming should stop animation.
  127751. */
  127752. get zoomStopsAnimation(): boolean;
  127753. /**
  127754. * Sets the default speed at which the camera rotates around the model.
  127755. */
  127756. set idleRotationSpeed(speed: number);
  127757. /**
  127758. * Gets the default speed at which the camera rotates around the model.
  127759. */
  127760. get idleRotationSpeed(): number;
  127761. /**
  127762. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  127763. */
  127764. set idleRotationWaitTime(time: number);
  127765. /**
  127766. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  127767. */
  127768. get idleRotationWaitTime(): number;
  127769. /**
  127770. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127771. */
  127772. set idleRotationSpinupTime(time: number);
  127773. /**
  127774. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127775. */
  127776. get idleRotationSpinupTime(): number;
  127777. /**
  127778. * Gets a value indicating if the camera is currently rotating because of this behavior
  127779. */
  127780. get rotationInProgress(): boolean;
  127781. private _onPrePointerObservableObserver;
  127782. private _onAfterCheckInputsObserver;
  127783. private _attachedCamera;
  127784. private _isPointerDown;
  127785. private _lastFrameTime;
  127786. private _lastInteractionTime;
  127787. private _cameraRotationSpeed;
  127788. /**
  127789. * Initializes the behavior.
  127790. */
  127791. init(): void;
  127792. /**
  127793. * Attaches the behavior to its arc rotate camera.
  127794. * @param camera Defines the camera to attach the behavior to
  127795. */
  127796. attach(camera: ArcRotateCamera): void;
  127797. /**
  127798. * Detaches the behavior from its current arc rotate camera.
  127799. */
  127800. detach(): void;
  127801. /**
  127802. * Returns true if user is scrolling.
  127803. * @return true if user is scrolling.
  127804. */
  127805. private _userIsZooming;
  127806. private _lastFrameRadius;
  127807. private _shouldAnimationStopForInteraction;
  127808. /**
  127809. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127810. */
  127811. private _applyUserInteraction;
  127812. private _userIsMoving;
  127813. }
  127814. }
  127815. declare module BABYLON {
  127816. /**
  127817. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  127818. */
  127819. export class AttachToBoxBehavior implements Behavior<Mesh> {
  127820. private ui;
  127821. /**
  127822. * The name of the behavior
  127823. */
  127824. name: string;
  127825. /**
  127826. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  127827. */
  127828. distanceAwayFromFace: number;
  127829. /**
  127830. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  127831. */
  127832. distanceAwayFromBottomOfFace: number;
  127833. private _faceVectors;
  127834. private _target;
  127835. private _scene;
  127836. private _onRenderObserver;
  127837. private _tmpMatrix;
  127838. private _tmpVector;
  127839. /**
  127840. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  127841. * @param ui The transform node that should be attched to the mesh
  127842. */
  127843. constructor(ui: TransformNode);
  127844. /**
  127845. * Initializes the behavior
  127846. */
  127847. init(): void;
  127848. private _closestFace;
  127849. private _zeroVector;
  127850. private _lookAtTmpMatrix;
  127851. private _lookAtToRef;
  127852. /**
  127853. * Attaches the AttachToBoxBehavior to the passed in mesh
  127854. * @param target The mesh that the specified node will be attached to
  127855. */
  127856. attach(target: Mesh): void;
  127857. /**
  127858. * Detaches the behavior from the mesh
  127859. */
  127860. detach(): void;
  127861. }
  127862. }
  127863. declare module BABYLON {
  127864. /**
  127865. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  127866. */
  127867. export class FadeInOutBehavior implements Behavior<Mesh> {
  127868. /**
  127869. * Time in milliseconds to delay before fading in (Default: 0)
  127870. */
  127871. delay: number;
  127872. /**
  127873. * Time in milliseconds for the mesh to fade in (Default: 300)
  127874. */
  127875. fadeInTime: number;
  127876. private _millisecondsPerFrame;
  127877. private _hovered;
  127878. private _hoverValue;
  127879. private _ownerNode;
  127880. /**
  127881. * Instatiates the FadeInOutBehavior
  127882. */
  127883. constructor();
  127884. /**
  127885. * The name of the behavior
  127886. */
  127887. get name(): string;
  127888. /**
  127889. * Initializes the behavior
  127890. */
  127891. init(): void;
  127892. /**
  127893. * Attaches the fade behavior on the passed in mesh
  127894. * @param ownerNode The mesh that will be faded in/out once attached
  127895. */
  127896. attach(ownerNode: Mesh): void;
  127897. /**
  127898. * Detaches the behavior from the mesh
  127899. */
  127900. detach(): void;
  127901. /**
  127902. * Triggers the mesh to begin fading in or out
  127903. * @param value if the object should fade in or out (true to fade in)
  127904. */
  127905. fadeIn(value: boolean): void;
  127906. private _update;
  127907. private _setAllVisibility;
  127908. }
  127909. }
  127910. declare module BABYLON {
  127911. /**
  127912. * Class containing a set of static utilities functions for managing Pivots
  127913. * @hidden
  127914. */
  127915. export class PivotTools {
  127916. private static _PivotCached;
  127917. private static _OldPivotPoint;
  127918. private static _PivotTranslation;
  127919. private static _PivotTmpVector;
  127920. private static _PivotPostMultiplyPivotMatrix;
  127921. /** @hidden */
  127922. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  127923. /** @hidden */
  127924. static _RestorePivotPoint(mesh: AbstractMesh): void;
  127925. }
  127926. }
  127927. declare module BABYLON {
  127928. /**
  127929. * Class containing static functions to help procedurally build meshes
  127930. */
  127931. export class PlaneBuilder {
  127932. /**
  127933. * Creates a plane mesh
  127934. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127935. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127936. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127938. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127940. * @param name defines the name of the mesh
  127941. * @param options defines the options used to create the mesh
  127942. * @param scene defines the hosting scene
  127943. * @returns the plane mesh
  127944. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127945. */
  127946. static CreatePlane(name: string, options: {
  127947. size?: number;
  127948. width?: number;
  127949. height?: number;
  127950. sideOrientation?: number;
  127951. frontUVs?: Vector4;
  127952. backUVs?: Vector4;
  127953. updatable?: boolean;
  127954. sourcePlane?: Plane;
  127955. }, scene?: Nullable<Scene>): Mesh;
  127956. }
  127957. }
  127958. declare module BABYLON {
  127959. /**
  127960. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  127961. */
  127962. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  127963. private static _AnyMouseID;
  127964. /**
  127965. * Abstract mesh the behavior is set on
  127966. */
  127967. attachedNode: AbstractMesh;
  127968. private _dragPlane;
  127969. private _scene;
  127970. private _pointerObserver;
  127971. private _beforeRenderObserver;
  127972. private static _planeScene;
  127973. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  127974. /**
  127975. * 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)
  127976. */
  127977. maxDragAngle: number;
  127978. /**
  127979. * @hidden
  127980. */
  127981. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  127982. /**
  127983. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127984. */
  127985. currentDraggingPointerID: number;
  127986. /**
  127987. * The last position where the pointer hit the drag plane in world space
  127988. */
  127989. lastDragPosition: Vector3;
  127990. /**
  127991. * If the behavior is currently in a dragging state
  127992. */
  127993. dragging: boolean;
  127994. /**
  127995. * 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)
  127996. */
  127997. dragDeltaRatio: number;
  127998. /**
  127999. * If the drag plane orientation should be updated during the dragging (Default: true)
  128000. */
  128001. updateDragPlane: boolean;
  128002. private _debugMode;
  128003. private _moving;
  128004. /**
  128005. * Fires each time the attached mesh is dragged with the pointer
  128006. * * delta between last drag position and current drag position in world space
  128007. * * dragDistance along the drag axis
  128008. * * dragPlaneNormal normal of the current drag plane used during the drag
  128009. * * dragPlanePoint in world space where the drag intersects the drag plane
  128010. */
  128011. onDragObservable: Observable<{
  128012. delta: Vector3;
  128013. dragPlanePoint: Vector3;
  128014. dragPlaneNormal: Vector3;
  128015. dragDistance: number;
  128016. pointerId: number;
  128017. }>;
  128018. /**
  128019. * Fires each time a drag begins (eg. mouse down on mesh)
  128020. */
  128021. onDragStartObservable: Observable<{
  128022. dragPlanePoint: Vector3;
  128023. pointerId: number;
  128024. }>;
  128025. /**
  128026. * Fires each time a drag ends (eg. mouse release after drag)
  128027. */
  128028. onDragEndObservable: Observable<{
  128029. dragPlanePoint: Vector3;
  128030. pointerId: number;
  128031. }>;
  128032. /**
  128033. * If the attached mesh should be moved when dragged
  128034. */
  128035. moveAttached: boolean;
  128036. /**
  128037. * If the drag behavior will react to drag events (Default: true)
  128038. */
  128039. enabled: boolean;
  128040. /**
  128041. * If pointer events should start and release the drag (Default: true)
  128042. */
  128043. startAndReleaseDragOnPointerEvents: boolean;
  128044. /**
  128045. * If camera controls should be detached during the drag
  128046. */
  128047. detachCameraControls: boolean;
  128048. /**
  128049. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  128050. */
  128051. useObjectOrientationForDragging: boolean;
  128052. private _options;
  128053. /**
  128054. * Gets the options used by the behavior
  128055. */
  128056. get options(): {
  128057. dragAxis?: Vector3;
  128058. dragPlaneNormal?: Vector3;
  128059. };
  128060. /**
  128061. * Sets the options used by the behavior
  128062. */
  128063. set options(options: {
  128064. dragAxis?: Vector3;
  128065. dragPlaneNormal?: Vector3;
  128066. });
  128067. /**
  128068. * Creates a pointer drag behavior that can be attached to a mesh
  128069. * @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)
  128070. */
  128071. constructor(options?: {
  128072. dragAxis?: Vector3;
  128073. dragPlaneNormal?: Vector3;
  128074. });
  128075. /**
  128076. * Predicate to determine if it is valid to move the object to a new position when it is moved
  128077. */
  128078. validateDrag: (targetPosition: Vector3) => boolean;
  128079. /**
  128080. * The name of the behavior
  128081. */
  128082. get name(): string;
  128083. /**
  128084. * Initializes the behavior
  128085. */
  128086. init(): void;
  128087. private _tmpVector;
  128088. private _alternatePickedPoint;
  128089. private _worldDragAxis;
  128090. private _targetPosition;
  128091. private _attachedElement;
  128092. /**
  128093. * Attaches the drag behavior the passed in mesh
  128094. * @param ownerNode The mesh that will be dragged around once attached
  128095. * @param predicate Predicate to use for pick filtering
  128096. */
  128097. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  128098. /**
  128099. * Force relase the drag action by code.
  128100. */
  128101. releaseDrag(): void;
  128102. private _startDragRay;
  128103. private _lastPointerRay;
  128104. /**
  128105. * Simulates the start of a pointer drag event on the behavior
  128106. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  128107. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  128108. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  128109. */
  128110. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128111. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128112. private _dragDelta;
  128113. protected _moveDrag(ray: Ray): void;
  128114. private _pickWithRayOnDragPlane;
  128115. private _pointA;
  128116. private _pointC;
  128117. private _localAxis;
  128118. private _lookAt;
  128119. private _updateDragPlanePosition;
  128120. /**
  128121. * Detaches the behavior from the mesh
  128122. */
  128123. detach(): void;
  128124. }
  128125. }
  128126. declare module BABYLON {
  128127. /**
  128128. * A behavior that when attached to a mesh will allow the mesh to be scaled
  128129. */
  128130. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  128131. private _dragBehaviorA;
  128132. private _dragBehaviorB;
  128133. private _startDistance;
  128134. private _initialScale;
  128135. private _targetScale;
  128136. private _ownerNode;
  128137. private _sceneRenderObserver;
  128138. /**
  128139. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  128140. */
  128141. constructor();
  128142. /**
  128143. * The name of the behavior
  128144. */
  128145. get name(): string;
  128146. /**
  128147. * Initializes the behavior
  128148. */
  128149. init(): void;
  128150. private _getCurrentDistance;
  128151. /**
  128152. * Attaches the scale behavior the passed in mesh
  128153. * @param ownerNode The mesh that will be scaled around once attached
  128154. */
  128155. attach(ownerNode: Mesh): void;
  128156. /**
  128157. * Detaches the behavior from the mesh
  128158. */
  128159. detach(): void;
  128160. }
  128161. }
  128162. declare module BABYLON {
  128163. /**
  128164. * 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
  128165. */
  128166. export class SixDofDragBehavior implements Behavior<Mesh> {
  128167. private static _virtualScene;
  128168. private _ownerNode;
  128169. private _sceneRenderObserver;
  128170. private _scene;
  128171. private _targetPosition;
  128172. private _virtualOriginMesh;
  128173. private _virtualDragMesh;
  128174. private _pointerObserver;
  128175. private _moving;
  128176. private _startingOrientation;
  128177. private _attachedElement;
  128178. /**
  128179. * 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)
  128180. */
  128181. private zDragFactor;
  128182. /**
  128183. * If the object should rotate to face the drag origin
  128184. */
  128185. rotateDraggedObject: boolean;
  128186. /**
  128187. * If the behavior is currently in a dragging state
  128188. */
  128189. dragging: boolean;
  128190. /**
  128191. * 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)
  128192. */
  128193. dragDeltaRatio: number;
  128194. /**
  128195. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  128196. */
  128197. currentDraggingPointerID: number;
  128198. /**
  128199. * If camera controls should be detached during the drag
  128200. */
  128201. detachCameraControls: boolean;
  128202. /**
  128203. * Fires each time a drag starts
  128204. */
  128205. onDragStartObservable: Observable<{}>;
  128206. /**
  128207. * Fires each time a drag ends (eg. mouse release after drag)
  128208. */
  128209. onDragEndObservable: Observable<{}>;
  128210. /**
  128211. * 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
  128212. */
  128213. constructor();
  128214. /**
  128215. * The name of the behavior
  128216. */
  128217. get name(): string;
  128218. /**
  128219. * Initializes the behavior
  128220. */
  128221. init(): void;
  128222. /**
  128223. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  128224. */
  128225. private get _pointerCamera();
  128226. /**
  128227. * Attaches the scale behavior the passed in mesh
  128228. * @param ownerNode The mesh that will be scaled around once attached
  128229. */
  128230. attach(ownerNode: Mesh): void;
  128231. /**
  128232. * Detaches the behavior from the mesh
  128233. */
  128234. detach(): void;
  128235. }
  128236. }
  128237. declare module BABYLON {
  128238. /**
  128239. * Class used to apply inverse kinematics to bones
  128240. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  128241. */
  128242. export class BoneIKController {
  128243. private static _tmpVecs;
  128244. private static _tmpQuat;
  128245. private static _tmpMats;
  128246. /**
  128247. * Gets or sets the target mesh
  128248. */
  128249. targetMesh: AbstractMesh;
  128250. /** Gets or sets the mesh used as pole */
  128251. poleTargetMesh: AbstractMesh;
  128252. /**
  128253. * Gets or sets the bone used as pole
  128254. */
  128255. poleTargetBone: Nullable<Bone>;
  128256. /**
  128257. * Gets or sets the target position
  128258. */
  128259. targetPosition: Vector3;
  128260. /**
  128261. * Gets or sets the pole target position
  128262. */
  128263. poleTargetPosition: Vector3;
  128264. /**
  128265. * Gets or sets the pole target local offset
  128266. */
  128267. poleTargetLocalOffset: Vector3;
  128268. /**
  128269. * Gets or sets the pole angle
  128270. */
  128271. poleAngle: number;
  128272. /**
  128273. * Gets or sets the mesh associated with the controller
  128274. */
  128275. mesh: AbstractMesh;
  128276. /**
  128277. * 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)
  128278. */
  128279. slerpAmount: number;
  128280. private _bone1Quat;
  128281. private _bone1Mat;
  128282. private _bone2Ang;
  128283. private _bone1;
  128284. private _bone2;
  128285. private _bone1Length;
  128286. private _bone2Length;
  128287. private _maxAngle;
  128288. private _maxReach;
  128289. private _rightHandedSystem;
  128290. private _bendAxis;
  128291. private _slerping;
  128292. private _adjustRoll;
  128293. /**
  128294. * Gets or sets maximum allowed angle
  128295. */
  128296. get maxAngle(): number;
  128297. set maxAngle(value: number);
  128298. /**
  128299. * Creates a new BoneIKController
  128300. * @param mesh defines the mesh to control
  128301. * @param bone defines the bone to control
  128302. * @param options defines options to set up the controller
  128303. */
  128304. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  128305. targetMesh?: AbstractMesh;
  128306. poleTargetMesh?: AbstractMesh;
  128307. poleTargetBone?: Bone;
  128308. poleTargetLocalOffset?: Vector3;
  128309. poleAngle?: number;
  128310. bendAxis?: Vector3;
  128311. maxAngle?: number;
  128312. slerpAmount?: number;
  128313. });
  128314. private _setMaxAngle;
  128315. /**
  128316. * Force the controller to update the bones
  128317. */
  128318. update(): void;
  128319. }
  128320. }
  128321. declare module BABYLON {
  128322. /**
  128323. * Class used to make a bone look toward a point in space
  128324. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  128325. */
  128326. export class BoneLookController {
  128327. private static _tmpVecs;
  128328. private static _tmpQuat;
  128329. private static _tmpMats;
  128330. /**
  128331. * The target Vector3 that the bone will look at
  128332. */
  128333. target: Vector3;
  128334. /**
  128335. * The mesh that the bone is attached to
  128336. */
  128337. mesh: AbstractMesh;
  128338. /**
  128339. * The bone that will be looking to the target
  128340. */
  128341. bone: Bone;
  128342. /**
  128343. * The up axis of the coordinate system that is used when the bone is rotated
  128344. */
  128345. upAxis: Vector3;
  128346. /**
  128347. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  128348. */
  128349. upAxisSpace: Space;
  128350. /**
  128351. * Used to make an adjustment to the yaw of the bone
  128352. */
  128353. adjustYaw: number;
  128354. /**
  128355. * Used to make an adjustment to the pitch of the bone
  128356. */
  128357. adjustPitch: number;
  128358. /**
  128359. * Used to make an adjustment to the roll of the bone
  128360. */
  128361. adjustRoll: number;
  128362. /**
  128363. * 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)
  128364. */
  128365. slerpAmount: number;
  128366. private _minYaw;
  128367. private _maxYaw;
  128368. private _minPitch;
  128369. private _maxPitch;
  128370. private _minYawSin;
  128371. private _minYawCos;
  128372. private _maxYawSin;
  128373. private _maxYawCos;
  128374. private _midYawConstraint;
  128375. private _minPitchTan;
  128376. private _maxPitchTan;
  128377. private _boneQuat;
  128378. private _slerping;
  128379. private _transformYawPitch;
  128380. private _transformYawPitchInv;
  128381. private _firstFrameSkipped;
  128382. private _yawRange;
  128383. private _fowardAxis;
  128384. /**
  128385. * Gets or sets the minimum yaw angle that the bone can look to
  128386. */
  128387. get minYaw(): number;
  128388. set minYaw(value: number);
  128389. /**
  128390. * Gets or sets the maximum yaw angle that the bone can look to
  128391. */
  128392. get maxYaw(): number;
  128393. set maxYaw(value: number);
  128394. /**
  128395. * Gets or sets the minimum pitch angle that the bone can look to
  128396. */
  128397. get minPitch(): number;
  128398. set minPitch(value: number);
  128399. /**
  128400. * Gets or sets the maximum pitch angle that the bone can look to
  128401. */
  128402. get maxPitch(): number;
  128403. set maxPitch(value: number);
  128404. /**
  128405. * Create a BoneLookController
  128406. * @param mesh the mesh that the bone belongs to
  128407. * @param bone the bone that will be looking to the target
  128408. * @param target the target Vector3 to look at
  128409. * @param options optional settings:
  128410. * * maxYaw: the maximum angle the bone will yaw to
  128411. * * minYaw: the minimum angle the bone will yaw to
  128412. * * maxPitch: the maximum angle the bone will pitch to
  128413. * * minPitch: the minimum angle the bone will yaw to
  128414. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  128415. * * upAxis: the up axis of the coordinate system
  128416. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  128417. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  128418. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  128419. * * adjustYaw: used to make an adjustment to the yaw of the bone
  128420. * * adjustPitch: used to make an adjustment to the pitch of the bone
  128421. * * adjustRoll: used to make an adjustment to the roll of the bone
  128422. **/
  128423. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  128424. maxYaw?: number;
  128425. minYaw?: number;
  128426. maxPitch?: number;
  128427. minPitch?: number;
  128428. slerpAmount?: number;
  128429. upAxis?: Vector3;
  128430. upAxisSpace?: Space;
  128431. yawAxis?: Vector3;
  128432. pitchAxis?: Vector3;
  128433. adjustYaw?: number;
  128434. adjustPitch?: number;
  128435. adjustRoll?: number;
  128436. });
  128437. /**
  128438. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  128439. */
  128440. update(): void;
  128441. private _getAngleDiff;
  128442. private _getAngleBetween;
  128443. private _isAngleBetween;
  128444. }
  128445. }
  128446. declare module BABYLON {
  128447. /**
  128448. * Manage the gamepad inputs to control an arc rotate camera.
  128449. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128450. */
  128451. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  128452. /**
  128453. * Defines the camera the input is attached to.
  128454. */
  128455. camera: ArcRotateCamera;
  128456. /**
  128457. * Defines the gamepad the input is gathering event from.
  128458. */
  128459. gamepad: Nullable<Gamepad>;
  128460. /**
  128461. * Defines the gamepad rotation sensiblity.
  128462. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  128463. */
  128464. gamepadRotationSensibility: number;
  128465. /**
  128466. * Defines the gamepad move sensiblity.
  128467. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  128468. */
  128469. gamepadMoveSensibility: number;
  128470. private _yAxisScale;
  128471. /**
  128472. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  128473. */
  128474. get invertYAxis(): boolean;
  128475. set invertYAxis(value: boolean);
  128476. private _onGamepadConnectedObserver;
  128477. private _onGamepadDisconnectedObserver;
  128478. /**
  128479. * Attach the input controls to a specific dom element to get the input from.
  128480. */
  128481. attachControl(): void;
  128482. /**
  128483. * Detach the current controls from the specified dom element.
  128484. * @param element Defines the element to stop listening the inputs from
  128485. */
  128486. detachControl(): void;
  128487. /**
  128488. * Update the current camera state depending on the inputs that have been used this frame.
  128489. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128490. */
  128491. checkInputs(): void;
  128492. /**
  128493. * Gets the class name of the current intput.
  128494. * @returns the class name
  128495. */
  128496. getClassName(): string;
  128497. /**
  128498. * Get the friendly name associated with the input class.
  128499. * @returns the input friendly name
  128500. */
  128501. getSimpleName(): string;
  128502. }
  128503. }
  128504. declare module BABYLON {
  128505. interface ArcRotateCameraInputsManager {
  128506. /**
  128507. * Add orientation input support to the input manager.
  128508. * @returns the current input manager
  128509. */
  128510. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  128511. }
  128512. /**
  128513. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  128514. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128515. */
  128516. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  128517. /**
  128518. * Defines the camera the input is attached to.
  128519. */
  128520. camera: ArcRotateCamera;
  128521. /**
  128522. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  128523. */
  128524. alphaCorrection: number;
  128525. /**
  128526. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  128527. */
  128528. gammaCorrection: number;
  128529. private _alpha;
  128530. private _gamma;
  128531. private _dirty;
  128532. private _deviceOrientationHandler;
  128533. /**
  128534. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  128535. */
  128536. constructor();
  128537. /**
  128538. * Attach the input controls to a specific dom element to get the input from.
  128539. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128540. */
  128541. attachControl(noPreventDefault?: boolean): void;
  128542. /** @hidden */
  128543. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  128544. /**
  128545. * Update the current camera state depending on the inputs that have been used this frame.
  128546. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128547. */
  128548. checkInputs(): void;
  128549. /**
  128550. * Detach the current controls from the specified dom element.
  128551. */
  128552. detachControl(): void;
  128553. /**
  128554. * Gets the class name of the current intput.
  128555. * @returns the class name
  128556. */
  128557. getClassName(): string;
  128558. /**
  128559. * Get the friendly name associated with the input class.
  128560. * @returns the input friendly name
  128561. */
  128562. getSimpleName(): string;
  128563. }
  128564. }
  128565. declare module BABYLON {
  128566. /**
  128567. * Listen to mouse events to control the camera.
  128568. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128569. */
  128570. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  128571. /**
  128572. * Defines the camera the input is attached to.
  128573. */
  128574. camera: FlyCamera;
  128575. /**
  128576. * Defines if touch is enabled. (Default is true.)
  128577. */
  128578. touchEnabled: boolean;
  128579. /**
  128580. * Defines the buttons associated with the input to handle camera rotation.
  128581. */
  128582. buttons: number[];
  128583. /**
  128584. * Assign buttons for Yaw control.
  128585. */
  128586. buttonsYaw: number[];
  128587. /**
  128588. * Assign buttons for Pitch control.
  128589. */
  128590. buttonsPitch: number[];
  128591. /**
  128592. * Assign buttons for Roll control.
  128593. */
  128594. buttonsRoll: number[];
  128595. /**
  128596. * Detect if any button is being pressed while mouse is moved.
  128597. * -1 = Mouse locked.
  128598. * 0 = Left button.
  128599. * 1 = Middle Button.
  128600. * 2 = Right Button.
  128601. */
  128602. activeButton: number;
  128603. /**
  128604. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  128605. * Higher values reduce its sensitivity.
  128606. */
  128607. angularSensibility: number;
  128608. private _observer;
  128609. private _rollObserver;
  128610. private previousPosition;
  128611. private noPreventDefault;
  128612. private element;
  128613. /**
  128614. * Listen to mouse events to control the camera.
  128615. * @param touchEnabled Define if touch is enabled. (Default is true.)
  128616. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128617. */
  128618. constructor(touchEnabled?: boolean);
  128619. /**
  128620. * Attach the mouse control to the HTML DOM element.
  128621. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  128622. */
  128623. attachControl(noPreventDefault?: boolean): void;
  128624. /**
  128625. * Detach the current controls from the specified dom element.
  128626. */
  128627. detachControl(): void;
  128628. /**
  128629. * Gets the class name of the current input.
  128630. * @returns the class name.
  128631. */
  128632. getClassName(): string;
  128633. /**
  128634. * Get the friendly name associated with the input class.
  128635. * @returns the input's friendly name.
  128636. */
  128637. getSimpleName(): string;
  128638. private _pointerInput;
  128639. private _onMouseMove;
  128640. /**
  128641. * Rotate camera by mouse offset.
  128642. */
  128643. private rotateCamera;
  128644. }
  128645. }
  128646. declare module BABYLON {
  128647. /**
  128648. * Default Inputs manager for the FlyCamera.
  128649. * It groups all the default supported inputs for ease of use.
  128650. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128651. */
  128652. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  128653. /**
  128654. * Instantiates a new FlyCameraInputsManager.
  128655. * @param camera Defines the camera the inputs belong to.
  128656. */
  128657. constructor(camera: FlyCamera);
  128658. /**
  128659. * Add keyboard input support to the input manager.
  128660. * @returns the new FlyCameraKeyboardMoveInput().
  128661. */
  128662. addKeyboard(): FlyCameraInputsManager;
  128663. /**
  128664. * Add mouse input support to the input manager.
  128665. * @param touchEnabled Enable touch screen support.
  128666. * @returns the new FlyCameraMouseInput().
  128667. */
  128668. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  128669. }
  128670. }
  128671. declare module BABYLON {
  128672. /**
  128673. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128674. * such as in a 3D Space Shooter or a Flight Simulator.
  128675. */
  128676. export class FlyCamera extends TargetCamera {
  128677. /**
  128678. * Define the collision ellipsoid of the camera.
  128679. * This is helpful for simulating a camera body, like a player's body.
  128680. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  128681. */
  128682. ellipsoid: Vector3;
  128683. /**
  128684. * Define an offset for the position of the ellipsoid around the camera.
  128685. * This can be helpful if the camera is attached away from the player's body center,
  128686. * such as at its head.
  128687. */
  128688. ellipsoidOffset: Vector3;
  128689. /**
  128690. * Enable or disable collisions of the camera with the rest of the scene objects.
  128691. */
  128692. checkCollisions: boolean;
  128693. /**
  128694. * Enable or disable gravity on the camera.
  128695. */
  128696. applyGravity: boolean;
  128697. /**
  128698. * Define the current direction the camera is moving to.
  128699. */
  128700. cameraDirection: Vector3;
  128701. /**
  128702. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  128703. * This overrides and empties cameraRotation.
  128704. */
  128705. rotationQuaternion: Quaternion;
  128706. /**
  128707. * Track Roll to maintain the wanted Rolling when looking around.
  128708. */
  128709. _trackRoll: number;
  128710. /**
  128711. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  128712. */
  128713. rollCorrect: number;
  128714. /**
  128715. * Mimic a banked turn, Rolling the camera when Yawing.
  128716. * It's recommended to use rollCorrect = 10 for faster banking correction.
  128717. */
  128718. bankedTurn: boolean;
  128719. /**
  128720. * Limit in radians for how much Roll banking will add. (Default: 90°)
  128721. */
  128722. bankedTurnLimit: number;
  128723. /**
  128724. * Value of 0 disables the banked Roll.
  128725. * Value of 1 is equal to the Yaw angle in radians.
  128726. */
  128727. bankedTurnMultiplier: number;
  128728. /**
  128729. * The inputs manager loads all the input sources, such as keyboard and mouse.
  128730. */
  128731. inputs: FlyCameraInputsManager;
  128732. /**
  128733. * Gets the input sensibility for mouse input.
  128734. * Higher values reduce sensitivity.
  128735. */
  128736. get angularSensibility(): number;
  128737. /**
  128738. * Sets the input sensibility for a mouse input.
  128739. * Higher values reduce sensitivity.
  128740. */
  128741. set angularSensibility(value: number);
  128742. /**
  128743. * Get the keys for camera movement forward.
  128744. */
  128745. get keysForward(): number[];
  128746. /**
  128747. * Set the keys for camera movement forward.
  128748. */
  128749. set keysForward(value: number[]);
  128750. /**
  128751. * Get the keys for camera movement backward.
  128752. */
  128753. get keysBackward(): number[];
  128754. set keysBackward(value: number[]);
  128755. /**
  128756. * Get the keys for camera movement up.
  128757. */
  128758. get keysUp(): number[];
  128759. /**
  128760. * Set the keys for camera movement up.
  128761. */
  128762. set keysUp(value: number[]);
  128763. /**
  128764. * Get the keys for camera movement down.
  128765. */
  128766. get keysDown(): number[];
  128767. /**
  128768. * Set the keys for camera movement down.
  128769. */
  128770. set keysDown(value: number[]);
  128771. /**
  128772. * Get the keys for camera movement left.
  128773. */
  128774. get keysLeft(): number[];
  128775. /**
  128776. * Set the keys for camera movement left.
  128777. */
  128778. set keysLeft(value: number[]);
  128779. /**
  128780. * Set the keys for camera movement right.
  128781. */
  128782. get keysRight(): number[];
  128783. /**
  128784. * Set the keys for camera movement right.
  128785. */
  128786. set keysRight(value: number[]);
  128787. /**
  128788. * Event raised when the camera collides with a mesh in the scene.
  128789. */
  128790. onCollide: (collidedMesh: AbstractMesh) => void;
  128791. private _collider;
  128792. private _needMoveForGravity;
  128793. private _oldPosition;
  128794. private _diffPosition;
  128795. private _newPosition;
  128796. /** @hidden */
  128797. _localDirection: Vector3;
  128798. /** @hidden */
  128799. _transformedDirection: Vector3;
  128800. /**
  128801. * Instantiates a FlyCamera.
  128802. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128803. * such as in a 3D Space Shooter or a Flight Simulator.
  128804. * @param name Define the name of the camera in the scene.
  128805. * @param position Define the starting position of the camera in the scene.
  128806. * @param scene Define the scene the camera belongs to.
  128807. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  128808. */
  128809. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  128810. /**
  128811. * Attach a control to the HTML DOM element.
  128812. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  128813. */
  128814. attachControl(noPreventDefault?: boolean): void;
  128815. /**
  128816. * Detach a control from the HTML DOM element.
  128817. * The camera will stop reacting to that input.
  128818. */
  128819. detachControl(): void;
  128820. private _collisionMask;
  128821. /**
  128822. * Get the mask that the camera ignores in collision events.
  128823. */
  128824. get collisionMask(): number;
  128825. /**
  128826. * Set the mask that the camera ignores in collision events.
  128827. */
  128828. set collisionMask(mask: number);
  128829. /** @hidden */
  128830. _collideWithWorld(displacement: Vector3): void;
  128831. /** @hidden */
  128832. private _onCollisionPositionChange;
  128833. /** @hidden */
  128834. _checkInputs(): void;
  128835. /** @hidden */
  128836. _decideIfNeedsToMove(): boolean;
  128837. /** @hidden */
  128838. _updatePosition(): void;
  128839. /**
  128840. * Restore the Roll to its target value at the rate specified.
  128841. * @param rate - Higher means slower restoring.
  128842. * @hidden
  128843. */
  128844. restoreRoll(rate: number): void;
  128845. /**
  128846. * Destroy the camera and release the current resources held by it.
  128847. */
  128848. dispose(): void;
  128849. /**
  128850. * Get the current object class name.
  128851. * @returns the class name.
  128852. */
  128853. getClassName(): string;
  128854. }
  128855. }
  128856. declare module BABYLON {
  128857. /**
  128858. * Listen to keyboard events to control the camera.
  128859. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128860. */
  128861. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  128862. /**
  128863. * Defines the camera the input is attached to.
  128864. */
  128865. camera: FlyCamera;
  128866. /**
  128867. * The list of keyboard keys used to control the forward move of the camera.
  128868. */
  128869. keysForward: number[];
  128870. /**
  128871. * The list of keyboard keys used to control the backward move of the camera.
  128872. */
  128873. keysBackward: number[];
  128874. /**
  128875. * The list of keyboard keys used to control the forward move of the camera.
  128876. */
  128877. keysUp: number[];
  128878. /**
  128879. * The list of keyboard keys used to control the backward move of the camera.
  128880. */
  128881. keysDown: number[];
  128882. /**
  128883. * The list of keyboard keys used to control the right strafe move of the camera.
  128884. */
  128885. keysRight: number[];
  128886. /**
  128887. * The list of keyboard keys used to control the left strafe move of the camera.
  128888. */
  128889. keysLeft: number[];
  128890. private _keys;
  128891. private _onCanvasBlurObserver;
  128892. private _onKeyboardObserver;
  128893. private _engine;
  128894. private _scene;
  128895. /**
  128896. * Attach the input controls to a specific dom element to get the input from.
  128897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128898. */
  128899. attachControl(noPreventDefault?: boolean): void;
  128900. /**
  128901. * Detach the current controls from the specified dom element.
  128902. */
  128903. detachControl(): void;
  128904. /**
  128905. * Gets the class name of the current intput.
  128906. * @returns the class name
  128907. */
  128908. getClassName(): string;
  128909. /** @hidden */
  128910. _onLostFocus(e: FocusEvent): void;
  128911. /**
  128912. * Get the friendly name associated with the input class.
  128913. * @returns the input friendly name
  128914. */
  128915. getSimpleName(): string;
  128916. /**
  128917. * Update the current camera state depending on the inputs that have been used this frame.
  128918. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128919. */
  128920. checkInputs(): void;
  128921. }
  128922. }
  128923. declare module BABYLON {
  128924. /**
  128925. * Manage the mouse wheel inputs to control a follow camera.
  128926. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128927. */
  128928. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  128929. /**
  128930. * Defines the camera the input is attached to.
  128931. */
  128932. camera: FollowCamera;
  128933. /**
  128934. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  128935. */
  128936. axisControlRadius: boolean;
  128937. /**
  128938. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  128939. */
  128940. axisControlHeight: boolean;
  128941. /**
  128942. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  128943. */
  128944. axisControlRotation: boolean;
  128945. /**
  128946. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  128947. * relation to mouseWheel events.
  128948. */
  128949. wheelPrecision: number;
  128950. /**
  128951. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  128952. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  128953. */
  128954. wheelDeltaPercentage: number;
  128955. private _wheel;
  128956. private _observer;
  128957. /**
  128958. * Attach the input controls to a specific dom element to get the input from.
  128959. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128960. */
  128961. attachControl(noPreventDefault?: boolean): void;
  128962. /**
  128963. * Detach the current controls from the specified dom element.
  128964. */
  128965. detachControl(): void;
  128966. /**
  128967. * Gets the class name of the current intput.
  128968. * @returns the class name
  128969. */
  128970. getClassName(): string;
  128971. /**
  128972. * Get the friendly name associated with the input class.
  128973. * @returns the input friendly name
  128974. */
  128975. getSimpleName(): string;
  128976. }
  128977. }
  128978. declare module BABYLON {
  128979. /**
  128980. * Manage the pointers inputs to control an follow camera.
  128981. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128982. */
  128983. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  128984. /**
  128985. * Defines the camera the input is attached to.
  128986. */
  128987. camera: FollowCamera;
  128988. /**
  128989. * Gets the class name of the current input.
  128990. * @returns the class name
  128991. */
  128992. getClassName(): string;
  128993. /**
  128994. * Defines the pointer angular sensibility along the X axis or how fast is
  128995. * the camera rotating.
  128996. * A negative number will reverse the axis direction.
  128997. */
  128998. angularSensibilityX: number;
  128999. /**
  129000. * Defines the pointer angular sensibility along the Y axis or how fast is
  129001. * the camera rotating.
  129002. * A negative number will reverse the axis direction.
  129003. */
  129004. angularSensibilityY: number;
  129005. /**
  129006. * Defines the pointer pinch precision or how fast is the camera zooming.
  129007. * A negative number will reverse the axis direction.
  129008. */
  129009. pinchPrecision: number;
  129010. /**
  129011. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  129012. * from 0.
  129013. * It defines the percentage of current camera.radius to use as delta when
  129014. * pinch zoom is used.
  129015. */
  129016. pinchDeltaPercentage: number;
  129017. /**
  129018. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  129019. */
  129020. axisXControlRadius: boolean;
  129021. /**
  129022. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  129023. */
  129024. axisXControlHeight: boolean;
  129025. /**
  129026. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  129027. */
  129028. axisXControlRotation: boolean;
  129029. /**
  129030. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  129031. */
  129032. axisYControlRadius: boolean;
  129033. /**
  129034. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  129035. */
  129036. axisYControlHeight: boolean;
  129037. /**
  129038. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  129039. */
  129040. axisYControlRotation: boolean;
  129041. /**
  129042. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  129043. */
  129044. axisPinchControlRadius: boolean;
  129045. /**
  129046. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  129047. */
  129048. axisPinchControlHeight: boolean;
  129049. /**
  129050. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  129051. */
  129052. axisPinchControlRotation: boolean;
  129053. /**
  129054. * Log error messages if basic misconfiguration has occurred.
  129055. */
  129056. warningEnable: boolean;
  129057. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  129058. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  129059. private _warningCounter;
  129060. private _warning;
  129061. }
  129062. }
  129063. declare module BABYLON {
  129064. /**
  129065. * Default Inputs manager for the FollowCamera.
  129066. * It groups all the default supported inputs for ease of use.
  129067. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129068. */
  129069. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  129070. /**
  129071. * Instantiates a new FollowCameraInputsManager.
  129072. * @param camera Defines the camera the inputs belong to
  129073. */
  129074. constructor(camera: FollowCamera);
  129075. /**
  129076. * Add keyboard input support to the input manager.
  129077. * @returns the current input manager
  129078. */
  129079. addKeyboard(): FollowCameraInputsManager;
  129080. /**
  129081. * Add mouse wheel input support to the input manager.
  129082. * @returns the current input manager
  129083. */
  129084. addMouseWheel(): FollowCameraInputsManager;
  129085. /**
  129086. * Add pointers input support to the input manager.
  129087. * @returns the current input manager
  129088. */
  129089. addPointers(): FollowCameraInputsManager;
  129090. /**
  129091. * Add orientation input support to the input manager.
  129092. * @returns the current input manager
  129093. */
  129094. addVRDeviceOrientation(): FollowCameraInputsManager;
  129095. }
  129096. }
  129097. declare module BABYLON {
  129098. /**
  129099. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  129100. * an arc rotate version arcFollowCamera are available.
  129101. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129102. */
  129103. export class FollowCamera extends TargetCamera {
  129104. /**
  129105. * Distance the follow camera should follow an object at
  129106. */
  129107. radius: number;
  129108. /**
  129109. * Minimum allowed distance of the camera to the axis of rotation
  129110. * (The camera can not get closer).
  129111. * This can help limiting how the Camera is able to move in the scene.
  129112. */
  129113. lowerRadiusLimit: Nullable<number>;
  129114. /**
  129115. * Maximum allowed distance of the camera to the axis of rotation
  129116. * (The camera can not get further).
  129117. * This can help limiting how the Camera is able to move in the scene.
  129118. */
  129119. upperRadiusLimit: Nullable<number>;
  129120. /**
  129121. * Define a rotation offset between the camera and the object it follows
  129122. */
  129123. rotationOffset: number;
  129124. /**
  129125. * Minimum allowed angle to camera position relative to target object.
  129126. * This can help limiting how the Camera is able to move in the scene.
  129127. */
  129128. lowerRotationOffsetLimit: Nullable<number>;
  129129. /**
  129130. * Maximum allowed angle to camera position relative to target object.
  129131. * This can help limiting how the Camera is able to move in the scene.
  129132. */
  129133. upperRotationOffsetLimit: Nullable<number>;
  129134. /**
  129135. * Define a height offset between the camera and the object it follows.
  129136. * It can help following an object from the top (like a car chaing a plane)
  129137. */
  129138. heightOffset: number;
  129139. /**
  129140. * Minimum allowed height of camera position relative to target object.
  129141. * This can help limiting how the Camera is able to move in the scene.
  129142. */
  129143. lowerHeightOffsetLimit: Nullable<number>;
  129144. /**
  129145. * Maximum allowed height of camera position relative to target object.
  129146. * This can help limiting how the Camera is able to move in the scene.
  129147. */
  129148. upperHeightOffsetLimit: Nullable<number>;
  129149. /**
  129150. * Define how fast the camera can accelerate to follow it s target.
  129151. */
  129152. cameraAcceleration: number;
  129153. /**
  129154. * Define the speed limit of the camera following an object.
  129155. */
  129156. maxCameraSpeed: number;
  129157. /**
  129158. * Define the target of the camera.
  129159. */
  129160. lockedTarget: Nullable<AbstractMesh>;
  129161. /**
  129162. * Defines the input associated with the camera.
  129163. */
  129164. inputs: FollowCameraInputsManager;
  129165. /**
  129166. * Instantiates the follow camera.
  129167. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129168. * @param name Define the name of the camera in the scene
  129169. * @param position Define the position of the camera
  129170. * @param scene Define the scene the camera belong to
  129171. * @param lockedTarget Define the target of the camera
  129172. */
  129173. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  129174. private _follow;
  129175. /**
  129176. * Attached controls to the current camera.
  129177. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129178. */
  129179. attachControl(noPreventDefault?: boolean): void;
  129180. /**
  129181. * Detach the current controls from the camera.
  129182. * The camera will stop reacting to inputs.
  129183. */
  129184. detachControl(): void;
  129185. /** @hidden */
  129186. _checkInputs(): void;
  129187. private _checkLimits;
  129188. /**
  129189. * Gets the camera class name.
  129190. * @returns the class name
  129191. */
  129192. getClassName(): string;
  129193. }
  129194. /**
  129195. * Arc Rotate version of the follow camera.
  129196. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  129197. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129198. */
  129199. export class ArcFollowCamera extends TargetCamera {
  129200. /** The longitudinal angle of the camera */
  129201. alpha: number;
  129202. /** The latitudinal angle of the camera */
  129203. beta: number;
  129204. /** The radius of the camera from its target */
  129205. radius: number;
  129206. private _cartesianCoordinates;
  129207. /** Define the camera target (the mesh it should follow) */
  129208. private _meshTarget;
  129209. /**
  129210. * Instantiates a new ArcFollowCamera
  129211. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129212. * @param name Define the name of the camera
  129213. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  129214. * @param beta Define the rotation angle of the camera around the elevation axis
  129215. * @param radius Define the radius of the camera from its target point
  129216. * @param target Define the target of the camera
  129217. * @param scene Define the scene the camera belongs to
  129218. */
  129219. constructor(name: string,
  129220. /** The longitudinal angle of the camera */
  129221. alpha: number,
  129222. /** The latitudinal angle of the camera */
  129223. beta: number,
  129224. /** The radius of the camera from its target */
  129225. radius: number,
  129226. /** Define the camera target (the mesh it should follow) */
  129227. target: Nullable<AbstractMesh>, scene: Scene);
  129228. private _follow;
  129229. /** @hidden */
  129230. _checkInputs(): void;
  129231. /**
  129232. * Returns the class name of the object.
  129233. * It is mostly used internally for serialization purposes.
  129234. */
  129235. getClassName(): string;
  129236. }
  129237. }
  129238. declare module BABYLON {
  129239. /**
  129240. * Manage the keyboard inputs to control the movement of a follow camera.
  129241. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129242. */
  129243. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  129244. /**
  129245. * Defines the camera the input is attached to.
  129246. */
  129247. camera: FollowCamera;
  129248. /**
  129249. * Defines the list of key codes associated with the up action (increase heightOffset)
  129250. */
  129251. keysHeightOffsetIncr: number[];
  129252. /**
  129253. * Defines the list of key codes associated with the down action (decrease heightOffset)
  129254. */
  129255. keysHeightOffsetDecr: number[];
  129256. /**
  129257. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  129258. */
  129259. keysHeightOffsetModifierAlt: boolean;
  129260. /**
  129261. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  129262. */
  129263. keysHeightOffsetModifierCtrl: boolean;
  129264. /**
  129265. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  129266. */
  129267. keysHeightOffsetModifierShift: boolean;
  129268. /**
  129269. * Defines the list of key codes associated with the left action (increase rotationOffset)
  129270. */
  129271. keysRotationOffsetIncr: number[];
  129272. /**
  129273. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  129274. */
  129275. keysRotationOffsetDecr: number[];
  129276. /**
  129277. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  129278. */
  129279. keysRotationOffsetModifierAlt: boolean;
  129280. /**
  129281. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  129282. */
  129283. keysRotationOffsetModifierCtrl: boolean;
  129284. /**
  129285. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  129286. */
  129287. keysRotationOffsetModifierShift: boolean;
  129288. /**
  129289. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  129290. */
  129291. keysRadiusIncr: number[];
  129292. /**
  129293. * Defines the list of key codes associated with the zoom-out action (increase radius)
  129294. */
  129295. keysRadiusDecr: number[];
  129296. /**
  129297. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  129298. */
  129299. keysRadiusModifierAlt: boolean;
  129300. /**
  129301. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  129302. */
  129303. keysRadiusModifierCtrl: boolean;
  129304. /**
  129305. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  129306. */
  129307. keysRadiusModifierShift: boolean;
  129308. /**
  129309. * Defines the rate of change of heightOffset.
  129310. */
  129311. heightSensibility: number;
  129312. /**
  129313. * Defines the rate of change of rotationOffset.
  129314. */
  129315. rotationSensibility: number;
  129316. /**
  129317. * Defines the rate of change of radius.
  129318. */
  129319. radiusSensibility: number;
  129320. private _keys;
  129321. private _ctrlPressed;
  129322. private _altPressed;
  129323. private _shiftPressed;
  129324. private _onCanvasBlurObserver;
  129325. private _onKeyboardObserver;
  129326. private _engine;
  129327. private _scene;
  129328. /**
  129329. * Attach the input controls to a specific dom element to get the input from.
  129330. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129331. */
  129332. attachControl(noPreventDefault?: boolean): void;
  129333. /**
  129334. * Detach the current controls from the specified dom element.
  129335. */
  129336. detachControl(): void;
  129337. /**
  129338. * Update the current camera state depending on the inputs that have been used this frame.
  129339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129340. */
  129341. checkInputs(): void;
  129342. /**
  129343. * Gets the class name of the current input.
  129344. * @returns the class name
  129345. */
  129346. getClassName(): string;
  129347. /**
  129348. * Get the friendly name associated with the input class.
  129349. * @returns the input friendly name
  129350. */
  129351. getSimpleName(): string;
  129352. /**
  129353. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129354. * allow modification of the heightOffset value.
  129355. */
  129356. private _modifierHeightOffset;
  129357. /**
  129358. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129359. * allow modification of the rotationOffset value.
  129360. */
  129361. private _modifierRotationOffset;
  129362. /**
  129363. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129364. * allow modification of the radius value.
  129365. */
  129366. private _modifierRadius;
  129367. }
  129368. }
  129369. declare module BABYLON {
  129370. interface FreeCameraInputsManager {
  129371. /**
  129372. * @hidden
  129373. */
  129374. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  129375. /**
  129376. * Add orientation input support to the input manager.
  129377. * @returns the current input manager
  129378. */
  129379. addDeviceOrientation(): FreeCameraInputsManager;
  129380. }
  129381. /**
  129382. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  129383. * Screen rotation is taken into account.
  129384. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129385. */
  129386. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  129387. private _camera;
  129388. private _screenOrientationAngle;
  129389. private _constantTranform;
  129390. private _screenQuaternion;
  129391. private _alpha;
  129392. private _beta;
  129393. private _gamma;
  129394. /**
  129395. * Can be used to detect if a device orientation sensor is available on a device
  129396. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  129397. * @returns a promise that will resolve on orientation change
  129398. */
  129399. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  129400. /**
  129401. * @hidden
  129402. */
  129403. _onDeviceOrientationChangedObservable: Observable<void>;
  129404. /**
  129405. * Instantiates a new input
  129406. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129407. */
  129408. constructor();
  129409. /**
  129410. * Define the camera controlled by the input.
  129411. */
  129412. get camera(): FreeCamera;
  129413. set camera(camera: FreeCamera);
  129414. /**
  129415. * Attach the input controls to a specific dom element to get the input from.
  129416. */
  129417. attachControl(): void;
  129418. private _orientationChanged;
  129419. private _deviceOrientation;
  129420. /**
  129421. * Detach the current controls from the specified dom element.
  129422. */
  129423. detachControl(): void;
  129424. /**
  129425. * Update the current camera state depending on the inputs that have been used this frame.
  129426. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129427. */
  129428. checkInputs(): void;
  129429. /**
  129430. * Gets the class name of the current intput.
  129431. * @returns the class name
  129432. */
  129433. getClassName(): string;
  129434. /**
  129435. * Get the friendly name associated with the input class.
  129436. * @returns the input friendly name
  129437. */
  129438. getSimpleName(): string;
  129439. }
  129440. }
  129441. declare module BABYLON {
  129442. /**
  129443. * Manage the gamepad inputs to control a free camera.
  129444. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129445. */
  129446. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  129447. /**
  129448. * Define the camera the input is attached to.
  129449. */
  129450. camera: FreeCamera;
  129451. /**
  129452. * Define the Gamepad controlling the input
  129453. */
  129454. gamepad: Nullable<Gamepad>;
  129455. /**
  129456. * Defines the gamepad rotation sensiblity.
  129457. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129458. */
  129459. gamepadAngularSensibility: number;
  129460. /**
  129461. * Defines the gamepad move sensiblity.
  129462. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129463. */
  129464. gamepadMoveSensibility: number;
  129465. private _yAxisScale;
  129466. /**
  129467. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  129468. */
  129469. get invertYAxis(): boolean;
  129470. set invertYAxis(value: boolean);
  129471. private _onGamepadConnectedObserver;
  129472. private _onGamepadDisconnectedObserver;
  129473. private _cameraTransform;
  129474. private _deltaTransform;
  129475. private _vector3;
  129476. private _vector2;
  129477. /**
  129478. * Attach the input controls to a specific dom element to get the input from.
  129479. */
  129480. attachControl(): void;
  129481. /**
  129482. * Detach the current controls from the specified dom element.
  129483. */
  129484. detachControl(): void;
  129485. /**
  129486. * Update the current camera state depending on the inputs that have been used this frame.
  129487. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129488. */
  129489. checkInputs(): void;
  129490. /**
  129491. * Gets the class name of the current intput.
  129492. * @returns the class name
  129493. */
  129494. getClassName(): string;
  129495. /**
  129496. * Get the friendly name associated with the input class.
  129497. * @returns the input friendly name
  129498. */
  129499. getSimpleName(): string;
  129500. }
  129501. }
  129502. declare module BABYLON {
  129503. /**
  129504. * Defines the potential axis of a Joystick
  129505. */
  129506. export enum JoystickAxis {
  129507. /** X axis */
  129508. X = 0,
  129509. /** Y axis */
  129510. Y = 1,
  129511. /** Z axis */
  129512. Z = 2
  129513. }
  129514. /**
  129515. * Represents the different customization options available
  129516. * for VirtualJoystick
  129517. */
  129518. interface VirtualJoystickCustomizations {
  129519. /**
  129520. * Size of the joystick's puck
  129521. */
  129522. puckSize: number;
  129523. /**
  129524. * Size of the joystick's container
  129525. */
  129526. containerSize: number;
  129527. /**
  129528. * Color of the joystick && puck
  129529. */
  129530. color: string;
  129531. /**
  129532. * Image URL for the joystick's puck
  129533. */
  129534. puckImage?: string;
  129535. /**
  129536. * Image URL for the joystick's container
  129537. */
  129538. containerImage?: string;
  129539. /**
  129540. * Defines the unmoving position of the joystick container
  129541. */
  129542. position?: {
  129543. x: number;
  129544. y: number;
  129545. };
  129546. /**
  129547. * Defines whether or not the joystick container is always visible
  129548. */
  129549. alwaysVisible: boolean;
  129550. /**
  129551. * Defines whether or not to limit the movement of the puck to the joystick's container
  129552. */
  129553. limitToContainer: boolean;
  129554. }
  129555. /**
  129556. * Class used to define virtual joystick (used in touch mode)
  129557. */
  129558. export class VirtualJoystick {
  129559. /**
  129560. * Gets or sets a boolean indicating that left and right values must be inverted
  129561. */
  129562. reverseLeftRight: boolean;
  129563. /**
  129564. * Gets or sets a boolean indicating that up and down values must be inverted
  129565. */
  129566. reverseUpDown: boolean;
  129567. /**
  129568. * Gets the offset value for the position (ie. the change of the position value)
  129569. */
  129570. deltaPosition: Vector3;
  129571. /**
  129572. * Gets a boolean indicating if the virtual joystick was pressed
  129573. */
  129574. pressed: boolean;
  129575. /**
  129576. * Canvas the virtual joystick will render onto, default z-index of this is 5
  129577. */
  129578. static Canvas: Nullable<HTMLCanvasElement>;
  129579. /**
  129580. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  129581. */
  129582. limitToContainer: boolean;
  129583. private static _globalJoystickIndex;
  129584. private static _alwaysVisibleSticks;
  129585. private static vjCanvasContext;
  129586. private static vjCanvasWidth;
  129587. private static vjCanvasHeight;
  129588. private static halfWidth;
  129589. private static _GetDefaultOptions;
  129590. private _action;
  129591. private _axisTargetedByLeftAndRight;
  129592. private _axisTargetedByUpAndDown;
  129593. private _joystickSensibility;
  129594. private _inversedSensibility;
  129595. private _joystickPointerID;
  129596. private _joystickColor;
  129597. private _joystickPointerPos;
  129598. private _joystickPreviousPointerPos;
  129599. private _joystickPointerStartPos;
  129600. private _deltaJoystickVector;
  129601. private _leftJoystick;
  129602. private _touches;
  129603. private _joystickPosition;
  129604. private _alwaysVisible;
  129605. private _puckImage;
  129606. private _containerImage;
  129607. private _joystickPuckSize;
  129608. private _joystickContainerSize;
  129609. private _clearPuckSize;
  129610. private _clearContainerSize;
  129611. private _clearPuckSizeOffset;
  129612. private _clearContainerSizeOffset;
  129613. private _onPointerDownHandlerRef;
  129614. private _onPointerMoveHandlerRef;
  129615. private _onPointerUpHandlerRef;
  129616. private _onResize;
  129617. /**
  129618. * Creates a new virtual joystick
  129619. * @param leftJoystick defines that the joystick is for left hand (false by default)
  129620. * @param customizations Defines the options we want to customize the VirtualJoystick
  129621. */
  129622. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  129623. /**
  129624. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  129625. * @param newJoystickSensibility defines the new sensibility
  129626. */
  129627. setJoystickSensibility(newJoystickSensibility: number): void;
  129628. private _onPointerDown;
  129629. private _onPointerMove;
  129630. private _onPointerUp;
  129631. /**
  129632. * Change the color of the virtual joystick
  129633. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  129634. */
  129635. setJoystickColor(newColor: string): void;
  129636. /**
  129637. * Size of the joystick's container
  129638. */
  129639. set containerSize(newSize: number);
  129640. get containerSize(): number;
  129641. /**
  129642. * Size of the joystick's puck
  129643. */
  129644. set puckSize(newSize: number);
  129645. get puckSize(): number;
  129646. /**
  129647. * Clears the set position of the joystick
  129648. */
  129649. clearPosition(): void;
  129650. /**
  129651. * Defines whether or not the joystick container is always visible
  129652. */
  129653. set alwaysVisible(value: boolean);
  129654. get alwaysVisible(): boolean;
  129655. /**
  129656. * Sets the constant position of the Joystick container
  129657. * @param x X axis coordinate
  129658. * @param y Y axis coordinate
  129659. */
  129660. setPosition(x: number, y: number): void;
  129661. /**
  129662. * Defines a callback to call when the joystick is touched
  129663. * @param action defines the callback
  129664. */
  129665. setActionOnTouch(action: () => any): void;
  129666. /**
  129667. * Defines which axis you'd like to control for left & right
  129668. * @param axis defines the axis to use
  129669. */
  129670. setAxisForLeftRight(axis: JoystickAxis): void;
  129671. /**
  129672. * Defines which axis you'd like to control for up & down
  129673. * @param axis defines the axis to use
  129674. */
  129675. setAxisForUpDown(axis: JoystickAxis): void;
  129676. /**
  129677. * Clears the canvas from the previous puck / container draw
  129678. */
  129679. private _clearPreviousDraw;
  129680. /**
  129681. * Loads `urlPath` to be used for the container's image
  129682. * @param urlPath defines the urlPath of an image to use
  129683. */
  129684. setContainerImage(urlPath: string): void;
  129685. /**
  129686. * Loads `urlPath` to be used for the puck's image
  129687. * @param urlPath defines the urlPath of an image to use
  129688. */
  129689. setPuckImage(urlPath: string): void;
  129690. /**
  129691. * Draws the Virtual Joystick's container
  129692. */
  129693. private _drawContainer;
  129694. /**
  129695. * Draws the Virtual Joystick's puck
  129696. */
  129697. private _drawPuck;
  129698. private _drawVirtualJoystick;
  129699. /**
  129700. * Release internal HTML canvas
  129701. */
  129702. releaseCanvas(): void;
  129703. }
  129704. }
  129705. declare module BABYLON {
  129706. interface FreeCameraInputsManager {
  129707. /**
  129708. * Add virtual joystick input support to the input manager.
  129709. * @returns the current input manager
  129710. */
  129711. addVirtualJoystick(): FreeCameraInputsManager;
  129712. }
  129713. /**
  129714. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  129715. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129716. */
  129717. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  129718. /**
  129719. * Defines the camera the input is attached to.
  129720. */
  129721. camera: FreeCamera;
  129722. private _leftjoystick;
  129723. private _rightjoystick;
  129724. /**
  129725. * Gets the left stick of the virtual joystick.
  129726. * @returns The virtual Joystick
  129727. */
  129728. getLeftJoystick(): VirtualJoystick;
  129729. /**
  129730. * Gets the right stick of the virtual joystick.
  129731. * @returns The virtual Joystick
  129732. */
  129733. getRightJoystick(): VirtualJoystick;
  129734. /**
  129735. * Update the current camera state depending on the inputs that have been used this frame.
  129736. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129737. */
  129738. checkInputs(): void;
  129739. /**
  129740. * Attach the input controls to a specific dom element to get the input from.
  129741. */
  129742. attachControl(): void;
  129743. /**
  129744. * Detach the current controls from the specified dom element.
  129745. */
  129746. detachControl(): void;
  129747. /**
  129748. * Gets the class name of the current intput.
  129749. * @returns the class name
  129750. */
  129751. getClassName(): string;
  129752. /**
  129753. * Get the friendly name associated with the input class.
  129754. * @returns the input friendly name
  129755. */
  129756. getSimpleName(): string;
  129757. }
  129758. }
  129759. declare module BABYLON {
  129760. /**
  129761. * This represents a FPS type of camera controlled by touch.
  129762. * This is like a universal camera minus the Gamepad controls.
  129763. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129764. */
  129765. export class TouchCamera extends FreeCamera {
  129766. /**
  129767. * Defines the touch sensibility for rotation.
  129768. * The higher the faster.
  129769. */
  129770. get touchAngularSensibility(): number;
  129771. set touchAngularSensibility(value: number);
  129772. /**
  129773. * Defines the touch sensibility for move.
  129774. * The higher the faster.
  129775. */
  129776. get touchMoveSensibility(): number;
  129777. set touchMoveSensibility(value: number);
  129778. /**
  129779. * Instantiates a new touch camera.
  129780. * This represents a FPS type of camera controlled by touch.
  129781. * This is like a universal camera minus the Gamepad controls.
  129782. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129783. * @param name Define the name of the camera in the scene
  129784. * @param position Define the start position of the camera in the scene
  129785. * @param scene Define the scene the camera belongs to
  129786. */
  129787. constructor(name: string, position: Vector3, scene: Scene);
  129788. /**
  129789. * Gets the current object class name.
  129790. * @return the class name
  129791. */
  129792. getClassName(): string;
  129793. /** @hidden */
  129794. _setupInputs(): void;
  129795. }
  129796. }
  129797. declare module BABYLON {
  129798. /**
  129799. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  129800. * being tilted forward or back and left or right.
  129801. */
  129802. export class DeviceOrientationCamera extends FreeCamera {
  129803. private _initialQuaternion;
  129804. private _quaternionCache;
  129805. private _tmpDragQuaternion;
  129806. private _disablePointerInputWhenUsingDeviceOrientation;
  129807. /**
  129808. * Creates a new device orientation camera
  129809. * @param name The name of the camera
  129810. * @param position The start position camera
  129811. * @param scene The scene the camera belongs to
  129812. */
  129813. constructor(name: string, position: Vector3, scene: Scene);
  129814. /**
  129815. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  129816. */
  129817. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  129818. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  129819. private _dragFactor;
  129820. /**
  129821. * Enabled turning on the y axis when the orientation sensor is active
  129822. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  129823. */
  129824. enableHorizontalDragging(dragFactor?: number): void;
  129825. /**
  129826. * Gets the current instance class name ("DeviceOrientationCamera").
  129827. * This helps avoiding instanceof at run time.
  129828. * @returns the class name
  129829. */
  129830. getClassName(): string;
  129831. /**
  129832. * @hidden
  129833. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  129834. */
  129835. _checkInputs(): void;
  129836. /**
  129837. * Reset the camera to its default orientation on the specified axis only.
  129838. * @param axis The axis to reset
  129839. */
  129840. resetToCurrentRotation(axis?: Axis): void;
  129841. }
  129842. }
  129843. declare module BABYLON {
  129844. /**
  129845. * Defines supported buttons for XBox360 compatible gamepads
  129846. */
  129847. export enum Xbox360Button {
  129848. /** A */
  129849. A = 0,
  129850. /** B */
  129851. B = 1,
  129852. /** X */
  129853. X = 2,
  129854. /** Y */
  129855. Y = 3,
  129856. /** Left button */
  129857. LB = 4,
  129858. /** Right button */
  129859. RB = 5,
  129860. /** Back */
  129861. Back = 8,
  129862. /** Start */
  129863. Start = 9,
  129864. /** Left stick */
  129865. LeftStick = 10,
  129866. /** Right stick */
  129867. RightStick = 11
  129868. }
  129869. /** Defines values for XBox360 DPad */
  129870. export enum Xbox360Dpad {
  129871. /** Up */
  129872. Up = 12,
  129873. /** Down */
  129874. Down = 13,
  129875. /** Left */
  129876. Left = 14,
  129877. /** Right */
  129878. Right = 15
  129879. }
  129880. /**
  129881. * Defines a XBox360 gamepad
  129882. */
  129883. export class Xbox360Pad extends Gamepad {
  129884. private _leftTrigger;
  129885. private _rightTrigger;
  129886. private _onlefttriggerchanged;
  129887. private _onrighttriggerchanged;
  129888. private _onbuttondown;
  129889. private _onbuttonup;
  129890. private _ondpaddown;
  129891. private _ondpadup;
  129892. /** Observable raised when a button is pressed */
  129893. onButtonDownObservable: Observable<Xbox360Button>;
  129894. /** Observable raised when a button is released */
  129895. onButtonUpObservable: Observable<Xbox360Button>;
  129896. /** Observable raised when a pad is pressed */
  129897. onPadDownObservable: Observable<Xbox360Dpad>;
  129898. /** Observable raised when a pad is released */
  129899. onPadUpObservable: Observable<Xbox360Dpad>;
  129900. private _buttonA;
  129901. private _buttonB;
  129902. private _buttonX;
  129903. private _buttonY;
  129904. private _buttonBack;
  129905. private _buttonStart;
  129906. private _buttonLB;
  129907. private _buttonRB;
  129908. private _buttonLeftStick;
  129909. private _buttonRightStick;
  129910. private _dPadUp;
  129911. private _dPadDown;
  129912. private _dPadLeft;
  129913. private _dPadRight;
  129914. private _isXboxOnePad;
  129915. /**
  129916. * Creates a new XBox360 gamepad object
  129917. * @param id defines the id of this gamepad
  129918. * @param index defines its index
  129919. * @param gamepad defines the internal HTML gamepad object
  129920. * @param xboxOne defines if it is a XBox One gamepad
  129921. */
  129922. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  129923. /**
  129924. * Defines the callback to call when left trigger is pressed
  129925. * @param callback defines the callback to use
  129926. */
  129927. onlefttriggerchanged(callback: (value: number) => void): void;
  129928. /**
  129929. * Defines the callback to call when right trigger is pressed
  129930. * @param callback defines the callback to use
  129931. */
  129932. onrighttriggerchanged(callback: (value: number) => void): void;
  129933. /**
  129934. * Gets the left trigger value
  129935. */
  129936. get leftTrigger(): number;
  129937. /**
  129938. * Sets the left trigger value
  129939. */
  129940. set leftTrigger(newValue: number);
  129941. /**
  129942. * Gets the right trigger value
  129943. */
  129944. get rightTrigger(): number;
  129945. /**
  129946. * Sets the right trigger value
  129947. */
  129948. set rightTrigger(newValue: number);
  129949. /**
  129950. * Defines the callback to call when a button is pressed
  129951. * @param callback defines the callback to use
  129952. */
  129953. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  129954. /**
  129955. * Defines the callback to call when a button is released
  129956. * @param callback defines the callback to use
  129957. */
  129958. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  129959. /**
  129960. * Defines the callback to call when a pad is pressed
  129961. * @param callback defines the callback to use
  129962. */
  129963. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  129964. /**
  129965. * Defines the callback to call when a pad is released
  129966. * @param callback defines the callback to use
  129967. */
  129968. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  129969. private _setButtonValue;
  129970. private _setDPadValue;
  129971. /**
  129972. * Gets the value of the `A` button
  129973. */
  129974. get buttonA(): number;
  129975. /**
  129976. * Sets the value of the `A` button
  129977. */
  129978. set buttonA(value: number);
  129979. /**
  129980. * Gets the value of the `B` button
  129981. */
  129982. get buttonB(): number;
  129983. /**
  129984. * Sets the value of the `B` button
  129985. */
  129986. set buttonB(value: number);
  129987. /**
  129988. * Gets the value of the `X` button
  129989. */
  129990. get buttonX(): number;
  129991. /**
  129992. * Sets the value of the `X` button
  129993. */
  129994. set buttonX(value: number);
  129995. /**
  129996. * Gets the value of the `Y` button
  129997. */
  129998. get buttonY(): number;
  129999. /**
  130000. * Sets the value of the `Y` button
  130001. */
  130002. set buttonY(value: number);
  130003. /**
  130004. * Gets the value of the `Start` button
  130005. */
  130006. get buttonStart(): number;
  130007. /**
  130008. * Sets the value of the `Start` button
  130009. */
  130010. set buttonStart(value: number);
  130011. /**
  130012. * Gets the value of the `Back` button
  130013. */
  130014. get buttonBack(): number;
  130015. /**
  130016. * Sets the value of the `Back` button
  130017. */
  130018. set buttonBack(value: number);
  130019. /**
  130020. * Gets the value of the `Left` button
  130021. */
  130022. get buttonLB(): number;
  130023. /**
  130024. * Sets the value of the `Left` button
  130025. */
  130026. set buttonLB(value: number);
  130027. /**
  130028. * Gets the value of the `Right` button
  130029. */
  130030. get buttonRB(): number;
  130031. /**
  130032. * Sets the value of the `Right` button
  130033. */
  130034. set buttonRB(value: number);
  130035. /**
  130036. * Gets the value of the Left joystick
  130037. */
  130038. get buttonLeftStick(): number;
  130039. /**
  130040. * Sets the value of the Left joystick
  130041. */
  130042. set buttonLeftStick(value: number);
  130043. /**
  130044. * Gets the value of the Right joystick
  130045. */
  130046. get buttonRightStick(): number;
  130047. /**
  130048. * Sets the value of the Right joystick
  130049. */
  130050. set buttonRightStick(value: number);
  130051. /**
  130052. * Gets the value of D-pad up
  130053. */
  130054. get dPadUp(): number;
  130055. /**
  130056. * Sets the value of D-pad up
  130057. */
  130058. set dPadUp(value: number);
  130059. /**
  130060. * Gets the value of D-pad down
  130061. */
  130062. get dPadDown(): number;
  130063. /**
  130064. * Sets the value of D-pad down
  130065. */
  130066. set dPadDown(value: number);
  130067. /**
  130068. * Gets the value of D-pad left
  130069. */
  130070. get dPadLeft(): number;
  130071. /**
  130072. * Sets the value of D-pad left
  130073. */
  130074. set dPadLeft(value: number);
  130075. /**
  130076. * Gets the value of D-pad right
  130077. */
  130078. get dPadRight(): number;
  130079. /**
  130080. * Sets the value of D-pad right
  130081. */
  130082. set dPadRight(value: number);
  130083. /**
  130084. * Force the gamepad to synchronize with device values
  130085. */
  130086. update(): void;
  130087. /**
  130088. * Disposes the gamepad
  130089. */
  130090. dispose(): void;
  130091. }
  130092. }
  130093. declare module BABYLON {
  130094. /**
  130095. * Defines supported buttons for DualShock compatible gamepads
  130096. */
  130097. export enum DualShockButton {
  130098. /** Cross */
  130099. Cross = 0,
  130100. /** Circle */
  130101. Circle = 1,
  130102. /** Square */
  130103. Square = 2,
  130104. /** Triangle */
  130105. Triangle = 3,
  130106. /** L1 */
  130107. L1 = 4,
  130108. /** R1 */
  130109. R1 = 5,
  130110. /** Share */
  130111. Share = 8,
  130112. /** Options */
  130113. Options = 9,
  130114. /** Left stick */
  130115. LeftStick = 10,
  130116. /** Right stick */
  130117. RightStick = 11
  130118. }
  130119. /** Defines values for DualShock DPad */
  130120. export enum DualShockDpad {
  130121. /** Up */
  130122. Up = 12,
  130123. /** Down */
  130124. Down = 13,
  130125. /** Left */
  130126. Left = 14,
  130127. /** Right */
  130128. Right = 15
  130129. }
  130130. /**
  130131. * Defines a DualShock gamepad
  130132. */
  130133. export class DualShockPad extends Gamepad {
  130134. private _leftTrigger;
  130135. private _rightTrigger;
  130136. private _onlefttriggerchanged;
  130137. private _onrighttriggerchanged;
  130138. private _onbuttondown;
  130139. private _onbuttonup;
  130140. private _ondpaddown;
  130141. private _ondpadup;
  130142. /** Observable raised when a button is pressed */
  130143. onButtonDownObservable: Observable<DualShockButton>;
  130144. /** Observable raised when a button is released */
  130145. onButtonUpObservable: Observable<DualShockButton>;
  130146. /** Observable raised when a pad is pressed */
  130147. onPadDownObservable: Observable<DualShockDpad>;
  130148. /** Observable raised when a pad is released */
  130149. onPadUpObservable: Observable<DualShockDpad>;
  130150. private _buttonCross;
  130151. private _buttonCircle;
  130152. private _buttonSquare;
  130153. private _buttonTriangle;
  130154. private _buttonShare;
  130155. private _buttonOptions;
  130156. private _buttonL1;
  130157. private _buttonR1;
  130158. private _buttonLeftStick;
  130159. private _buttonRightStick;
  130160. private _dPadUp;
  130161. private _dPadDown;
  130162. private _dPadLeft;
  130163. private _dPadRight;
  130164. /**
  130165. * Creates a new DualShock gamepad object
  130166. * @param id defines the id of this gamepad
  130167. * @param index defines its index
  130168. * @param gamepad defines the internal HTML gamepad object
  130169. */
  130170. constructor(id: string, index: number, gamepad: any);
  130171. /**
  130172. * Defines the callback to call when left trigger is pressed
  130173. * @param callback defines the callback to use
  130174. */
  130175. onlefttriggerchanged(callback: (value: number) => void): void;
  130176. /**
  130177. * Defines the callback to call when right trigger is pressed
  130178. * @param callback defines the callback to use
  130179. */
  130180. onrighttriggerchanged(callback: (value: number) => void): void;
  130181. /**
  130182. * Gets the left trigger value
  130183. */
  130184. get leftTrigger(): number;
  130185. /**
  130186. * Sets the left trigger value
  130187. */
  130188. set leftTrigger(newValue: number);
  130189. /**
  130190. * Gets the right trigger value
  130191. */
  130192. get rightTrigger(): number;
  130193. /**
  130194. * Sets the right trigger value
  130195. */
  130196. set rightTrigger(newValue: number);
  130197. /**
  130198. * Defines the callback to call when a button is pressed
  130199. * @param callback defines the callback to use
  130200. */
  130201. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  130202. /**
  130203. * Defines the callback to call when a button is released
  130204. * @param callback defines the callback to use
  130205. */
  130206. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  130207. /**
  130208. * Defines the callback to call when a pad is pressed
  130209. * @param callback defines the callback to use
  130210. */
  130211. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  130212. /**
  130213. * Defines the callback to call when a pad is released
  130214. * @param callback defines the callback to use
  130215. */
  130216. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  130217. private _setButtonValue;
  130218. private _setDPadValue;
  130219. /**
  130220. * Gets the value of the `Cross` button
  130221. */
  130222. get buttonCross(): number;
  130223. /**
  130224. * Sets the value of the `Cross` button
  130225. */
  130226. set buttonCross(value: number);
  130227. /**
  130228. * Gets the value of the `Circle` button
  130229. */
  130230. get buttonCircle(): number;
  130231. /**
  130232. * Sets the value of the `Circle` button
  130233. */
  130234. set buttonCircle(value: number);
  130235. /**
  130236. * Gets the value of the `Square` button
  130237. */
  130238. get buttonSquare(): number;
  130239. /**
  130240. * Sets the value of the `Square` button
  130241. */
  130242. set buttonSquare(value: number);
  130243. /**
  130244. * Gets the value of the `Triangle` button
  130245. */
  130246. get buttonTriangle(): number;
  130247. /**
  130248. * Sets the value of the `Triangle` button
  130249. */
  130250. set buttonTriangle(value: number);
  130251. /**
  130252. * Gets the value of the `Options` button
  130253. */
  130254. get buttonOptions(): number;
  130255. /**
  130256. * Sets the value of the `Options` button
  130257. */
  130258. set buttonOptions(value: number);
  130259. /**
  130260. * Gets the value of the `Share` button
  130261. */
  130262. get buttonShare(): number;
  130263. /**
  130264. * Sets the value of the `Share` button
  130265. */
  130266. set buttonShare(value: number);
  130267. /**
  130268. * Gets the value of the `L1` button
  130269. */
  130270. get buttonL1(): number;
  130271. /**
  130272. * Sets the value of the `L1` button
  130273. */
  130274. set buttonL1(value: number);
  130275. /**
  130276. * Gets the value of the `R1` button
  130277. */
  130278. get buttonR1(): number;
  130279. /**
  130280. * Sets the value of the `R1` button
  130281. */
  130282. set buttonR1(value: number);
  130283. /**
  130284. * Gets the value of the Left joystick
  130285. */
  130286. get buttonLeftStick(): number;
  130287. /**
  130288. * Sets the value of the Left joystick
  130289. */
  130290. set buttonLeftStick(value: number);
  130291. /**
  130292. * Gets the value of the Right joystick
  130293. */
  130294. get buttonRightStick(): number;
  130295. /**
  130296. * Sets the value of the Right joystick
  130297. */
  130298. set buttonRightStick(value: number);
  130299. /**
  130300. * Gets the value of D-pad up
  130301. */
  130302. get dPadUp(): number;
  130303. /**
  130304. * Sets the value of D-pad up
  130305. */
  130306. set dPadUp(value: number);
  130307. /**
  130308. * Gets the value of D-pad down
  130309. */
  130310. get dPadDown(): number;
  130311. /**
  130312. * Sets the value of D-pad down
  130313. */
  130314. set dPadDown(value: number);
  130315. /**
  130316. * Gets the value of D-pad left
  130317. */
  130318. get dPadLeft(): number;
  130319. /**
  130320. * Sets the value of D-pad left
  130321. */
  130322. set dPadLeft(value: number);
  130323. /**
  130324. * Gets the value of D-pad right
  130325. */
  130326. get dPadRight(): number;
  130327. /**
  130328. * Sets the value of D-pad right
  130329. */
  130330. set dPadRight(value: number);
  130331. /**
  130332. * Force the gamepad to synchronize with device values
  130333. */
  130334. update(): void;
  130335. /**
  130336. * Disposes the gamepad
  130337. */
  130338. dispose(): void;
  130339. }
  130340. }
  130341. declare module BABYLON {
  130342. /**
  130343. * Manager for handling gamepads
  130344. */
  130345. export class GamepadManager {
  130346. private _scene?;
  130347. private _babylonGamepads;
  130348. private _oneGamepadConnected;
  130349. /** @hidden */
  130350. _isMonitoring: boolean;
  130351. private _gamepadEventSupported;
  130352. private _gamepadSupport?;
  130353. /**
  130354. * observable to be triggered when the gamepad controller has been connected
  130355. */
  130356. onGamepadConnectedObservable: Observable<Gamepad>;
  130357. /**
  130358. * observable to be triggered when the gamepad controller has been disconnected
  130359. */
  130360. onGamepadDisconnectedObservable: Observable<Gamepad>;
  130361. private _onGamepadConnectedEvent;
  130362. private _onGamepadDisconnectedEvent;
  130363. /**
  130364. * Initializes the gamepad manager
  130365. * @param _scene BabylonJS scene
  130366. */
  130367. constructor(_scene?: Scene | undefined);
  130368. /**
  130369. * The gamepads in the game pad manager
  130370. */
  130371. get gamepads(): Gamepad[];
  130372. /**
  130373. * Get the gamepad controllers based on type
  130374. * @param type The type of gamepad controller
  130375. * @returns Nullable gamepad
  130376. */
  130377. getGamepadByType(type?: number): Nullable<Gamepad>;
  130378. /**
  130379. * Disposes the gamepad manager
  130380. */
  130381. dispose(): void;
  130382. private _addNewGamepad;
  130383. private _startMonitoringGamepads;
  130384. private _stopMonitoringGamepads;
  130385. /** @hidden */
  130386. _checkGamepadsStatus(): void;
  130387. private _updateGamepadObjects;
  130388. }
  130389. }
  130390. declare module BABYLON {
  130391. interface Scene {
  130392. /** @hidden */
  130393. _gamepadManager: Nullable<GamepadManager>;
  130394. /**
  130395. * Gets the gamepad manager associated with the scene
  130396. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  130397. */
  130398. gamepadManager: GamepadManager;
  130399. }
  130400. /**
  130401. * Interface representing a free camera inputs manager
  130402. */
  130403. interface FreeCameraInputsManager {
  130404. /**
  130405. * Adds gamepad input support to the FreeCameraInputsManager.
  130406. * @returns the FreeCameraInputsManager
  130407. */
  130408. addGamepad(): FreeCameraInputsManager;
  130409. }
  130410. /**
  130411. * Interface representing an arc rotate camera inputs manager
  130412. */
  130413. interface ArcRotateCameraInputsManager {
  130414. /**
  130415. * Adds gamepad input support to the ArcRotateCamera InputManager.
  130416. * @returns the camera inputs manager
  130417. */
  130418. addGamepad(): ArcRotateCameraInputsManager;
  130419. }
  130420. /**
  130421. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  130422. */
  130423. export class GamepadSystemSceneComponent implements ISceneComponent {
  130424. /**
  130425. * The component name helpfull to identify the component in the list of scene components.
  130426. */
  130427. readonly name: string;
  130428. /**
  130429. * The scene the component belongs to.
  130430. */
  130431. scene: Scene;
  130432. /**
  130433. * Creates a new instance of the component for the given scene
  130434. * @param scene Defines the scene to register the component in
  130435. */
  130436. constructor(scene: Scene);
  130437. /**
  130438. * Registers the component in a given scene
  130439. */
  130440. register(): void;
  130441. /**
  130442. * Rebuilds the elements related to this component in case of
  130443. * context lost for instance.
  130444. */
  130445. rebuild(): void;
  130446. /**
  130447. * Disposes the component and the associated ressources
  130448. */
  130449. dispose(): void;
  130450. private _beforeCameraUpdate;
  130451. }
  130452. }
  130453. declare module BABYLON {
  130454. /**
  130455. * 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,
  130456. * which still works and will still be found in many Playgrounds.
  130457. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130458. */
  130459. export class UniversalCamera extends TouchCamera {
  130460. /**
  130461. * Defines the gamepad rotation sensiblity.
  130462. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  130463. */
  130464. get gamepadAngularSensibility(): number;
  130465. set gamepadAngularSensibility(value: number);
  130466. /**
  130467. * Defines the gamepad move sensiblity.
  130468. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  130469. */
  130470. get gamepadMoveSensibility(): number;
  130471. set gamepadMoveSensibility(value: number);
  130472. /**
  130473. * 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,
  130474. * which still works and will still be found in many Playgrounds.
  130475. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130476. * @param name Define the name of the camera in the scene
  130477. * @param position Define the start position of the camera in the scene
  130478. * @param scene Define the scene the camera belongs to
  130479. */
  130480. constructor(name: string, position: Vector3, scene: Scene);
  130481. /**
  130482. * Gets the current object class name.
  130483. * @return the class name
  130484. */
  130485. getClassName(): string;
  130486. }
  130487. }
  130488. declare module BABYLON {
  130489. /**
  130490. * This represents a FPS type of camera. This is only here for back compat purpose.
  130491. * Please use the UniversalCamera instead as both are identical.
  130492. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130493. */
  130494. export class GamepadCamera extends UniversalCamera {
  130495. /**
  130496. * Instantiates a new Gamepad Camera
  130497. * This represents a FPS type of camera. This is only here for back compat purpose.
  130498. * Please use the UniversalCamera instead as both are identical.
  130499. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130500. * @param name Define the name of the camera in the scene
  130501. * @param position Define the start position of the camera in the scene
  130502. * @param scene Define the scene the camera belongs to
  130503. */
  130504. constructor(name: string, position: Vector3, scene: Scene);
  130505. /**
  130506. * Gets the current object class name.
  130507. * @return the class name
  130508. */
  130509. getClassName(): string;
  130510. }
  130511. }
  130512. declare module BABYLON {
  130513. /** @hidden */
  130514. export var passPixelShader: {
  130515. name: string;
  130516. shader: string;
  130517. };
  130518. }
  130519. declare module BABYLON {
  130520. /** @hidden */
  130521. export var passCubePixelShader: {
  130522. name: string;
  130523. shader: string;
  130524. };
  130525. }
  130526. declare module BABYLON {
  130527. /**
  130528. * PassPostProcess which produces an output the same as it's input
  130529. */
  130530. export class PassPostProcess extends PostProcess {
  130531. /**
  130532. * Gets a string identifying the name of the class
  130533. * @returns "PassPostProcess" string
  130534. */
  130535. getClassName(): string;
  130536. /**
  130537. * Creates the PassPostProcess
  130538. * @param name The name of the effect.
  130539. * @param options The required width/height ratio to downsize to before computing the render pass.
  130540. * @param camera The camera to apply the render pass to.
  130541. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130542. * @param engine The engine which the post process will be applied. (default: current engine)
  130543. * @param reusable If the post process can be reused on the same frame. (default: false)
  130544. * @param textureType The type of texture to be used when performing the post processing.
  130545. * @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)
  130546. */
  130547. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130548. /** @hidden */
  130549. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  130550. }
  130551. /**
  130552. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  130553. */
  130554. export class PassCubePostProcess extends PostProcess {
  130555. private _face;
  130556. /**
  130557. * Gets or sets the cube face to display.
  130558. * * 0 is +X
  130559. * * 1 is -X
  130560. * * 2 is +Y
  130561. * * 3 is -Y
  130562. * * 4 is +Z
  130563. * * 5 is -Z
  130564. */
  130565. get face(): number;
  130566. set face(value: number);
  130567. /**
  130568. * Gets a string identifying the name of the class
  130569. * @returns "PassCubePostProcess" string
  130570. */
  130571. getClassName(): string;
  130572. /**
  130573. * Creates the PassCubePostProcess
  130574. * @param name The name of the effect.
  130575. * @param options The required width/height ratio to downsize to before computing the render pass.
  130576. * @param camera The camera to apply the render pass to.
  130577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130578. * @param engine The engine which the post process will be applied. (default: current engine)
  130579. * @param reusable If the post process can be reused on the same frame. (default: false)
  130580. * @param textureType The type of texture to be used when performing the post processing.
  130581. * @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)
  130582. */
  130583. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130584. /** @hidden */
  130585. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  130586. }
  130587. }
  130588. declare module BABYLON {
  130589. /** @hidden */
  130590. export var anaglyphPixelShader: {
  130591. name: string;
  130592. shader: string;
  130593. };
  130594. }
  130595. declare module BABYLON {
  130596. /**
  130597. * Postprocess used to generate anaglyphic rendering
  130598. */
  130599. export class AnaglyphPostProcess extends PostProcess {
  130600. private _passedProcess;
  130601. /**
  130602. * Gets a string identifying the name of the class
  130603. * @returns "AnaglyphPostProcess" string
  130604. */
  130605. getClassName(): string;
  130606. /**
  130607. * Creates a new AnaglyphPostProcess
  130608. * @param name defines postprocess name
  130609. * @param options defines creation options or target ratio scale
  130610. * @param rigCameras defines cameras using this postprocess
  130611. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  130612. * @param engine defines hosting engine
  130613. * @param reusable defines if the postprocess will be reused multiple times per frame
  130614. */
  130615. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  130616. }
  130617. }
  130618. declare module BABYLON {
  130619. /**
  130620. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  130621. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130622. */
  130623. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  130624. /**
  130625. * Creates a new AnaglyphArcRotateCamera
  130626. * @param name defines camera name
  130627. * @param alpha defines alpha angle (in radians)
  130628. * @param beta defines beta angle (in radians)
  130629. * @param radius defines radius
  130630. * @param target defines camera target
  130631. * @param interaxialDistance defines distance between each color axis
  130632. * @param scene defines the hosting scene
  130633. */
  130634. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  130635. /**
  130636. * Gets camera class name
  130637. * @returns AnaglyphArcRotateCamera
  130638. */
  130639. getClassName(): string;
  130640. }
  130641. }
  130642. declare module BABYLON {
  130643. /**
  130644. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  130645. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130646. */
  130647. export class AnaglyphFreeCamera extends FreeCamera {
  130648. /**
  130649. * Creates a new AnaglyphFreeCamera
  130650. * @param name defines camera name
  130651. * @param position defines initial position
  130652. * @param interaxialDistance defines distance between each color axis
  130653. * @param scene defines the hosting scene
  130654. */
  130655. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130656. /**
  130657. * Gets camera class name
  130658. * @returns AnaglyphFreeCamera
  130659. */
  130660. getClassName(): string;
  130661. }
  130662. }
  130663. declare module BABYLON {
  130664. /**
  130665. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  130666. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130667. */
  130668. export class AnaglyphGamepadCamera extends GamepadCamera {
  130669. /**
  130670. * Creates a new AnaglyphGamepadCamera
  130671. * @param name defines camera name
  130672. * @param position defines initial position
  130673. * @param interaxialDistance defines distance between each color axis
  130674. * @param scene defines the hosting scene
  130675. */
  130676. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130677. /**
  130678. * Gets camera class name
  130679. * @returns AnaglyphGamepadCamera
  130680. */
  130681. getClassName(): string;
  130682. }
  130683. }
  130684. declare module BABYLON {
  130685. /**
  130686. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  130687. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130688. */
  130689. export class AnaglyphUniversalCamera extends UniversalCamera {
  130690. /**
  130691. * Creates a new AnaglyphUniversalCamera
  130692. * @param name defines camera name
  130693. * @param position defines initial position
  130694. * @param interaxialDistance defines distance between each color axis
  130695. * @param scene defines the hosting scene
  130696. */
  130697. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130698. /**
  130699. * Gets camera class name
  130700. * @returns AnaglyphUniversalCamera
  130701. */
  130702. getClassName(): string;
  130703. }
  130704. }
  130705. declare module BABYLON {
  130706. /**
  130707. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  130708. * @see https://doc.babylonjs.com/features/cameras
  130709. */
  130710. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  130711. /**
  130712. * Creates a new StereoscopicArcRotateCamera
  130713. * @param name defines camera name
  130714. * @param alpha defines alpha angle (in radians)
  130715. * @param beta defines beta angle (in radians)
  130716. * @param radius defines radius
  130717. * @param target defines camera target
  130718. * @param interaxialDistance defines distance between each color axis
  130719. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130720. * @param scene defines the hosting scene
  130721. */
  130722. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130723. /**
  130724. * Gets camera class name
  130725. * @returns StereoscopicArcRotateCamera
  130726. */
  130727. getClassName(): string;
  130728. }
  130729. }
  130730. declare module BABYLON {
  130731. /**
  130732. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  130733. * @see https://doc.babylonjs.com/features/cameras
  130734. */
  130735. export class StereoscopicFreeCamera extends FreeCamera {
  130736. /**
  130737. * Creates a new StereoscopicFreeCamera
  130738. * @param name defines camera name
  130739. * @param position defines initial position
  130740. * @param interaxialDistance defines distance between each color axis
  130741. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130742. * @param scene defines the hosting scene
  130743. */
  130744. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130745. /**
  130746. * Gets camera class name
  130747. * @returns StereoscopicFreeCamera
  130748. */
  130749. getClassName(): string;
  130750. }
  130751. }
  130752. declare module BABYLON {
  130753. /**
  130754. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  130755. * @see https://doc.babylonjs.com/features/cameras
  130756. */
  130757. export class StereoscopicGamepadCamera extends GamepadCamera {
  130758. /**
  130759. * Creates a new StereoscopicGamepadCamera
  130760. * @param name defines camera name
  130761. * @param position defines initial position
  130762. * @param interaxialDistance defines distance between each color axis
  130763. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130764. * @param scene defines the hosting scene
  130765. */
  130766. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130767. /**
  130768. * Gets camera class name
  130769. * @returns StereoscopicGamepadCamera
  130770. */
  130771. getClassName(): string;
  130772. }
  130773. }
  130774. declare module BABYLON {
  130775. /**
  130776. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  130777. * @see https://doc.babylonjs.com/features/cameras
  130778. */
  130779. export class StereoscopicUniversalCamera extends UniversalCamera {
  130780. /**
  130781. * Creates a new StereoscopicUniversalCamera
  130782. * @param name defines camera name
  130783. * @param position defines initial position
  130784. * @param interaxialDistance defines distance between each color axis
  130785. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130786. * @param scene defines the hosting scene
  130787. */
  130788. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130789. /**
  130790. * Gets camera class name
  130791. * @returns StereoscopicUniversalCamera
  130792. */
  130793. getClassName(): string;
  130794. }
  130795. }
  130796. declare module BABYLON {
  130797. /**
  130798. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  130799. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130800. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130801. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130802. */
  130803. export class VirtualJoysticksCamera extends FreeCamera {
  130804. /**
  130805. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  130806. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130807. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130808. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130809. * @param name Define the name of the camera in the scene
  130810. * @param position Define the start position of the camera in the scene
  130811. * @param scene Define the scene the camera belongs to
  130812. */
  130813. constructor(name: string, position: Vector3, scene: Scene);
  130814. /**
  130815. * Gets the current object class name.
  130816. * @return the class name
  130817. */
  130818. getClassName(): string;
  130819. }
  130820. }
  130821. declare module BABYLON {
  130822. /**
  130823. * This represents all the required metrics to create a VR camera.
  130824. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  130825. */
  130826. export class VRCameraMetrics {
  130827. /**
  130828. * Define the horizontal resolution off the screen.
  130829. */
  130830. hResolution: number;
  130831. /**
  130832. * Define the vertical resolution off the screen.
  130833. */
  130834. vResolution: number;
  130835. /**
  130836. * Define the horizontal screen size.
  130837. */
  130838. hScreenSize: number;
  130839. /**
  130840. * Define the vertical screen size.
  130841. */
  130842. vScreenSize: number;
  130843. /**
  130844. * Define the vertical screen center position.
  130845. */
  130846. vScreenCenter: number;
  130847. /**
  130848. * Define the distance of the eyes to the screen.
  130849. */
  130850. eyeToScreenDistance: number;
  130851. /**
  130852. * Define the distance between both lenses
  130853. */
  130854. lensSeparationDistance: number;
  130855. /**
  130856. * Define the distance between both viewer's eyes.
  130857. */
  130858. interpupillaryDistance: number;
  130859. /**
  130860. * Define the distortion factor of the VR postprocess.
  130861. * Please, touch with care.
  130862. */
  130863. distortionK: number[];
  130864. /**
  130865. * Define the chromatic aberration correction factors for the VR post process.
  130866. */
  130867. chromaAbCorrection: number[];
  130868. /**
  130869. * Define the scale factor of the post process.
  130870. * The smaller the better but the slower.
  130871. */
  130872. postProcessScaleFactor: number;
  130873. /**
  130874. * Define an offset for the lens center.
  130875. */
  130876. lensCenterOffset: number;
  130877. /**
  130878. * Define if the current vr camera should compensate the distortion of the lense or not.
  130879. */
  130880. compensateDistortion: boolean;
  130881. /**
  130882. * Defines if multiview should be enabled when rendering (Default: false)
  130883. */
  130884. multiviewEnabled: boolean;
  130885. /**
  130886. * Gets the rendering aspect ratio based on the provided resolutions.
  130887. */
  130888. get aspectRatio(): number;
  130889. /**
  130890. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  130891. */
  130892. get aspectRatioFov(): number;
  130893. /**
  130894. * @hidden
  130895. */
  130896. get leftHMatrix(): Matrix;
  130897. /**
  130898. * @hidden
  130899. */
  130900. get rightHMatrix(): Matrix;
  130901. /**
  130902. * @hidden
  130903. */
  130904. get leftPreViewMatrix(): Matrix;
  130905. /**
  130906. * @hidden
  130907. */
  130908. get rightPreViewMatrix(): Matrix;
  130909. /**
  130910. * Get the default VRMetrics based on the most generic setup.
  130911. * @returns the default vr metrics
  130912. */
  130913. static GetDefault(): VRCameraMetrics;
  130914. }
  130915. }
  130916. declare module BABYLON {
  130917. /** @hidden */
  130918. export var vrDistortionCorrectionPixelShader: {
  130919. name: string;
  130920. shader: string;
  130921. };
  130922. }
  130923. declare module BABYLON {
  130924. /**
  130925. * VRDistortionCorrectionPostProcess used for mobile VR
  130926. */
  130927. export class VRDistortionCorrectionPostProcess extends PostProcess {
  130928. private _isRightEye;
  130929. private _distortionFactors;
  130930. private _postProcessScaleFactor;
  130931. private _lensCenterOffset;
  130932. private _scaleIn;
  130933. private _scaleFactor;
  130934. private _lensCenter;
  130935. /**
  130936. * Gets a string identifying the name of the class
  130937. * @returns "VRDistortionCorrectionPostProcess" string
  130938. */
  130939. getClassName(): string;
  130940. /**
  130941. * Initializes the VRDistortionCorrectionPostProcess
  130942. * @param name The name of the effect.
  130943. * @param camera The camera to apply the render pass to.
  130944. * @param isRightEye If this is for the right eye distortion
  130945. * @param vrMetrics All the required metrics for the VR camera
  130946. */
  130947. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  130948. }
  130949. }
  130950. declare module BABYLON {
  130951. /**
  130952. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  130953. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130954. */
  130955. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  130956. /**
  130957. * Creates a new VRDeviceOrientationArcRotateCamera
  130958. * @param name defines camera name
  130959. * @param alpha defines the camera rotation along the logitudinal axis
  130960. * @param beta defines the camera rotation along the latitudinal axis
  130961. * @param radius defines the camera distance from its target
  130962. * @param target defines the camera target
  130963. * @param scene defines the scene the camera belongs to
  130964. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130965. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130966. */
  130967. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130968. /**
  130969. * Gets camera class name
  130970. * @returns VRDeviceOrientationArcRotateCamera
  130971. */
  130972. getClassName(): string;
  130973. }
  130974. }
  130975. declare module BABYLON {
  130976. /**
  130977. * Camera used to simulate VR rendering (based on FreeCamera)
  130978. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130979. */
  130980. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  130981. /**
  130982. * Creates a new VRDeviceOrientationFreeCamera
  130983. * @param name defines camera name
  130984. * @param position defines the start position of the camera
  130985. * @param scene defines the scene the camera belongs to
  130986. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130987. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130988. */
  130989. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130990. /**
  130991. * Gets camera class name
  130992. * @returns VRDeviceOrientationFreeCamera
  130993. */
  130994. getClassName(): string;
  130995. }
  130996. }
  130997. declare module BABYLON {
  130998. /**
  130999. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  131000. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131001. */
  131002. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  131003. /**
  131004. * Creates a new VRDeviceOrientationGamepadCamera
  131005. * @param name defines camera name
  131006. * @param position defines the start position of the camera
  131007. * @param scene defines the scene the camera belongs to
  131008. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131009. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131010. */
  131011. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131012. /**
  131013. * Gets camera class name
  131014. * @returns VRDeviceOrientationGamepadCamera
  131015. */
  131016. getClassName(): string;
  131017. }
  131018. }
  131019. declare module BABYLON {
  131020. /**
  131021. * A class extending Texture allowing drawing on a texture
  131022. * @see https://doc.babylonjs.com/how_to/dynamictexture
  131023. */
  131024. export class DynamicTexture extends Texture {
  131025. private _generateMipMaps;
  131026. private _canvas;
  131027. private _context;
  131028. /**
  131029. * Creates a DynamicTexture
  131030. * @param name defines the name of the texture
  131031. * @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
  131032. * @param scene defines the scene where you want the texture
  131033. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  131034. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131035. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  131036. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  131037. */
  131038. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  131039. /**
  131040. * Get the current class name of the texture useful for serialization or dynamic coding.
  131041. * @returns "DynamicTexture"
  131042. */
  131043. getClassName(): string;
  131044. /**
  131045. * Gets the current state of canRescale
  131046. */
  131047. get canRescale(): boolean;
  131048. private _recreate;
  131049. /**
  131050. * Scales the texture
  131051. * @param ratio the scale factor to apply to both width and height
  131052. */
  131053. scale(ratio: number): void;
  131054. /**
  131055. * Resizes the texture
  131056. * @param width the new width
  131057. * @param height the new height
  131058. */
  131059. scaleTo(width: number, height: number): void;
  131060. /**
  131061. * Gets the context of the canvas used by the texture
  131062. * @returns the canvas context of the dynamic texture
  131063. */
  131064. getContext(): CanvasRenderingContext2D;
  131065. /**
  131066. * Clears the texture
  131067. */
  131068. clear(): void;
  131069. /**
  131070. * Updates the texture
  131071. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131072. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  131073. */
  131074. update(invertY?: boolean, premulAlpha?: boolean): void;
  131075. /**
  131076. * Draws text onto the texture
  131077. * @param text defines the text to be drawn
  131078. * @param x defines the placement of the text from the left
  131079. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  131080. * @param font defines the font to be used with font-style, font-size, font-name
  131081. * @param color defines the color used for the text
  131082. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  131083. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131084. * @param update defines whether texture is immediately update (default is true)
  131085. */
  131086. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  131087. /**
  131088. * Clones the texture
  131089. * @returns the clone of the texture.
  131090. */
  131091. clone(): DynamicTexture;
  131092. /**
  131093. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  131094. * @returns a serialized dynamic texture object
  131095. */
  131096. serialize(): any;
  131097. private _IsCanvasElement;
  131098. /** @hidden */
  131099. _rebuild(): void;
  131100. }
  131101. }
  131102. declare module BABYLON {
  131103. /**
  131104. * Class containing static functions to help procedurally build meshes
  131105. */
  131106. export class GroundBuilder {
  131107. /**
  131108. * Creates a ground mesh
  131109. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  131110. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  131111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131112. * @param name defines the name of the mesh
  131113. * @param options defines the options used to create the mesh
  131114. * @param scene defines the hosting scene
  131115. * @returns the ground mesh
  131116. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  131117. */
  131118. static CreateGround(name: string, options: {
  131119. width?: number;
  131120. height?: number;
  131121. subdivisions?: number;
  131122. subdivisionsX?: number;
  131123. subdivisionsY?: number;
  131124. updatable?: boolean;
  131125. }, scene: any): Mesh;
  131126. /**
  131127. * Creates a tiled ground mesh
  131128. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  131129. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  131130. * * 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
  131131. * * 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
  131132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131133. * @param name defines the name of the mesh
  131134. * @param options defines the options used to create the mesh
  131135. * @param scene defines the hosting scene
  131136. * @returns the tiled ground mesh
  131137. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  131138. */
  131139. static CreateTiledGround(name: string, options: {
  131140. xmin: number;
  131141. zmin: number;
  131142. xmax: number;
  131143. zmax: number;
  131144. subdivisions?: {
  131145. w: number;
  131146. h: number;
  131147. };
  131148. precision?: {
  131149. w: number;
  131150. h: number;
  131151. };
  131152. updatable?: boolean;
  131153. }, scene?: Nullable<Scene>): Mesh;
  131154. /**
  131155. * Creates a ground mesh from a height map
  131156. * * The parameter `url` sets the URL of the height map image resource.
  131157. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  131158. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  131159. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  131160. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  131161. * * 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.
  131162. * * 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).
  131163. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  131164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131165. * @param name defines the name of the mesh
  131166. * @param url defines the url to the height map
  131167. * @param options defines the options used to create the mesh
  131168. * @param scene defines the hosting scene
  131169. * @returns the ground mesh
  131170. * @see https://doc.babylonjs.com/babylon101/height_map
  131171. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  131172. */
  131173. static CreateGroundFromHeightMap(name: string, url: string, options: {
  131174. width?: number;
  131175. height?: number;
  131176. subdivisions?: number;
  131177. minHeight?: number;
  131178. maxHeight?: number;
  131179. colorFilter?: Color3;
  131180. alphaFilter?: number;
  131181. updatable?: boolean;
  131182. onReady?: (mesh: GroundMesh) => void;
  131183. }, scene?: Nullable<Scene>): GroundMesh;
  131184. }
  131185. }
  131186. declare module BABYLON {
  131187. /**
  131188. * Class containing static functions to help procedurally build meshes
  131189. */
  131190. export class TorusBuilder {
  131191. /**
  131192. * Creates a torus mesh
  131193. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  131194. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  131195. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  131196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131197. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131199. * @param name defines the name of the mesh
  131200. * @param options defines the options used to create the mesh
  131201. * @param scene defines the hosting scene
  131202. * @returns the torus mesh
  131203. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  131204. */
  131205. static CreateTorus(name: string, options: {
  131206. diameter?: number;
  131207. thickness?: number;
  131208. tessellation?: number;
  131209. updatable?: boolean;
  131210. sideOrientation?: number;
  131211. frontUVs?: Vector4;
  131212. backUVs?: Vector4;
  131213. }, scene: any): Mesh;
  131214. }
  131215. }
  131216. declare module BABYLON {
  131217. /**
  131218. * Class containing static functions to help procedurally build meshes
  131219. */
  131220. export class CylinderBuilder {
  131221. /**
  131222. * Creates a cylinder or a cone mesh
  131223. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  131224. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  131225. * * 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.
  131226. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  131227. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  131228. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  131229. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  131230. * * 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).
  131231. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  131232. * * 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).
  131233. * * 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
  131234. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  131235. * * 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
  131236. * * 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.
  131237. * * If `enclose` is false, a ring surface is one element.
  131238. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  131239. * * 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
  131240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131243. * @param name defines the name of the mesh
  131244. * @param options defines the options used to create the mesh
  131245. * @param scene defines the hosting scene
  131246. * @returns the cylinder mesh
  131247. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  131248. */
  131249. static CreateCylinder(name: string, options: {
  131250. height?: number;
  131251. diameterTop?: number;
  131252. diameterBottom?: number;
  131253. diameter?: number;
  131254. tessellation?: number;
  131255. subdivisions?: number;
  131256. arc?: number;
  131257. faceColors?: Color4[];
  131258. faceUV?: Vector4[];
  131259. updatable?: boolean;
  131260. hasRings?: boolean;
  131261. enclose?: boolean;
  131262. cap?: number;
  131263. sideOrientation?: number;
  131264. frontUVs?: Vector4;
  131265. backUVs?: Vector4;
  131266. }, scene: any): Mesh;
  131267. }
  131268. }
  131269. declare module BABYLON {
  131270. /**
  131271. * States of the webXR experience
  131272. */
  131273. export enum WebXRState {
  131274. /**
  131275. * Transitioning to being in XR mode
  131276. */
  131277. ENTERING_XR = 0,
  131278. /**
  131279. * Transitioning to non XR mode
  131280. */
  131281. EXITING_XR = 1,
  131282. /**
  131283. * In XR mode and presenting
  131284. */
  131285. IN_XR = 2,
  131286. /**
  131287. * Not entered XR mode
  131288. */
  131289. NOT_IN_XR = 3
  131290. }
  131291. /**
  131292. * The state of the XR camera's tracking
  131293. */
  131294. export enum WebXRTrackingState {
  131295. /**
  131296. * No transformation received, device is not being tracked
  131297. */
  131298. NOT_TRACKING = 0,
  131299. /**
  131300. * Tracking lost - using emulated position
  131301. */
  131302. TRACKING_LOST = 1,
  131303. /**
  131304. * Transformation tracking works normally
  131305. */
  131306. TRACKING = 2
  131307. }
  131308. /**
  131309. * Abstraction of the XR render target
  131310. */
  131311. export interface WebXRRenderTarget extends IDisposable {
  131312. /**
  131313. * xrpresent context of the canvas which can be used to display/mirror xr content
  131314. */
  131315. canvasContext: WebGLRenderingContext;
  131316. /**
  131317. * xr layer for the canvas
  131318. */
  131319. xrLayer: Nullable<XRWebGLLayer>;
  131320. /**
  131321. * Initializes the xr layer for the session
  131322. * @param xrSession xr session
  131323. * @returns a promise that will resolve once the XR Layer has been created
  131324. */
  131325. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  131326. }
  131327. }
  131328. declare module BABYLON {
  131329. /**
  131330. * COnfiguration object for WebXR output canvas
  131331. */
  131332. export class WebXRManagedOutputCanvasOptions {
  131333. /**
  131334. * An optional canvas in case you wish to create it yourself and provide it here.
  131335. * If not provided, a new canvas will be created
  131336. */
  131337. canvasElement?: HTMLCanvasElement;
  131338. /**
  131339. * Options for this XR Layer output
  131340. */
  131341. canvasOptions?: XRWebGLLayerInit;
  131342. /**
  131343. * CSS styling for a newly created canvas (if not provided)
  131344. */
  131345. newCanvasCssStyle?: string;
  131346. /**
  131347. * Get the default values of the configuration object
  131348. * @param engine defines the engine to use (can be null)
  131349. * @returns default values of this configuration object
  131350. */
  131351. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  131352. }
  131353. /**
  131354. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  131355. */
  131356. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  131357. private _options;
  131358. private _canvas;
  131359. private _engine;
  131360. private _originalCanvasSize;
  131361. /**
  131362. * Rendering context of the canvas which can be used to display/mirror xr content
  131363. */
  131364. canvasContext: WebGLRenderingContext;
  131365. /**
  131366. * xr layer for the canvas
  131367. */
  131368. xrLayer: Nullable<XRWebGLLayer>;
  131369. /**
  131370. * Obseervers registered here will be triggered when the xr layer was initialized
  131371. */
  131372. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  131373. /**
  131374. * Initializes the canvas to be added/removed upon entering/exiting xr
  131375. * @param _xrSessionManager The XR Session manager
  131376. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  131377. */
  131378. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  131379. /**
  131380. * Disposes of the object
  131381. */
  131382. dispose(): void;
  131383. /**
  131384. * Initializes the xr layer for the session
  131385. * @param xrSession xr session
  131386. * @returns a promise that will resolve once the XR Layer has been created
  131387. */
  131388. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  131389. private _addCanvas;
  131390. private _removeCanvas;
  131391. private _setCanvasSize;
  131392. private _setManagedOutputCanvas;
  131393. }
  131394. }
  131395. declare module BABYLON {
  131396. /**
  131397. * Manages an XRSession to work with Babylon's engine
  131398. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  131399. */
  131400. export class WebXRSessionManager implements IDisposable {
  131401. /** The scene which the session should be created for */
  131402. scene: Scene;
  131403. private _referenceSpace;
  131404. private _rttProvider;
  131405. private _sessionEnded;
  131406. private _xrNavigator;
  131407. private baseLayer;
  131408. /**
  131409. * The base reference space from which the session started. good if you want to reset your
  131410. * reference space
  131411. */
  131412. baseReferenceSpace: XRReferenceSpace;
  131413. /**
  131414. * Current XR frame
  131415. */
  131416. currentFrame: Nullable<XRFrame>;
  131417. /** WebXR timestamp updated every frame */
  131418. currentTimestamp: number;
  131419. /**
  131420. * Used just in case of a failure to initialize an immersive session.
  131421. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  131422. */
  131423. defaultHeightCompensation: number;
  131424. /**
  131425. * Fires every time a new xrFrame arrives which can be used to update the camera
  131426. */
  131427. onXRFrameObservable: Observable<XRFrame>;
  131428. /**
  131429. * Fires when the reference space changed
  131430. */
  131431. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  131432. /**
  131433. * Fires when the xr session is ended either by the device or manually done
  131434. */
  131435. onXRSessionEnded: Observable<any>;
  131436. /**
  131437. * Fires when the xr session is ended either by the device or manually done
  131438. */
  131439. onXRSessionInit: Observable<XRSession>;
  131440. /**
  131441. * Underlying xr session
  131442. */
  131443. session: XRSession;
  131444. /**
  131445. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  131446. * or get the offset the player is currently at.
  131447. */
  131448. viewerReferenceSpace: XRReferenceSpace;
  131449. /**
  131450. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  131451. * @param scene The scene which the session should be created for
  131452. */
  131453. constructor(
  131454. /** The scene which the session should be created for */
  131455. scene: Scene);
  131456. /**
  131457. * The current reference space used in this session. This reference space can constantly change!
  131458. * It is mainly used to offset the camera's position.
  131459. */
  131460. get referenceSpace(): XRReferenceSpace;
  131461. /**
  131462. * Set a new reference space and triggers the observable
  131463. */
  131464. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  131465. /**
  131466. * Disposes of the session manager
  131467. */
  131468. dispose(): void;
  131469. /**
  131470. * Stops the xrSession and restores the render loop
  131471. * @returns Promise which resolves after it exits XR
  131472. */
  131473. exitXRAsync(): Promise<void>;
  131474. /**
  131475. * Gets the correct render target texture to be rendered this frame for this eye
  131476. * @param eye the eye for which to get the render target
  131477. * @returns the render target for the specified eye
  131478. */
  131479. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  131480. /**
  131481. * Creates a WebXRRenderTarget object for the XR session
  131482. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  131483. * @param options optional options to provide when creating a new render target
  131484. * @returns a WebXR render target to which the session can render
  131485. */
  131486. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  131487. /**
  131488. * Initializes the manager
  131489. * After initialization enterXR can be called to start an XR session
  131490. * @returns Promise which resolves after it is initialized
  131491. */
  131492. initializeAsync(): Promise<void>;
  131493. /**
  131494. * Initializes an xr session
  131495. * @param xrSessionMode mode to initialize
  131496. * @param xrSessionInit defines optional and required values to pass to the session builder
  131497. * @returns a promise which will resolve once the session has been initialized
  131498. */
  131499. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  131500. /**
  131501. * Checks if a session would be supported for the creation options specified
  131502. * @param sessionMode session mode to check if supported eg. immersive-vr
  131503. * @returns A Promise that resolves to true if supported and false if not
  131504. */
  131505. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  131506. /**
  131507. * Resets the reference space to the one started the session
  131508. */
  131509. resetReferenceSpace(): void;
  131510. /**
  131511. * Starts rendering to the xr layer
  131512. */
  131513. runXRRenderLoop(): void;
  131514. /**
  131515. * Sets the reference space on the xr session
  131516. * @param referenceSpaceType space to set
  131517. * @returns a promise that will resolve once the reference space has been set
  131518. */
  131519. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  131520. /**
  131521. * Updates the render state of the session
  131522. * @param state state to set
  131523. * @returns a promise that resolves once the render state has been updated
  131524. */
  131525. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  131526. /**
  131527. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  131528. * @param sessionMode defines the session to test
  131529. * @returns a promise with boolean as final value
  131530. */
  131531. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  131532. private _createRenderTargetTexture;
  131533. }
  131534. }
  131535. declare module BABYLON {
  131536. /**
  131537. * WebXR Camera which holds the views for the xrSession
  131538. * @see https://doc.babylonjs.com/how_to/webxr_camera
  131539. */
  131540. export class WebXRCamera extends FreeCamera {
  131541. private _xrSessionManager;
  131542. private _firstFrame;
  131543. private _referenceQuaternion;
  131544. private _referencedPosition;
  131545. private _xrInvPositionCache;
  131546. private _xrInvQuaternionCache;
  131547. private _trackingState;
  131548. /**
  131549. * Observable raised before camera teleportation
  131550. */
  131551. onBeforeCameraTeleport: Observable<Vector3>;
  131552. /**
  131553. * Observable raised after camera teleportation
  131554. */
  131555. onAfterCameraTeleport: Observable<Vector3>;
  131556. /**
  131557. * Notifies when the camera's tracking state has changed.
  131558. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  131559. */
  131560. onTrackingStateChanged: Observable<WebXRTrackingState>;
  131561. /**
  131562. * Should position compensation execute on first frame.
  131563. * This is used when copying the position from a native (non XR) camera
  131564. */
  131565. compensateOnFirstFrame: boolean;
  131566. /**
  131567. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  131568. * @param name the name of the camera
  131569. * @param scene the scene to add the camera to
  131570. * @param _xrSessionManager a constructed xr session manager
  131571. */
  131572. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  131573. /**
  131574. * Get the current XR tracking state of the camera
  131575. */
  131576. get trackingState(): WebXRTrackingState;
  131577. private _setTrackingState;
  131578. /**
  131579. * Return the user's height, unrelated to the current ground.
  131580. * This will be the y position of this camera, when ground level is 0.
  131581. */
  131582. get realWorldHeight(): number;
  131583. /** @hidden */
  131584. _updateForDualEyeDebugging(): void;
  131585. /**
  131586. * Sets this camera's transformation based on a non-vr camera
  131587. * @param otherCamera the non-vr camera to copy the transformation from
  131588. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  131589. */
  131590. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  131591. /**
  131592. * Gets the current instance class name ("WebXRCamera").
  131593. * @returns the class name
  131594. */
  131595. getClassName(): string;
  131596. private _rotate180;
  131597. private _updateFromXRSession;
  131598. private _updateNumberOfRigCameras;
  131599. private _updateReferenceSpace;
  131600. private _updateReferenceSpaceOffset;
  131601. }
  131602. }
  131603. declare module BABYLON {
  131604. /**
  131605. * Defining the interface required for a (webxr) feature
  131606. */
  131607. export interface IWebXRFeature extends IDisposable {
  131608. /**
  131609. * Is this feature attached
  131610. */
  131611. attached: boolean;
  131612. /**
  131613. * Should auto-attach be disabled?
  131614. */
  131615. disableAutoAttach: boolean;
  131616. /**
  131617. * Attach the feature to the session
  131618. * Will usually be called by the features manager
  131619. *
  131620. * @param force should attachment be forced (even when already attached)
  131621. * @returns true if successful.
  131622. */
  131623. attach(force?: boolean): boolean;
  131624. /**
  131625. * Detach the feature from the session
  131626. * Will usually be called by the features manager
  131627. *
  131628. * @returns true if successful.
  131629. */
  131630. detach(): boolean;
  131631. /**
  131632. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  131633. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  131634. *
  131635. * @returns whether or not the feature is compatible in this environment
  131636. */
  131637. isCompatible(): boolean;
  131638. /**
  131639. * Was this feature disposed;
  131640. */
  131641. isDisposed: boolean;
  131642. /**
  131643. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  131644. */
  131645. xrNativeFeatureName?: string;
  131646. /**
  131647. * A list of (Babylon WebXR) features this feature depends on
  131648. */
  131649. dependsOn?: string[];
  131650. }
  131651. /**
  131652. * A list of the currently available features without referencing them
  131653. */
  131654. export class WebXRFeatureName {
  131655. /**
  131656. * The name of the anchor system feature
  131657. */
  131658. static readonly ANCHOR_SYSTEM: string;
  131659. /**
  131660. * The name of the background remover feature
  131661. */
  131662. static readonly BACKGROUND_REMOVER: string;
  131663. /**
  131664. * The name of the hit test feature
  131665. */
  131666. static readonly HIT_TEST: string;
  131667. /**
  131668. * physics impostors for xr controllers feature
  131669. */
  131670. static readonly PHYSICS_CONTROLLERS: string;
  131671. /**
  131672. * The name of the plane detection feature
  131673. */
  131674. static readonly PLANE_DETECTION: string;
  131675. /**
  131676. * The name of the pointer selection feature
  131677. */
  131678. static readonly POINTER_SELECTION: string;
  131679. /**
  131680. * The name of the teleportation feature
  131681. */
  131682. static readonly TELEPORTATION: string;
  131683. /**
  131684. * The name of the feature points feature.
  131685. */
  131686. static readonly FEATURE_POINTS: string;
  131687. /**
  131688. * The name of the hand tracking feature.
  131689. */
  131690. static readonly HAND_TRACKING: string;
  131691. }
  131692. /**
  131693. * Defining the constructor of a feature. Used to register the modules.
  131694. */
  131695. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  131696. /**
  131697. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  131698. * It is mainly used in AR sessions.
  131699. *
  131700. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  131701. */
  131702. export class WebXRFeaturesManager implements IDisposable {
  131703. private _xrSessionManager;
  131704. private static readonly _AvailableFeatures;
  131705. private _features;
  131706. /**
  131707. * constructs a new features manages.
  131708. *
  131709. * @param _xrSessionManager an instance of WebXRSessionManager
  131710. */
  131711. constructor(_xrSessionManager: WebXRSessionManager);
  131712. /**
  131713. * Used to register a module. After calling this function a developer can use this feature in the scene.
  131714. * Mainly used internally.
  131715. *
  131716. * @param featureName the name of the feature to register
  131717. * @param constructorFunction the function used to construct the module
  131718. * @param version the (babylon) version of the module
  131719. * @param stable is that a stable version of this module
  131720. */
  131721. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  131722. /**
  131723. * Returns a constructor of a specific feature.
  131724. *
  131725. * @param featureName the name of the feature to construct
  131726. * @param version the version of the feature to load
  131727. * @param xrSessionManager the xrSessionManager. Used to construct the module
  131728. * @param options optional options provided to the module.
  131729. * @returns a function that, when called, will return a new instance of this feature
  131730. */
  131731. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  131732. /**
  131733. * Can be used to return the list of features currently registered
  131734. *
  131735. * @returns an Array of available features
  131736. */
  131737. static GetAvailableFeatures(): string[];
  131738. /**
  131739. * Gets the versions available for a specific feature
  131740. * @param featureName the name of the feature
  131741. * @returns an array with the available versions
  131742. */
  131743. static GetAvailableVersions(featureName: string): string[];
  131744. /**
  131745. * Return the latest unstable version of this feature
  131746. * @param featureName the name of the feature to search
  131747. * @returns the version number. if not found will return -1
  131748. */
  131749. static GetLatestVersionOfFeature(featureName: string): number;
  131750. /**
  131751. * Return the latest stable version of this feature
  131752. * @param featureName the name of the feature to search
  131753. * @returns the version number. if not found will return -1
  131754. */
  131755. static GetStableVersionOfFeature(featureName: string): number;
  131756. /**
  131757. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  131758. * Can be used during a session to start a feature
  131759. * @param featureName the name of feature to attach
  131760. */
  131761. attachFeature(featureName: string): void;
  131762. /**
  131763. * Can be used inside a session or when the session ends to detach a specific feature
  131764. * @param featureName the name of the feature to detach
  131765. */
  131766. detachFeature(featureName: string): void;
  131767. /**
  131768. * Used to disable an already-enabled feature
  131769. * The feature will be disposed and will be recreated once enabled.
  131770. * @param featureName the feature to disable
  131771. * @returns true if disable was successful
  131772. */
  131773. disableFeature(featureName: string | {
  131774. Name: string;
  131775. }): boolean;
  131776. /**
  131777. * dispose this features manager
  131778. */
  131779. dispose(): void;
  131780. /**
  131781. * 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.
  131782. * 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.
  131783. *
  131784. * @param featureName the name of the feature to load or the class of the feature
  131785. * @param version optional version to load. if not provided the latest version will be enabled
  131786. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  131787. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  131788. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  131789. * @returns a new constructed feature or throws an error if feature not found.
  131790. */
  131791. enableFeature(featureName: string | {
  131792. Name: string;
  131793. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  131794. /**
  131795. * get the implementation of an enabled feature.
  131796. * @param featureName the name of the feature to load
  131797. * @returns the feature class, if found
  131798. */
  131799. getEnabledFeature(featureName: string): IWebXRFeature;
  131800. /**
  131801. * Get the list of enabled features
  131802. * @returns an array of enabled features
  131803. */
  131804. getEnabledFeatures(): string[];
  131805. /**
  131806. * This function will exten the session creation configuration object with enabled features.
  131807. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  131808. * according to the defined "required" variable, provided during enableFeature call
  131809. * @param xrSessionInit the xr Session init object to extend
  131810. *
  131811. * @returns an extended XRSessionInit object
  131812. */
  131813. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  131814. }
  131815. }
  131816. declare module BABYLON {
  131817. /**
  131818. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  131819. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  131820. */
  131821. export class WebXRExperienceHelper implements IDisposable {
  131822. private scene;
  131823. private _nonVRCamera;
  131824. private _originalSceneAutoClear;
  131825. private _supported;
  131826. /**
  131827. * Camera used to render xr content
  131828. */
  131829. camera: WebXRCamera;
  131830. /** A features manager for this xr session */
  131831. featuresManager: WebXRFeaturesManager;
  131832. /**
  131833. * Observers registered here will be triggered after the camera's initial transformation is set
  131834. * This can be used to set a different ground level or an extra rotation.
  131835. *
  131836. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  131837. * to the position set after this observable is done executing.
  131838. */
  131839. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  131840. /**
  131841. * Fires when the state of the experience helper has changed
  131842. */
  131843. onStateChangedObservable: Observable<WebXRState>;
  131844. /** Session manager used to keep track of xr session */
  131845. sessionManager: WebXRSessionManager;
  131846. /**
  131847. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  131848. */
  131849. state: WebXRState;
  131850. /**
  131851. * Creates a WebXRExperienceHelper
  131852. * @param scene The scene the helper should be created in
  131853. */
  131854. private constructor();
  131855. /**
  131856. * Creates the experience helper
  131857. * @param scene the scene to attach the experience helper to
  131858. * @returns a promise for the experience helper
  131859. */
  131860. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  131861. /**
  131862. * Disposes of the experience helper
  131863. */
  131864. dispose(): void;
  131865. /**
  131866. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  131867. * @param sessionMode options for the XR session
  131868. * @param referenceSpaceType frame of reference of the XR session
  131869. * @param renderTarget the output canvas that will be used to enter XR mode
  131870. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  131871. * @returns promise that resolves after xr mode has entered
  131872. */
  131873. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  131874. /**
  131875. * Exits XR mode and returns the scene to its original state
  131876. * @returns promise that resolves after xr mode has exited
  131877. */
  131878. exitXRAsync(): Promise<void>;
  131879. private _nonXRToXRCamera;
  131880. private _setState;
  131881. }
  131882. }
  131883. declare module BABYLON {
  131884. /**
  131885. * X-Y values for axes in WebXR
  131886. */
  131887. export interface IWebXRMotionControllerAxesValue {
  131888. /**
  131889. * The value of the x axis
  131890. */
  131891. x: number;
  131892. /**
  131893. * The value of the y-axis
  131894. */
  131895. y: number;
  131896. }
  131897. /**
  131898. * changed / previous values for the values of this component
  131899. */
  131900. export interface IWebXRMotionControllerComponentChangesValues<T> {
  131901. /**
  131902. * current (this frame) value
  131903. */
  131904. current: T;
  131905. /**
  131906. * previous (last change) value
  131907. */
  131908. previous: T;
  131909. }
  131910. /**
  131911. * Represents changes in the component between current frame and last values recorded
  131912. */
  131913. export interface IWebXRMotionControllerComponentChanges {
  131914. /**
  131915. * will be populated with previous and current values if axes changed
  131916. */
  131917. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  131918. /**
  131919. * will be populated with previous and current values if pressed changed
  131920. */
  131921. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131922. /**
  131923. * will be populated with previous and current values if touched changed
  131924. */
  131925. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131926. /**
  131927. * will be populated with previous and current values if value changed
  131928. */
  131929. value?: IWebXRMotionControllerComponentChangesValues<number>;
  131930. }
  131931. /**
  131932. * This class represents a single component (for example button or thumbstick) of a motion controller
  131933. */
  131934. export class WebXRControllerComponent implements IDisposable {
  131935. /**
  131936. * the id of this component
  131937. */
  131938. id: string;
  131939. /**
  131940. * the type of the component
  131941. */
  131942. type: MotionControllerComponentType;
  131943. private _buttonIndex;
  131944. private _axesIndices;
  131945. private _axes;
  131946. private _changes;
  131947. private _currentValue;
  131948. private _hasChanges;
  131949. private _pressed;
  131950. private _touched;
  131951. /**
  131952. * button component type
  131953. */
  131954. static BUTTON_TYPE: MotionControllerComponentType;
  131955. /**
  131956. * squeeze component type
  131957. */
  131958. static SQUEEZE_TYPE: MotionControllerComponentType;
  131959. /**
  131960. * Thumbstick component type
  131961. */
  131962. static THUMBSTICK_TYPE: MotionControllerComponentType;
  131963. /**
  131964. * Touchpad component type
  131965. */
  131966. static TOUCHPAD_TYPE: MotionControllerComponentType;
  131967. /**
  131968. * trigger component type
  131969. */
  131970. static TRIGGER_TYPE: MotionControllerComponentType;
  131971. /**
  131972. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  131973. * the axes data changes
  131974. */
  131975. onAxisValueChangedObservable: Observable<{
  131976. x: number;
  131977. y: number;
  131978. }>;
  131979. /**
  131980. * Observers registered here will be triggered when the state of a button changes
  131981. * State change is either pressed / touched / value
  131982. */
  131983. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  131984. /**
  131985. * Creates a new component for a motion controller.
  131986. * It is created by the motion controller itself
  131987. *
  131988. * @param id the id of this component
  131989. * @param type the type of the component
  131990. * @param _buttonIndex index in the buttons array of the gamepad
  131991. * @param _axesIndices indices of the values in the axes array of the gamepad
  131992. */
  131993. constructor(
  131994. /**
  131995. * the id of this component
  131996. */
  131997. id: string,
  131998. /**
  131999. * the type of the component
  132000. */
  132001. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  132002. /**
  132003. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  132004. */
  132005. get axes(): IWebXRMotionControllerAxesValue;
  132006. /**
  132007. * Get the changes. Elements will be populated only if they changed with their previous and current value
  132008. */
  132009. get changes(): IWebXRMotionControllerComponentChanges;
  132010. /**
  132011. * Return whether or not the component changed the last frame
  132012. */
  132013. get hasChanges(): boolean;
  132014. /**
  132015. * is the button currently pressed
  132016. */
  132017. get pressed(): boolean;
  132018. /**
  132019. * is the button currently touched
  132020. */
  132021. get touched(): boolean;
  132022. /**
  132023. * Get the current value of this component
  132024. */
  132025. get value(): number;
  132026. /**
  132027. * Dispose this component
  132028. */
  132029. dispose(): void;
  132030. /**
  132031. * Are there axes correlating to this component
  132032. * @return true is axes data is available
  132033. */
  132034. isAxes(): boolean;
  132035. /**
  132036. * Is this component a button (hence - pressable)
  132037. * @returns true if can be pressed
  132038. */
  132039. isButton(): boolean;
  132040. /**
  132041. * update this component using the gamepad object it is in. Called on every frame
  132042. * @param nativeController the native gamepad controller object
  132043. */
  132044. update(nativeController: IMinimalMotionControllerObject): void;
  132045. }
  132046. }
  132047. declare module BABYLON {
  132048. /**
  132049. * Interface used to represent data loading progression
  132050. */
  132051. export interface ISceneLoaderProgressEvent {
  132052. /**
  132053. * Defines if data length to load can be evaluated
  132054. */
  132055. readonly lengthComputable: boolean;
  132056. /**
  132057. * Defines the loaded data length
  132058. */
  132059. readonly loaded: number;
  132060. /**
  132061. * Defines the data length to load
  132062. */
  132063. readonly total: number;
  132064. }
  132065. /**
  132066. * Interface used by SceneLoader plugins to define supported file extensions
  132067. */
  132068. export interface ISceneLoaderPluginExtensions {
  132069. /**
  132070. * Defines the list of supported extensions
  132071. */
  132072. [extension: string]: {
  132073. isBinary: boolean;
  132074. };
  132075. }
  132076. /**
  132077. * Interface used by SceneLoader plugin factory
  132078. */
  132079. export interface ISceneLoaderPluginFactory {
  132080. /**
  132081. * Defines the name of the factory
  132082. */
  132083. name: string;
  132084. /**
  132085. * Function called to create a new plugin
  132086. * @return the new plugin
  132087. */
  132088. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  132089. /**
  132090. * The callback that returns true if the data can be directly loaded.
  132091. * @param data string containing the file data
  132092. * @returns if the data can be loaded directly
  132093. */
  132094. canDirectLoad?(data: string): boolean;
  132095. }
  132096. /**
  132097. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  132098. */
  132099. export interface ISceneLoaderPluginBase {
  132100. /**
  132101. * The friendly name of this plugin.
  132102. */
  132103. name: string;
  132104. /**
  132105. * The file extensions supported by this plugin.
  132106. */
  132107. extensions: string | ISceneLoaderPluginExtensions;
  132108. /**
  132109. * The callback called when loading from a url.
  132110. * @param scene scene loading this url
  132111. * @param url url to load
  132112. * @param onSuccess callback called when the file successfully loads
  132113. * @param onProgress callback called while file is loading (if the server supports this mode)
  132114. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  132115. * @param onError callback called when the file fails to load
  132116. * @returns a file request object
  132117. */
  132118. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132119. /**
  132120. * The callback called when loading from a file object.
  132121. * @param scene scene loading this file
  132122. * @param file defines the file to load
  132123. * @param onSuccess defines the callback to call when data is loaded
  132124. * @param onProgress defines the callback to call during loading process
  132125. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  132126. * @param onError defines the callback to call when an error occurs
  132127. * @returns a file request object
  132128. */
  132129. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132130. /**
  132131. * The callback that returns true if the data can be directly loaded.
  132132. * @param data string containing the file data
  132133. * @returns if the data can be loaded directly
  132134. */
  132135. canDirectLoad?(data: string): boolean;
  132136. /**
  132137. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  132138. * @param scene scene loading this data
  132139. * @param data string containing the data
  132140. * @returns data to pass to the plugin
  132141. */
  132142. directLoad?(scene: Scene, data: string): any;
  132143. /**
  132144. * The callback that allows custom handling of the root url based on the response url.
  132145. * @param rootUrl the original root url
  132146. * @param responseURL the response url if available
  132147. * @returns the new root url
  132148. */
  132149. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  132150. }
  132151. /**
  132152. * Interface used to define a SceneLoader plugin
  132153. */
  132154. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  132155. /**
  132156. * Import meshes into a scene.
  132157. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132158. * @param scene The scene to import into
  132159. * @param data The data to import
  132160. * @param rootUrl The root url for scene and resources
  132161. * @param meshes The meshes array to import into
  132162. * @param particleSystems The particle systems array to import into
  132163. * @param skeletons The skeletons array to import into
  132164. * @param onError The callback when import fails
  132165. * @returns True if successful or false otherwise
  132166. */
  132167. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  132168. /**
  132169. * Load into a scene.
  132170. * @param scene The scene to load into
  132171. * @param data The data to import
  132172. * @param rootUrl The root url for scene and resources
  132173. * @param onError The callback when import fails
  132174. * @returns True if successful or false otherwise
  132175. */
  132176. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  132177. /**
  132178. * Load into an asset container.
  132179. * @param scene The scene to load into
  132180. * @param data The data to import
  132181. * @param rootUrl The root url for scene and resources
  132182. * @param onError The callback when import fails
  132183. * @returns The loaded asset container
  132184. */
  132185. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  132186. }
  132187. /**
  132188. * Interface used to define an async SceneLoader plugin
  132189. */
  132190. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  132191. /**
  132192. * Import meshes into a scene.
  132193. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132194. * @param scene The scene to import into
  132195. * @param data The data to import
  132196. * @param rootUrl The root url for scene and resources
  132197. * @param onProgress The callback when the load progresses
  132198. * @param fileName Defines the name of the file to load
  132199. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  132200. */
  132201. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  132202. meshes: AbstractMesh[];
  132203. particleSystems: IParticleSystem[];
  132204. skeletons: Skeleton[];
  132205. animationGroups: AnimationGroup[];
  132206. }>;
  132207. /**
  132208. * Load into a scene.
  132209. * @param scene The scene to load into
  132210. * @param data The data to import
  132211. * @param rootUrl The root url for scene and resources
  132212. * @param onProgress The callback when the load progresses
  132213. * @param fileName Defines the name of the file to load
  132214. * @returns Nothing
  132215. */
  132216. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  132217. /**
  132218. * Load into an asset container.
  132219. * @param scene The scene to load into
  132220. * @param data The data to import
  132221. * @param rootUrl The root url for scene and resources
  132222. * @param onProgress The callback when the load progresses
  132223. * @param fileName Defines the name of the file to load
  132224. * @returns The loaded asset container
  132225. */
  132226. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  132227. }
  132228. /**
  132229. * Mode that determines how to handle old animation groups before loading new ones.
  132230. */
  132231. export enum SceneLoaderAnimationGroupLoadingMode {
  132232. /**
  132233. * Reset all old animations to initial state then dispose them.
  132234. */
  132235. Clean = 0,
  132236. /**
  132237. * Stop all old animations.
  132238. */
  132239. Stop = 1,
  132240. /**
  132241. * Restart old animations from first frame.
  132242. */
  132243. Sync = 2,
  132244. /**
  132245. * Old animations remains untouched.
  132246. */
  132247. NoSync = 3
  132248. }
  132249. /**
  132250. * Defines a plugin registered by the SceneLoader
  132251. */
  132252. interface IRegisteredPlugin {
  132253. /**
  132254. * Defines the plugin to use
  132255. */
  132256. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  132257. /**
  132258. * Defines if the plugin supports binary data
  132259. */
  132260. isBinary: boolean;
  132261. }
  132262. /**
  132263. * Class used to load scene from various file formats using registered plugins
  132264. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  132265. */
  132266. export class SceneLoader {
  132267. /**
  132268. * No logging while loading
  132269. */
  132270. static readonly NO_LOGGING: number;
  132271. /**
  132272. * Minimal logging while loading
  132273. */
  132274. static readonly MINIMAL_LOGGING: number;
  132275. /**
  132276. * Summary logging while loading
  132277. */
  132278. static readonly SUMMARY_LOGGING: number;
  132279. /**
  132280. * Detailled logging while loading
  132281. */
  132282. static readonly DETAILED_LOGGING: number;
  132283. /**
  132284. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  132285. */
  132286. static get ForceFullSceneLoadingForIncremental(): boolean;
  132287. static set ForceFullSceneLoadingForIncremental(value: boolean);
  132288. /**
  132289. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  132290. */
  132291. static get ShowLoadingScreen(): boolean;
  132292. static set ShowLoadingScreen(value: boolean);
  132293. /**
  132294. * Defines the current logging level (while loading the scene)
  132295. * @ignorenaming
  132296. */
  132297. static get loggingLevel(): number;
  132298. static set loggingLevel(value: number);
  132299. /**
  132300. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  132301. */
  132302. static get CleanBoneMatrixWeights(): boolean;
  132303. static set CleanBoneMatrixWeights(value: boolean);
  132304. /**
  132305. * Event raised when a plugin is used to load a scene
  132306. */
  132307. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  132308. private static _registeredPlugins;
  132309. private static _showingLoadingScreen;
  132310. /**
  132311. * Gets the default plugin (used to load Babylon files)
  132312. * @returns the .babylon plugin
  132313. */
  132314. static GetDefaultPlugin(): IRegisteredPlugin;
  132315. private static _GetPluginForExtension;
  132316. private static _GetPluginForDirectLoad;
  132317. private static _GetPluginForFilename;
  132318. private static _GetDirectLoad;
  132319. private static _LoadData;
  132320. private static _GetFileInfo;
  132321. /**
  132322. * Gets a plugin that can load the given extension
  132323. * @param extension defines the extension to load
  132324. * @returns a plugin or null if none works
  132325. */
  132326. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  132327. /**
  132328. * Gets a boolean indicating that the given extension can be loaded
  132329. * @param extension defines the extension to load
  132330. * @returns true if the extension is supported
  132331. */
  132332. static IsPluginForExtensionAvailable(extension: string): boolean;
  132333. /**
  132334. * Adds a new plugin to the list of registered plugins
  132335. * @param plugin defines the plugin to add
  132336. */
  132337. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  132338. /**
  132339. * Import meshes into a scene
  132340. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132341. * @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)
  132342. * @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)
  132343. * @param scene the instance of BABYLON.Scene to append to
  132344. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  132345. * @param onProgress a callback with a progress event for each file being loaded
  132346. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132347. * @param pluginExtension the extension used to determine the plugin
  132348. * @returns The loaded plugin
  132349. */
  132350. 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>;
  132351. /**
  132352. * Import meshes into a scene
  132353. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132354. * @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)
  132355. * @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)
  132356. * @param scene the instance of BABYLON.Scene to append to
  132357. * @param onProgress a callback with a progress event for each file being loaded
  132358. * @param pluginExtension the extension used to determine the plugin
  132359. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  132360. */
  132361. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  132362. meshes: AbstractMesh[];
  132363. particleSystems: IParticleSystem[];
  132364. skeletons: Skeleton[];
  132365. animationGroups: AnimationGroup[];
  132366. }>;
  132367. /**
  132368. * Load a scene
  132369. * @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)
  132370. * @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)
  132371. * @param engine is the instance of BABYLON.Engine to use to create the scene
  132372. * @param onSuccess a callback with the scene when import succeeds
  132373. * @param onProgress a callback with a progress event for each file being loaded
  132374. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132375. * @param pluginExtension the extension used to determine the plugin
  132376. * @returns The loaded plugin
  132377. */
  132378. 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>;
  132379. /**
  132380. * Load a scene
  132381. * @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)
  132382. * @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)
  132383. * @param engine is the instance of BABYLON.Engine to use to create the scene
  132384. * @param onProgress a callback with a progress event for each file being loaded
  132385. * @param pluginExtension the extension used to determine the plugin
  132386. * @returns The loaded scene
  132387. */
  132388. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  132389. /**
  132390. * Append a scene
  132391. * @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)
  132392. * @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)
  132393. * @param scene is the instance of BABYLON.Scene to append to
  132394. * @param onSuccess a callback with the scene when import succeeds
  132395. * @param onProgress a callback with a progress event for each file being loaded
  132396. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132397. * @param pluginExtension the extension used to determine the plugin
  132398. * @returns The loaded plugin
  132399. */
  132400. 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>;
  132401. /**
  132402. * Append a scene
  132403. * @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)
  132404. * @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)
  132405. * @param scene is the instance of BABYLON.Scene to append to
  132406. * @param onProgress a callback with a progress event for each file being loaded
  132407. * @param pluginExtension the extension used to determine the plugin
  132408. * @returns The given scene
  132409. */
  132410. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  132411. /**
  132412. * Load a scene into an asset container
  132413. * @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)
  132414. * @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)
  132415. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132416. * @param onSuccess a callback with the scene when import succeeds
  132417. * @param onProgress a callback with a progress event for each file being loaded
  132418. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132419. * @param pluginExtension the extension used to determine the plugin
  132420. * @returns The loaded plugin
  132421. */
  132422. 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>;
  132423. /**
  132424. * Load a scene into an asset container
  132425. * @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)
  132426. * @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)
  132427. * @param scene is the instance of Scene to append to
  132428. * @param onProgress a callback with a progress event for each file being loaded
  132429. * @param pluginExtension the extension used to determine the plugin
  132430. * @returns The loaded asset container
  132431. */
  132432. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  132433. /**
  132434. * Import animations from a file into a scene
  132435. * @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)
  132436. * @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)
  132437. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132438. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  132439. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  132440. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  132441. * @param onSuccess a callback with the scene when import succeeds
  132442. * @param onProgress a callback with a progress event for each file being loaded
  132443. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132444. * @param pluginExtension the extension used to determine the plugin
  132445. */
  132446. 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;
  132447. /**
  132448. * Import animations from a file into a scene
  132449. * @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)
  132450. * @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)
  132451. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132452. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  132453. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  132454. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  132455. * @param onSuccess a callback with the scene when import succeeds
  132456. * @param onProgress a callback with a progress event for each file being loaded
  132457. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132458. * @param pluginExtension the extension used to determine the plugin
  132459. * @returns the updated scene with imported animations
  132460. */
  132461. 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>;
  132462. }
  132463. }
  132464. declare module BABYLON {
  132465. /**
  132466. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  132467. */
  132468. export type MotionControllerHandedness = "none" | "left" | "right";
  132469. /**
  132470. * The type of components available in motion controllers.
  132471. * This is not the name of the component.
  132472. */
  132473. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  132474. /**
  132475. * The state of a controller component
  132476. */
  132477. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  132478. /**
  132479. * The schema of motion controller layout.
  132480. * No object will be initialized using this interface
  132481. * This is used just to define the profile.
  132482. */
  132483. export interface IMotionControllerLayout {
  132484. /**
  132485. * Path to load the assets. Usually relative to the base path
  132486. */
  132487. assetPath: string;
  132488. /**
  132489. * Available components (unsorted)
  132490. */
  132491. components: {
  132492. /**
  132493. * A map of component Ids
  132494. */
  132495. [componentId: string]: {
  132496. /**
  132497. * The type of input the component outputs
  132498. */
  132499. type: MotionControllerComponentType;
  132500. /**
  132501. * The indices of this component in the gamepad object
  132502. */
  132503. gamepadIndices: {
  132504. /**
  132505. * Index of button
  132506. */
  132507. button?: number;
  132508. /**
  132509. * If available, index of x-axis
  132510. */
  132511. xAxis?: number;
  132512. /**
  132513. * If available, index of y-axis
  132514. */
  132515. yAxis?: number;
  132516. };
  132517. /**
  132518. * The mesh's root node name
  132519. */
  132520. rootNodeName: string;
  132521. /**
  132522. * Animation definitions for this model
  132523. */
  132524. visualResponses: {
  132525. [stateKey: string]: {
  132526. /**
  132527. * What property will be animated
  132528. */
  132529. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  132530. /**
  132531. * What states influence this visual response
  132532. */
  132533. states: MotionControllerComponentStateType[];
  132534. /**
  132535. * Type of animation - movement or visibility
  132536. */
  132537. valueNodeProperty: "transform" | "visibility";
  132538. /**
  132539. * Base node name to move. Its position will be calculated according to the min and max nodes
  132540. */
  132541. valueNodeName?: string;
  132542. /**
  132543. * Minimum movement node
  132544. */
  132545. minNodeName?: string;
  132546. /**
  132547. * Max movement node
  132548. */
  132549. maxNodeName?: string;
  132550. };
  132551. };
  132552. /**
  132553. * If touch enabled, what is the name of node to display user feedback
  132554. */
  132555. touchPointNodeName?: string;
  132556. };
  132557. };
  132558. /**
  132559. * Is it xr standard mapping or not
  132560. */
  132561. gamepadMapping: "" | "xr-standard";
  132562. /**
  132563. * Base root node of this entire model
  132564. */
  132565. rootNodeName: string;
  132566. /**
  132567. * Defines the main button component id
  132568. */
  132569. selectComponentId: string;
  132570. }
  132571. /**
  132572. * A definition for the layout map in the input profile
  132573. */
  132574. export interface IMotionControllerLayoutMap {
  132575. /**
  132576. * Layouts with handedness type as a key
  132577. */
  132578. [handedness: string]: IMotionControllerLayout;
  132579. }
  132580. /**
  132581. * The XR Input profile schema
  132582. * Profiles can be found here:
  132583. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  132584. */
  132585. export interface IMotionControllerProfile {
  132586. /**
  132587. * fallback profiles for this profileId
  132588. */
  132589. fallbackProfileIds: string[];
  132590. /**
  132591. * The layout map, with handedness as key
  132592. */
  132593. layouts: IMotionControllerLayoutMap;
  132594. /**
  132595. * The id of this profile
  132596. * correlates to the profile(s) in the xrInput.profiles array
  132597. */
  132598. profileId: string;
  132599. }
  132600. /**
  132601. * A helper-interface for the 3 meshes needed for controller button animation
  132602. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  132603. */
  132604. export interface IMotionControllerButtonMeshMap {
  132605. /**
  132606. * the mesh that defines the pressed value mesh position.
  132607. * This is used to find the max-position of this button
  132608. */
  132609. pressedMesh: AbstractMesh;
  132610. /**
  132611. * the mesh that defines the unpressed value mesh position.
  132612. * This is used to find the min (or initial) position of this button
  132613. */
  132614. unpressedMesh: AbstractMesh;
  132615. /**
  132616. * The mesh that will be changed when value changes
  132617. */
  132618. valueMesh: AbstractMesh;
  132619. }
  132620. /**
  132621. * A helper-interface for the 3 meshes needed for controller axis animation.
  132622. * This will be expanded when touchpad animations are fully supported
  132623. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  132624. */
  132625. export interface IMotionControllerMeshMap {
  132626. /**
  132627. * the mesh that defines the maximum value mesh position.
  132628. */
  132629. maxMesh?: AbstractMesh;
  132630. /**
  132631. * the mesh that defines the minimum value mesh position.
  132632. */
  132633. minMesh?: AbstractMesh;
  132634. /**
  132635. * The mesh that will be changed when axis value changes
  132636. */
  132637. valueMesh?: AbstractMesh;
  132638. }
  132639. /**
  132640. * The elements needed for change-detection of the gamepad objects in motion controllers
  132641. */
  132642. export interface IMinimalMotionControllerObject {
  132643. /**
  132644. * Available axes of this controller
  132645. */
  132646. axes: number[];
  132647. /**
  132648. * An array of available buttons
  132649. */
  132650. buttons: Array<{
  132651. /**
  132652. * Value of the button/trigger
  132653. */
  132654. value: number;
  132655. /**
  132656. * If the button/trigger is currently touched
  132657. */
  132658. touched: boolean;
  132659. /**
  132660. * If the button/trigger is currently pressed
  132661. */
  132662. pressed: boolean;
  132663. }>;
  132664. /**
  132665. * EXPERIMENTAL haptic support.
  132666. */
  132667. hapticActuators?: Array<{
  132668. pulse: (value: number, duration: number) => Promise<boolean>;
  132669. }>;
  132670. }
  132671. /**
  132672. * An Abstract Motion controller
  132673. * This class receives an xrInput and a profile layout and uses those to initialize the components
  132674. * Each component has an observable to check for changes in value and state
  132675. */
  132676. export abstract class WebXRAbstractMotionController implements IDisposable {
  132677. protected scene: Scene;
  132678. protected layout: IMotionControllerLayout;
  132679. /**
  132680. * The gamepad object correlating to this controller
  132681. */
  132682. gamepadObject: IMinimalMotionControllerObject;
  132683. /**
  132684. * handedness (left/right/none) of this controller
  132685. */
  132686. handedness: MotionControllerHandedness;
  132687. private _initComponent;
  132688. private _modelReady;
  132689. /**
  132690. * A map of components (WebXRControllerComponent) in this motion controller
  132691. * Components have a ComponentType and can also have both button and axis definitions
  132692. */
  132693. readonly components: {
  132694. [id: string]: WebXRControllerComponent;
  132695. };
  132696. /**
  132697. * Disable the model's animation. Can be set at any time.
  132698. */
  132699. disableAnimation: boolean;
  132700. /**
  132701. * Observers registered here will be triggered when the model of this controller is done loading
  132702. */
  132703. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  132704. /**
  132705. * The profile id of this motion controller
  132706. */
  132707. abstract profileId: string;
  132708. /**
  132709. * The root mesh of the model. It is null if the model was not yet initialized
  132710. */
  132711. rootMesh: Nullable<AbstractMesh>;
  132712. /**
  132713. * constructs a new abstract motion controller
  132714. * @param scene the scene to which the model of the controller will be added
  132715. * @param layout The profile layout to load
  132716. * @param gamepadObject The gamepad object correlating to this controller
  132717. * @param handedness handedness (left/right/none) of this controller
  132718. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  132719. */
  132720. constructor(scene: Scene, layout: IMotionControllerLayout,
  132721. /**
  132722. * The gamepad object correlating to this controller
  132723. */
  132724. gamepadObject: IMinimalMotionControllerObject,
  132725. /**
  132726. * handedness (left/right/none) of this controller
  132727. */
  132728. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  132729. /**
  132730. * Dispose this controller, the model mesh and all its components
  132731. */
  132732. dispose(): void;
  132733. /**
  132734. * Returns all components of specific type
  132735. * @param type the type to search for
  132736. * @return an array of components with this type
  132737. */
  132738. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  132739. /**
  132740. * get a component based an its component id as defined in layout.components
  132741. * @param id the id of the component
  132742. * @returns the component correlates to the id or undefined if not found
  132743. */
  132744. getComponent(id: string): WebXRControllerComponent;
  132745. /**
  132746. * Get the list of components available in this motion controller
  132747. * @returns an array of strings correlating to available components
  132748. */
  132749. getComponentIds(): string[];
  132750. /**
  132751. * Get the first component of specific type
  132752. * @param type type of component to find
  132753. * @return a controller component or null if not found
  132754. */
  132755. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  132756. /**
  132757. * Get the main (Select) component of this controller as defined in the layout
  132758. * @returns the main component of this controller
  132759. */
  132760. getMainComponent(): WebXRControllerComponent;
  132761. /**
  132762. * Loads the model correlating to this controller
  132763. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  132764. * @returns A promise fulfilled with the result of the model loading
  132765. */
  132766. loadModel(): Promise<boolean>;
  132767. /**
  132768. * Update this model using the current XRFrame
  132769. * @param xrFrame the current xr frame to use and update the model
  132770. */
  132771. updateFromXRFrame(xrFrame: XRFrame): void;
  132772. /**
  132773. * Backwards compatibility due to a deeply-integrated typo
  132774. */
  132775. get handness(): XREye;
  132776. /**
  132777. * Pulse (vibrate) this controller
  132778. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  132779. * Consecutive calls to this function will cancel the last pulse call
  132780. *
  132781. * @param value the strength of the pulse in 0.0...1.0 range
  132782. * @param duration Duration of the pulse in milliseconds
  132783. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  132784. * @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
  132785. */
  132786. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  132787. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132788. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132789. /**
  132790. * Moves the axis on the controller mesh based on its current state
  132791. * @param axis the index of the axis
  132792. * @param axisValue the value of the axis which determines the meshes new position
  132793. * @hidden
  132794. */
  132795. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  132796. /**
  132797. * Update the model itself with the current frame data
  132798. * @param xrFrame the frame to use for updating the model mesh
  132799. */
  132800. protected updateModel(xrFrame: XRFrame): void;
  132801. /**
  132802. * Get the filename and path for this controller's model
  132803. * @returns a map of filename and path
  132804. */
  132805. protected abstract _getFilenameAndPath(): {
  132806. filename: string;
  132807. path: string;
  132808. };
  132809. /**
  132810. * This function is called before the mesh is loaded. It checks for loading constraints.
  132811. * For example, this function can check if the GLB loader is available
  132812. * If this function returns false, the generic controller will be loaded instead
  132813. * @returns Is the client ready to load the mesh
  132814. */
  132815. protected abstract _getModelLoadingConstraints(): boolean;
  132816. /**
  132817. * This function will be called after the model was successfully loaded and can be used
  132818. * for mesh transformations before it is available for the user
  132819. * @param meshes the loaded meshes
  132820. */
  132821. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  132822. /**
  132823. * Set the root mesh for this controller. Important for the WebXR controller class
  132824. * @param meshes the loaded meshes
  132825. */
  132826. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  132827. /**
  132828. * A function executed each frame that updates the mesh (if needed)
  132829. * @param xrFrame the current xrFrame
  132830. */
  132831. protected abstract _updateModel(xrFrame: XRFrame): void;
  132832. private _getGenericFilenameAndPath;
  132833. private _getGenericParentMesh;
  132834. }
  132835. }
  132836. declare module BABYLON {
  132837. /**
  132838. * A generic trigger-only motion controller for WebXR
  132839. */
  132840. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  132841. /**
  132842. * Static version of the profile id of this controller
  132843. */
  132844. static ProfileId: string;
  132845. profileId: string;
  132846. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  132847. protected _getFilenameAndPath(): {
  132848. filename: string;
  132849. path: string;
  132850. };
  132851. protected _getModelLoadingConstraints(): boolean;
  132852. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  132853. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132854. protected _updateModel(): void;
  132855. }
  132856. }
  132857. declare module BABYLON {
  132858. /**
  132859. * Class containing static functions to help procedurally build meshes
  132860. */
  132861. export class SphereBuilder {
  132862. /**
  132863. * Creates a sphere mesh
  132864. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  132865. * * 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`)
  132866. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  132867. * * 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
  132868. * * 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)
  132869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132870. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132872. * @param name defines the name of the mesh
  132873. * @param options defines the options used to create the mesh
  132874. * @param scene defines the hosting scene
  132875. * @returns the sphere mesh
  132876. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  132877. */
  132878. static CreateSphere(name: string, options: {
  132879. segments?: number;
  132880. diameter?: number;
  132881. diameterX?: number;
  132882. diameterY?: number;
  132883. diameterZ?: number;
  132884. arc?: number;
  132885. slice?: number;
  132886. sideOrientation?: number;
  132887. frontUVs?: Vector4;
  132888. backUVs?: Vector4;
  132889. updatable?: boolean;
  132890. }, scene?: Nullable<Scene>): Mesh;
  132891. }
  132892. }
  132893. declare module BABYLON {
  132894. /**
  132895. * A profiled motion controller has its profile loaded from an online repository.
  132896. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  132897. */
  132898. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  132899. private _repositoryUrl;
  132900. private _buttonMeshMapping;
  132901. private _touchDots;
  132902. /**
  132903. * The profile ID of this controller. Will be populated when the controller initializes.
  132904. */
  132905. profileId: string;
  132906. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  132907. dispose(): void;
  132908. protected _getFilenameAndPath(): {
  132909. filename: string;
  132910. path: string;
  132911. };
  132912. protected _getModelLoadingConstraints(): boolean;
  132913. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  132914. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132915. protected _updateModel(_xrFrame: XRFrame): void;
  132916. }
  132917. }
  132918. declare module BABYLON {
  132919. /**
  132920. * A construction function type to create a new controller based on an xrInput object
  132921. */
  132922. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  132923. /**
  132924. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  132925. *
  132926. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  132927. * it should be replaced with auto-loaded controllers.
  132928. *
  132929. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  132930. */
  132931. export class WebXRMotionControllerManager {
  132932. private static _AvailableControllers;
  132933. private static _Fallbacks;
  132934. private static _ProfileLoadingPromises;
  132935. private static _ProfilesList;
  132936. /**
  132937. * The base URL of the online controller repository. Can be changed at any time.
  132938. */
  132939. static BaseRepositoryUrl: string;
  132940. /**
  132941. * Which repository gets priority - local or online
  132942. */
  132943. static PrioritizeOnlineRepository: boolean;
  132944. /**
  132945. * Use the online repository, or use only locally-defined controllers
  132946. */
  132947. static UseOnlineRepository: boolean;
  132948. /**
  132949. * Clear the cache used for profile loading and reload when requested again
  132950. */
  132951. static ClearProfilesCache(): void;
  132952. /**
  132953. * Register the default fallbacks.
  132954. * This function is called automatically when this file is imported.
  132955. */
  132956. static DefaultFallbacks(): void;
  132957. /**
  132958. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  132959. * @param profileId the profile to which a fallback needs to be found
  132960. * @return an array with corresponding fallback profiles
  132961. */
  132962. static FindFallbackWithProfileId(profileId: string): string[];
  132963. /**
  132964. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  132965. * The order of search:
  132966. *
  132967. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  132968. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  132969. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  132970. * 4) return the generic trigger controller if none were found
  132971. *
  132972. * @param xrInput the xrInput to which a new controller is initialized
  132973. * @param scene the scene to which the model will be added
  132974. * @param forceProfile force a certain profile for this controller
  132975. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  132976. */
  132977. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  132978. /**
  132979. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  132980. *
  132981. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  132982. *
  132983. * @param type the profile type to register
  132984. * @param constructFunction the function to be called when loading this profile
  132985. */
  132986. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  132987. /**
  132988. * Register a fallback to a specific profile.
  132989. * @param profileId the profileId that will receive the fallbacks
  132990. * @param fallbacks A list of fallback profiles
  132991. */
  132992. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  132993. /**
  132994. * Will update the list of profiles available in the repository
  132995. * @return a promise that resolves to a map of profiles available online
  132996. */
  132997. static UpdateProfilesList(): Promise<{
  132998. [profile: string]: string;
  132999. }>;
  133000. private static _LoadProfileFromRepository;
  133001. private static _LoadProfilesFromAvailableControllers;
  133002. }
  133003. }
  133004. declare module BABYLON {
  133005. /**
  133006. * Configuration options for the WebXR controller creation
  133007. */
  133008. export interface IWebXRControllerOptions {
  133009. /**
  133010. * Should the controller mesh be animated when a user interacts with it
  133011. * The pressed buttons / thumbstick and touchpad animations will be disabled
  133012. */
  133013. disableMotionControllerAnimation?: boolean;
  133014. /**
  133015. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  133016. */
  133017. doNotLoadControllerMesh?: boolean;
  133018. /**
  133019. * Force a specific controller type for this controller.
  133020. * This can be used when creating your own profile or when testing different controllers
  133021. */
  133022. forceControllerProfile?: string;
  133023. /**
  133024. * Defines a rendering group ID for meshes that will be loaded.
  133025. * This is for the default controllers only.
  133026. */
  133027. renderingGroupId?: number;
  133028. }
  133029. /**
  133030. * Represents an XR controller
  133031. */
  133032. export class WebXRInputSource {
  133033. private _scene;
  133034. /** The underlying input source for the controller */
  133035. inputSource: XRInputSource;
  133036. private _options;
  133037. private _tmpVector;
  133038. private _uniqueId;
  133039. private _disposed;
  133040. /**
  133041. * 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
  133042. */
  133043. grip?: AbstractMesh;
  133044. /**
  133045. * If available, this is the gamepad object related to this controller.
  133046. * Using this object it is possible to get click events and trackpad changes of the
  133047. * webxr controller that is currently being used.
  133048. */
  133049. motionController?: WebXRAbstractMotionController;
  133050. /**
  133051. * Event that fires when the controller is removed/disposed.
  133052. * The object provided as event data is this controller, after associated assets were disposed.
  133053. * uniqueId is still available.
  133054. */
  133055. onDisposeObservable: Observable<WebXRInputSource>;
  133056. /**
  133057. * Will be triggered when the mesh associated with the motion controller is done loading.
  133058. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  133059. * A shortened version of controller -> motion controller -> on mesh loaded.
  133060. */
  133061. onMeshLoadedObservable: Observable<AbstractMesh>;
  133062. /**
  133063. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  133064. */
  133065. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  133066. /**
  133067. * Pointer which can be used to select objects or attach a visible laser to
  133068. */
  133069. pointer: AbstractMesh;
  133070. /**
  133071. * Creates the input source object
  133072. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  133073. * @param _scene the scene which the controller should be associated to
  133074. * @param inputSource the underlying input source for the controller
  133075. * @param _options options for this controller creation
  133076. */
  133077. constructor(_scene: Scene,
  133078. /** The underlying input source for the controller */
  133079. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  133080. /**
  133081. * Get this controllers unique id
  133082. */
  133083. get uniqueId(): string;
  133084. /**
  133085. * Disposes of the object
  133086. */
  133087. dispose(): void;
  133088. /**
  133089. * Gets a world space ray coming from the pointer or grip
  133090. * @param result the resulting ray
  133091. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  133092. */
  133093. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  133094. /**
  133095. * Updates the controller pose based on the given XRFrame
  133096. * @param xrFrame xr frame to update the pose with
  133097. * @param referenceSpace reference space to use
  133098. */
  133099. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  133100. }
  133101. }
  133102. declare module BABYLON {
  133103. /**
  133104. * The schema for initialization options of the XR Input class
  133105. */
  133106. export interface IWebXRInputOptions {
  133107. /**
  133108. * If set to true no model will be automatically loaded
  133109. */
  133110. doNotLoadControllerMeshes?: boolean;
  133111. /**
  133112. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  133113. * If not found, the xr input profile data will be used.
  133114. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  133115. */
  133116. forceInputProfile?: string;
  133117. /**
  133118. * Do not send a request to the controller repository to load the profile.
  133119. *
  133120. * Instead, use the controllers available in babylon itself.
  133121. */
  133122. disableOnlineControllerRepository?: boolean;
  133123. /**
  133124. * A custom URL for the controllers repository
  133125. */
  133126. customControllersRepositoryURL?: string;
  133127. /**
  133128. * Should the controller model's components not move according to the user input
  133129. */
  133130. disableControllerAnimation?: boolean;
  133131. /**
  133132. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  133133. */
  133134. controllerOptions?: IWebXRControllerOptions;
  133135. }
  133136. /**
  133137. * XR input used to track XR inputs such as controllers/rays
  133138. */
  133139. export class WebXRInput implements IDisposable {
  133140. /**
  133141. * the xr session manager for this session
  133142. */
  133143. xrSessionManager: WebXRSessionManager;
  133144. /**
  133145. * the WebXR camera for this session. Mainly used for teleportation
  133146. */
  133147. xrCamera: WebXRCamera;
  133148. private readonly options;
  133149. /**
  133150. * XR controllers being tracked
  133151. */
  133152. controllers: Array<WebXRInputSource>;
  133153. private _frameObserver;
  133154. private _sessionEndedObserver;
  133155. private _sessionInitObserver;
  133156. /**
  133157. * Event when a controller has been connected/added
  133158. */
  133159. onControllerAddedObservable: Observable<WebXRInputSource>;
  133160. /**
  133161. * Event when a controller has been removed/disconnected
  133162. */
  133163. onControllerRemovedObservable: Observable<WebXRInputSource>;
  133164. /**
  133165. * Initializes the WebXRInput
  133166. * @param xrSessionManager the xr session manager for this session
  133167. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  133168. * @param options = initialization options for this xr input
  133169. */
  133170. constructor(
  133171. /**
  133172. * the xr session manager for this session
  133173. */
  133174. xrSessionManager: WebXRSessionManager,
  133175. /**
  133176. * the WebXR camera for this session. Mainly used for teleportation
  133177. */
  133178. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  133179. private _onInputSourcesChange;
  133180. private _addAndRemoveControllers;
  133181. /**
  133182. * Disposes of the object
  133183. */
  133184. dispose(): void;
  133185. }
  133186. }
  133187. declare module BABYLON {
  133188. /**
  133189. * This is the base class for all WebXR features.
  133190. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  133191. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  133192. */
  133193. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  133194. protected _xrSessionManager: WebXRSessionManager;
  133195. private _attached;
  133196. private _removeOnDetach;
  133197. /**
  133198. * Is this feature disposed?
  133199. */
  133200. isDisposed: boolean;
  133201. /**
  133202. * Should auto-attach be disabled?
  133203. */
  133204. disableAutoAttach: boolean;
  133205. /**
  133206. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  133207. */
  133208. xrNativeFeatureName: string;
  133209. /**
  133210. * Construct a new (abstract) WebXR feature
  133211. * @param _xrSessionManager the xr session manager for this feature
  133212. */
  133213. constructor(_xrSessionManager: WebXRSessionManager);
  133214. /**
  133215. * Is this feature attached
  133216. */
  133217. get attached(): boolean;
  133218. /**
  133219. * attach this feature
  133220. *
  133221. * @param force should attachment be forced (even when already attached)
  133222. * @returns true if successful, false is failed or already attached
  133223. */
  133224. attach(force?: boolean): boolean;
  133225. /**
  133226. * detach this feature.
  133227. *
  133228. * @returns true if successful, false if failed or already detached
  133229. */
  133230. detach(): boolean;
  133231. /**
  133232. * Dispose this feature and all of the resources attached
  133233. */
  133234. dispose(): void;
  133235. /**
  133236. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  133237. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  133238. *
  133239. * @returns whether or not the feature is compatible in this environment
  133240. */
  133241. isCompatible(): boolean;
  133242. /**
  133243. * This is used to register callbacks that will automatically be removed when detach is called.
  133244. * @param observable the observable to which the observer will be attached
  133245. * @param callback the callback to register
  133246. */
  133247. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  133248. /**
  133249. * Code in this function will be executed on each xrFrame received from the browser.
  133250. * This function will not execute after the feature is detached.
  133251. * @param _xrFrame the current frame
  133252. */
  133253. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  133254. }
  133255. }
  133256. declare module BABYLON {
  133257. /**
  133258. * Renders a layer on top of an existing scene
  133259. */
  133260. export class UtilityLayerRenderer implements IDisposable {
  133261. /** the original scene that will be rendered on top of */
  133262. originalScene: Scene;
  133263. private _pointerCaptures;
  133264. private _lastPointerEvents;
  133265. private static _DefaultUtilityLayer;
  133266. private static _DefaultKeepDepthUtilityLayer;
  133267. private _sharedGizmoLight;
  133268. private _renderCamera;
  133269. /**
  133270. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  133271. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  133272. * @returns the camera that is used when rendering the utility layer
  133273. */
  133274. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  133275. /**
  133276. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  133277. * @param cam the camera that should be used when rendering the utility layer
  133278. */
  133279. setRenderCamera(cam: Nullable<Camera>): void;
  133280. /**
  133281. * @hidden
  133282. * Light which used by gizmos to get light shading
  133283. */
  133284. _getSharedGizmoLight(): HemisphericLight;
  133285. /**
  133286. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  133287. */
  133288. pickUtilitySceneFirst: boolean;
  133289. /**
  133290. * 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)
  133291. */
  133292. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  133293. /**
  133294. * 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)
  133295. */
  133296. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  133297. /**
  133298. * The scene that is rendered on top of the original scene
  133299. */
  133300. utilityLayerScene: Scene;
  133301. /**
  133302. * If the utility layer should automatically be rendered on top of existing scene
  133303. */
  133304. shouldRender: boolean;
  133305. /**
  133306. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  133307. */
  133308. onlyCheckPointerDownEvents: boolean;
  133309. /**
  133310. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  133311. */
  133312. processAllEvents: boolean;
  133313. /**
  133314. * Observable raised when the pointer move from the utility layer scene to the main scene
  133315. */
  133316. onPointerOutObservable: Observable<number>;
  133317. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  133318. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  133319. private _afterRenderObserver;
  133320. private _sceneDisposeObserver;
  133321. private _originalPointerObserver;
  133322. /**
  133323. * Instantiates a UtilityLayerRenderer
  133324. * @param originalScene the original scene that will be rendered on top of
  133325. * @param handleEvents boolean indicating if the utility layer should handle events
  133326. */
  133327. constructor(
  133328. /** the original scene that will be rendered on top of */
  133329. originalScene: Scene, handleEvents?: boolean);
  133330. private _notifyObservers;
  133331. /**
  133332. * Renders the utility layers scene on top of the original scene
  133333. */
  133334. render(): void;
  133335. /**
  133336. * Disposes of the renderer
  133337. */
  133338. dispose(): void;
  133339. private _updateCamera;
  133340. }
  133341. }
  133342. declare module BABYLON {
  133343. /**
  133344. * Options interface for the pointer selection module
  133345. */
  133346. export interface IWebXRControllerPointerSelectionOptions {
  133347. /**
  133348. * if provided, this scene will be used to render meshes.
  133349. */
  133350. customUtilityLayerScene?: Scene;
  133351. /**
  133352. * 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)
  133353. * If not disabled, the last picked point will be used to execute a pointer up event
  133354. * If disabled, pointer up event will be triggered right after the pointer down event.
  133355. * Used in screen and gaze target ray mode only
  133356. */
  133357. disablePointerUpOnTouchOut: boolean;
  133358. /**
  133359. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  133360. */
  133361. forceGazeMode: boolean;
  133362. /**
  133363. * 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
  133364. * to start a new countdown to the pointer down event.
  133365. * Defaults to 1.
  133366. */
  133367. gazeModePointerMovedFactor?: number;
  133368. /**
  133369. * Different button type to use instead of the main component
  133370. */
  133371. overrideButtonId?: string;
  133372. /**
  133373. * use this rendering group id for the meshes (optional)
  133374. */
  133375. renderingGroupId?: number;
  133376. /**
  133377. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  133378. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  133379. * 3000 means 3 seconds between pointing at something and selecting it
  133380. */
  133381. timeToSelect?: number;
  133382. /**
  133383. * Should meshes created here be added to a utility layer or the main scene
  133384. */
  133385. useUtilityLayer?: boolean;
  133386. /**
  133387. * Optional WebXR camera to be used for gaze selection
  133388. */
  133389. gazeCamera?: WebXRCamera;
  133390. /**
  133391. * the xr input to use with this pointer selection
  133392. */
  133393. xrInput: WebXRInput;
  133394. /**
  133395. * Should the scene pointerX and pointerY update be disabled
  133396. * This is required for fullscreen AR GUI, but might slow down other experiences.
  133397. * Disable in VR, if not needed.
  133398. * The first rig camera (left eye) will be used to calculate the projection
  133399. */
  133400. disableScenePointerVectorUpdate: boolean;
  133401. /**
  133402. * Enable pointer selection on all controllers instead of switching between them
  133403. */
  133404. enablePointerSelectionOnAllControllers?: boolean;
  133405. /**
  133406. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  133407. * If switch is enabled, it will still allow the user to switch between the different controllers
  133408. */
  133409. preferredHandedness?: XRHandedness;
  133410. /**
  133411. * Disable switching the pointer selection from one controller to the other.
  133412. * 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
  133413. */
  133414. disableSwitchOnClick?: boolean;
  133415. /**
  133416. * The maximum distance of the pointer selection feature. Defaults to 100.
  133417. */
  133418. maxPointerDistance?: number;
  133419. }
  133420. /**
  133421. * A module that will enable pointer selection for motion controllers of XR Input Sources
  133422. */
  133423. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  133424. private readonly _options;
  133425. private static _idCounter;
  133426. private _attachController;
  133427. private _controllers;
  133428. private _scene;
  133429. private _tmpVectorForPickCompare;
  133430. private _attachedController;
  133431. /**
  133432. * The module's name
  133433. */
  133434. static readonly Name: string;
  133435. /**
  133436. * The (Babylon) version of this module.
  133437. * This is an integer representing the implementation version.
  133438. * This number does not correspond to the WebXR specs version
  133439. */
  133440. static readonly Version: number;
  133441. /**
  133442. * Disable lighting on the laser pointer (so it will always be visible)
  133443. */
  133444. disablePointerLighting: boolean;
  133445. /**
  133446. * Disable lighting on the selection mesh (so it will always be visible)
  133447. */
  133448. disableSelectionMeshLighting: boolean;
  133449. /**
  133450. * Should the laser pointer be displayed
  133451. */
  133452. displayLaserPointer: boolean;
  133453. /**
  133454. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  133455. */
  133456. displaySelectionMesh: boolean;
  133457. /**
  133458. * This color will be set to the laser pointer when selection is triggered
  133459. */
  133460. laserPointerPickedColor: Color3;
  133461. /**
  133462. * Default color of the laser pointer
  133463. */
  133464. laserPointerDefaultColor: Color3;
  133465. /**
  133466. * default color of the selection ring
  133467. */
  133468. selectionMeshDefaultColor: Color3;
  133469. /**
  133470. * This color will be applied to the selection ring when selection is triggered
  133471. */
  133472. selectionMeshPickedColor: Color3;
  133473. /**
  133474. * Optional filter to be used for ray selection. This predicate shares behavior with
  133475. * scene.pointerMovePredicate which takes priority if it is also assigned.
  133476. */
  133477. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  133478. /**
  133479. * constructs a new background remover module
  133480. * @param _xrSessionManager the session manager for this module
  133481. * @param _options read-only options to be used in this module
  133482. */
  133483. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  133484. /**
  133485. * attach this feature
  133486. * Will usually be called by the features manager
  133487. *
  133488. * @returns true if successful.
  133489. */
  133490. attach(): boolean;
  133491. /**
  133492. * detach this feature.
  133493. * Will usually be called by the features manager
  133494. *
  133495. * @returns true if successful.
  133496. */
  133497. detach(): boolean;
  133498. /**
  133499. * Will get the mesh under a specific pointer.
  133500. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  133501. * @param controllerId the controllerId to check
  133502. * @returns The mesh under pointer or null if no mesh is under the pointer
  133503. */
  133504. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  133505. /**
  133506. * Get the xr controller that correlates to the pointer id in the pointer event
  133507. *
  133508. * @param id the pointer id to search for
  133509. * @returns the controller that correlates to this id or null if not found
  133510. */
  133511. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  133512. private _identityMatrix;
  133513. private _screenCoordinatesRef;
  133514. private _viewportRef;
  133515. protected _onXRFrame(_xrFrame: XRFrame): void;
  133516. private _attachGazeMode;
  133517. private _attachScreenRayMode;
  133518. private _attachTrackedPointerRayMode;
  133519. private _convertNormalToDirectionOfRay;
  133520. private _detachController;
  133521. private _generateNewMeshPair;
  133522. private _pickingMoved;
  133523. private _updatePointerDistance;
  133524. /** @hidden */
  133525. get lasterPointerDefaultColor(): Color3;
  133526. }
  133527. }
  133528. declare module BABYLON {
  133529. /**
  133530. * Button which can be used to enter a different mode of XR
  133531. */
  133532. export class WebXREnterExitUIButton {
  133533. /** button element */
  133534. element: HTMLElement;
  133535. /** XR initialization options for the button */
  133536. sessionMode: XRSessionMode;
  133537. /** Reference space type */
  133538. referenceSpaceType: XRReferenceSpaceType;
  133539. /**
  133540. * Creates a WebXREnterExitUIButton
  133541. * @param element button element
  133542. * @param sessionMode XR initialization session mode
  133543. * @param referenceSpaceType the type of reference space to be used
  133544. */
  133545. constructor(
  133546. /** button element */
  133547. element: HTMLElement,
  133548. /** XR initialization options for the button */
  133549. sessionMode: XRSessionMode,
  133550. /** Reference space type */
  133551. referenceSpaceType: XRReferenceSpaceType);
  133552. /**
  133553. * Extendable function which can be used to update the button's visuals when the state changes
  133554. * @param activeButton the current active button in the UI
  133555. */
  133556. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  133557. }
  133558. /**
  133559. * Options to create the webXR UI
  133560. */
  133561. export class WebXREnterExitUIOptions {
  133562. /**
  133563. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  133564. */
  133565. customButtons?: Array<WebXREnterExitUIButton>;
  133566. /**
  133567. * A reference space type to use when creating the default button.
  133568. * Default is local-floor
  133569. */
  133570. referenceSpaceType?: XRReferenceSpaceType;
  133571. /**
  133572. * Context to enter xr with
  133573. */
  133574. renderTarget?: Nullable<WebXRRenderTarget>;
  133575. /**
  133576. * A session mode to use when creating the default button.
  133577. * Default is immersive-vr
  133578. */
  133579. sessionMode?: XRSessionMode;
  133580. /**
  133581. * A list of optional features to init the session with
  133582. */
  133583. optionalFeatures?: string[];
  133584. /**
  133585. * A list of optional features to init the session with
  133586. */
  133587. requiredFeatures?: string[];
  133588. /**
  133589. * If defined, this function will be executed if the UI encounters an error when entering XR
  133590. */
  133591. onError?: (error: any) => void;
  133592. }
  133593. /**
  133594. * UI to allow the user to enter/exit XR mode
  133595. */
  133596. export class WebXREnterExitUI implements IDisposable {
  133597. private scene;
  133598. /** version of the options passed to this UI */
  133599. options: WebXREnterExitUIOptions;
  133600. private _activeButton;
  133601. private _buttons;
  133602. /**
  133603. * The HTML Div Element to which buttons are added.
  133604. */
  133605. readonly overlay: HTMLDivElement;
  133606. /**
  133607. * Fired every time the active button is changed.
  133608. *
  133609. * When xr is entered via a button that launches xr that button will be the callback parameter
  133610. *
  133611. * When exiting xr the callback parameter will be null)
  133612. */
  133613. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  133614. /**
  133615. *
  133616. * @param scene babylon scene object to use
  133617. * @param options (read-only) version of the options passed to this UI
  133618. */
  133619. private constructor();
  133620. /**
  133621. * Creates UI to allow the user to enter/exit XR mode
  133622. * @param scene the scene to add the ui to
  133623. * @param helper the xr experience helper to enter/exit xr with
  133624. * @param options options to configure the UI
  133625. * @returns the created ui
  133626. */
  133627. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  133628. /**
  133629. * Disposes of the XR UI component
  133630. */
  133631. dispose(): void;
  133632. private _updateButtons;
  133633. }
  133634. }
  133635. declare module BABYLON {
  133636. /**
  133637. * Class containing static functions to help procedurally build meshes
  133638. */
  133639. export class LinesBuilder {
  133640. /**
  133641. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  133642. * * 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
  133643. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  133644. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  133645. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  133646. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  133647. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133648. * * 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
  133649. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  133650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  133652. * @param name defines the name of the new line system
  133653. * @param options defines the options used to create the line system
  133654. * @param scene defines the hosting scene
  133655. * @returns a new line system mesh
  133656. */
  133657. static CreateLineSystem(name: string, options: {
  133658. lines: Vector3[][];
  133659. updatable?: boolean;
  133660. instance?: Nullable<LinesMesh>;
  133661. colors?: Nullable<Color4[][]>;
  133662. useVertexAlpha?: boolean;
  133663. }, scene: Nullable<Scene>): LinesMesh;
  133664. /**
  133665. * Creates a line mesh
  133666. * 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
  133667. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133668. * * The parameter `points` is an array successive Vector3
  133669. * * 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
  133670. * * The optional parameter `colors` is an array of successive Color4, one per line point
  133671. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  133672. * * When updating an instance, remember that only point positions can change, not the number of points
  133673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133674. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  133675. * @param name defines the name of the new line system
  133676. * @param options defines the options used to create the line system
  133677. * @param scene defines the hosting scene
  133678. * @returns a new line mesh
  133679. */
  133680. static CreateLines(name: string, options: {
  133681. points: Vector3[];
  133682. updatable?: boolean;
  133683. instance?: Nullable<LinesMesh>;
  133684. colors?: Color4[];
  133685. useVertexAlpha?: boolean;
  133686. }, scene?: Nullable<Scene>): LinesMesh;
  133687. /**
  133688. * Creates a dashed line mesh
  133689. * * 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
  133690. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133691. * * The parameter `points` is an array successive Vector3
  133692. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  133693. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  133694. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  133695. * * 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
  133696. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133697. * * When updating an instance, remember that only point positions can change, not the number of points
  133698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133699. * @param name defines the name of the mesh
  133700. * @param options defines the options used to create the mesh
  133701. * @param scene defines the hosting scene
  133702. * @returns the dashed line mesh
  133703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  133704. */
  133705. static CreateDashedLines(name: string, options: {
  133706. points: Vector3[];
  133707. dashSize?: number;
  133708. gapSize?: number;
  133709. dashNb?: number;
  133710. updatable?: boolean;
  133711. instance?: LinesMesh;
  133712. useVertexAlpha?: boolean;
  133713. }, scene?: Nullable<Scene>): LinesMesh;
  133714. }
  133715. }
  133716. declare module BABYLON {
  133717. /**
  133718. * Construction options for a timer
  133719. */
  133720. export interface ITimerOptions<T> {
  133721. /**
  133722. * Time-to-end
  133723. */
  133724. timeout: number;
  133725. /**
  133726. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  133727. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  133728. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  133729. */
  133730. contextObservable: Observable<T>;
  133731. /**
  133732. * Optional parameters when adding an observer to the observable
  133733. */
  133734. observableParameters?: {
  133735. mask?: number;
  133736. insertFirst?: boolean;
  133737. scope?: any;
  133738. };
  133739. /**
  133740. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  133741. */
  133742. breakCondition?: (data?: ITimerData<T>) => boolean;
  133743. /**
  133744. * Will be triggered when the time condition has met
  133745. */
  133746. onEnded?: (data: ITimerData<any>) => void;
  133747. /**
  133748. * Will be triggered when the break condition has met (prematurely ended)
  133749. */
  133750. onAborted?: (data: ITimerData<any>) => void;
  133751. /**
  133752. * Optional function to execute on each tick (or count)
  133753. */
  133754. onTick?: (data: ITimerData<any>) => void;
  133755. }
  133756. /**
  133757. * An interface defining the data sent by the timer
  133758. */
  133759. export interface ITimerData<T> {
  133760. /**
  133761. * When did it start
  133762. */
  133763. startTime: number;
  133764. /**
  133765. * Time now
  133766. */
  133767. currentTime: number;
  133768. /**
  133769. * Time passed since started
  133770. */
  133771. deltaTime: number;
  133772. /**
  133773. * How much is completed, in [0.0...1.0].
  133774. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  133775. */
  133776. completeRate: number;
  133777. /**
  133778. * What the registered observable sent in the last count
  133779. */
  133780. payload: T;
  133781. }
  133782. /**
  133783. * The current state of the timer
  133784. */
  133785. export enum TimerState {
  133786. /**
  133787. * Timer initialized, not yet started
  133788. */
  133789. INIT = 0,
  133790. /**
  133791. * Timer started and counting
  133792. */
  133793. STARTED = 1,
  133794. /**
  133795. * Timer ended (whether aborted or time reached)
  133796. */
  133797. ENDED = 2
  133798. }
  133799. /**
  133800. * A simple version of the timer. Will take options and start the timer immediately after calling it
  133801. *
  133802. * @param options options with which to initialize this timer
  133803. */
  133804. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  133805. /**
  133806. * An advanced implementation of a timer class
  133807. */
  133808. export class AdvancedTimer<T = any> implements IDisposable {
  133809. /**
  133810. * Will notify each time the timer calculates the remaining time
  133811. */
  133812. onEachCountObservable: Observable<ITimerData<T>>;
  133813. /**
  133814. * Will trigger when the timer was aborted due to the break condition
  133815. */
  133816. onTimerAbortedObservable: Observable<ITimerData<T>>;
  133817. /**
  133818. * Will trigger when the timer ended successfully
  133819. */
  133820. onTimerEndedObservable: Observable<ITimerData<T>>;
  133821. /**
  133822. * Will trigger when the timer state has changed
  133823. */
  133824. onStateChangedObservable: Observable<TimerState>;
  133825. private _observer;
  133826. private _contextObservable;
  133827. private _observableParameters;
  133828. private _startTime;
  133829. private _timer;
  133830. private _state;
  133831. private _breakCondition;
  133832. private _timeToEnd;
  133833. private _breakOnNextTick;
  133834. /**
  133835. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  133836. * @param options construction options for this advanced timer
  133837. */
  133838. constructor(options: ITimerOptions<T>);
  133839. /**
  133840. * set a breaking condition for this timer. Default is to never break during count
  133841. * @param predicate the new break condition. Returns true to break, false otherwise
  133842. */
  133843. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  133844. /**
  133845. * Reset ALL associated observables in this advanced timer
  133846. */
  133847. clearObservables(): void;
  133848. /**
  133849. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  133850. *
  133851. * @param timeToEnd how much time to measure until timer ended
  133852. */
  133853. start(timeToEnd?: number): void;
  133854. /**
  133855. * Will force a stop on the next tick.
  133856. */
  133857. stop(): void;
  133858. /**
  133859. * Dispose this timer, clearing all resources
  133860. */
  133861. dispose(): void;
  133862. private _setState;
  133863. private _tick;
  133864. private _stop;
  133865. }
  133866. }
  133867. declare module BABYLON {
  133868. /**
  133869. * The options container for the teleportation module
  133870. */
  133871. export interface IWebXRTeleportationOptions {
  133872. /**
  133873. * if provided, this scene will be used to render meshes.
  133874. */
  133875. customUtilityLayerScene?: Scene;
  133876. /**
  133877. * Values to configure the default target mesh
  133878. */
  133879. defaultTargetMeshOptions?: {
  133880. /**
  133881. * Fill color of the teleportation area
  133882. */
  133883. teleportationFillColor?: string;
  133884. /**
  133885. * Border color for the teleportation area
  133886. */
  133887. teleportationBorderColor?: string;
  133888. /**
  133889. * Disable the mesh's animation sequence
  133890. */
  133891. disableAnimation?: boolean;
  133892. /**
  133893. * Disable lighting on the material or the ring and arrow
  133894. */
  133895. disableLighting?: boolean;
  133896. /**
  133897. * Override the default material of the torus and arrow
  133898. */
  133899. torusArrowMaterial?: Material;
  133900. };
  133901. /**
  133902. * A list of meshes to use as floor meshes.
  133903. * Meshes can be added and removed after initializing the feature using the
  133904. * addFloorMesh and removeFloorMesh functions
  133905. * If empty, rotation will still work
  133906. */
  133907. floorMeshes?: AbstractMesh[];
  133908. /**
  133909. * use this rendering group id for the meshes (optional)
  133910. */
  133911. renderingGroupId?: number;
  133912. /**
  133913. * Should teleportation move only to snap points
  133914. */
  133915. snapPointsOnly?: boolean;
  133916. /**
  133917. * An array of points to which the teleportation will snap to.
  133918. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  133919. */
  133920. snapPositions?: Vector3[];
  133921. /**
  133922. * How close should the teleportation ray be in order to snap to position.
  133923. * Default to 0.8 units (meters)
  133924. */
  133925. snapToPositionRadius?: number;
  133926. /**
  133927. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  133928. * If you want to support rotation, make sure your mesh has a direction indicator.
  133929. *
  133930. * When left untouched, the default mesh will be initialized.
  133931. */
  133932. teleportationTargetMesh?: AbstractMesh;
  133933. /**
  133934. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  133935. */
  133936. timeToTeleport?: number;
  133937. /**
  133938. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  133939. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  133940. */
  133941. useMainComponentOnly?: boolean;
  133942. /**
  133943. * Should meshes created here be added to a utility layer or the main scene
  133944. */
  133945. useUtilityLayer?: boolean;
  133946. /**
  133947. * Babylon XR Input class for controller
  133948. */
  133949. xrInput: WebXRInput;
  133950. /**
  133951. * Meshes that the teleportation ray cannot go through
  133952. */
  133953. pickBlockerMeshes?: AbstractMesh[];
  133954. }
  133955. /**
  133956. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  133957. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  133958. * the input of the attached controllers.
  133959. */
  133960. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  133961. private _options;
  133962. private _controllers;
  133963. private _currentTeleportationControllerId;
  133964. private _floorMeshes;
  133965. private _quadraticBezierCurve;
  133966. private _selectionFeature;
  133967. private _snapToPositions;
  133968. private _snappedToPoint;
  133969. private _teleportationRingMaterial?;
  133970. private _tmpRay;
  133971. private _tmpVector;
  133972. private _tmpQuaternion;
  133973. /**
  133974. * The module's name
  133975. */
  133976. static readonly Name: string;
  133977. /**
  133978. * The (Babylon) version of this module.
  133979. * This is an integer representing the implementation version.
  133980. * This number does not correspond to the webxr specs version
  133981. */
  133982. static readonly Version: number;
  133983. /**
  133984. * Is movement backwards enabled
  133985. */
  133986. backwardsMovementEnabled: boolean;
  133987. /**
  133988. * Distance to travel when moving backwards
  133989. */
  133990. backwardsTeleportationDistance: number;
  133991. /**
  133992. * The distance from the user to the inspection point in the direction of the controller
  133993. * A higher number will allow the user to move further
  133994. * defaults to 5 (meters, in xr units)
  133995. */
  133996. parabolicCheckRadius: number;
  133997. /**
  133998. * Should the module support parabolic ray on top of direct ray
  133999. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  134000. * Very helpful when moving between floors / different heights
  134001. */
  134002. parabolicRayEnabled: boolean;
  134003. /**
  134004. * How much rotation should be applied when rotating right and left
  134005. */
  134006. rotationAngle: number;
  134007. /**
  134008. * Is rotation enabled when moving forward?
  134009. * Disabling this feature will prevent the user from deciding the direction when teleporting
  134010. */
  134011. rotationEnabled: boolean;
  134012. /**
  134013. * constructs a new anchor system
  134014. * @param _xrSessionManager an instance of WebXRSessionManager
  134015. * @param _options configuration object for this feature
  134016. */
  134017. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  134018. /**
  134019. * Get the snapPointsOnly flag
  134020. */
  134021. get snapPointsOnly(): boolean;
  134022. /**
  134023. * Sets the snapPointsOnly flag
  134024. * @param snapToPoints should teleportation be exclusively to snap points
  134025. */
  134026. set snapPointsOnly(snapToPoints: boolean);
  134027. /**
  134028. * Add a new mesh to the floor meshes array
  134029. * @param mesh the mesh to use as floor mesh
  134030. */
  134031. addFloorMesh(mesh: AbstractMesh): void;
  134032. /**
  134033. * Add a new snap-to point to fix teleportation to this position
  134034. * @param newSnapPoint The new Snap-To point
  134035. */
  134036. addSnapPoint(newSnapPoint: Vector3): void;
  134037. attach(): boolean;
  134038. detach(): boolean;
  134039. dispose(): void;
  134040. /**
  134041. * Remove a mesh from the floor meshes array
  134042. * @param mesh the mesh to remove
  134043. */
  134044. removeFloorMesh(mesh: AbstractMesh): void;
  134045. /**
  134046. * Remove a mesh from the floor meshes array using its name
  134047. * @param name the mesh name to remove
  134048. */
  134049. removeFloorMeshByName(name: string): void;
  134050. /**
  134051. * 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
  134052. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  134053. * @returns was the point found and removed or not
  134054. */
  134055. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  134056. /**
  134057. * This function sets a selection feature that will be disabled when
  134058. * the forward ray is shown and will be reattached when hidden.
  134059. * This is used to remove the selection rays when moving.
  134060. * @param selectionFeature the feature to disable when forward movement is enabled
  134061. */
  134062. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  134063. protected _onXRFrame(_xrFrame: XRFrame): void;
  134064. private _attachController;
  134065. private _createDefaultTargetMesh;
  134066. private _detachController;
  134067. private _findClosestSnapPointWithRadius;
  134068. private _setTargetMeshPosition;
  134069. private _setTargetMeshVisibility;
  134070. private _showParabolicPath;
  134071. private _teleportForward;
  134072. }
  134073. }
  134074. declare module BABYLON {
  134075. /**
  134076. * Options for the default xr helper
  134077. */
  134078. export class WebXRDefaultExperienceOptions {
  134079. /**
  134080. * Enable or disable default UI to enter XR
  134081. */
  134082. disableDefaultUI?: boolean;
  134083. /**
  134084. * Should teleportation not initialize. defaults to false.
  134085. */
  134086. disableTeleportation?: boolean;
  134087. /**
  134088. * Floor meshes that will be used for teleport
  134089. */
  134090. floorMeshes?: Array<AbstractMesh>;
  134091. /**
  134092. * If set to true, the first frame will not be used to reset position
  134093. * The first frame is mainly used when copying transformation from the old camera
  134094. * Mainly used in AR
  134095. */
  134096. ignoreNativeCameraTransformation?: boolean;
  134097. /**
  134098. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  134099. */
  134100. inputOptions?: IWebXRInputOptions;
  134101. /**
  134102. * optional configuration for the output canvas
  134103. */
  134104. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  134105. /**
  134106. * optional UI options. This can be used among other to change session mode and reference space type
  134107. */
  134108. uiOptions?: WebXREnterExitUIOptions;
  134109. /**
  134110. * When loading teleportation and pointer select, use stable versions instead of latest.
  134111. */
  134112. useStablePlugins?: boolean;
  134113. /**
  134114. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  134115. */
  134116. renderingGroupId?: number;
  134117. /**
  134118. * A list of optional features to init the session with
  134119. * If set to true, all features we support will be added
  134120. */
  134121. optionalFeatures?: boolean | string[];
  134122. }
  134123. /**
  134124. * Default experience which provides a similar setup to the previous webVRExperience
  134125. */
  134126. export class WebXRDefaultExperience {
  134127. /**
  134128. * Base experience
  134129. */
  134130. baseExperience: WebXRExperienceHelper;
  134131. /**
  134132. * Enables ui for entering/exiting xr
  134133. */
  134134. enterExitUI: WebXREnterExitUI;
  134135. /**
  134136. * Input experience extension
  134137. */
  134138. input: WebXRInput;
  134139. /**
  134140. * Enables laser pointer and selection
  134141. */
  134142. pointerSelection: WebXRControllerPointerSelection;
  134143. /**
  134144. * Default target xr should render to
  134145. */
  134146. renderTarget: WebXRRenderTarget;
  134147. /**
  134148. * Enables teleportation
  134149. */
  134150. teleportation: WebXRMotionControllerTeleportation;
  134151. private constructor();
  134152. /**
  134153. * Creates the default xr experience
  134154. * @param scene scene
  134155. * @param options options for basic configuration
  134156. * @returns resulting WebXRDefaultExperience
  134157. */
  134158. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134159. /**
  134160. * DIsposes of the experience helper
  134161. */
  134162. dispose(): void;
  134163. }
  134164. }
  134165. declare module BABYLON {
  134166. /**
  134167. * Options to modify the vr teleportation behavior.
  134168. */
  134169. export interface VRTeleportationOptions {
  134170. /**
  134171. * The name of the mesh which should be used as the teleportation floor. (default: null)
  134172. */
  134173. floorMeshName?: string;
  134174. /**
  134175. * A list of meshes to be used as the teleportation floor. (default: empty)
  134176. */
  134177. floorMeshes?: Mesh[];
  134178. /**
  134179. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  134180. */
  134181. teleportationMode?: number;
  134182. /**
  134183. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  134184. */
  134185. teleportationTime?: number;
  134186. /**
  134187. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  134188. */
  134189. teleportationSpeed?: number;
  134190. /**
  134191. * The easing function used in the animation or null for Linear. (default CircleEase)
  134192. */
  134193. easingFunction?: EasingFunction;
  134194. }
  134195. /**
  134196. * Options to modify the vr experience helper's behavior.
  134197. */
  134198. export interface VRExperienceHelperOptions extends WebVROptions {
  134199. /**
  134200. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  134201. */
  134202. createDeviceOrientationCamera?: boolean;
  134203. /**
  134204. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  134205. */
  134206. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  134207. /**
  134208. * Uses the main button on the controller to toggle the laser casted. (default: true)
  134209. */
  134210. laserToggle?: boolean;
  134211. /**
  134212. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  134213. */
  134214. floorMeshes?: Mesh[];
  134215. /**
  134216. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  134217. */
  134218. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  134219. /**
  134220. * Defines if WebXR should be used instead of WebVR (if available)
  134221. */
  134222. useXR?: boolean;
  134223. }
  134224. /**
  134225. * Event containing information after VR has been entered
  134226. */
  134227. export class OnAfterEnteringVRObservableEvent {
  134228. /**
  134229. * If entering vr was successful
  134230. */
  134231. success: boolean;
  134232. }
  134233. /**
  134234. * Helps to quickly add VR support to an existing scene.
  134235. * See https://doc.babylonjs.com/how_to/webvr_helper
  134236. */
  134237. export class VRExperienceHelper {
  134238. /** Options to modify the vr experience helper's behavior. */
  134239. webVROptions: VRExperienceHelperOptions;
  134240. private _scene;
  134241. private _position;
  134242. private _btnVR;
  134243. private _btnVRDisplayed;
  134244. private _webVRsupported;
  134245. private _webVRready;
  134246. private _webVRrequesting;
  134247. private _webVRpresenting;
  134248. private _hasEnteredVR;
  134249. private _fullscreenVRpresenting;
  134250. private _inputElement;
  134251. private _webVRCamera;
  134252. private _vrDeviceOrientationCamera;
  134253. private _deviceOrientationCamera;
  134254. private _existingCamera;
  134255. private _onKeyDown;
  134256. private _onVrDisplayPresentChange;
  134257. private _onVRDisplayChanged;
  134258. private _onVRRequestPresentStart;
  134259. private _onVRRequestPresentComplete;
  134260. /**
  134261. * 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)
  134262. */
  134263. enableGazeEvenWhenNoPointerLock: boolean;
  134264. /**
  134265. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  134266. */
  134267. exitVROnDoubleTap: boolean;
  134268. /**
  134269. * Observable raised right before entering VR.
  134270. */
  134271. onEnteringVRObservable: Observable<VRExperienceHelper>;
  134272. /**
  134273. * Observable raised when entering VR has completed.
  134274. */
  134275. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  134276. /**
  134277. * Observable raised when exiting VR.
  134278. */
  134279. onExitingVRObservable: Observable<VRExperienceHelper>;
  134280. /**
  134281. * Observable raised when controller mesh is loaded.
  134282. */
  134283. onControllerMeshLoadedObservable: Observable<WebVRController>;
  134284. /** Return this.onEnteringVRObservable
  134285. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  134286. */
  134287. get onEnteringVR(): Observable<VRExperienceHelper>;
  134288. /** Return this.onExitingVRObservable
  134289. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  134290. */
  134291. get onExitingVR(): Observable<VRExperienceHelper>;
  134292. /** Return this.onControllerMeshLoadedObservable
  134293. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  134294. */
  134295. get onControllerMeshLoaded(): Observable<WebVRController>;
  134296. private _rayLength;
  134297. private _useCustomVRButton;
  134298. private _teleportationRequested;
  134299. private _teleportActive;
  134300. private _floorMeshName;
  134301. private _floorMeshesCollection;
  134302. private _teleportationMode;
  134303. private _teleportationTime;
  134304. private _teleportationSpeed;
  134305. private _teleportationEasing;
  134306. private _rotationAllowed;
  134307. private _teleportBackwardsVector;
  134308. private _teleportationTarget;
  134309. private _isDefaultTeleportationTarget;
  134310. private _postProcessMove;
  134311. private _teleportationFillColor;
  134312. private _teleportationBorderColor;
  134313. private _rotationAngle;
  134314. private _haloCenter;
  134315. private _cameraGazer;
  134316. private _padSensibilityUp;
  134317. private _padSensibilityDown;
  134318. private _leftController;
  134319. private _rightController;
  134320. private _gazeColor;
  134321. private _laserColor;
  134322. private _pickedLaserColor;
  134323. private _pickedGazeColor;
  134324. /**
  134325. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  134326. */
  134327. onNewMeshSelected: Observable<AbstractMesh>;
  134328. /**
  134329. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  134330. * This observable will provide the mesh and the controller used to select the mesh
  134331. */
  134332. onMeshSelectedWithController: Observable<{
  134333. mesh: AbstractMesh;
  134334. controller: WebVRController;
  134335. }>;
  134336. /**
  134337. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  134338. */
  134339. onNewMeshPicked: Observable<PickingInfo>;
  134340. private _circleEase;
  134341. /**
  134342. * Observable raised before camera teleportation
  134343. */
  134344. onBeforeCameraTeleport: Observable<Vector3>;
  134345. /**
  134346. * Observable raised after camera teleportation
  134347. */
  134348. onAfterCameraTeleport: Observable<Vector3>;
  134349. /**
  134350. * Observable raised when current selected mesh gets unselected
  134351. */
  134352. onSelectedMeshUnselected: Observable<AbstractMesh>;
  134353. private _raySelectionPredicate;
  134354. /**
  134355. * To be optionaly changed by user to define custom ray selection
  134356. */
  134357. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  134358. /**
  134359. * To be optionaly changed by user to define custom selection logic (after ray selection)
  134360. */
  134361. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  134362. /**
  134363. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  134364. */
  134365. teleportationEnabled: boolean;
  134366. private _defaultHeight;
  134367. private _teleportationInitialized;
  134368. private _interactionsEnabled;
  134369. private _interactionsRequested;
  134370. private _displayGaze;
  134371. private _displayLaserPointer;
  134372. /**
  134373. * The mesh used to display where the user is going to teleport.
  134374. */
  134375. get teleportationTarget(): Mesh;
  134376. /**
  134377. * Sets the mesh to be used to display where the user is going to teleport.
  134378. */
  134379. set teleportationTarget(value: Mesh);
  134380. /**
  134381. * 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
  134382. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  134383. * See https://doc.babylonjs.com/resources/baking_transformations
  134384. */
  134385. get gazeTrackerMesh(): Mesh;
  134386. set gazeTrackerMesh(value: Mesh);
  134387. /**
  134388. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  134389. */
  134390. updateGazeTrackerScale: boolean;
  134391. /**
  134392. * If the gaze trackers color should be updated when selecting meshes
  134393. */
  134394. updateGazeTrackerColor: boolean;
  134395. /**
  134396. * If the controller laser color should be updated when selecting meshes
  134397. */
  134398. updateControllerLaserColor: boolean;
  134399. /**
  134400. * The gaze tracking mesh corresponding to the left controller
  134401. */
  134402. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  134403. /**
  134404. * The gaze tracking mesh corresponding to the right controller
  134405. */
  134406. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  134407. /**
  134408. * If the ray of the gaze should be displayed.
  134409. */
  134410. get displayGaze(): boolean;
  134411. /**
  134412. * Sets if the ray of the gaze should be displayed.
  134413. */
  134414. set displayGaze(value: boolean);
  134415. /**
  134416. * If the ray of the LaserPointer should be displayed.
  134417. */
  134418. get displayLaserPointer(): boolean;
  134419. /**
  134420. * Sets if the ray of the LaserPointer should be displayed.
  134421. */
  134422. set displayLaserPointer(value: boolean);
  134423. /**
  134424. * The deviceOrientationCamera used as the camera when not in VR.
  134425. */
  134426. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  134427. /**
  134428. * Based on the current WebVR support, returns the current VR camera used.
  134429. */
  134430. get currentVRCamera(): Nullable<Camera>;
  134431. /**
  134432. * The webVRCamera which is used when in VR.
  134433. */
  134434. get webVRCamera(): WebVRFreeCamera;
  134435. /**
  134436. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  134437. */
  134438. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  134439. /**
  134440. * The html button that is used to trigger entering into VR.
  134441. */
  134442. get vrButton(): Nullable<HTMLButtonElement>;
  134443. private get _teleportationRequestInitiated();
  134444. /**
  134445. * Defines whether or not Pointer lock should be requested when switching to
  134446. * full screen.
  134447. */
  134448. requestPointerLockOnFullScreen: boolean;
  134449. /**
  134450. * If asking to force XR, this will be populated with the default xr experience
  134451. */
  134452. xr: WebXRDefaultExperience;
  134453. /**
  134454. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  134455. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  134456. */
  134457. xrTestDone: boolean;
  134458. /**
  134459. * Instantiates a VRExperienceHelper.
  134460. * Helps to quickly add VR support to an existing scene.
  134461. * @param scene The scene the VRExperienceHelper belongs to.
  134462. * @param webVROptions Options to modify the vr experience helper's behavior.
  134463. */
  134464. constructor(scene: Scene,
  134465. /** Options to modify the vr experience helper's behavior. */
  134466. webVROptions?: VRExperienceHelperOptions);
  134467. private completeVRInit;
  134468. private _onDefaultMeshLoaded;
  134469. private _onResize;
  134470. private _onFullscreenChange;
  134471. /**
  134472. * Gets a value indicating if we are currently in VR mode.
  134473. */
  134474. get isInVRMode(): boolean;
  134475. private onVrDisplayPresentChange;
  134476. private onVRDisplayChanged;
  134477. private moveButtonToBottomRight;
  134478. private displayVRButton;
  134479. private updateButtonVisibility;
  134480. private _cachedAngularSensibility;
  134481. /**
  134482. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  134483. * Otherwise, will use the fullscreen API.
  134484. */
  134485. enterVR(): void;
  134486. /**
  134487. * Attempt to exit VR, or fullscreen.
  134488. */
  134489. exitVR(): void;
  134490. /**
  134491. * The position of the vr experience helper.
  134492. */
  134493. get position(): Vector3;
  134494. /**
  134495. * Sets the position of the vr experience helper.
  134496. */
  134497. set position(value: Vector3);
  134498. /**
  134499. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  134500. */
  134501. enableInteractions(): void;
  134502. private get _noControllerIsActive();
  134503. private beforeRender;
  134504. private _isTeleportationFloor;
  134505. /**
  134506. * Adds a floor mesh to be used for teleportation.
  134507. * @param floorMesh the mesh to be used for teleportation.
  134508. */
  134509. addFloorMesh(floorMesh: Mesh): void;
  134510. /**
  134511. * Removes a floor mesh from being used for teleportation.
  134512. * @param floorMesh the mesh to be removed.
  134513. */
  134514. removeFloorMesh(floorMesh: Mesh): void;
  134515. /**
  134516. * Enables interactions and teleportation using the VR controllers and gaze.
  134517. * @param vrTeleportationOptions options to modify teleportation behavior.
  134518. */
  134519. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  134520. private _onNewGamepadConnected;
  134521. private _tryEnableInteractionOnController;
  134522. private _onNewGamepadDisconnected;
  134523. private _enableInteractionOnController;
  134524. private _checkTeleportWithRay;
  134525. private _checkRotate;
  134526. private _checkTeleportBackwards;
  134527. private _enableTeleportationOnController;
  134528. private _createTeleportationCircles;
  134529. private _displayTeleportationTarget;
  134530. private _hideTeleportationTarget;
  134531. private _rotateCamera;
  134532. private _moveTeleportationSelectorTo;
  134533. private _workingVector;
  134534. private _workingQuaternion;
  134535. private _workingMatrix;
  134536. /**
  134537. * Time Constant Teleportation Mode
  134538. */
  134539. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  134540. /**
  134541. * Speed Constant Teleportation Mode
  134542. */
  134543. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  134544. /**
  134545. * Teleports the users feet to the desired location
  134546. * @param location The location where the user's feet should be placed
  134547. */
  134548. teleportCamera(location: Vector3): void;
  134549. private _convertNormalToDirectionOfRay;
  134550. private _castRayAndSelectObject;
  134551. private _notifySelectedMeshUnselected;
  134552. /**
  134553. * Permanently set new colors for the laser pointer
  134554. * @param color the new laser color
  134555. * @param pickedColor the new laser color when picked mesh detected
  134556. */
  134557. setLaserColor(color: Color3, pickedColor?: Color3): void;
  134558. /**
  134559. * Set lighting enabled / disabled on the laser pointer of both controllers
  134560. * @param enabled should the lighting be enabled on the laser pointer
  134561. */
  134562. setLaserLightingState(enabled?: boolean): void;
  134563. /**
  134564. * Permanently set new colors for the gaze pointer
  134565. * @param color the new gaze color
  134566. * @param pickedColor the new gaze color when picked mesh detected
  134567. */
  134568. setGazeColor(color: Color3, pickedColor?: Color3): void;
  134569. /**
  134570. * Sets the color of the laser ray from the vr controllers.
  134571. * @param color new color for the ray.
  134572. */
  134573. changeLaserColor(color: Color3): void;
  134574. /**
  134575. * Sets the color of the ray from the vr headsets gaze.
  134576. * @param color new color for the ray.
  134577. */
  134578. changeGazeColor(color: Color3): void;
  134579. /**
  134580. * Exits VR and disposes of the vr experience helper
  134581. */
  134582. dispose(): void;
  134583. /**
  134584. * Gets the name of the VRExperienceHelper class
  134585. * @returns "VRExperienceHelper"
  134586. */
  134587. getClassName(): string;
  134588. }
  134589. }
  134590. declare module BABYLON {
  134591. /**
  134592. * Contains an array of blocks representing the octree
  134593. */
  134594. export interface IOctreeContainer<T> {
  134595. /**
  134596. * Blocks within the octree
  134597. */
  134598. blocks: Array<OctreeBlock<T>>;
  134599. }
  134600. /**
  134601. * Class used to store a cell in an octree
  134602. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134603. */
  134604. export class OctreeBlock<T> {
  134605. /**
  134606. * Gets the content of the current block
  134607. */
  134608. entries: T[];
  134609. /**
  134610. * Gets the list of block children
  134611. */
  134612. blocks: Array<OctreeBlock<T>>;
  134613. private _depth;
  134614. private _maxDepth;
  134615. private _capacity;
  134616. private _minPoint;
  134617. private _maxPoint;
  134618. private _boundingVectors;
  134619. private _creationFunc;
  134620. /**
  134621. * Creates a new block
  134622. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  134623. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  134624. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  134625. * @param depth defines the current depth of this block in the octree
  134626. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  134627. * @param creationFunc defines a callback to call when an element is added to the block
  134628. */
  134629. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  134630. /**
  134631. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  134632. */
  134633. get capacity(): number;
  134634. /**
  134635. * Gets the minimum vector (in world space) of the block's bounding box
  134636. */
  134637. get minPoint(): Vector3;
  134638. /**
  134639. * Gets the maximum vector (in world space) of the block's bounding box
  134640. */
  134641. get maxPoint(): Vector3;
  134642. /**
  134643. * Add a new element to this block
  134644. * @param entry defines the element to add
  134645. */
  134646. addEntry(entry: T): void;
  134647. /**
  134648. * Remove an element from this block
  134649. * @param entry defines the element to remove
  134650. */
  134651. removeEntry(entry: T): void;
  134652. /**
  134653. * Add an array of elements to this block
  134654. * @param entries defines the array of elements to add
  134655. */
  134656. addEntries(entries: T[]): void;
  134657. /**
  134658. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  134659. * @param frustumPlanes defines the frustum planes to test
  134660. * @param selection defines the array to store current content if selection is positive
  134661. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134662. */
  134663. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  134664. /**
  134665. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  134666. * @param sphereCenter defines the bounding sphere center
  134667. * @param sphereRadius defines the bounding sphere radius
  134668. * @param selection defines the array to store current content if selection is positive
  134669. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134670. */
  134671. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  134672. /**
  134673. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  134674. * @param ray defines the ray to test with
  134675. * @param selection defines the array to store current content if selection is positive
  134676. */
  134677. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  134678. /**
  134679. * Subdivide the content into child blocks (this block will then be empty)
  134680. */
  134681. createInnerBlocks(): void;
  134682. /**
  134683. * @hidden
  134684. */
  134685. 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;
  134686. }
  134687. }
  134688. declare module BABYLON {
  134689. /**
  134690. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  134691. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134692. */
  134693. export class Octree<T> {
  134694. /** 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.) */
  134695. maxDepth: number;
  134696. /**
  134697. * Blocks within the octree containing objects
  134698. */
  134699. blocks: Array<OctreeBlock<T>>;
  134700. /**
  134701. * Content stored in the octree
  134702. */
  134703. dynamicContent: T[];
  134704. private _maxBlockCapacity;
  134705. private _selectionContent;
  134706. private _creationFunc;
  134707. /**
  134708. * Creates a octree
  134709. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134710. * @param creationFunc function to be used to instatiate the octree
  134711. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  134712. * @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.)
  134713. */
  134714. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  134715. /** 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.) */
  134716. maxDepth?: number);
  134717. /**
  134718. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  134719. * @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);
  134720. * @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);
  134721. * @param entries meshes to be added to the octree blocks
  134722. */
  134723. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  134724. /**
  134725. * Adds a mesh to the octree
  134726. * @param entry Mesh to add to the octree
  134727. */
  134728. addMesh(entry: T): void;
  134729. /**
  134730. * Remove an element from the octree
  134731. * @param entry defines the element to remove
  134732. */
  134733. removeMesh(entry: T): void;
  134734. /**
  134735. * Selects an array of meshes within the frustum
  134736. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  134737. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  134738. * @returns array of meshes within the frustum
  134739. */
  134740. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  134741. /**
  134742. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  134743. * @param sphereCenter defines the bounding sphere center
  134744. * @param sphereRadius defines the bounding sphere radius
  134745. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134746. * @returns an array of objects that intersect the sphere
  134747. */
  134748. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  134749. /**
  134750. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  134751. * @param ray defines the ray to test with
  134752. * @returns array of intersected objects
  134753. */
  134754. intersectsRay(ray: Ray): SmartArray<T>;
  134755. /**
  134756. * Adds a mesh into the octree block if it intersects the block
  134757. */
  134758. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  134759. /**
  134760. * Adds a submesh into the octree block if it intersects the block
  134761. */
  134762. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  134763. }
  134764. }
  134765. declare module BABYLON {
  134766. interface Scene {
  134767. /**
  134768. * @hidden
  134769. * Backing Filed
  134770. */
  134771. _selectionOctree: Octree<AbstractMesh>;
  134772. /**
  134773. * Gets the octree used to boost mesh selection (picking)
  134774. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134775. */
  134776. selectionOctree: Octree<AbstractMesh>;
  134777. /**
  134778. * Creates or updates the octree used to boost selection (picking)
  134779. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134780. * @param maxCapacity defines the maximum capacity per leaf
  134781. * @param maxDepth defines the maximum depth of the octree
  134782. * @returns an octree of AbstractMesh
  134783. */
  134784. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  134785. }
  134786. interface AbstractMesh {
  134787. /**
  134788. * @hidden
  134789. * Backing Field
  134790. */
  134791. _submeshesOctree: Octree<SubMesh>;
  134792. /**
  134793. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  134794. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  134795. * @param maxCapacity defines the maximum size of each block (64 by default)
  134796. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  134797. * @returns the new octree
  134798. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  134799. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134800. */
  134801. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  134802. }
  134803. /**
  134804. * Defines the octree scene component responsible to manage any octrees
  134805. * in a given scene.
  134806. */
  134807. export class OctreeSceneComponent {
  134808. /**
  134809. * The component name help to identify the component in the list of scene components.
  134810. */
  134811. readonly name: string;
  134812. /**
  134813. * The scene the component belongs to.
  134814. */
  134815. scene: Scene;
  134816. /**
  134817. * Indicates if the meshes have been checked to make sure they are isEnabled()
  134818. */
  134819. readonly checksIsEnabled: boolean;
  134820. /**
  134821. * Creates a new instance of the component for the given scene
  134822. * @param scene Defines the scene to register the component in
  134823. */
  134824. constructor(scene: Scene);
  134825. /**
  134826. * Registers the component in a given scene
  134827. */
  134828. register(): void;
  134829. /**
  134830. * Return the list of active meshes
  134831. * @returns the list of active meshes
  134832. */
  134833. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  134834. /**
  134835. * Return the list of active sub meshes
  134836. * @param mesh The mesh to get the candidates sub meshes from
  134837. * @returns the list of active sub meshes
  134838. */
  134839. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  134840. private _tempRay;
  134841. /**
  134842. * Return the list of sub meshes intersecting with a given local ray
  134843. * @param mesh defines the mesh to find the submesh for
  134844. * @param localRay defines the ray in local space
  134845. * @returns the list of intersecting sub meshes
  134846. */
  134847. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  134848. /**
  134849. * Return the list of sub meshes colliding with a collider
  134850. * @param mesh defines the mesh to find the submesh for
  134851. * @param collider defines the collider to evaluate the collision against
  134852. * @returns the list of colliding sub meshes
  134853. */
  134854. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  134855. /**
  134856. * Rebuilds the elements related to this component in case of
  134857. * context lost for instance.
  134858. */
  134859. rebuild(): void;
  134860. /**
  134861. * Disposes the component and the associated ressources.
  134862. */
  134863. dispose(): void;
  134864. }
  134865. }
  134866. declare module BABYLON {
  134867. /**
  134868. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  134869. */
  134870. export class Gizmo implements IDisposable {
  134871. /** The utility layer the gizmo will be added to */
  134872. gizmoLayer: UtilityLayerRenderer;
  134873. /**
  134874. * The root mesh of the gizmo
  134875. */
  134876. _rootMesh: Mesh;
  134877. private _attachedMesh;
  134878. private _attachedNode;
  134879. /**
  134880. * Ratio for the scale of the gizmo (Default: 1)
  134881. */
  134882. protected _scaleRatio: number;
  134883. /**
  134884. * boolean updated by pointermove when a gizmo mesh is hovered
  134885. */
  134886. protected _isHovered: boolean;
  134887. /**
  134888. * Ratio for the scale of the gizmo (Default: 1)
  134889. */
  134890. set scaleRatio(value: number);
  134891. get scaleRatio(): number;
  134892. /**
  134893. * True when the mouse pointer is hovered a gizmo mesh
  134894. */
  134895. get isHovered(): boolean;
  134896. /**
  134897. * If a custom mesh has been set (Default: false)
  134898. */
  134899. protected _customMeshSet: boolean;
  134900. /**
  134901. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  134902. * * When set, interactions will be enabled
  134903. */
  134904. get attachedMesh(): Nullable<AbstractMesh>;
  134905. set attachedMesh(value: Nullable<AbstractMesh>);
  134906. /**
  134907. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  134908. * * When set, interactions will be enabled
  134909. */
  134910. get attachedNode(): Nullable<Node>;
  134911. set attachedNode(value: Nullable<Node>);
  134912. /**
  134913. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134914. * @param mesh The mesh to replace the default mesh of the gizmo
  134915. */
  134916. setCustomMesh(mesh: Mesh): void;
  134917. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  134918. /**
  134919. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  134920. */
  134921. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134922. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134923. /**
  134924. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  134925. */
  134926. updateGizmoPositionToMatchAttachedMesh: boolean;
  134927. /**
  134928. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  134929. */
  134930. updateScale: boolean;
  134931. protected _interactionsEnabled: boolean;
  134932. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134933. private _beforeRenderObserver;
  134934. private _tempQuaternion;
  134935. private _tempVector;
  134936. private _tempVector2;
  134937. private _tempMatrix1;
  134938. private _tempMatrix2;
  134939. private _rightHandtoLeftHandMatrix;
  134940. /**
  134941. * Creates a gizmo
  134942. * @param gizmoLayer The utility layer the gizmo will be added to
  134943. */
  134944. constructor(
  134945. /** The utility layer the gizmo will be added to */
  134946. gizmoLayer?: UtilityLayerRenderer);
  134947. /**
  134948. * Updates the gizmo to match the attached mesh's position/rotation
  134949. */
  134950. protected _update(): void;
  134951. /**
  134952. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  134953. * @param value Node, TransformNode or mesh
  134954. */
  134955. protected _matrixChanged(): void;
  134956. /**
  134957. * Disposes of the gizmo
  134958. */
  134959. dispose(): void;
  134960. }
  134961. }
  134962. declare module BABYLON {
  134963. /**
  134964. * Single plane drag gizmo
  134965. */
  134966. export class PlaneDragGizmo extends Gizmo {
  134967. /**
  134968. * Drag behavior responsible for the gizmos dragging interactions
  134969. */
  134970. dragBehavior: PointerDragBehavior;
  134971. private _pointerObserver;
  134972. /**
  134973. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134974. */
  134975. snapDistance: number;
  134976. /**
  134977. * Event that fires each time the gizmo snaps to a new location.
  134978. * * snapDistance is the the change in distance
  134979. */
  134980. onSnapObservable: Observable<{
  134981. snapDistance: number;
  134982. }>;
  134983. private _plane;
  134984. private _coloredMaterial;
  134985. private _hoverMaterial;
  134986. private _isEnabled;
  134987. private _parent;
  134988. /** @hidden */
  134989. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  134990. /** @hidden */
  134991. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134992. /**
  134993. * Creates a PlaneDragGizmo
  134994. * @param gizmoLayer The utility layer the gizmo will be added to
  134995. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  134996. * @param color The color of the gizmo
  134997. */
  134998. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  134999. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135000. /**
  135001. * If the gizmo is enabled
  135002. */
  135003. set isEnabled(value: boolean);
  135004. get isEnabled(): boolean;
  135005. /**
  135006. * Disposes of the gizmo
  135007. */
  135008. dispose(): void;
  135009. }
  135010. }
  135011. declare module BABYLON {
  135012. /**
  135013. * Gizmo that enables dragging a mesh along 3 axis
  135014. */
  135015. export class PositionGizmo extends Gizmo {
  135016. /**
  135017. * Internal gizmo used for interactions on the x axis
  135018. */
  135019. xGizmo: AxisDragGizmo;
  135020. /**
  135021. * Internal gizmo used for interactions on the y axis
  135022. */
  135023. yGizmo: AxisDragGizmo;
  135024. /**
  135025. * Internal gizmo used for interactions on the z axis
  135026. */
  135027. zGizmo: AxisDragGizmo;
  135028. /**
  135029. * Internal gizmo used for interactions on the yz plane
  135030. */
  135031. xPlaneGizmo: PlaneDragGizmo;
  135032. /**
  135033. * Internal gizmo used for interactions on the xz plane
  135034. */
  135035. yPlaneGizmo: PlaneDragGizmo;
  135036. /**
  135037. * Internal gizmo used for interactions on the xy plane
  135038. */
  135039. zPlaneGizmo: PlaneDragGizmo;
  135040. /**
  135041. * private variables
  135042. */
  135043. private _meshAttached;
  135044. private _nodeAttached;
  135045. private _snapDistance;
  135046. /** Fires an event when any of it's sub gizmos are dragged */
  135047. onDragStartObservable: Observable<unknown>;
  135048. /** Fires an event when any of it's sub gizmos are released from dragging */
  135049. onDragEndObservable: Observable<unknown>;
  135050. /**
  135051. * If set to true, planar drag is enabled
  135052. */
  135053. private _planarGizmoEnabled;
  135054. get attachedMesh(): Nullable<AbstractMesh>;
  135055. set attachedMesh(mesh: Nullable<AbstractMesh>);
  135056. get attachedNode(): Nullable<Node>;
  135057. set attachedNode(node: Nullable<Node>);
  135058. /**
  135059. * True when the mouse pointer is hovering a gizmo mesh
  135060. */
  135061. get isHovered(): boolean;
  135062. /**
  135063. * Creates a PositionGizmo
  135064. * @param gizmoLayer The utility layer the gizmo will be added to
  135065. @param thickness display gizmo axis thickness
  135066. */
  135067. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  135068. /**
  135069. * If the planar drag gizmo is enabled
  135070. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  135071. */
  135072. set planarGizmoEnabled(value: boolean);
  135073. get planarGizmoEnabled(): boolean;
  135074. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135075. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135076. /**
  135077. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135078. */
  135079. set snapDistance(value: number);
  135080. get snapDistance(): number;
  135081. /**
  135082. * Ratio for the scale of the gizmo (Default: 1)
  135083. */
  135084. set scaleRatio(value: number);
  135085. get scaleRatio(): number;
  135086. /**
  135087. * Disposes of the gizmo
  135088. */
  135089. dispose(): void;
  135090. /**
  135091. * CustomMeshes are not supported by this gizmo
  135092. * @param mesh The mesh to replace the default mesh of the gizmo
  135093. */
  135094. setCustomMesh(mesh: Mesh): void;
  135095. }
  135096. }
  135097. declare module BABYLON {
  135098. /**
  135099. * Single axis drag gizmo
  135100. */
  135101. export class AxisDragGizmo extends Gizmo {
  135102. /**
  135103. * Drag behavior responsible for the gizmos dragging interactions
  135104. */
  135105. dragBehavior: PointerDragBehavior;
  135106. private _pointerObserver;
  135107. /**
  135108. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135109. */
  135110. snapDistance: number;
  135111. /**
  135112. * Event that fires each time the gizmo snaps to a new location.
  135113. * * snapDistance is the the change in distance
  135114. */
  135115. onSnapObservable: Observable<{
  135116. snapDistance: number;
  135117. }>;
  135118. private _isEnabled;
  135119. private _parent;
  135120. private _arrow;
  135121. private _coloredMaterial;
  135122. private _hoverMaterial;
  135123. /** @hidden */
  135124. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  135125. /** @hidden */
  135126. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  135127. /**
  135128. * Creates an AxisDragGizmo
  135129. * @param gizmoLayer The utility layer the gizmo will be added to
  135130. * @param dragAxis The axis which the gizmo will be able to drag on
  135131. * @param color The color of the gizmo
  135132. * @param thickness display gizmo axis thickness
  135133. */
  135134. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  135135. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135136. /**
  135137. * If the gizmo is enabled
  135138. */
  135139. set isEnabled(value: boolean);
  135140. get isEnabled(): boolean;
  135141. /**
  135142. * Disposes of the gizmo
  135143. */
  135144. dispose(): void;
  135145. }
  135146. }
  135147. declare module BABYLON.Debug {
  135148. /**
  135149. * The Axes viewer will show 3 axes in a specific point in space
  135150. */
  135151. export class AxesViewer {
  135152. private _xAxis;
  135153. private _yAxis;
  135154. private _zAxis;
  135155. private _scaleLinesFactor;
  135156. private _instanced;
  135157. /**
  135158. * Gets the hosting scene
  135159. */
  135160. scene: Nullable<Scene>;
  135161. /**
  135162. * Gets or sets a number used to scale line length
  135163. */
  135164. scaleLines: number;
  135165. /** Gets the node hierarchy used to render x-axis */
  135166. get xAxis(): TransformNode;
  135167. /** Gets the node hierarchy used to render y-axis */
  135168. get yAxis(): TransformNode;
  135169. /** Gets the node hierarchy used to render z-axis */
  135170. get zAxis(): TransformNode;
  135171. /**
  135172. * Creates a new AxesViewer
  135173. * @param scene defines the hosting scene
  135174. * @param scaleLines defines a number used to scale line length (1 by default)
  135175. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  135176. * @param xAxis defines the node hierarchy used to render the x-axis
  135177. * @param yAxis defines the node hierarchy used to render the y-axis
  135178. * @param zAxis defines the node hierarchy used to render the z-axis
  135179. */
  135180. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  135181. /**
  135182. * Force the viewer to update
  135183. * @param position defines the position of the viewer
  135184. * @param xaxis defines the x axis of the viewer
  135185. * @param yaxis defines the y axis of the viewer
  135186. * @param zaxis defines the z axis of the viewer
  135187. */
  135188. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  135189. /**
  135190. * Creates an instance of this axes viewer.
  135191. * @returns a new axes viewer with instanced meshes
  135192. */
  135193. createInstance(): AxesViewer;
  135194. /** Releases resources */
  135195. dispose(): void;
  135196. private static _SetRenderingGroupId;
  135197. }
  135198. }
  135199. declare module BABYLON.Debug {
  135200. /**
  135201. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  135202. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  135203. */
  135204. export class BoneAxesViewer extends AxesViewer {
  135205. /**
  135206. * Gets or sets the target mesh where to display the axes viewer
  135207. */
  135208. mesh: Nullable<Mesh>;
  135209. /**
  135210. * Gets or sets the target bone where to display the axes viewer
  135211. */
  135212. bone: Nullable<Bone>;
  135213. /** Gets current position */
  135214. pos: Vector3;
  135215. /** Gets direction of X axis */
  135216. xaxis: Vector3;
  135217. /** Gets direction of Y axis */
  135218. yaxis: Vector3;
  135219. /** Gets direction of Z axis */
  135220. zaxis: Vector3;
  135221. /**
  135222. * Creates a new BoneAxesViewer
  135223. * @param scene defines the hosting scene
  135224. * @param bone defines the target bone
  135225. * @param mesh defines the target mesh
  135226. * @param scaleLines defines a scaling factor for line length (1 by default)
  135227. */
  135228. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  135229. /**
  135230. * Force the viewer to update
  135231. */
  135232. update(): void;
  135233. /** Releases resources */
  135234. dispose(): void;
  135235. }
  135236. }
  135237. declare module BABYLON {
  135238. /**
  135239. * Interface used to define scene explorer extensibility option
  135240. */
  135241. export interface IExplorerExtensibilityOption {
  135242. /**
  135243. * Define the option label
  135244. */
  135245. label: string;
  135246. /**
  135247. * Defines the action to execute on click
  135248. */
  135249. action: (entity: any) => void;
  135250. }
  135251. /**
  135252. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  135253. */
  135254. export interface IExplorerExtensibilityGroup {
  135255. /**
  135256. * Defines a predicate to test if a given type mut be extended
  135257. */
  135258. predicate: (entity: any) => boolean;
  135259. /**
  135260. * Gets the list of options added to a type
  135261. */
  135262. entries: IExplorerExtensibilityOption[];
  135263. }
  135264. /**
  135265. * Interface used to define the options to use to create the Inspector
  135266. */
  135267. export interface IInspectorOptions {
  135268. /**
  135269. * Display in overlay mode (default: false)
  135270. */
  135271. overlay?: boolean;
  135272. /**
  135273. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  135274. */
  135275. globalRoot?: HTMLElement;
  135276. /**
  135277. * Display the Scene explorer
  135278. */
  135279. showExplorer?: boolean;
  135280. /**
  135281. * Display the property inspector
  135282. */
  135283. showInspector?: boolean;
  135284. /**
  135285. * Display in embed mode (both panes on the right)
  135286. */
  135287. embedMode?: boolean;
  135288. /**
  135289. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  135290. */
  135291. handleResize?: boolean;
  135292. /**
  135293. * Allow the panes to popup (default: true)
  135294. */
  135295. enablePopup?: boolean;
  135296. /**
  135297. * Allow the panes to be closed by users (default: true)
  135298. */
  135299. enableClose?: boolean;
  135300. /**
  135301. * Optional list of extensibility entries
  135302. */
  135303. explorerExtensibility?: IExplorerExtensibilityGroup[];
  135304. /**
  135305. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  135306. */
  135307. inspectorURL?: string;
  135308. /**
  135309. * Optional initial tab (default to DebugLayerTab.Properties)
  135310. */
  135311. initialTab?: DebugLayerTab;
  135312. }
  135313. interface Scene {
  135314. /**
  135315. * @hidden
  135316. * Backing field
  135317. */
  135318. _debugLayer: DebugLayer;
  135319. /**
  135320. * Gets the debug layer (aka Inspector) associated with the scene
  135321. * @see https://doc.babylonjs.com/features/playground_debuglayer
  135322. */
  135323. debugLayer: DebugLayer;
  135324. }
  135325. /**
  135326. * Enum of inspector action tab
  135327. */
  135328. export enum DebugLayerTab {
  135329. /**
  135330. * Properties tag (default)
  135331. */
  135332. Properties = 0,
  135333. /**
  135334. * Debug tab
  135335. */
  135336. Debug = 1,
  135337. /**
  135338. * Statistics tab
  135339. */
  135340. Statistics = 2,
  135341. /**
  135342. * Tools tab
  135343. */
  135344. Tools = 3,
  135345. /**
  135346. * Settings tab
  135347. */
  135348. Settings = 4
  135349. }
  135350. /**
  135351. * The debug layer (aka Inspector) is the go to tool in order to better understand
  135352. * what is happening in your scene
  135353. * @see https://doc.babylonjs.com/features/playground_debuglayer
  135354. */
  135355. export class DebugLayer {
  135356. /**
  135357. * Define the url to get the inspector script from.
  135358. * By default it uses the babylonjs CDN.
  135359. * @ignoreNaming
  135360. */
  135361. static InspectorURL: string;
  135362. private _scene;
  135363. private BJSINSPECTOR;
  135364. private _onPropertyChangedObservable?;
  135365. /**
  135366. * Observable triggered when a property is changed through the inspector.
  135367. */
  135368. get onPropertyChangedObservable(): any;
  135369. /**
  135370. * Instantiates a new debug layer.
  135371. * The debug layer (aka Inspector) is the go to tool in order to better understand
  135372. * what is happening in your scene
  135373. * @see https://doc.babylonjs.com/features/playground_debuglayer
  135374. * @param scene Defines the scene to inspect
  135375. */
  135376. constructor(scene: Scene);
  135377. /** Creates the inspector window. */
  135378. private _createInspector;
  135379. /**
  135380. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  135381. * @param entity defines the entity to select
  135382. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  135383. */
  135384. select(entity: any, lineContainerTitles?: string | string[]): void;
  135385. /** Get the inspector from bundle or global */
  135386. private _getGlobalInspector;
  135387. /**
  135388. * Get if the inspector is visible or not.
  135389. * @returns true if visible otherwise, false
  135390. */
  135391. isVisible(): boolean;
  135392. /**
  135393. * Hide the inspector and close its window.
  135394. */
  135395. hide(): void;
  135396. /**
  135397. * Update the scene in the inspector
  135398. */
  135399. setAsActiveScene(): void;
  135400. /**
  135401. * Launch the debugLayer.
  135402. * @param config Define the configuration of the inspector
  135403. * @return a promise fulfilled when the debug layer is visible
  135404. */
  135405. show(config?: IInspectorOptions): Promise<DebugLayer>;
  135406. }
  135407. }
  135408. declare module BABYLON {
  135409. /**
  135410. * Class containing static functions to help procedurally build meshes
  135411. */
  135412. export class BoxBuilder {
  135413. /**
  135414. * Creates a box mesh
  135415. * * The parameter `size` sets the size (float) of each box side (default 1)
  135416. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  135417. * * 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)
  135418. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135422. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135423. * @param name defines the name of the mesh
  135424. * @param options defines the options used to create the mesh
  135425. * @param scene defines the hosting scene
  135426. * @returns the box mesh
  135427. */
  135428. static CreateBox(name: string, options: {
  135429. size?: number;
  135430. width?: number;
  135431. height?: number;
  135432. depth?: number;
  135433. faceUV?: Vector4[];
  135434. faceColors?: Color4[];
  135435. sideOrientation?: number;
  135436. frontUVs?: Vector4;
  135437. backUVs?: Vector4;
  135438. wrap?: boolean;
  135439. topBaseAt?: number;
  135440. bottomBaseAt?: number;
  135441. updatable?: boolean;
  135442. }, scene?: Nullable<Scene>): Mesh;
  135443. }
  135444. }
  135445. declare module BABYLON.Debug {
  135446. /**
  135447. * Used to show the physics impostor around the specific mesh
  135448. */
  135449. export class PhysicsViewer {
  135450. /** @hidden */
  135451. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  135452. /** @hidden */
  135453. protected _meshes: Array<Nullable<AbstractMesh>>;
  135454. /** @hidden */
  135455. protected _scene: Nullable<Scene>;
  135456. /** @hidden */
  135457. protected _numMeshes: number;
  135458. /** @hidden */
  135459. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  135460. private _renderFunction;
  135461. private _utilityLayer;
  135462. private _debugBoxMesh;
  135463. private _debugSphereMesh;
  135464. private _debugCylinderMesh;
  135465. private _debugMaterial;
  135466. private _debugMeshMeshes;
  135467. /**
  135468. * Creates a new PhysicsViewer
  135469. * @param scene defines the hosting scene
  135470. */
  135471. constructor(scene: Scene);
  135472. /** @hidden */
  135473. protected _updateDebugMeshes(): void;
  135474. /**
  135475. * Renders a specified physic impostor
  135476. * @param impostor defines the impostor to render
  135477. * @param targetMesh defines the mesh represented by the impostor
  135478. * @returns the new debug mesh used to render the impostor
  135479. */
  135480. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  135481. /**
  135482. * Hides a specified physic impostor
  135483. * @param impostor defines the impostor to hide
  135484. */
  135485. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  135486. private _getDebugMaterial;
  135487. private _getDebugBoxMesh;
  135488. private _getDebugSphereMesh;
  135489. private _getDebugCylinderMesh;
  135490. private _getDebugMeshMesh;
  135491. private _getDebugMesh;
  135492. /** Releases all resources */
  135493. dispose(): void;
  135494. }
  135495. }
  135496. declare module BABYLON {
  135497. /**
  135498. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  135499. * in order to better appreciate the issue one might have.
  135500. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  135501. */
  135502. export class RayHelper {
  135503. /**
  135504. * Defines the ray we are currently tryin to visualize.
  135505. */
  135506. ray: Nullable<Ray>;
  135507. private _renderPoints;
  135508. private _renderLine;
  135509. private _renderFunction;
  135510. private _scene;
  135511. private _onAfterRenderObserver;
  135512. private _onAfterStepObserver;
  135513. private _attachedToMesh;
  135514. private _meshSpaceDirection;
  135515. private _meshSpaceOrigin;
  135516. /**
  135517. * Helper function to create a colored helper in a scene in one line.
  135518. * @param ray Defines the ray we are currently tryin to visualize
  135519. * @param scene Defines the scene the ray is used in
  135520. * @param color Defines the color we want to see the ray in
  135521. * @returns The newly created ray helper.
  135522. */
  135523. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  135524. /**
  135525. * Instantiate a new ray helper.
  135526. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  135527. * in order to better appreciate the issue one might have.
  135528. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  135529. * @param ray Defines the ray we are currently tryin to visualize
  135530. */
  135531. constructor(ray: Ray);
  135532. /**
  135533. * Shows the ray we are willing to debug.
  135534. * @param scene Defines the scene the ray needs to be rendered in
  135535. * @param color Defines the color the ray needs to be rendered in
  135536. */
  135537. show(scene: Scene, color?: Color3): void;
  135538. /**
  135539. * Hides the ray we are debugging.
  135540. */
  135541. hide(): void;
  135542. private _render;
  135543. /**
  135544. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  135545. * @param mesh Defines the mesh we want the helper attached to
  135546. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  135547. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  135548. * @param length Defines the length of the ray
  135549. */
  135550. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  135551. /**
  135552. * Detach the ray helper from the mesh it has previously been attached to.
  135553. */
  135554. detachFromMesh(): void;
  135555. private _updateToMesh;
  135556. /**
  135557. * Dispose the helper and release its associated resources.
  135558. */
  135559. dispose(): void;
  135560. }
  135561. }
  135562. declare module BABYLON {
  135563. /**
  135564. * Defines the options associated with the creation of a SkeletonViewer.
  135565. */
  135566. export interface ISkeletonViewerOptions {
  135567. /** Should the system pause animations before building the Viewer? */
  135568. pauseAnimations: boolean;
  135569. /** Should the system return the skeleton to rest before building? */
  135570. returnToRest: boolean;
  135571. /** public Display Mode of the Viewer */
  135572. displayMode: number;
  135573. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  135574. displayOptions: ISkeletonViewerDisplayOptions;
  135575. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  135576. computeBonesUsingShaders: boolean;
  135577. /** Flag ignore non weighted bones */
  135578. useAllBones: boolean;
  135579. }
  135580. /**
  135581. * Defines how to display the various bone meshes for the viewer.
  135582. */
  135583. export interface ISkeletonViewerDisplayOptions {
  135584. /** How far down to start tapering the bone spurs */
  135585. midStep?: number;
  135586. /** How big is the midStep? */
  135587. midStepFactor?: number;
  135588. /** Base for the Sphere Size */
  135589. sphereBaseSize?: number;
  135590. /** The ratio of the sphere to the longest bone in units */
  135591. sphereScaleUnit?: number;
  135592. /** Ratio for the Sphere Size */
  135593. sphereFactor?: number;
  135594. /** Whether a spur should attach its far end to the child bone position */
  135595. spurFollowsChild?: boolean;
  135596. /** Whether to show local axes or not */
  135597. showLocalAxes?: boolean;
  135598. /** Length of each local axis */
  135599. localAxesSize?: number;
  135600. }
  135601. /**
  135602. * Defines the constructor options for the BoneWeight Shader.
  135603. */
  135604. export interface IBoneWeightShaderOptions {
  135605. /** Skeleton to Map */
  135606. skeleton: Skeleton;
  135607. /** Colors for Uninfluenced bones */
  135608. colorBase?: Color3;
  135609. /** Colors for 0.0-0.25 Weight bones */
  135610. colorZero?: Color3;
  135611. /** Color for 0.25-0.5 Weight Influence */
  135612. colorQuarter?: Color3;
  135613. /** Color for 0.5-0.75 Weight Influence */
  135614. colorHalf?: Color3;
  135615. /** Color for 0.75-1 Weight Influence */
  135616. colorFull?: Color3;
  135617. /** Color for Zero Weight Influence */
  135618. targetBoneIndex?: number;
  135619. }
  135620. /**
  135621. * Simple structure of the gradient steps for the Color Map.
  135622. */
  135623. export interface ISkeletonMapShaderColorMapKnot {
  135624. /** Color of the Knot */
  135625. color: Color3;
  135626. /** Location of the Knot */
  135627. location: number;
  135628. }
  135629. /**
  135630. * Defines the constructor options for the SkeletonMap Shader.
  135631. */
  135632. export interface ISkeletonMapShaderOptions {
  135633. /** Skeleton to Map */
  135634. skeleton: Skeleton;
  135635. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  135636. colorMap?: ISkeletonMapShaderColorMapKnot[];
  135637. }
  135638. }
  135639. declare module BABYLON {
  135640. /**
  135641. * Class containing static functions to help procedurally build meshes
  135642. */
  135643. export class RibbonBuilder {
  135644. /**
  135645. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135646. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  135647. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  135648. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  135649. * * 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
  135650. * * 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
  135651. * * 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
  135652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135653. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135654. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135655. * * 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
  135656. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  135657. * * 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
  135658. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  135659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135660. * @param name defines the name of the mesh
  135661. * @param options defines the options used to create the mesh
  135662. * @param scene defines the hosting scene
  135663. * @returns the ribbon mesh
  135664. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  135665. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135666. */
  135667. static CreateRibbon(name: string, options: {
  135668. pathArray: Vector3[][];
  135669. closeArray?: boolean;
  135670. closePath?: boolean;
  135671. offset?: number;
  135672. updatable?: boolean;
  135673. sideOrientation?: number;
  135674. frontUVs?: Vector4;
  135675. backUVs?: Vector4;
  135676. instance?: Mesh;
  135677. invertUV?: boolean;
  135678. uvs?: Vector2[];
  135679. colors?: Color4[];
  135680. }, scene?: Nullable<Scene>): Mesh;
  135681. }
  135682. }
  135683. declare module BABYLON {
  135684. /**
  135685. * Class containing static functions to help procedurally build meshes
  135686. */
  135687. export class ShapeBuilder {
  135688. /**
  135689. * 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.
  135690. * * 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.
  135691. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135692. * * 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.
  135693. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  135694. * * 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
  135695. * * 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
  135696. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  135697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135699. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  135700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135701. * @param name defines the name of the mesh
  135702. * @param options defines the options used to create the mesh
  135703. * @param scene defines the hosting scene
  135704. * @returns the extruded shape mesh
  135705. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135706. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135707. */
  135708. static ExtrudeShape(name: string, options: {
  135709. shape: Vector3[];
  135710. path: Vector3[];
  135711. scale?: number;
  135712. rotation?: number;
  135713. cap?: number;
  135714. updatable?: boolean;
  135715. sideOrientation?: number;
  135716. frontUVs?: Vector4;
  135717. backUVs?: Vector4;
  135718. instance?: Mesh;
  135719. invertUV?: boolean;
  135720. }, scene?: Nullable<Scene>): Mesh;
  135721. /**
  135722. * Creates an custom extruded shape mesh.
  135723. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  135724. * * 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.
  135725. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135726. * * 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
  135727. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  135728. * * 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
  135729. * * It must returns a float value that will be the scale value applied to the shape on each path point
  135730. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  135731. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  135732. * * 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
  135733. * * 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
  135734. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  135735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135737. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135739. * @param name defines the name of the mesh
  135740. * @param options defines the options used to create the mesh
  135741. * @param scene defines the hosting scene
  135742. * @returns the custom extruded shape mesh
  135743. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  135744. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135746. */
  135747. static ExtrudeShapeCustom(name: string, options: {
  135748. shape: Vector3[];
  135749. path: Vector3[];
  135750. scaleFunction?: any;
  135751. rotationFunction?: any;
  135752. ribbonCloseArray?: boolean;
  135753. ribbonClosePath?: boolean;
  135754. cap?: number;
  135755. updatable?: boolean;
  135756. sideOrientation?: number;
  135757. frontUVs?: Vector4;
  135758. backUVs?: Vector4;
  135759. instance?: Mesh;
  135760. invertUV?: boolean;
  135761. }, scene?: Nullable<Scene>): Mesh;
  135762. private static _ExtrudeShapeGeneric;
  135763. }
  135764. }
  135765. declare module BABYLON.Debug {
  135766. /**
  135767. * Class used to render a debug view of a given skeleton
  135768. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  135769. */
  135770. export class SkeletonViewer {
  135771. /** defines the skeleton to render */
  135772. skeleton: Skeleton;
  135773. /** defines the mesh attached to the skeleton */
  135774. mesh: AbstractMesh;
  135775. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135776. autoUpdateBonesMatrices: boolean;
  135777. /** defines the rendering group id to use with the viewer */
  135778. renderingGroupId: number;
  135779. /** is the options for the viewer */
  135780. options: Partial<ISkeletonViewerOptions>;
  135781. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  135782. static readonly DISPLAY_LINES: number;
  135783. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  135784. static readonly DISPLAY_SPHERES: number;
  135785. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  135786. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  135787. /** public static method to create a BoneWeight Shader
  135788. * @param options The constructor options
  135789. * @param scene The scene that the shader is scoped to
  135790. * @returns The created ShaderMaterial
  135791. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  135792. */
  135793. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  135794. /** public static method to create a BoneWeight Shader
  135795. * @param options The constructor options
  135796. * @param scene The scene that the shader is scoped to
  135797. * @returns The created ShaderMaterial
  135798. */
  135799. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  135800. /** private static method to create a BoneWeight Shader
  135801. * @param size The size of the buffer to create (usually the bone count)
  135802. * @param colorMap The gradient data to generate
  135803. * @param scene The scene that the shader is scoped to
  135804. * @returns an Array of floats from the color gradient values
  135805. */
  135806. private static _CreateBoneMapColorBuffer;
  135807. /** If SkeletonViewer scene scope. */
  135808. private _scene;
  135809. /** Gets or sets the color used to render the skeleton */
  135810. color: Color3;
  135811. /** Array of the points of the skeleton fo the line view. */
  135812. private _debugLines;
  135813. /** The SkeletonViewers Mesh. */
  135814. private _debugMesh;
  135815. /** The local axes Meshes. */
  135816. private _localAxes;
  135817. /** If SkeletonViewer is enabled. */
  135818. private _isEnabled;
  135819. /** If SkeletonViewer is ready. */
  135820. private _ready;
  135821. /** SkeletonViewer render observable. */
  135822. private _obs;
  135823. /** The Utility Layer to render the gizmos in. */
  135824. private _utilityLayer;
  135825. private _boneIndices;
  135826. /** Gets the Scene. */
  135827. get scene(): Scene;
  135828. /** Gets the utilityLayer. */
  135829. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  135830. /** Checks Ready Status. */
  135831. get isReady(): Boolean;
  135832. /** Sets Ready Status. */
  135833. set ready(value: boolean);
  135834. /** Gets the debugMesh */
  135835. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  135836. /** Sets the debugMesh */
  135837. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  135838. /** Gets the displayMode */
  135839. get displayMode(): number;
  135840. /** Sets the displayMode */
  135841. set displayMode(value: number);
  135842. /**
  135843. * Creates a new SkeletonViewer
  135844. * @param skeleton defines the skeleton to render
  135845. * @param mesh defines the mesh attached to the skeleton
  135846. * @param scene defines the hosting scene
  135847. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  135848. * @param renderingGroupId defines the rendering group id to use with the viewer
  135849. * @param options All of the extra constructor options for the SkeletonViewer
  135850. */
  135851. constructor(
  135852. /** defines the skeleton to render */
  135853. skeleton: Skeleton,
  135854. /** defines the mesh attached to the skeleton */
  135855. mesh: AbstractMesh,
  135856. /** The Scene scope*/
  135857. scene: Scene,
  135858. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135859. autoUpdateBonesMatrices?: boolean,
  135860. /** defines the rendering group id to use with the viewer */
  135861. renderingGroupId?: number,
  135862. /** is the options for the viewer */
  135863. options?: Partial<ISkeletonViewerOptions>);
  135864. /** The Dynamic bindings for the update functions */
  135865. private _bindObs;
  135866. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  135867. update(): void;
  135868. /** Gets or sets a boolean indicating if the viewer is enabled */
  135869. set isEnabled(value: boolean);
  135870. get isEnabled(): boolean;
  135871. private _getBonePosition;
  135872. private _getLinesForBonesWithLength;
  135873. private _getLinesForBonesNoLength;
  135874. /** function to revert the mesh and scene back to the initial state. */
  135875. private _revert;
  135876. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  135877. private _getAbsoluteBindPoseToRef;
  135878. /** function to build and bind sphere joint points and spur bone representations. */
  135879. private _buildSpheresAndSpurs;
  135880. private _buildLocalAxes;
  135881. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  135882. private _displayLinesUpdate;
  135883. /** Changes the displayMode of the skeleton viewer
  135884. * @param mode The displayMode numerical value
  135885. */
  135886. changeDisplayMode(mode: number): void;
  135887. /** Sets a display option of the skeleton viewer
  135888. *
  135889. * | Option | Type | Default | Description |
  135890. * | ---------------- | ------- | ------- | ----------- |
  135891. * | 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`. |
  135892. * | 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`. |
  135893. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135894. * | 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`. |
  135895. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  135896. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  135897. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  135898. *
  135899. * @param option String of the option name
  135900. * @param value The numerical option value
  135901. */
  135902. changeDisplayOptions(option: string, value: number): void;
  135903. /** Release associated resources */
  135904. dispose(): void;
  135905. }
  135906. }
  135907. declare module BABYLON {
  135908. /**
  135909. * Enum for Device Types
  135910. */
  135911. export enum DeviceType {
  135912. /** Generic */
  135913. Generic = 0,
  135914. /** Keyboard */
  135915. Keyboard = 1,
  135916. /** Mouse */
  135917. Mouse = 2,
  135918. /** Touch Pointers */
  135919. Touch = 3,
  135920. /** PS4 Dual Shock */
  135921. DualShock = 4,
  135922. /** Xbox */
  135923. Xbox = 5,
  135924. /** Switch Controller */
  135925. Switch = 6
  135926. }
  135927. /**
  135928. * Enum for All Pointers (Touch/Mouse)
  135929. */
  135930. export enum PointerInput {
  135931. /** Horizontal Axis */
  135932. Horizontal = 0,
  135933. /** Vertical Axis */
  135934. Vertical = 1,
  135935. /** Left Click or Touch */
  135936. LeftClick = 2,
  135937. /** Middle Click */
  135938. MiddleClick = 3,
  135939. /** Right Click */
  135940. RightClick = 4,
  135941. /** Browser Back */
  135942. BrowserBack = 5,
  135943. /** Browser Forward */
  135944. BrowserForward = 6
  135945. }
  135946. /**
  135947. * Enum for Dual Shock Gamepad
  135948. */
  135949. export enum DualShockInput {
  135950. /** Cross */
  135951. Cross = 0,
  135952. /** Circle */
  135953. Circle = 1,
  135954. /** Square */
  135955. Square = 2,
  135956. /** Triangle */
  135957. Triangle = 3,
  135958. /** L1 */
  135959. L1 = 4,
  135960. /** R1 */
  135961. R1 = 5,
  135962. /** L2 */
  135963. L2 = 6,
  135964. /** R2 */
  135965. R2 = 7,
  135966. /** Share */
  135967. Share = 8,
  135968. /** Options */
  135969. Options = 9,
  135970. /** L3 */
  135971. L3 = 10,
  135972. /** R3 */
  135973. R3 = 11,
  135974. /** DPadUp */
  135975. DPadUp = 12,
  135976. /** DPadDown */
  135977. DPadDown = 13,
  135978. /** DPadLeft */
  135979. DPadLeft = 14,
  135980. /** DRight */
  135981. DPadRight = 15,
  135982. /** Home */
  135983. Home = 16,
  135984. /** TouchPad */
  135985. TouchPad = 17,
  135986. /** LStickXAxis */
  135987. LStickXAxis = 18,
  135988. /** LStickYAxis */
  135989. LStickYAxis = 19,
  135990. /** RStickXAxis */
  135991. RStickXAxis = 20,
  135992. /** RStickYAxis */
  135993. RStickYAxis = 21
  135994. }
  135995. /**
  135996. * Enum for Xbox Gamepad
  135997. */
  135998. export enum XboxInput {
  135999. /** A */
  136000. A = 0,
  136001. /** B */
  136002. B = 1,
  136003. /** X */
  136004. X = 2,
  136005. /** Y */
  136006. Y = 3,
  136007. /** LB */
  136008. LB = 4,
  136009. /** RB */
  136010. RB = 5,
  136011. /** LT */
  136012. LT = 6,
  136013. /** RT */
  136014. RT = 7,
  136015. /** Back */
  136016. Back = 8,
  136017. /** Start */
  136018. Start = 9,
  136019. /** LS */
  136020. LS = 10,
  136021. /** RS */
  136022. RS = 11,
  136023. /** DPadUp */
  136024. DPadUp = 12,
  136025. /** DPadDown */
  136026. DPadDown = 13,
  136027. /** DPadLeft */
  136028. DPadLeft = 14,
  136029. /** DRight */
  136030. DPadRight = 15,
  136031. /** Home */
  136032. Home = 16,
  136033. /** LStickXAxis */
  136034. LStickXAxis = 17,
  136035. /** LStickYAxis */
  136036. LStickYAxis = 18,
  136037. /** RStickXAxis */
  136038. RStickXAxis = 19,
  136039. /** RStickYAxis */
  136040. RStickYAxis = 20
  136041. }
  136042. /**
  136043. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  136044. */
  136045. export enum SwitchInput {
  136046. /** B */
  136047. B = 0,
  136048. /** A */
  136049. A = 1,
  136050. /** Y */
  136051. Y = 2,
  136052. /** X */
  136053. X = 3,
  136054. /** L */
  136055. L = 4,
  136056. /** R */
  136057. R = 5,
  136058. /** ZL */
  136059. ZL = 6,
  136060. /** ZR */
  136061. ZR = 7,
  136062. /** Minus */
  136063. Minus = 8,
  136064. /** Plus */
  136065. Plus = 9,
  136066. /** LS */
  136067. LS = 10,
  136068. /** RS */
  136069. RS = 11,
  136070. /** DPadUp */
  136071. DPadUp = 12,
  136072. /** DPadDown */
  136073. DPadDown = 13,
  136074. /** DPadLeft */
  136075. DPadLeft = 14,
  136076. /** DRight */
  136077. DPadRight = 15,
  136078. /** Home */
  136079. Home = 16,
  136080. /** Capture */
  136081. Capture = 17,
  136082. /** LStickXAxis */
  136083. LStickXAxis = 18,
  136084. /** LStickYAxis */
  136085. LStickYAxis = 19,
  136086. /** RStickXAxis */
  136087. RStickXAxis = 20,
  136088. /** RStickYAxis */
  136089. RStickYAxis = 21
  136090. }
  136091. }
  136092. declare module BABYLON {
  136093. /**
  136094. * This class will take all inputs from Keyboard, Pointer, and
  136095. * any Gamepads and provide a polling system that all devices
  136096. * will use. This class assumes that there will only be one
  136097. * pointer device and one keyboard.
  136098. */
  136099. export class DeviceInputSystem implements IDisposable {
  136100. /**
  136101. * Returns onDeviceConnected callback property
  136102. * @returns Callback with function to execute when a device is connected
  136103. */
  136104. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  136105. /**
  136106. * Sets callback function when a device is connected and executes against all connected devices
  136107. * @param callback Function to execute when a device is connected
  136108. */
  136109. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  136110. /**
  136111. * Callback to be triggered when a device is disconnected
  136112. */
  136113. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  136114. /**
  136115. * Callback to be triggered when event driven input is updated
  136116. */
  136117. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  136118. private _inputs;
  136119. private _gamepads;
  136120. private _keyboardActive;
  136121. private _pointerActive;
  136122. private _elementToAttachTo;
  136123. private _keyboardDownEvent;
  136124. private _keyboardUpEvent;
  136125. private _pointerMoveEvent;
  136126. private _pointerDownEvent;
  136127. private _pointerUpEvent;
  136128. private _gamepadConnectedEvent;
  136129. private _gamepadDisconnectedEvent;
  136130. private _onDeviceConnected;
  136131. private static _MAX_KEYCODES;
  136132. private static _MAX_POINTER_INPUTS;
  136133. private constructor();
  136134. /**
  136135. * Creates a new DeviceInputSystem instance
  136136. * @param engine Engine to pull input element from
  136137. * @returns The new instance
  136138. */
  136139. static Create(engine: Engine): DeviceInputSystem;
  136140. /**
  136141. * Checks for current device input value, given an id and input index
  136142. * @param deviceName Id of connected device
  136143. * @param inputIndex Index of device input
  136144. * @returns Current value of input
  136145. */
  136146. /**
  136147. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  136148. * @param deviceType Enum specifiying device type
  136149. * @param deviceSlot "Slot" or index that device is referenced in
  136150. * @param inputIndex Id of input to be checked
  136151. * @returns Current value of input
  136152. */
  136153. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  136154. /**
  136155. * Dispose of all the eventlisteners
  136156. */
  136157. dispose(): void;
  136158. /**
  136159. * Checks for existing connections to devices and register them, if necessary
  136160. * Currently handles gamepads and mouse
  136161. */
  136162. private _checkForConnectedDevices;
  136163. /**
  136164. * Add a gamepad to the DeviceInputSystem
  136165. * @param gamepad A single DOM Gamepad object
  136166. */
  136167. private _addGamePad;
  136168. /**
  136169. * Add pointer device to DeviceInputSystem
  136170. * @param deviceType Type of Pointer to add
  136171. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  136172. * @param currentX Current X at point of adding
  136173. * @param currentY Current Y at point of adding
  136174. */
  136175. private _addPointerDevice;
  136176. /**
  136177. * Add device and inputs to device array
  136178. * @param deviceType Enum specifiying device type
  136179. * @param deviceSlot "Slot" or index that device is referenced in
  136180. * @param numberOfInputs Number of input entries to create for given device
  136181. */
  136182. private _registerDevice;
  136183. /**
  136184. * Given a specific device name, remove that device from the device map
  136185. * @param deviceType Enum specifiying device type
  136186. * @param deviceSlot "Slot" or index that device is referenced in
  136187. */
  136188. private _unregisterDevice;
  136189. /**
  136190. * Handle all actions that come from keyboard interaction
  136191. */
  136192. private _handleKeyActions;
  136193. /**
  136194. * Handle all actions that come from pointer interaction
  136195. */
  136196. private _handlePointerActions;
  136197. /**
  136198. * Handle all actions that come from gamepad interaction
  136199. */
  136200. private _handleGamepadActions;
  136201. /**
  136202. * Update all non-event based devices with each frame
  136203. * @param deviceType Enum specifiying device type
  136204. * @param deviceSlot "Slot" or index that device is referenced in
  136205. * @param inputIndex Id of input to be checked
  136206. */
  136207. private _updateDevice;
  136208. /**
  136209. * Gets DeviceType from the device name
  136210. * @param deviceName Name of Device from DeviceInputSystem
  136211. * @returns DeviceType enum value
  136212. */
  136213. private _getGamepadDeviceType;
  136214. }
  136215. }
  136216. declare module BABYLON {
  136217. /**
  136218. * Type to handle enforcement of inputs
  136219. */
  136220. 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;
  136221. }
  136222. declare module BABYLON {
  136223. /**
  136224. * Class that handles all input for a specific device
  136225. */
  136226. export class DeviceSource<T extends DeviceType> {
  136227. /** Type of device */
  136228. readonly deviceType: DeviceType;
  136229. /** "Slot" or index that device is referenced in */
  136230. readonly deviceSlot: number;
  136231. /**
  136232. * Observable to handle device input changes per device
  136233. */
  136234. readonly onInputChangedObservable: Observable<{
  136235. inputIndex: DeviceInput<T>;
  136236. previousState: Nullable<number>;
  136237. currentState: Nullable<number>;
  136238. }>;
  136239. private readonly _deviceInputSystem;
  136240. /**
  136241. * Default Constructor
  136242. * @param deviceInputSystem Reference to DeviceInputSystem
  136243. * @param deviceType Type of device
  136244. * @param deviceSlot "Slot" or index that device is referenced in
  136245. */
  136246. constructor(deviceInputSystem: DeviceInputSystem,
  136247. /** Type of device */
  136248. deviceType: DeviceType,
  136249. /** "Slot" or index that device is referenced in */
  136250. deviceSlot?: number);
  136251. /**
  136252. * Get input for specific input
  136253. * @param inputIndex index of specific input on device
  136254. * @returns Input value from DeviceInputSystem
  136255. */
  136256. getInput(inputIndex: DeviceInput<T>): number;
  136257. }
  136258. /**
  136259. * Class to keep track of devices
  136260. */
  136261. export class DeviceSourceManager implements IDisposable {
  136262. /**
  136263. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  136264. */
  136265. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  136266. /**
  136267. * Observable to be triggered when after a device is disconnected
  136268. */
  136269. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  136270. private readonly _devices;
  136271. private readonly _firstDevice;
  136272. private readonly _deviceInputSystem;
  136273. /**
  136274. * Default Constructor
  136275. * @param engine engine to pull input element from
  136276. */
  136277. constructor(engine: Engine);
  136278. /**
  136279. * Gets a DeviceSource, given a type and slot
  136280. * @param deviceType Enum specifying device type
  136281. * @param deviceSlot "Slot" or index that device is referenced in
  136282. * @returns DeviceSource object
  136283. */
  136284. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  136285. /**
  136286. * Gets an array of DeviceSource objects for a given device type
  136287. * @param deviceType Enum specifying device type
  136288. * @returns Array of DeviceSource objects
  136289. */
  136290. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  136291. /**
  136292. * Returns a read-only list of all available devices
  136293. * @returns Read-only array with active devices
  136294. */
  136295. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  136296. /**
  136297. * Dispose of DeviceInputSystem and other parts
  136298. */
  136299. dispose(): void;
  136300. /**
  136301. * Function to add device name to device list
  136302. * @param deviceType Enum specifying device type
  136303. * @param deviceSlot "Slot" or index that device is referenced in
  136304. */
  136305. private _addDevice;
  136306. /**
  136307. * Function to remove device name to device list
  136308. * @param deviceType Enum specifying device type
  136309. * @param deviceSlot "Slot" or index that device is referenced in
  136310. */
  136311. private _removeDevice;
  136312. /**
  136313. * Updates array storing first connected device of each type
  136314. * @param type Type of Device
  136315. */
  136316. private _updateFirstDevices;
  136317. }
  136318. }
  136319. declare module BABYLON {
  136320. /**
  136321. * Options to create the null engine
  136322. */
  136323. export class NullEngineOptions {
  136324. /**
  136325. * Render width (Default: 512)
  136326. */
  136327. renderWidth: number;
  136328. /**
  136329. * Render height (Default: 256)
  136330. */
  136331. renderHeight: number;
  136332. /**
  136333. * Texture size (Default: 512)
  136334. */
  136335. textureSize: number;
  136336. /**
  136337. * If delta time between frames should be constant
  136338. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136339. */
  136340. deterministicLockstep: boolean;
  136341. /**
  136342. * Maximum about of steps between frames (Default: 4)
  136343. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136344. */
  136345. lockstepMaxSteps: number;
  136346. /**
  136347. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  136348. */
  136349. useHighPrecisionMatrix?: boolean;
  136350. }
  136351. /**
  136352. * The null engine class provides support for headless version of babylon.js.
  136353. * This can be used in server side scenario or for testing purposes
  136354. */
  136355. export class NullEngine extends Engine {
  136356. private _options;
  136357. /**
  136358. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  136359. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136360. * @returns true if engine is in deterministic lock step mode
  136361. */
  136362. isDeterministicLockStep(): boolean;
  136363. /**
  136364. * Gets the max steps when engine is running in deterministic lock step
  136365. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136366. * @returns the max steps
  136367. */
  136368. getLockstepMaxSteps(): number;
  136369. /**
  136370. * Gets the current hardware scaling level.
  136371. * By default the hardware scaling level is computed from the window device ratio.
  136372. * 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.
  136373. * @returns a number indicating the current hardware scaling level
  136374. */
  136375. getHardwareScalingLevel(): number;
  136376. constructor(options?: NullEngineOptions);
  136377. /**
  136378. * Creates a vertex buffer
  136379. * @param vertices the data for the vertex buffer
  136380. * @returns the new WebGL static buffer
  136381. */
  136382. createVertexBuffer(vertices: FloatArray): DataBuffer;
  136383. /**
  136384. * Creates a new index buffer
  136385. * @param indices defines the content of the index buffer
  136386. * @param updatable defines if the index buffer must be updatable
  136387. * @returns a new webGL buffer
  136388. */
  136389. createIndexBuffer(indices: IndicesArray): DataBuffer;
  136390. /**
  136391. * Clear the current render buffer or the current render target (if any is set up)
  136392. * @param color defines the color to use
  136393. * @param backBuffer defines if the back buffer must be cleared
  136394. * @param depth defines if the depth buffer must be cleared
  136395. * @param stencil defines if the stencil buffer must be cleared
  136396. */
  136397. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  136398. /**
  136399. * Gets the current render width
  136400. * @param useScreen defines if screen size must be used (or the current render target if any)
  136401. * @returns a number defining the current render width
  136402. */
  136403. getRenderWidth(useScreen?: boolean): number;
  136404. /**
  136405. * Gets the current render height
  136406. * @param useScreen defines if screen size must be used (or the current render target if any)
  136407. * @returns a number defining the current render height
  136408. */
  136409. getRenderHeight(useScreen?: boolean): number;
  136410. /**
  136411. * Set the WebGL's viewport
  136412. * @param viewport defines the viewport element to be used
  136413. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  136414. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  136415. */
  136416. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  136417. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  136418. /**
  136419. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  136420. * @param pipelineContext defines the pipeline context to use
  136421. * @param uniformsNames defines the list of uniform names
  136422. * @returns an array of webGL uniform locations
  136423. */
  136424. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  136425. /**
  136426. * Gets the lsit of active attributes for a given webGL program
  136427. * @param pipelineContext defines the pipeline context to use
  136428. * @param attributesNames defines the list of attribute names to get
  136429. * @returns an array of indices indicating the offset of each attribute
  136430. */
  136431. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  136432. /**
  136433. * Binds an effect to the webGL context
  136434. * @param effect defines the effect to bind
  136435. */
  136436. bindSamplers(effect: Effect): void;
  136437. /**
  136438. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  136439. * @param effect defines the effect to activate
  136440. */
  136441. enableEffect(effect: Effect): void;
  136442. /**
  136443. * Set various states to the webGL context
  136444. * @param culling defines backface culling state
  136445. * @param zOffset defines the value to apply to zOffset (0 by default)
  136446. * @param force defines if states must be applied even if cache is up to date
  136447. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  136448. */
  136449. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  136450. /**
  136451. * Set the value of an uniform to an array of int32
  136452. * @param uniform defines the webGL uniform location where to store the value
  136453. * @param array defines the array of int32 to store
  136454. * @returns true if value was set
  136455. */
  136456. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136457. /**
  136458. * Set the value of an uniform to an array of int32 (stored as vec2)
  136459. * @param uniform defines the webGL uniform location where to store the value
  136460. * @param array defines the array of int32 to store
  136461. * @returns true if value was set
  136462. */
  136463. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136464. /**
  136465. * Set the value of an uniform to an array of int32 (stored as vec3)
  136466. * @param uniform defines the webGL uniform location where to store the value
  136467. * @param array defines the array of int32 to store
  136468. * @returns true if value was set
  136469. */
  136470. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136471. /**
  136472. * Set the value of an uniform to an array of int32 (stored as vec4)
  136473. * @param uniform defines the webGL uniform location where to store the value
  136474. * @param array defines the array of int32 to store
  136475. * @returns true if value was set
  136476. */
  136477. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136478. /**
  136479. * Set the value of an uniform to an array of float32
  136480. * @param uniform defines the webGL uniform location where to store the value
  136481. * @param array defines the array of float32 to store
  136482. * @returns true if value was set
  136483. */
  136484. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136485. /**
  136486. * Set the value of an uniform to an array of float32 (stored as vec2)
  136487. * @param uniform defines the webGL uniform location where to store the value
  136488. * @param array defines the array of float32 to store
  136489. * @returns true if value was set
  136490. */
  136491. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136492. /**
  136493. * Set the value of an uniform to an array of float32 (stored as vec3)
  136494. * @param uniform defines the webGL uniform location where to store the value
  136495. * @param array defines the array of float32 to store
  136496. * @returns true if value was set
  136497. */
  136498. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136499. /**
  136500. * Set the value of an uniform to an array of float32 (stored as vec4)
  136501. * @param uniform defines the webGL uniform location where to store the value
  136502. * @param array defines the array of float32 to store
  136503. * @returns true if value was set
  136504. */
  136505. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136506. /**
  136507. * Set the value of an uniform to an array of number
  136508. * @param uniform defines the webGL uniform location where to store the value
  136509. * @param array defines the array of number to store
  136510. * @returns true if value was set
  136511. */
  136512. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  136513. /**
  136514. * Set the value of an uniform to an array of number (stored as vec2)
  136515. * @param uniform defines the webGL uniform location where to store the value
  136516. * @param array defines the array of number to store
  136517. * @returns true if value was set
  136518. */
  136519. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  136520. /**
  136521. * Set the value of an uniform to an array of number (stored as vec3)
  136522. * @param uniform defines the webGL uniform location where to store the value
  136523. * @param array defines the array of number to store
  136524. * @returns true if value was set
  136525. */
  136526. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  136527. /**
  136528. * Set the value of an uniform to an array of number (stored as vec4)
  136529. * @param uniform defines the webGL uniform location where to store the value
  136530. * @param array defines the array of number to store
  136531. * @returns true if value was set
  136532. */
  136533. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  136534. /**
  136535. * Set the value of an uniform to an array of float32 (stored as matrices)
  136536. * @param uniform defines the webGL uniform location where to store the value
  136537. * @param matrices defines the array of float32 to store
  136538. * @returns true if value was set
  136539. */
  136540. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  136541. /**
  136542. * Set the value of an uniform to a matrix (3x3)
  136543. * @param uniform defines the webGL uniform location where to store the value
  136544. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  136545. * @returns true if value was set
  136546. */
  136547. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136548. /**
  136549. * Set the value of an uniform to a matrix (2x2)
  136550. * @param uniform defines the webGL uniform location where to store the value
  136551. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  136552. * @returns true if value was set
  136553. */
  136554. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136555. /**
  136556. * Set the value of an uniform to a number (float)
  136557. * @param uniform defines the webGL uniform location where to store the value
  136558. * @param value defines the float number to store
  136559. * @returns true if value was set
  136560. */
  136561. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  136562. /**
  136563. * Set the value of an uniform to a vec2
  136564. * @param uniform defines the webGL uniform location where to store the value
  136565. * @param x defines the 1st component of the value
  136566. * @param y defines the 2nd component of the value
  136567. * @returns true if value was set
  136568. */
  136569. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  136570. /**
  136571. * Set the value of an uniform to a vec3
  136572. * @param uniform defines the webGL uniform location where to store the value
  136573. * @param x defines the 1st component of the value
  136574. * @param y defines the 2nd component of the value
  136575. * @param z defines the 3rd component of the value
  136576. * @returns true if value was set
  136577. */
  136578. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  136579. /**
  136580. * Set the value of an uniform to a boolean
  136581. * @param uniform defines the webGL uniform location where to store the value
  136582. * @param bool defines the boolean to store
  136583. * @returns true if value was set
  136584. */
  136585. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  136586. /**
  136587. * Set the value of an uniform to a vec4
  136588. * @param uniform defines the webGL uniform location where to store the value
  136589. * @param x defines the 1st component of the value
  136590. * @param y defines the 2nd component of the value
  136591. * @param z defines the 3rd component of the value
  136592. * @param w defines the 4th component of the value
  136593. * @returns true if value was set
  136594. */
  136595. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  136596. /**
  136597. * Sets the current alpha mode
  136598. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  136599. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  136600. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136601. */
  136602. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  136603. /**
  136604. * Bind webGl buffers directly to the webGL context
  136605. * @param vertexBuffers defines the vertex buffer to bind
  136606. * @param indexBuffer defines the index buffer to bind
  136607. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  136608. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  136609. * @param effect defines the effect associated with the vertex buffer
  136610. */
  136611. bindBuffers(vertexBuffers: {
  136612. [key: string]: VertexBuffer;
  136613. }, indexBuffer: DataBuffer, effect: Effect): void;
  136614. /**
  136615. * Force the entire cache to be cleared
  136616. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  136617. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  136618. */
  136619. wipeCaches(bruteForce?: boolean): void;
  136620. /**
  136621. * Send a draw order
  136622. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  136623. * @param indexStart defines the starting index
  136624. * @param indexCount defines the number of index to draw
  136625. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136626. */
  136627. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  136628. /**
  136629. * Draw a list of indexed primitives
  136630. * @param fillMode defines the primitive to use
  136631. * @param indexStart defines the starting index
  136632. * @param indexCount defines the number of index to draw
  136633. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136634. */
  136635. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  136636. /**
  136637. * Draw a list of unindexed primitives
  136638. * @param fillMode defines the primitive to use
  136639. * @param verticesStart defines the index of first vertex to draw
  136640. * @param verticesCount defines the count of vertices to draw
  136641. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136642. */
  136643. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  136644. /** @hidden */
  136645. _createTexture(): WebGLTexture;
  136646. /** @hidden */
  136647. _releaseTexture(texture: InternalTexture): void;
  136648. /**
  136649. * Usually called from Texture.ts.
  136650. * Passed information to create a WebGLTexture
  136651. * @param urlArg defines a value which contains one of the following:
  136652. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  136653. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  136654. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  136655. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  136656. * @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)
  136657. * @param scene needed for loading to the correct scene
  136658. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  136659. * @param onLoad optional callback to be called upon successful completion
  136660. * @param onError optional callback to be called upon failure
  136661. * @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
  136662. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  136663. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  136664. * @param forcedExtension defines the extension to use to pick the right loader
  136665. * @param mimeType defines an optional mime type
  136666. * @returns a InternalTexture for assignment back into BABYLON.Texture
  136667. */
  136668. 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;
  136669. /**
  136670. * Creates a new render target texture
  136671. * @param size defines the size of the texture
  136672. * @param options defines the options used to create the texture
  136673. * @returns a new render target texture stored in an InternalTexture
  136674. */
  136675. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  136676. /**
  136677. * Update the sampling mode of a given texture
  136678. * @param samplingMode defines the required sampling mode
  136679. * @param texture defines the texture to update
  136680. */
  136681. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136682. /**
  136683. * Binds the frame buffer to the specified texture.
  136684. * @param texture The texture to render to or null for the default canvas
  136685. * @param faceIndex The face of the texture to render to in case of cube texture
  136686. * @param requiredWidth The width of the target to render to
  136687. * @param requiredHeight The height of the target to render to
  136688. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  136689. * @param lodLevel defines le lod level to bind to the frame buffer
  136690. */
  136691. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136692. /**
  136693. * Unbind the current render target texture from the webGL context
  136694. * @param texture defines the render target texture to unbind
  136695. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  136696. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  136697. */
  136698. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136699. /**
  136700. * Creates a dynamic vertex buffer
  136701. * @param vertices the data for the dynamic vertex buffer
  136702. * @returns the new WebGL dynamic buffer
  136703. */
  136704. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  136705. /**
  136706. * Update the content of a dynamic texture
  136707. * @param texture defines the texture to update
  136708. * @param canvas defines the canvas containing the source
  136709. * @param invertY defines if data must be stored with Y axis inverted
  136710. * @param premulAlpha defines if alpha is stored as premultiplied
  136711. * @param format defines the format of the data
  136712. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136713. */
  136714. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136715. /**
  136716. * Gets a boolean indicating if all created effects are ready
  136717. * @returns true if all effects are ready
  136718. */
  136719. areAllEffectsReady(): boolean;
  136720. /**
  136721. * @hidden
  136722. * Get the current error code of the webGL context
  136723. * @returns the error code
  136724. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  136725. */
  136726. getError(): number;
  136727. /** @hidden */
  136728. _getUnpackAlignement(): number;
  136729. /** @hidden */
  136730. _unpackFlipY(value: boolean): void;
  136731. /**
  136732. * Update a dynamic index buffer
  136733. * @param indexBuffer defines the target index buffer
  136734. * @param indices defines the data to update
  136735. * @param offset defines the offset in the target index buffer where update should start
  136736. */
  136737. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  136738. /**
  136739. * Updates a dynamic vertex buffer.
  136740. * @param vertexBuffer the vertex buffer to update
  136741. * @param vertices the data used to update the vertex buffer
  136742. * @param byteOffset the byte offset of the data (optional)
  136743. * @param byteLength the byte length of the data (optional)
  136744. */
  136745. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  136746. /** @hidden */
  136747. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  136748. /** @hidden */
  136749. _bindTexture(channel: number, texture: InternalTexture): void;
  136750. protected _deleteBuffer(buffer: WebGLBuffer): void;
  136751. /**
  136752. * 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
  136753. */
  136754. releaseEffects(): void;
  136755. displayLoadingUI(): void;
  136756. hideLoadingUI(): void;
  136757. /** @hidden */
  136758. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136759. /** @hidden */
  136760. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136761. /** @hidden */
  136762. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136763. /** @hidden */
  136764. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136765. }
  136766. }
  136767. declare module BABYLON {
  136768. /**
  136769. * @hidden
  136770. **/
  136771. export class _TimeToken {
  136772. _startTimeQuery: Nullable<WebGLQuery>;
  136773. _endTimeQuery: Nullable<WebGLQuery>;
  136774. _timeElapsedQuery: Nullable<WebGLQuery>;
  136775. _timeElapsedQueryEnded: boolean;
  136776. }
  136777. }
  136778. declare module BABYLON {
  136779. /** @hidden */
  136780. export class _OcclusionDataStorage {
  136781. /** @hidden */
  136782. occlusionInternalRetryCounter: number;
  136783. /** @hidden */
  136784. isOcclusionQueryInProgress: boolean;
  136785. /** @hidden */
  136786. isOccluded: boolean;
  136787. /** @hidden */
  136788. occlusionRetryCount: number;
  136789. /** @hidden */
  136790. occlusionType: number;
  136791. /** @hidden */
  136792. occlusionQueryAlgorithmType: number;
  136793. }
  136794. interface Engine {
  136795. /**
  136796. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  136797. * @return the new query
  136798. */
  136799. createQuery(): WebGLQuery;
  136800. /**
  136801. * Delete and release a webGL query
  136802. * @param query defines the query to delete
  136803. * @return the current engine
  136804. */
  136805. deleteQuery(query: WebGLQuery): Engine;
  136806. /**
  136807. * Check if a given query has resolved and got its value
  136808. * @param query defines the query to check
  136809. * @returns true if the query got its value
  136810. */
  136811. isQueryResultAvailable(query: WebGLQuery): boolean;
  136812. /**
  136813. * Gets the value of a given query
  136814. * @param query defines the query to check
  136815. * @returns the value of the query
  136816. */
  136817. getQueryResult(query: WebGLQuery): number;
  136818. /**
  136819. * Initiates an occlusion query
  136820. * @param algorithmType defines the algorithm to use
  136821. * @param query defines the query to use
  136822. * @returns the current engine
  136823. * @see https://doc.babylonjs.com/features/occlusionquery
  136824. */
  136825. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  136826. /**
  136827. * Ends an occlusion query
  136828. * @see https://doc.babylonjs.com/features/occlusionquery
  136829. * @param algorithmType defines the algorithm to use
  136830. * @returns the current engine
  136831. */
  136832. endOcclusionQuery(algorithmType: number): Engine;
  136833. /**
  136834. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  136835. * Please note that only one query can be issued at a time
  136836. * @returns a time token used to track the time span
  136837. */
  136838. startTimeQuery(): Nullable<_TimeToken>;
  136839. /**
  136840. * Ends a time query
  136841. * @param token defines the token used to measure the time span
  136842. * @returns the time spent (in ns)
  136843. */
  136844. endTimeQuery(token: _TimeToken): int;
  136845. /** @hidden */
  136846. _currentNonTimestampToken: Nullable<_TimeToken>;
  136847. /** @hidden */
  136848. _createTimeQuery(): WebGLQuery;
  136849. /** @hidden */
  136850. _deleteTimeQuery(query: WebGLQuery): void;
  136851. /** @hidden */
  136852. _getGlAlgorithmType(algorithmType: number): number;
  136853. /** @hidden */
  136854. _getTimeQueryResult(query: WebGLQuery): any;
  136855. /** @hidden */
  136856. _getTimeQueryAvailability(query: WebGLQuery): any;
  136857. }
  136858. interface AbstractMesh {
  136859. /**
  136860. * Backing filed
  136861. * @hidden
  136862. */
  136863. __occlusionDataStorage: _OcclusionDataStorage;
  136864. /**
  136865. * Access property
  136866. * @hidden
  136867. */
  136868. _occlusionDataStorage: _OcclusionDataStorage;
  136869. /**
  136870. * 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.
  136871. * The default value is -1 which means don't break the query and wait till the result
  136872. * @see https://doc.babylonjs.com/features/occlusionquery
  136873. */
  136874. occlusionRetryCount: number;
  136875. /**
  136876. * 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:
  136877. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  136878. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  136879. * * 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.
  136880. * @see https://doc.babylonjs.com/features/occlusionquery
  136881. */
  136882. occlusionType: number;
  136883. /**
  136884. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  136885. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  136886. * * 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.
  136887. * @see https://doc.babylonjs.com/features/occlusionquery
  136888. */
  136889. occlusionQueryAlgorithmType: number;
  136890. /**
  136891. * 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
  136892. * @see https://doc.babylonjs.com/features/occlusionquery
  136893. */
  136894. isOccluded: boolean;
  136895. /**
  136896. * Flag to check the progress status of the query
  136897. * @see https://doc.babylonjs.com/features/occlusionquery
  136898. */
  136899. isOcclusionQueryInProgress: boolean;
  136900. }
  136901. }
  136902. declare module BABYLON {
  136903. /** @hidden */
  136904. export var _forceTransformFeedbackToBundle: boolean;
  136905. interface Engine {
  136906. /**
  136907. * Creates a webGL transform feedback object
  136908. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  136909. * @returns the webGL transform feedback object
  136910. */
  136911. createTransformFeedback(): WebGLTransformFeedback;
  136912. /**
  136913. * Delete a webGL transform feedback object
  136914. * @param value defines the webGL transform feedback object to delete
  136915. */
  136916. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  136917. /**
  136918. * Bind a webGL transform feedback object to the webgl context
  136919. * @param value defines the webGL transform feedback object to bind
  136920. */
  136921. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  136922. /**
  136923. * Begins a transform feedback operation
  136924. * @param usePoints defines if points or triangles must be used
  136925. */
  136926. beginTransformFeedback(usePoints: boolean): void;
  136927. /**
  136928. * Ends a transform feedback operation
  136929. */
  136930. endTransformFeedback(): void;
  136931. /**
  136932. * Specify the varyings to use with transform feedback
  136933. * @param program defines the associated webGL program
  136934. * @param value defines the list of strings representing the varying names
  136935. */
  136936. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  136937. /**
  136938. * Bind a webGL buffer for a transform feedback operation
  136939. * @param value defines the webGL buffer to bind
  136940. */
  136941. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  136942. }
  136943. }
  136944. declare module BABYLON {
  136945. /**
  136946. * Class used to define an additional view for the engine
  136947. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136948. */
  136949. export class EngineView {
  136950. /** Defines the canvas where to render the view */
  136951. target: HTMLCanvasElement;
  136952. /** Defines an optional camera used to render the view (will use active camera else) */
  136953. camera?: Camera;
  136954. }
  136955. interface Engine {
  136956. /**
  136957. * Gets or sets the HTML element to use for attaching events
  136958. */
  136959. inputElement: Nullable<HTMLElement>;
  136960. /**
  136961. * Gets the current engine view
  136962. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136963. */
  136964. activeView: Nullable<EngineView>;
  136965. /** Gets or sets the list of views */
  136966. views: EngineView[];
  136967. /**
  136968. * Register a new child canvas
  136969. * @param canvas defines the canvas to register
  136970. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  136971. * @returns the associated view
  136972. */
  136973. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  136974. /**
  136975. * Remove a registered child canvas
  136976. * @param canvas defines the canvas to remove
  136977. * @returns the current engine
  136978. */
  136979. unRegisterView(canvas: HTMLCanvasElement): Engine;
  136980. }
  136981. }
  136982. declare module BABYLON {
  136983. interface Engine {
  136984. /** @hidden */
  136985. _excludedCompressedTextures: string[];
  136986. /** @hidden */
  136987. _textureFormatInUse: string;
  136988. /**
  136989. * Gets the list of texture formats supported
  136990. */
  136991. readonly texturesSupported: Array<string>;
  136992. /**
  136993. * Gets the texture format in use
  136994. */
  136995. readonly textureFormatInUse: Nullable<string>;
  136996. /**
  136997. * Set the compressed texture extensions or file names to skip.
  136998. *
  136999. * @param skippedFiles defines the list of those texture files you want to skip
  137000. * Example: [".dds", ".env", "myfile.png"]
  137001. */
  137002. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  137003. /**
  137004. * Set the compressed texture format to use, based on the formats you have, and the formats
  137005. * supported by the hardware / browser.
  137006. *
  137007. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  137008. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  137009. * to API arguments needed to compressed textures. This puts the burden on the container
  137010. * generator to house the arcane code for determining these for current & future formats.
  137011. *
  137012. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  137013. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  137014. *
  137015. * Note: The result of this call is not taken into account when a texture is base64.
  137016. *
  137017. * @param formatsAvailable defines the list of those format families you have created
  137018. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  137019. *
  137020. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  137021. * @returns The extension selected.
  137022. */
  137023. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  137024. }
  137025. }
  137026. declare module BABYLON {
  137027. /** @hidden */
  137028. export var rgbdEncodePixelShader: {
  137029. name: string;
  137030. shader: string;
  137031. };
  137032. }
  137033. declare module BABYLON {
  137034. /**
  137035. * Raw texture data and descriptor sufficient for WebGL texture upload
  137036. */
  137037. export interface EnvironmentTextureInfo {
  137038. /**
  137039. * Version of the environment map
  137040. */
  137041. version: number;
  137042. /**
  137043. * Width of image
  137044. */
  137045. width: number;
  137046. /**
  137047. * Irradiance information stored in the file.
  137048. */
  137049. irradiance: any;
  137050. /**
  137051. * Specular information stored in the file.
  137052. */
  137053. specular: any;
  137054. }
  137055. /**
  137056. * Defines One Image in the file. It requires only the position in the file
  137057. * as well as the length.
  137058. */
  137059. interface BufferImageData {
  137060. /**
  137061. * Length of the image data.
  137062. */
  137063. length: number;
  137064. /**
  137065. * Position of the data from the null terminator delimiting the end of the JSON.
  137066. */
  137067. position: number;
  137068. }
  137069. /**
  137070. * Defines the specular data enclosed in the file.
  137071. * This corresponds to the version 1 of the data.
  137072. */
  137073. export interface EnvironmentTextureSpecularInfoV1 {
  137074. /**
  137075. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  137076. */
  137077. specularDataPosition?: number;
  137078. /**
  137079. * This contains all the images data needed to reconstruct the cubemap.
  137080. */
  137081. mipmaps: Array<BufferImageData>;
  137082. /**
  137083. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  137084. */
  137085. lodGenerationScale: number;
  137086. }
  137087. /**
  137088. * Sets of helpers addressing the serialization and deserialization of environment texture
  137089. * stored in a BabylonJS env file.
  137090. * Those files are usually stored as .env files.
  137091. */
  137092. export class EnvironmentTextureTools {
  137093. /**
  137094. * Magic number identifying the env file.
  137095. */
  137096. private static _MagicBytes;
  137097. /**
  137098. * Gets the environment info from an env file.
  137099. * @param data The array buffer containing the .env bytes.
  137100. * @returns the environment file info (the json header) if successfully parsed.
  137101. */
  137102. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  137103. /**
  137104. * Creates an environment texture from a loaded cube texture.
  137105. * @param texture defines the cube texture to convert in env file
  137106. * @return a promise containing the environment data if succesfull.
  137107. */
  137108. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  137109. /**
  137110. * Creates a JSON representation of the spherical data.
  137111. * @param texture defines the texture containing the polynomials
  137112. * @return the JSON representation of the spherical info
  137113. */
  137114. private static _CreateEnvTextureIrradiance;
  137115. /**
  137116. * Creates the ArrayBufferViews used for initializing environment texture image data.
  137117. * @param data the image data
  137118. * @param info parameters that determine what views will be created for accessing the underlying buffer
  137119. * @return the views described by info providing access to the underlying buffer
  137120. */
  137121. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  137122. /**
  137123. * Uploads the texture info contained in the env file to the GPU.
  137124. * @param texture defines the internal texture to upload to
  137125. * @param data defines the data to load
  137126. * @param info defines the texture info retrieved through the GetEnvInfo method
  137127. * @returns a promise
  137128. */
  137129. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  137130. private static _OnImageReadyAsync;
  137131. /**
  137132. * Uploads the levels of image data to the GPU.
  137133. * @param texture defines the internal texture to upload to
  137134. * @param imageData defines the array buffer views of image data [mipmap][face]
  137135. * @returns a promise
  137136. */
  137137. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  137138. /**
  137139. * Uploads spherical polynomials information to the texture.
  137140. * @param texture defines the texture we are trying to upload the information to
  137141. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  137142. */
  137143. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  137144. /** @hidden */
  137145. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  137146. }
  137147. }
  137148. declare module BABYLON {
  137149. /**
  137150. * Class used to inline functions in shader code
  137151. */
  137152. export class ShaderCodeInliner {
  137153. private static readonly _RegexpFindFunctionNameAndType;
  137154. private _sourceCode;
  137155. private _functionDescr;
  137156. private _numMaxIterations;
  137157. /** Gets or sets the token used to mark the functions to inline */
  137158. inlineToken: string;
  137159. /** Gets or sets the debug mode */
  137160. debug: boolean;
  137161. /** Gets the code after the inlining process */
  137162. get code(): string;
  137163. /**
  137164. * Initializes the inliner
  137165. * @param sourceCode shader code source to inline
  137166. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  137167. */
  137168. constructor(sourceCode: string, numMaxIterations?: number);
  137169. /**
  137170. * Start the processing of the shader code
  137171. */
  137172. processCode(): void;
  137173. private _collectFunctions;
  137174. private _processInlining;
  137175. private _extractBetweenMarkers;
  137176. private _skipWhitespaces;
  137177. private _removeComments;
  137178. private _replaceFunctionCallsByCode;
  137179. private _findBackward;
  137180. private _escapeRegExp;
  137181. private _replaceNames;
  137182. }
  137183. }
  137184. declare module BABYLON {
  137185. /**
  137186. * Container for accessors for natively-stored mesh data buffers.
  137187. */
  137188. class NativeDataBuffer extends DataBuffer {
  137189. /**
  137190. * Accessor value used to identify/retrieve a natively-stored index buffer.
  137191. */
  137192. nativeIndexBuffer?: any;
  137193. /**
  137194. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  137195. */
  137196. nativeVertexBuffer?: any;
  137197. }
  137198. /** @hidden */
  137199. class NativeTexture extends InternalTexture {
  137200. getInternalTexture(): InternalTexture;
  137201. getViewCount(): number;
  137202. }
  137203. /** @hidden */
  137204. export class NativeEngine extends Engine {
  137205. private readonly _native;
  137206. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  137207. private readonly INVALID_HANDLE;
  137208. private _boundBuffersVertexArray;
  137209. private _currentDepthTest;
  137210. getHardwareScalingLevel(): number;
  137211. constructor();
  137212. dispose(): void;
  137213. /**
  137214. * Can be used to override the current requestAnimationFrame requester.
  137215. * @hidden
  137216. */
  137217. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  137218. /**
  137219. * Override default engine behavior.
  137220. * @param color
  137221. * @param backBuffer
  137222. * @param depth
  137223. * @param stencil
  137224. */
  137225. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  137226. /**
  137227. * Gets host document
  137228. * @returns the host document object
  137229. */
  137230. getHostDocument(): Nullable<Document>;
  137231. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  137232. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  137233. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  137234. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  137235. [key: string]: VertexBuffer;
  137236. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  137237. bindBuffers(vertexBuffers: {
  137238. [key: string]: VertexBuffer;
  137239. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  137240. recordVertexArrayObject(vertexBuffers: {
  137241. [key: string]: VertexBuffer;
  137242. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  137243. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  137244. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  137245. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  137246. /**
  137247. * Draw a list of indexed primitives
  137248. * @param fillMode defines the primitive to use
  137249. * @param indexStart defines the starting index
  137250. * @param indexCount defines the number of index to draw
  137251. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137252. */
  137253. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  137254. /**
  137255. * Draw a list of unindexed primitives
  137256. * @param fillMode defines the primitive to use
  137257. * @param verticesStart defines the index of first vertex to draw
  137258. * @param verticesCount defines the count of vertices to draw
  137259. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137260. */
  137261. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  137262. createPipelineContext(): IPipelineContext;
  137263. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  137264. /** @hidden */
  137265. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  137266. /** @hidden */
  137267. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  137268. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  137269. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  137270. protected _setProgram(program: WebGLProgram): void;
  137271. _releaseEffect(effect: Effect): void;
  137272. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  137273. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  137274. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  137275. bindSamplers(effect: Effect): void;
  137276. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  137277. getRenderWidth(useScreen?: boolean): number;
  137278. getRenderHeight(useScreen?: boolean): number;
  137279. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  137280. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  137281. /**
  137282. * Set the z offset to apply to current rendering
  137283. * @param value defines the offset to apply
  137284. */
  137285. setZOffset(value: number): void;
  137286. /**
  137287. * Gets the current value of the zOffset
  137288. * @returns the current zOffset state
  137289. */
  137290. getZOffset(): number;
  137291. /**
  137292. * Enable or disable depth buffering
  137293. * @param enable defines the state to set
  137294. */
  137295. setDepthBuffer(enable: boolean): void;
  137296. /**
  137297. * Gets a boolean indicating if depth writing is enabled
  137298. * @returns the current depth writing state
  137299. */
  137300. getDepthWrite(): boolean;
  137301. setDepthFunctionToGreater(): void;
  137302. setDepthFunctionToGreaterOrEqual(): void;
  137303. setDepthFunctionToLess(): void;
  137304. setDepthFunctionToLessOrEqual(): void;
  137305. /**
  137306. * Enable or disable depth writing
  137307. * @param enable defines the state to set
  137308. */
  137309. setDepthWrite(enable: boolean): void;
  137310. /**
  137311. * Enable or disable color writing
  137312. * @param enable defines the state to set
  137313. */
  137314. setColorWrite(enable: boolean): void;
  137315. /**
  137316. * Gets a boolean indicating if color writing is enabled
  137317. * @returns the current color writing state
  137318. */
  137319. getColorWrite(): boolean;
  137320. /**
  137321. * Sets alpha constants used by some alpha blending modes
  137322. * @param r defines the red component
  137323. * @param g defines the green component
  137324. * @param b defines the blue component
  137325. * @param a defines the alpha component
  137326. */
  137327. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  137328. /**
  137329. * Sets the current alpha mode
  137330. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  137331. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  137332. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  137333. */
  137334. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  137335. /**
  137336. * Gets the current alpha mode
  137337. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  137338. * @returns the current alpha mode
  137339. */
  137340. getAlphaMode(): number;
  137341. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  137342. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137343. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137344. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137345. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137346. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137347. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137348. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137349. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137350. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  137351. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  137352. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  137353. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  137354. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  137355. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  137356. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  137357. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  137358. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  137359. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  137360. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  137361. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  137362. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  137363. wipeCaches(bruteForce?: boolean): void;
  137364. _createTexture(): WebGLTexture;
  137365. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  137366. /**
  137367. * Update the content of a dynamic texture
  137368. * @param texture defines the texture to update
  137369. * @param canvas defines the canvas containing the source
  137370. * @param invertY defines if data must be stored with Y axis inverted
  137371. * @param premulAlpha defines if alpha is stored as premultiplied
  137372. * @param format defines the format of the data
  137373. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  137374. */
  137375. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  137376. /**
  137377. * Usually called from Texture.ts.
  137378. * Passed information to create a WebGLTexture
  137379. * @param url defines a value which contains one of the following:
  137380. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  137381. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  137382. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  137383. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  137384. * @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)
  137385. * @param scene needed for loading to the correct scene
  137386. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  137387. * @param onLoad optional callback to be called upon successful completion
  137388. * @param onError optional callback to be called upon failure
  137389. * @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
  137390. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  137391. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  137392. * @param forcedExtension defines the extension to use to pick the right loader
  137393. * @param mimeType defines an optional mime type
  137394. * @param loaderOptions options to be passed to the loader
  137395. * @returns a InternalTexture for assignment back into BABYLON.Texture
  137396. */
  137397. 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;
  137398. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  137399. _releaseFramebufferObjects(texture: InternalTexture): void;
  137400. /**
  137401. * Creates a cube texture
  137402. * @param rootUrl defines the url where the files to load is located
  137403. * @param scene defines the current scene
  137404. * @param files defines the list of files to load (1 per face)
  137405. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  137406. * @param onLoad defines an optional callback raised when the texture is loaded
  137407. * @param onError defines an optional callback raised if there is an issue to load the texture
  137408. * @param format defines the format of the data
  137409. * @param forcedExtension defines the extension to use to pick the right loader
  137410. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  137411. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  137412. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  137413. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  137414. * @returns the cube texture as an InternalTexture
  137415. */
  137416. 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;
  137417. createRenderTargetTexture(size: number | {
  137418. width: number;
  137419. height: number;
  137420. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  137421. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  137422. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  137423. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  137424. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  137425. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  137426. /**
  137427. * Updates a dynamic vertex buffer.
  137428. * @param vertexBuffer the vertex buffer to update
  137429. * @param data the data used to update the vertex buffer
  137430. * @param byteOffset the byte offset of the data (optional)
  137431. * @param byteLength the byte length of the data (optional)
  137432. */
  137433. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  137434. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  137435. private _updateAnisotropicLevel;
  137436. private _getAddressMode;
  137437. /** @hidden */
  137438. _bindTexture(channel: number, texture: InternalTexture): void;
  137439. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  137440. releaseEffects(): void;
  137441. /** @hidden */
  137442. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137443. /** @hidden */
  137444. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137445. /** @hidden */
  137446. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137447. /** @hidden */
  137448. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  137449. private _getNativeSamplingMode;
  137450. private _getNativeTextureFormat;
  137451. private _getNativeAlphaMode;
  137452. private _getNativeAttribType;
  137453. }
  137454. }
  137455. declare module BABYLON {
  137456. /**
  137457. * Gather the list of clipboard event types as constants.
  137458. */
  137459. export class ClipboardEventTypes {
  137460. /**
  137461. * The clipboard event is fired when a copy command is active (pressed).
  137462. */
  137463. static readonly COPY: number;
  137464. /**
  137465. * The clipboard event is fired when a cut command is active (pressed).
  137466. */
  137467. static readonly CUT: number;
  137468. /**
  137469. * The clipboard event is fired when a paste command is active (pressed).
  137470. */
  137471. static readonly PASTE: number;
  137472. }
  137473. /**
  137474. * This class is used to store clipboard related info for the onClipboardObservable event.
  137475. */
  137476. export class ClipboardInfo {
  137477. /**
  137478. * Defines the type of event (BABYLON.ClipboardEventTypes)
  137479. */
  137480. type: number;
  137481. /**
  137482. * Defines the related dom event
  137483. */
  137484. event: ClipboardEvent;
  137485. /**
  137486. *Creates an instance of ClipboardInfo.
  137487. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  137488. * @param event Defines the related dom event
  137489. */
  137490. constructor(
  137491. /**
  137492. * Defines the type of event (BABYLON.ClipboardEventTypes)
  137493. */
  137494. type: number,
  137495. /**
  137496. * Defines the related dom event
  137497. */
  137498. event: ClipboardEvent);
  137499. /**
  137500. * Get the clipboard event's type from the keycode.
  137501. * @param keyCode Defines the keyCode for the current keyboard event.
  137502. * @return {number}
  137503. */
  137504. static GetTypeFromCharacter(keyCode: number): number;
  137505. }
  137506. }
  137507. declare module BABYLON {
  137508. /**
  137509. * Google Daydream controller
  137510. */
  137511. export class DaydreamController extends WebVRController {
  137512. /**
  137513. * Base Url for the controller model.
  137514. */
  137515. static MODEL_BASE_URL: string;
  137516. /**
  137517. * File name for the controller model.
  137518. */
  137519. static MODEL_FILENAME: string;
  137520. /**
  137521. * Gamepad Id prefix used to identify Daydream Controller.
  137522. */
  137523. static readonly GAMEPAD_ID_PREFIX: string;
  137524. /**
  137525. * Creates a new DaydreamController from a gamepad
  137526. * @param vrGamepad the gamepad that the controller should be created from
  137527. */
  137528. constructor(vrGamepad: any);
  137529. /**
  137530. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137531. * @param scene scene in which to add meshes
  137532. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137533. */
  137534. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137535. /**
  137536. * Called once for each button that changed state since the last frame
  137537. * @param buttonIdx Which button index changed
  137538. * @param state New state of the button
  137539. * @param changes Which properties on the state changed since last frame
  137540. */
  137541. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137542. }
  137543. }
  137544. declare module BABYLON {
  137545. /**
  137546. * Gear VR Controller
  137547. */
  137548. export class GearVRController extends WebVRController {
  137549. /**
  137550. * Base Url for the controller model.
  137551. */
  137552. static MODEL_BASE_URL: string;
  137553. /**
  137554. * File name for the controller model.
  137555. */
  137556. static MODEL_FILENAME: string;
  137557. /**
  137558. * Gamepad Id prefix used to identify this controller.
  137559. */
  137560. static readonly GAMEPAD_ID_PREFIX: string;
  137561. private readonly _buttonIndexToObservableNameMap;
  137562. /**
  137563. * Creates a new GearVRController from a gamepad
  137564. * @param vrGamepad the gamepad that the controller should be created from
  137565. */
  137566. constructor(vrGamepad: any);
  137567. /**
  137568. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137569. * @param scene scene in which to add meshes
  137570. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137571. */
  137572. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137573. /**
  137574. * Called once for each button that changed state since the last frame
  137575. * @param buttonIdx Which button index changed
  137576. * @param state New state of the button
  137577. * @param changes Which properties on the state changed since last frame
  137578. */
  137579. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137580. }
  137581. }
  137582. declare module BABYLON {
  137583. /**
  137584. * Generic Controller
  137585. */
  137586. export class GenericController extends WebVRController {
  137587. /**
  137588. * Base Url for the controller model.
  137589. */
  137590. static readonly MODEL_BASE_URL: string;
  137591. /**
  137592. * File name for the controller model.
  137593. */
  137594. static readonly MODEL_FILENAME: string;
  137595. /**
  137596. * Creates a new GenericController from a gamepad
  137597. * @param vrGamepad the gamepad that the controller should be created from
  137598. */
  137599. constructor(vrGamepad: any);
  137600. /**
  137601. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137602. * @param scene scene in which to add meshes
  137603. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137604. */
  137605. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137606. /**
  137607. * Called once for each button that changed state since the last frame
  137608. * @param buttonIdx Which button index changed
  137609. * @param state New state of the button
  137610. * @param changes Which properties on the state changed since last frame
  137611. */
  137612. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137613. }
  137614. }
  137615. declare module BABYLON {
  137616. /**
  137617. * Oculus Touch Controller
  137618. */
  137619. export class OculusTouchController extends WebVRController {
  137620. /**
  137621. * Base Url for the controller model.
  137622. */
  137623. static MODEL_BASE_URL: string;
  137624. /**
  137625. * File name for the left controller model.
  137626. */
  137627. static MODEL_LEFT_FILENAME: string;
  137628. /**
  137629. * File name for the right controller model.
  137630. */
  137631. static MODEL_RIGHT_FILENAME: string;
  137632. /**
  137633. * Base Url for the Quest controller model.
  137634. */
  137635. static QUEST_MODEL_BASE_URL: string;
  137636. /**
  137637. * @hidden
  137638. * If the controllers are running on a device that needs the updated Quest controller models
  137639. */
  137640. static _IsQuest: boolean;
  137641. /**
  137642. * Fired when the secondary trigger on this controller is modified
  137643. */
  137644. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  137645. /**
  137646. * Fired when the thumb rest on this controller is modified
  137647. */
  137648. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  137649. /**
  137650. * Creates a new OculusTouchController from a gamepad
  137651. * @param vrGamepad the gamepad that the controller should be created from
  137652. */
  137653. constructor(vrGamepad: any);
  137654. /**
  137655. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137656. * @param scene scene in which to add meshes
  137657. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137658. */
  137659. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137660. /**
  137661. * Fired when the A button on this controller is modified
  137662. */
  137663. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137664. /**
  137665. * Fired when the B button on this controller is modified
  137666. */
  137667. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137668. /**
  137669. * Fired when the X button on this controller is modified
  137670. */
  137671. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137672. /**
  137673. * Fired when the Y button on this controller is modified
  137674. */
  137675. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137676. /**
  137677. * Called once for each button that changed state since the last frame
  137678. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  137679. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  137680. * 2) secondary trigger (same)
  137681. * 3) A (right) X (left), touch, pressed = value
  137682. * 4) B / Y
  137683. * 5) thumb rest
  137684. * @param buttonIdx Which button index changed
  137685. * @param state New state of the button
  137686. * @param changes Which properties on the state changed since last frame
  137687. */
  137688. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137689. }
  137690. }
  137691. declare module BABYLON {
  137692. /**
  137693. * Vive Controller
  137694. */
  137695. export class ViveController extends WebVRController {
  137696. /**
  137697. * Base Url for the controller model.
  137698. */
  137699. static MODEL_BASE_URL: string;
  137700. /**
  137701. * File name for the controller model.
  137702. */
  137703. static MODEL_FILENAME: string;
  137704. /**
  137705. * Creates a new ViveController from a gamepad
  137706. * @param vrGamepad the gamepad that the controller should be created from
  137707. */
  137708. constructor(vrGamepad: any);
  137709. /**
  137710. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137711. * @param scene scene in which to add meshes
  137712. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137713. */
  137714. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137715. /**
  137716. * Fired when the left button on this controller is modified
  137717. */
  137718. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137719. /**
  137720. * Fired when the right button on this controller is modified
  137721. */
  137722. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137723. /**
  137724. * Fired when the menu button on this controller is modified
  137725. */
  137726. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137727. /**
  137728. * Called once for each button that changed state since the last frame
  137729. * Vive mapping:
  137730. * 0: touchpad
  137731. * 1: trigger
  137732. * 2: left AND right buttons
  137733. * 3: menu button
  137734. * @param buttonIdx Which button index changed
  137735. * @param state New state of the button
  137736. * @param changes Which properties on the state changed since last frame
  137737. */
  137738. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137739. }
  137740. }
  137741. declare module BABYLON {
  137742. /**
  137743. * Defines the WindowsMotionController object that the state of the windows motion controller
  137744. */
  137745. export class WindowsMotionController extends WebVRController {
  137746. /**
  137747. * The base url used to load the left and right controller models
  137748. */
  137749. static MODEL_BASE_URL: string;
  137750. /**
  137751. * The name of the left controller model file
  137752. */
  137753. static MODEL_LEFT_FILENAME: string;
  137754. /**
  137755. * The name of the right controller model file
  137756. */
  137757. static MODEL_RIGHT_FILENAME: string;
  137758. /**
  137759. * The controller name prefix for this controller type
  137760. */
  137761. static readonly GAMEPAD_ID_PREFIX: string;
  137762. /**
  137763. * The controller id pattern for this controller type
  137764. */
  137765. private static readonly GAMEPAD_ID_PATTERN;
  137766. private _loadedMeshInfo;
  137767. protected readonly _mapping: {
  137768. buttons: string[];
  137769. buttonMeshNames: {
  137770. trigger: string;
  137771. menu: string;
  137772. grip: string;
  137773. thumbstick: string;
  137774. trackpad: string;
  137775. };
  137776. buttonObservableNames: {
  137777. trigger: string;
  137778. menu: string;
  137779. grip: string;
  137780. thumbstick: string;
  137781. trackpad: string;
  137782. };
  137783. axisMeshNames: string[];
  137784. pointingPoseMeshName: string;
  137785. };
  137786. /**
  137787. * Fired when the trackpad on this controller is clicked
  137788. */
  137789. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  137790. /**
  137791. * Fired when the trackpad on this controller is modified
  137792. */
  137793. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137794. /**
  137795. * The current x and y values of this controller's trackpad
  137796. */
  137797. trackpad: StickValues;
  137798. /**
  137799. * Creates a new WindowsMotionController from a gamepad
  137800. * @param vrGamepad the gamepad that the controller should be created from
  137801. */
  137802. constructor(vrGamepad: any);
  137803. /**
  137804. * Fired when the trigger on this controller is modified
  137805. */
  137806. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137807. /**
  137808. * Fired when the menu button on this controller is modified
  137809. */
  137810. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137811. /**
  137812. * Fired when the grip button on this controller is modified
  137813. */
  137814. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137815. /**
  137816. * Fired when the thumbstick button on this controller is modified
  137817. */
  137818. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137819. /**
  137820. * Fired when the touchpad button on this controller is modified
  137821. */
  137822. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137823. /**
  137824. * Fired when the touchpad values on this controller are modified
  137825. */
  137826. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  137827. protected _updateTrackpad(): void;
  137828. /**
  137829. * Called once per frame by the engine.
  137830. */
  137831. update(): void;
  137832. /**
  137833. * Called once for each button that changed state since the last frame
  137834. * @param buttonIdx Which button index changed
  137835. * @param state New state of the button
  137836. * @param changes Which properties on the state changed since last frame
  137837. */
  137838. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137839. /**
  137840. * Moves the buttons on the controller mesh based on their current state
  137841. * @param buttonName the name of the button to move
  137842. * @param buttonValue the value of the button which determines the buttons new position
  137843. */
  137844. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  137845. /**
  137846. * Moves the axis on the controller mesh based on its current state
  137847. * @param axis the index of the axis
  137848. * @param axisValue the value of the axis which determines the meshes new position
  137849. * @hidden
  137850. */
  137851. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  137852. /**
  137853. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137854. * @param scene scene in which to add meshes
  137855. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137856. */
  137857. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  137858. /**
  137859. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  137860. * can be transformed by button presses and axes values, based on this._mapping.
  137861. *
  137862. * @param scene scene in which the meshes exist
  137863. * @param meshes list of meshes that make up the controller model to process
  137864. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  137865. */
  137866. private processModel;
  137867. private createMeshInfo;
  137868. /**
  137869. * Gets the ray of the controller in the direction the controller is pointing
  137870. * @param length the length the resulting ray should be
  137871. * @returns a ray in the direction the controller is pointing
  137872. */
  137873. getForwardRay(length?: number): Ray;
  137874. /**
  137875. * Disposes of the controller
  137876. */
  137877. dispose(): void;
  137878. }
  137879. /**
  137880. * This class represents a new windows motion controller in XR.
  137881. */
  137882. export class XRWindowsMotionController extends WindowsMotionController {
  137883. /**
  137884. * Changing the original WIndowsMotionController mapping to fir the new mapping
  137885. */
  137886. protected readonly _mapping: {
  137887. buttons: string[];
  137888. buttonMeshNames: {
  137889. trigger: string;
  137890. menu: string;
  137891. grip: string;
  137892. thumbstick: string;
  137893. trackpad: string;
  137894. };
  137895. buttonObservableNames: {
  137896. trigger: string;
  137897. menu: string;
  137898. grip: string;
  137899. thumbstick: string;
  137900. trackpad: string;
  137901. };
  137902. axisMeshNames: string[];
  137903. pointingPoseMeshName: string;
  137904. };
  137905. /**
  137906. * Construct a new XR-Based windows motion controller
  137907. *
  137908. * @param gamepadInfo the gamepad object from the browser
  137909. */
  137910. constructor(gamepadInfo: any);
  137911. /**
  137912. * holds the thumbstick values (X,Y)
  137913. */
  137914. thumbstickValues: StickValues;
  137915. /**
  137916. * Fired when the thumbstick on this controller is clicked
  137917. */
  137918. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  137919. /**
  137920. * Fired when the thumbstick on this controller is modified
  137921. */
  137922. onThumbstickValuesChangedObservable: Observable<StickValues>;
  137923. /**
  137924. * Fired when the touchpad button on this controller is modified
  137925. */
  137926. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  137927. /**
  137928. * Fired when the touchpad values on this controller are modified
  137929. */
  137930. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137931. /**
  137932. * Fired when the thumbstick button on this controller is modified
  137933. * here to prevent breaking changes
  137934. */
  137935. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137936. /**
  137937. * updating the thumbstick(!) and not the trackpad.
  137938. * This is named this way due to the difference between WebVR and XR and to avoid
  137939. * changing the parent class.
  137940. */
  137941. protected _updateTrackpad(): void;
  137942. /**
  137943. * Disposes the class with joy
  137944. */
  137945. dispose(): void;
  137946. }
  137947. }
  137948. declare module BABYLON {
  137949. /**
  137950. * Class containing static functions to help procedurally build meshes
  137951. */
  137952. export class PolyhedronBuilder {
  137953. /**
  137954. * Creates a polyhedron mesh
  137955. * * 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
  137956. * * The parameter `size` (positive float, default 1) sets the polygon size
  137957. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  137958. * * 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`
  137959. * * 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
  137960. * * 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)`)
  137961. * * 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
  137962. * * 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
  137963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137964. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137966. * @param name defines the name of the mesh
  137967. * @param options defines the options used to create the mesh
  137968. * @param scene defines the hosting scene
  137969. * @returns the polyhedron mesh
  137970. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  137971. */
  137972. static CreatePolyhedron(name: string, options: {
  137973. type?: number;
  137974. size?: number;
  137975. sizeX?: number;
  137976. sizeY?: number;
  137977. sizeZ?: number;
  137978. custom?: any;
  137979. faceUV?: Vector4[];
  137980. faceColors?: Color4[];
  137981. flat?: boolean;
  137982. updatable?: boolean;
  137983. sideOrientation?: number;
  137984. frontUVs?: Vector4;
  137985. backUVs?: Vector4;
  137986. }, scene?: Nullable<Scene>): Mesh;
  137987. }
  137988. }
  137989. declare module BABYLON {
  137990. /**
  137991. * Gizmo that enables scaling a mesh along 3 axis
  137992. */
  137993. export class ScaleGizmo extends Gizmo {
  137994. /**
  137995. * Internal gizmo used for interactions on the x axis
  137996. */
  137997. xGizmo: AxisScaleGizmo;
  137998. /**
  137999. * Internal gizmo used for interactions on the y axis
  138000. */
  138001. yGizmo: AxisScaleGizmo;
  138002. /**
  138003. * Internal gizmo used for interactions on the z axis
  138004. */
  138005. zGizmo: AxisScaleGizmo;
  138006. /**
  138007. * Internal gizmo used to scale all axis equally
  138008. */
  138009. uniformScaleGizmo: AxisScaleGizmo;
  138010. private _meshAttached;
  138011. private _nodeAttached;
  138012. private _snapDistance;
  138013. private _uniformScalingMesh;
  138014. private _octahedron;
  138015. private _sensitivity;
  138016. /** Fires an event when any of it's sub gizmos are dragged */
  138017. onDragStartObservable: Observable<unknown>;
  138018. /** Fires an event when any of it's sub gizmos are released from dragging */
  138019. onDragEndObservable: Observable<unknown>;
  138020. get attachedMesh(): Nullable<AbstractMesh>;
  138021. set attachedMesh(mesh: Nullable<AbstractMesh>);
  138022. get attachedNode(): Nullable<Node>;
  138023. set attachedNode(node: Nullable<Node>);
  138024. /**
  138025. * True when the mouse pointer is hovering a gizmo mesh
  138026. */
  138027. get isHovered(): boolean;
  138028. /**
  138029. * Creates a ScaleGizmo
  138030. * @param gizmoLayer The utility layer the gizmo will be added to
  138031. * @param thickness display gizmo axis thickness
  138032. */
  138033. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  138034. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  138035. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  138036. /**
  138037. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  138038. */
  138039. set snapDistance(value: number);
  138040. get snapDistance(): number;
  138041. /**
  138042. * Ratio for the scale of the gizmo (Default: 1)
  138043. */
  138044. set scaleRatio(value: number);
  138045. get scaleRatio(): number;
  138046. /**
  138047. * Sensitivity factor for dragging (Default: 1)
  138048. */
  138049. set sensitivity(value: number);
  138050. get sensitivity(): number;
  138051. /**
  138052. * Disposes of the gizmo
  138053. */
  138054. dispose(): void;
  138055. }
  138056. }
  138057. declare module BABYLON {
  138058. /**
  138059. * Single axis scale gizmo
  138060. */
  138061. export class AxisScaleGizmo extends Gizmo {
  138062. /**
  138063. * Drag behavior responsible for the gizmos dragging interactions
  138064. */
  138065. dragBehavior: PointerDragBehavior;
  138066. private _pointerObserver;
  138067. /**
  138068. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  138069. */
  138070. snapDistance: number;
  138071. /**
  138072. * Event that fires each time the gizmo snaps to a new location.
  138073. * * snapDistance is the the change in distance
  138074. */
  138075. onSnapObservable: Observable<{
  138076. snapDistance: number;
  138077. }>;
  138078. /**
  138079. * If the scaling operation should be done on all axis (default: false)
  138080. */
  138081. uniformScaling: boolean;
  138082. /**
  138083. * Custom sensitivity value for the drag strength
  138084. */
  138085. sensitivity: number;
  138086. private _isEnabled;
  138087. private _parent;
  138088. private _arrow;
  138089. private _coloredMaterial;
  138090. private _hoverMaterial;
  138091. /**
  138092. * Creates an AxisScaleGizmo
  138093. * @param gizmoLayer The utility layer the gizmo will be added to
  138094. * @param dragAxis The axis which the gizmo will be able to scale on
  138095. * @param color The color of the gizmo
  138096. * @param thickness display gizmo axis thickness
  138097. */
  138098. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  138099. protected _attachedNodeChanged(value: Nullable<Node>): void;
  138100. /**
  138101. * If the gizmo is enabled
  138102. */
  138103. set isEnabled(value: boolean);
  138104. get isEnabled(): boolean;
  138105. /**
  138106. * Disposes of the gizmo
  138107. */
  138108. dispose(): void;
  138109. /**
  138110. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  138111. * @param mesh The mesh to replace the default mesh of the gizmo
  138112. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  138113. */
  138114. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  138115. }
  138116. }
  138117. declare module BABYLON {
  138118. /**
  138119. * Bounding box gizmo
  138120. */
  138121. export class BoundingBoxGizmo extends Gizmo {
  138122. private _lineBoundingBox;
  138123. private _rotateSpheresParent;
  138124. private _scaleBoxesParent;
  138125. private _boundingDimensions;
  138126. private _renderObserver;
  138127. private _pointerObserver;
  138128. private _scaleDragSpeed;
  138129. private _tmpQuaternion;
  138130. private _tmpVector;
  138131. private _tmpRotationMatrix;
  138132. /**
  138133. * 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)
  138134. */
  138135. ignoreChildren: boolean;
  138136. /**
  138137. * 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)
  138138. */
  138139. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  138140. /**
  138141. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  138142. */
  138143. rotationSphereSize: number;
  138144. /**
  138145. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  138146. */
  138147. scaleBoxSize: number;
  138148. /**
  138149. * 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)
  138150. */
  138151. fixedDragMeshScreenSize: boolean;
  138152. /**
  138153. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  138154. */
  138155. fixedDragMeshScreenSizeDistanceFactor: number;
  138156. /**
  138157. * Fired when a rotation sphere or scale box is dragged
  138158. */
  138159. onDragStartObservable: Observable<{}>;
  138160. /**
  138161. * Fired when a scale box is dragged
  138162. */
  138163. onScaleBoxDragObservable: Observable<{}>;
  138164. /**
  138165. * Fired when a scale box drag is ended
  138166. */
  138167. onScaleBoxDragEndObservable: Observable<{}>;
  138168. /**
  138169. * Fired when a rotation sphere is dragged
  138170. */
  138171. onRotationSphereDragObservable: Observable<{}>;
  138172. /**
  138173. * Fired when a rotation sphere drag is ended
  138174. */
  138175. onRotationSphereDragEndObservable: Observable<{}>;
  138176. /**
  138177. * 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)
  138178. */
  138179. scalePivot: Nullable<Vector3>;
  138180. /**
  138181. * Mesh used as a pivot to rotate the attached node
  138182. */
  138183. private _anchorMesh;
  138184. private _existingMeshScale;
  138185. private _dragMesh;
  138186. private pointerDragBehavior;
  138187. private coloredMaterial;
  138188. private hoverColoredMaterial;
  138189. /**
  138190. * Sets the color of the bounding box gizmo
  138191. * @param color the color to set
  138192. */
  138193. setColor(color: Color3): void;
  138194. /**
  138195. * Creates an BoundingBoxGizmo
  138196. * @param gizmoLayer The utility layer the gizmo will be added to
  138197. * @param color The color of the gizmo
  138198. */
  138199. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  138200. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  138201. private _selectNode;
  138202. /**
  138203. * Updates the bounding box information for the Gizmo
  138204. */
  138205. updateBoundingBox(): void;
  138206. private _updateRotationSpheres;
  138207. private _updateScaleBoxes;
  138208. /**
  138209. * Enables rotation on the specified axis and disables rotation on the others
  138210. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  138211. */
  138212. setEnabledRotationAxis(axis: string): void;
  138213. /**
  138214. * Enables/disables scaling
  138215. * @param enable if scaling should be enabled
  138216. * @param homogeneousScaling defines if scaling should only be homogeneous
  138217. */
  138218. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  138219. private _updateDummy;
  138220. /**
  138221. * Enables a pointer drag behavior on the bounding box of the gizmo
  138222. */
  138223. enableDragBehavior(): void;
  138224. /**
  138225. * Disposes of the gizmo
  138226. */
  138227. dispose(): void;
  138228. /**
  138229. * 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)
  138230. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  138231. * @returns the bounding box mesh with the passed in mesh as a child
  138232. */
  138233. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  138234. /**
  138235. * CustomMeshes are not supported by this gizmo
  138236. * @param mesh The mesh to replace the default mesh of the gizmo
  138237. */
  138238. setCustomMesh(mesh: Mesh): void;
  138239. }
  138240. }
  138241. declare module BABYLON {
  138242. /**
  138243. * Single plane rotation gizmo
  138244. */
  138245. export class PlaneRotationGizmo extends Gizmo {
  138246. /**
  138247. * Drag behavior responsible for the gizmos dragging interactions
  138248. */
  138249. dragBehavior: PointerDragBehavior;
  138250. private _pointerObserver;
  138251. /**
  138252. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  138253. */
  138254. snapDistance: number;
  138255. /**
  138256. * Event that fires each time the gizmo snaps to a new location.
  138257. * * snapDistance is the the change in distance
  138258. */
  138259. onSnapObservable: Observable<{
  138260. snapDistance: number;
  138261. }>;
  138262. private _isEnabled;
  138263. private _parent;
  138264. /**
  138265. * Creates a PlaneRotationGizmo
  138266. * @param gizmoLayer The utility layer the gizmo will be added to
  138267. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  138268. * @param color The color of the gizmo
  138269. * @param tessellation Amount of tessellation to be used when creating rotation circles
  138270. * @param useEulerRotation Use and update Euler angle instead of quaternion
  138271. * @param thickness display gizmo axis thickness
  138272. */
  138273. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  138274. protected _attachedNodeChanged(value: Nullable<Node>): void;
  138275. /**
  138276. * If the gizmo is enabled
  138277. */
  138278. set isEnabled(value: boolean);
  138279. get isEnabled(): boolean;
  138280. /**
  138281. * Disposes of the gizmo
  138282. */
  138283. dispose(): void;
  138284. }
  138285. }
  138286. declare module BABYLON {
  138287. /**
  138288. * Gizmo that enables rotating a mesh along 3 axis
  138289. */
  138290. export class RotationGizmo extends Gizmo {
  138291. /**
  138292. * Internal gizmo used for interactions on the x axis
  138293. */
  138294. xGizmo: PlaneRotationGizmo;
  138295. /**
  138296. * Internal gizmo used for interactions on the y axis
  138297. */
  138298. yGizmo: PlaneRotationGizmo;
  138299. /**
  138300. * Internal gizmo used for interactions on the z axis
  138301. */
  138302. zGizmo: PlaneRotationGizmo;
  138303. /** Fires an event when any of it's sub gizmos are dragged */
  138304. onDragStartObservable: Observable<unknown>;
  138305. /** Fires an event when any of it's sub gizmos are released from dragging */
  138306. onDragEndObservable: Observable<unknown>;
  138307. private _meshAttached;
  138308. private _nodeAttached;
  138309. get attachedMesh(): Nullable<AbstractMesh>;
  138310. set attachedMesh(mesh: Nullable<AbstractMesh>);
  138311. get attachedNode(): Nullable<Node>;
  138312. set attachedNode(node: Nullable<Node>);
  138313. protected _checkBillboardTransform(): void;
  138314. /**
  138315. * True when the mouse pointer is hovering a gizmo mesh
  138316. */
  138317. get isHovered(): boolean;
  138318. /**
  138319. * Creates a RotationGizmo
  138320. * @param gizmoLayer The utility layer the gizmo will be added to
  138321. * @param tessellation Amount of tessellation to be used when creating rotation circles
  138322. * @param useEulerRotation Use and update Euler angle instead of quaternion
  138323. * @param thickness display gizmo axis thickness
  138324. */
  138325. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  138326. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  138327. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  138328. /**
  138329. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  138330. */
  138331. set snapDistance(value: number);
  138332. get snapDistance(): number;
  138333. /**
  138334. * Ratio for the scale of the gizmo (Default: 1)
  138335. */
  138336. set scaleRatio(value: number);
  138337. get scaleRatio(): number;
  138338. /**
  138339. * Disposes of the gizmo
  138340. */
  138341. dispose(): void;
  138342. /**
  138343. * CustomMeshes are not supported by this gizmo
  138344. * @param mesh The mesh to replace the default mesh of the gizmo
  138345. */
  138346. setCustomMesh(mesh: Mesh): void;
  138347. }
  138348. }
  138349. declare module BABYLON {
  138350. /**
  138351. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  138352. */
  138353. export class GizmoManager implements IDisposable {
  138354. private scene;
  138355. /**
  138356. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  138357. */
  138358. gizmos: {
  138359. positionGizmo: Nullable<PositionGizmo>;
  138360. rotationGizmo: Nullable<RotationGizmo>;
  138361. scaleGizmo: Nullable<ScaleGizmo>;
  138362. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  138363. };
  138364. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  138365. clearGizmoOnEmptyPointerEvent: boolean;
  138366. /** Fires an event when the manager is attached to a mesh */
  138367. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  138368. /** Fires an event when the manager is attached to a node */
  138369. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  138370. private _gizmosEnabled;
  138371. private _pointerObserver;
  138372. private _attachedMesh;
  138373. private _attachedNode;
  138374. private _boundingBoxColor;
  138375. private _defaultUtilityLayer;
  138376. private _defaultKeepDepthUtilityLayer;
  138377. private _thickness;
  138378. /**
  138379. * When bounding box gizmo is enabled, this can be used to track drag/end events
  138380. */
  138381. boundingBoxDragBehavior: SixDofDragBehavior;
  138382. /**
  138383. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  138384. */
  138385. attachableMeshes: Nullable<Array<AbstractMesh>>;
  138386. /**
  138387. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  138388. */
  138389. attachableNodes: Nullable<Array<Node>>;
  138390. /**
  138391. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  138392. */
  138393. usePointerToAttachGizmos: boolean;
  138394. /**
  138395. * Utility layer that the bounding box gizmo belongs to
  138396. */
  138397. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  138398. /**
  138399. * Utility layer that all gizmos besides bounding box belong to
  138400. */
  138401. get utilityLayer(): UtilityLayerRenderer;
  138402. /**
  138403. * True when the mouse pointer is hovering a gizmo mesh
  138404. */
  138405. get isHovered(): boolean;
  138406. /**
  138407. * Instatiates a gizmo manager
  138408. * @param scene the scene to overlay the gizmos on top of
  138409. * @param thickness display gizmo axis thickness
  138410. */
  138411. constructor(scene: Scene, thickness?: number);
  138412. /**
  138413. * Attaches a set of gizmos to the specified mesh
  138414. * @param mesh The mesh the gizmo's should be attached to
  138415. */
  138416. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  138417. /**
  138418. * Attaches a set of gizmos to the specified node
  138419. * @param node The node the gizmo's should be attached to
  138420. */
  138421. attachToNode(node: Nullable<Node>): void;
  138422. /**
  138423. * If the position gizmo is enabled
  138424. */
  138425. set positionGizmoEnabled(value: boolean);
  138426. get positionGizmoEnabled(): boolean;
  138427. /**
  138428. * If the rotation gizmo is enabled
  138429. */
  138430. set rotationGizmoEnabled(value: boolean);
  138431. get rotationGizmoEnabled(): boolean;
  138432. /**
  138433. * If the scale gizmo is enabled
  138434. */
  138435. set scaleGizmoEnabled(value: boolean);
  138436. get scaleGizmoEnabled(): boolean;
  138437. /**
  138438. * If the boundingBox gizmo is enabled
  138439. */
  138440. set boundingBoxGizmoEnabled(value: boolean);
  138441. get boundingBoxGizmoEnabled(): boolean;
  138442. /**
  138443. * Disposes of the gizmo manager
  138444. */
  138445. dispose(): void;
  138446. }
  138447. }
  138448. declare module BABYLON {
  138449. /**
  138450. * A directional light is defined by a direction (what a surprise!).
  138451. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  138452. * 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.
  138453. * Documentation: https://doc.babylonjs.com/babylon101/lights
  138454. */
  138455. export class DirectionalLight extends ShadowLight {
  138456. private _shadowFrustumSize;
  138457. /**
  138458. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  138459. */
  138460. get shadowFrustumSize(): number;
  138461. /**
  138462. * Specifies a fix frustum size for the shadow generation.
  138463. */
  138464. set shadowFrustumSize(value: number);
  138465. private _shadowOrthoScale;
  138466. /**
  138467. * Gets the shadow projection scale against the optimal computed one.
  138468. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  138469. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  138470. */
  138471. get shadowOrthoScale(): number;
  138472. /**
  138473. * Sets the shadow projection scale against the optimal computed one.
  138474. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  138475. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  138476. */
  138477. set shadowOrthoScale(value: number);
  138478. /**
  138479. * Automatically compute the projection matrix to best fit (including all the casters)
  138480. * on each frame.
  138481. */
  138482. autoUpdateExtends: boolean;
  138483. /**
  138484. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  138485. * on each frame. autoUpdateExtends must be set to true for this to work
  138486. */
  138487. autoCalcShadowZBounds: boolean;
  138488. private _orthoLeft;
  138489. private _orthoRight;
  138490. private _orthoTop;
  138491. private _orthoBottom;
  138492. /**
  138493. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  138494. * The directional light is emitted from everywhere in the given direction.
  138495. * It can cast shadows.
  138496. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138497. * @param name The friendly name of the light
  138498. * @param direction The direction of the light
  138499. * @param scene The scene the light belongs to
  138500. */
  138501. constructor(name: string, direction: Vector3, scene: Scene);
  138502. /**
  138503. * Returns the string "DirectionalLight".
  138504. * @return The class name
  138505. */
  138506. getClassName(): string;
  138507. /**
  138508. * Returns the integer 1.
  138509. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138510. */
  138511. getTypeID(): number;
  138512. /**
  138513. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  138514. * Returns the DirectionalLight Shadow projection matrix.
  138515. */
  138516. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138517. /**
  138518. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  138519. * Returns the DirectionalLight Shadow projection matrix.
  138520. */
  138521. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  138522. /**
  138523. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  138524. * Returns the DirectionalLight Shadow projection matrix.
  138525. */
  138526. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138527. protected _buildUniformLayout(): void;
  138528. /**
  138529. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  138530. * @param effect The effect to update
  138531. * @param lightIndex The index of the light in the effect to update
  138532. * @returns The directional light
  138533. */
  138534. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  138535. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  138536. /**
  138537. * Gets the minZ used for shadow according to both the scene and the light.
  138538. *
  138539. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  138540. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  138541. * @param activeCamera The camera we are returning the min for
  138542. * @returns the depth min z
  138543. */
  138544. getDepthMinZ(activeCamera: Camera): number;
  138545. /**
  138546. * Gets the maxZ used for shadow according to both the scene and the light.
  138547. *
  138548. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  138549. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  138550. * @param activeCamera The camera we are returning the max for
  138551. * @returns the depth max z
  138552. */
  138553. getDepthMaxZ(activeCamera: Camera): number;
  138554. /**
  138555. * Prepares the list of defines specific to the light type.
  138556. * @param defines the list of defines
  138557. * @param lightIndex defines the index of the light for the effect
  138558. */
  138559. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138560. }
  138561. }
  138562. declare module BABYLON {
  138563. /**
  138564. * Class containing static functions to help procedurally build meshes
  138565. */
  138566. export class HemisphereBuilder {
  138567. /**
  138568. * Creates a hemisphere mesh
  138569. * @param name defines the name of the mesh
  138570. * @param options defines the options used to create the mesh
  138571. * @param scene defines the hosting scene
  138572. * @returns the hemisphere mesh
  138573. */
  138574. static CreateHemisphere(name: string, options: {
  138575. segments?: number;
  138576. diameter?: number;
  138577. sideOrientation?: number;
  138578. }, scene: any): Mesh;
  138579. }
  138580. }
  138581. declare module BABYLON {
  138582. /**
  138583. * A spot light is defined by a position, a direction, an angle, and an exponent.
  138584. * These values define a cone of light starting from the position, emitting toward the direction.
  138585. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  138586. * and the exponent defines the speed of the decay of the light with distance (reach).
  138587. * Documentation: https://doc.babylonjs.com/babylon101/lights
  138588. */
  138589. export class SpotLight extends ShadowLight {
  138590. private _angle;
  138591. private _innerAngle;
  138592. private _cosHalfAngle;
  138593. private _lightAngleScale;
  138594. private _lightAngleOffset;
  138595. /**
  138596. * Gets the cone angle of the spot light in Radians.
  138597. */
  138598. get angle(): number;
  138599. /**
  138600. * Sets the cone angle of the spot light in Radians.
  138601. */
  138602. set angle(value: number);
  138603. /**
  138604. * Only used in gltf falloff mode, this defines the angle where
  138605. * the directional falloff will start before cutting at angle which could be seen
  138606. * as outer angle.
  138607. */
  138608. get innerAngle(): number;
  138609. /**
  138610. * Only used in gltf falloff mode, this defines the angle where
  138611. * the directional falloff will start before cutting at angle which could be seen
  138612. * as outer angle.
  138613. */
  138614. set innerAngle(value: number);
  138615. private _shadowAngleScale;
  138616. /**
  138617. * Allows scaling the angle of the light for shadow generation only.
  138618. */
  138619. get shadowAngleScale(): number;
  138620. /**
  138621. * Allows scaling the angle of the light for shadow generation only.
  138622. */
  138623. set shadowAngleScale(value: number);
  138624. /**
  138625. * The light decay speed with the distance from the emission spot.
  138626. */
  138627. exponent: number;
  138628. private _projectionTextureMatrix;
  138629. /**
  138630. * Allows reading the projecton texture
  138631. */
  138632. get projectionTextureMatrix(): Matrix;
  138633. protected _projectionTextureLightNear: number;
  138634. /**
  138635. * Gets the near clip of the Spotlight for texture projection.
  138636. */
  138637. get projectionTextureLightNear(): number;
  138638. /**
  138639. * Sets the near clip of the Spotlight for texture projection.
  138640. */
  138641. set projectionTextureLightNear(value: number);
  138642. protected _projectionTextureLightFar: number;
  138643. /**
  138644. * Gets the far clip of the Spotlight for texture projection.
  138645. */
  138646. get projectionTextureLightFar(): number;
  138647. /**
  138648. * Sets the far clip of the Spotlight for texture projection.
  138649. */
  138650. set projectionTextureLightFar(value: number);
  138651. protected _projectionTextureUpDirection: Vector3;
  138652. /**
  138653. * Gets the Up vector of the Spotlight for texture projection.
  138654. */
  138655. get projectionTextureUpDirection(): Vector3;
  138656. /**
  138657. * Sets the Up vector of the Spotlight for texture projection.
  138658. */
  138659. set projectionTextureUpDirection(value: Vector3);
  138660. private _projectionTexture;
  138661. /**
  138662. * Gets the projection texture of the light.
  138663. */
  138664. get projectionTexture(): Nullable<BaseTexture>;
  138665. /**
  138666. * Sets the projection texture of the light.
  138667. */
  138668. set projectionTexture(value: Nullable<BaseTexture>);
  138669. private _projectionTextureViewLightDirty;
  138670. private _projectionTextureProjectionLightDirty;
  138671. private _projectionTextureDirty;
  138672. private _projectionTextureViewTargetVector;
  138673. private _projectionTextureViewLightMatrix;
  138674. private _projectionTextureProjectionLightMatrix;
  138675. private _projectionTextureScalingMatrix;
  138676. /**
  138677. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  138678. * It can cast shadows.
  138679. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138680. * @param name The light friendly name
  138681. * @param position The position of the spot light in the scene
  138682. * @param direction The direction of the light in the scene
  138683. * @param angle The cone angle of the light in Radians
  138684. * @param exponent The light decay speed with the distance from the emission spot
  138685. * @param scene The scene the lights belongs to
  138686. */
  138687. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  138688. /**
  138689. * Returns the string "SpotLight".
  138690. * @returns the class name
  138691. */
  138692. getClassName(): string;
  138693. /**
  138694. * Returns the integer 2.
  138695. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138696. */
  138697. getTypeID(): number;
  138698. /**
  138699. * Overrides the direction setter to recompute the projection texture view light Matrix.
  138700. */
  138701. protected _setDirection(value: Vector3): void;
  138702. /**
  138703. * Overrides the position setter to recompute the projection texture view light Matrix.
  138704. */
  138705. protected _setPosition(value: Vector3): void;
  138706. /**
  138707. * 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.
  138708. * Returns the SpotLight.
  138709. */
  138710. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138711. protected _computeProjectionTextureViewLightMatrix(): void;
  138712. protected _computeProjectionTextureProjectionLightMatrix(): void;
  138713. /**
  138714. * Main function for light texture projection matrix computing.
  138715. */
  138716. protected _computeProjectionTextureMatrix(): void;
  138717. protected _buildUniformLayout(): void;
  138718. private _computeAngleValues;
  138719. /**
  138720. * Sets the passed Effect "effect" with the Light textures.
  138721. * @param effect The effect to update
  138722. * @param lightIndex The index of the light in the effect to update
  138723. * @returns The light
  138724. */
  138725. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  138726. /**
  138727. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  138728. * @param effect The effect to update
  138729. * @param lightIndex The index of the light in the effect to update
  138730. * @returns The spot light
  138731. */
  138732. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  138733. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  138734. /**
  138735. * Disposes the light and the associated resources.
  138736. */
  138737. dispose(): void;
  138738. /**
  138739. * Prepares the list of defines specific to the light type.
  138740. * @param defines the list of defines
  138741. * @param lightIndex defines the index of the light for the effect
  138742. */
  138743. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138744. }
  138745. }
  138746. declare module BABYLON {
  138747. /**
  138748. * Gizmo that enables viewing a light
  138749. */
  138750. export class LightGizmo extends Gizmo {
  138751. private _lightMesh;
  138752. private _material;
  138753. private _cachedPosition;
  138754. private _cachedForward;
  138755. private _attachedMeshParent;
  138756. private _pointerObserver;
  138757. /**
  138758. * Event that fires each time the gizmo is clicked
  138759. */
  138760. onClickedObservable: Observable<Light>;
  138761. /**
  138762. * Creates a LightGizmo
  138763. * @param gizmoLayer The utility layer the gizmo will be added to
  138764. */
  138765. constructor(gizmoLayer?: UtilityLayerRenderer);
  138766. private _light;
  138767. /**
  138768. * The light that the gizmo is attached to
  138769. */
  138770. set light(light: Nullable<Light>);
  138771. get light(): Nullable<Light>;
  138772. /**
  138773. * Gets the material used to render the light gizmo
  138774. */
  138775. get material(): StandardMaterial;
  138776. /**
  138777. * @hidden
  138778. * Updates the gizmo to match the attached mesh's position/rotation
  138779. */
  138780. protected _update(): void;
  138781. private static _Scale;
  138782. /**
  138783. * Creates the lines for a light mesh
  138784. */
  138785. private static _CreateLightLines;
  138786. /**
  138787. * Disposes of the light gizmo
  138788. */
  138789. dispose(): void;
  138790. private static _CreateHemisphericLightMesh;
  138791. private static _CreatePointLightMesh;
  138792. private static _CreateSpotLightMesh;
  138793. private static _CreateDirectionalLightMesh;
  138794. }
  138795. }
  138796. declare module BABYLON {
  138797. /**
  138798. * Gizmo that enables viewing a camera
  138799. */
  138800. export class CameraGizmo extends Gizmo {
  138801. private _cameraMesh;
  138802. private _cameraLinesMesh;
  138803. private _material;
  138804. private _pointerObserver;
  138805. /**
  138806. * Event that fires each time the gizmo is clicked
  138807. */
  138808. onClickedObservable: Observable<Camera>;
  138809. /**
  138810. * Creates a CameraGizmo
  138811. * @param gizmoLayer The utility layer the gizmo will be added to
  138812. */
  138813. constructor(gizmoLayer?: UtilityLayerRenderer);
  138814. private _camera;
  138815. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  138816. get displayFrustum(): boolean;
  138817. set displayFrustum(value: boolean);
  138818. /**
  138819. * The camera that the gizmo is attached to
  138820. */
  138821. set camera(camera: Nullable<Camera>);
  138822. get camera(): Nullable<Camera>;
  138823. /**
  138824. * Gets the material used to render the camera gizmo
  138825. */
  138826. get material(): StandardMaterial;
  138827. /**
  138828. * @hidden
  138829. * Updates the gizmo to match the attached mesh's position/rotation
  138830. */
  138831. protected _update(): void;
  138832. private static _Scale;
  138833. private _invProjection;
  138834. /**
  138835. * Disposes of the camera gizmo
  138836. */
  138837. dispose(): void;
  138838. private static _CreateCameraMesh;
  138839. private static _CreateCameraFrustum;
  138840. }
  138841. }
  138842. declare module BABYLON {
  138843. /** @hidden */
  138844. export var backgroundFragmentDeclaration: {
  138845. name: string;
  138846. shader: string;
  138847. };
  138848. }
  138849. declare module BABYLON {
  138850. /** @hidden */
  138851. export var backgroundUboDeclaration: {
  138852. name: string;
  138853. shader: string;
  138854. };
  138855. }
  138856. declare module BABYLON {
  138857. /** @hidden */
  138858. export var backgroundPixelShader: {
  138859. name: string;
  138860. shader: string;
  138861. };
  138862. }
  138863. declare module BABYLON {
  138864. /** @hidden */
  138865. export var backgroundVertexDeclaration: {
  138866. name: string;
  138867. shader: string;
  138868. };
  138869. }
  138870. declare module BABYLON {
  138871. /** @hidden */
  138872. export var backgroundVertexShader: {
  138873. name: string;
  138874. shader: string;
  138875. };
  138876. }
  138877. declare module BABYLON {
  138878. /**
  138879. * Background material used to create an efficient environement around your scene.
  138880. */
  138881. export class BackgroundMaterial extends PushMaterial {
  138882. /**
  138883. * Standard reflectance value at parallel view angle.
  138884. */
  138885. static StandardReflectance0: number;
  138886. /**
  138887. * Standard reflectance value at grazing angle.
  138888. */
  138889. static StandardReflectance90: number;
  138890. protected _primaryColor: Color3;
  138891. /**
  138892. * Key light Color (multiply against the environement texture)
  138893. */
  138894. primaryColor: Color3;
  138895. protected __perceptualColor: Nullable<Color3>;
  138896. /**
  138897. * Experimental Internal Use Only.
  138898. *
  138899. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  138900. * This acts as a helper to set the primary color to a more "human friendly" value.
  138901. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  138902. * output color as close as possible from the chosen value.
  138903. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  138904. * part of lighting setup.)
  138905. */
  138906. get _perceptualColor(): Nullable<Color3>;
  138907. set _perceptualColor(value: Nullable<Color3>);
  138908. protected _primaryColorShadowLevel: float;
  138909. /**
  138910. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  138911. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  138912. */
  138913. get primaryColorShadowLevel(): float;
  138914. set primaryColorShadowLevel(value: float);
  138915. protected _primaryColorHighlightLevel: float;
  138916. /**
  138917. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  138918. * The primary color is used at the level chosen to define what the white area would look.
  138919. */
  138920. get primaryColorHighlightLevel(): float;
  138921. set primaryColorHighlightLevel(value: float);
  138922. protected _reflectionTexture: Nullable<BaseTexture>;
  138923. /**
  138924. * Reflection Texture used in the material.
  138925. * Should be author in a specific way for the best result (refer to the documentation).
  138926. */
  138927. reflectionTexture: Nullable<BaseTexture>;
  138928. protected _reflectionBlur: float;
  138929. /**
  138930. * Reflection Texture level of blur.
  138931. *
  138932. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  138933. * texture twice.
  138934. */
  138935. reflectionBlur: float;
  138936. protected _diffuseTexture: Nullable<BaseTexture>;
  138937. /**
  138938. * Diffuse Texture used in the material.
  138939. * Should be author in a specific way for the best result (refer to the documentation).
  138940. */
  138941. diffuseTexture: Nullable<BaseTexture>;
  138942. protected _shadowLights: Nullable<IShadowLight[]>;
  138943. /**
  138944. * Specify the list of lights casting shadow on the material.
  138945. * All scene shadow lights will be included if null.
  138946. */
  138947. shadowLights: Nullable<IShadowLight[]>;
  138948. protected _shadowLevel: float;
  138949. /**
  138950. * Helps adjusting the shadow to a softer level if required.
  138951. * 0 means black shadows and 1 means no shadows.
  138952. */
  138953. shadowLevel: float;
  138954. protected _sceneCenter: Vector3;
  138955. /**
  138956. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  138957. * It is usually zero but might be interesting to modify according to your setup.
  138958. */
  138959. sceneCenter: Vector3;
  138960. protected _opacityFresnel: boolean;
  138961. /**
  138962. * This helps specifying that the material is falling off to the sky box at grazing angle.
  138963. * This helps ensuring a nice transition when the camera goes under the ground.
  138964. */
  138965. opacityFresnel: boolean;
  138966. protected _reflectionFresnel: boolean;
  138967. /**
  138968. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  138969. * This helps adding a mirror texture on the ground.
  138970. */
  138971. reflectionFresnel: boolean;
  138972. protected _reflectionFalloffDistance: number;
  138973. /**
  138974. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  138975. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  138976. */
  138977. reflectionFalloffDistance: number;
  138978. protected _reflectionAmount: number;
  138979. /**
  138980. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  138981. */
  138982. reflectionAmount: number;
  138983. protected _reflectionReflectance0: number;
  138984. /**
  138985. * This specifies the weight of the reflection at grazing angle.
  138986. */
  138987. reflectionReflectance0: number;
  138988. protected _reflectionReflectance90: number;
  138989. /**
  138990. * This specifies the weight of the reflection at a perpendicular point of view.
  138991. */
  138992. reflectionReflectance90: number;
  138993. /**
  138994. * Sets the reflection reflectance fresnel values according to the default standard
  138995. * empirically know to work well :-)
  138996. */
  138997. set reflectionStandardFresnelWeight(value: number);
  138998. protected _useRGBColor: boolean;
  138999. /**
  139000. * Helps to directly use the maps channels instead of their level.
  139001. */
  139002. useRGBColor: boolean;
  139003. protected _enableNoise: boolean;
  139004. /**
  139005. * This helps reducing the banding effect that could occur on the background.
  139006. */
  139007. enableNoise: boolean;
  139008. /**
  139009. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  139010. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  139011. * Recommended to be keep at 1.0 except for special cases.
  139012. */
  139013. get fovMultiplier(): number;
  139014. set fovMultiplier(value: number);
  139015. private _fovMultiplier;
  139016. /**
  139017. * Enable the FOV adjustment feature controlled by fovMultiplier.
  139018. */
  139019. useEquirectangularFOV: boolean;
  139020. private _maxSimultaneousLights;
  139021. /**
  139022. * Number of Simultaneous lights allowed on the material.
  139023. */
  139024. maxSimultaneousLights: int;
  139025. private _shadowOnly;
  139026. /**
  139027. * Make the material only render shadows
  139028. */
  139029. shadowOnly: boolean;
  139030. /**
  139031. * Default configuration related to image processing available in the Background Material.
  139032. */
  139033. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  139034. /**
  139035. * Keep track of the image processing observer to allow dispose and replace.
  139036. */
  139037. private _imageProcessingObserver;
  139038. /**
  139039. * Attaches a new image processing configuration to the PBR Material.
  139040. * @param configuration (if null the scene configuration will be use)
  139041. */
  139042. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  139043. /**
  139044. * Gets the image processing configuration used either in this material.
  139045. */
  139046. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  139047. /**
  139048. * Sets the Default image processing configuration used either in the this material.
  139049. *
  139050. * If sets to null, the scene one is in use.
  139051. */
  139052. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  139053. /**
  139054. * Gets wether the color curves effect is enabled.
  139055. */
  139056. get cameraColorCurvesEnabled(): boolean;
  139057. /**
  139058. * Sets wether the color curves effect is enabled.
  139059. */
  139060. set cameraColorCurvesEnabled(value: boolean);
  139061. /**
  139062. * Gets wether the color grading effect is enabled.
  139063. */
  139064. get cameraColorGradingEnabled(): boolean;
  139065. /**
  139066. * Gets wether the color grading effect is enabled.
  139067. */
  139068. set cameraColorGradingEnabled(value: boolean);
  139069. /**
  139070. * Gets wether tonemapping is enabled or not.
  139071. */
  139072. get cameraToneMappingEnabled(): boolean;
  139073. /**
  139074. * Sets wether tonemapping is enabled or not
  139075. */
  139076. set cameraToneMappingEnabled(value: boolean);
  139077. /**
  139078. * The camera exposure used on this material.
  139079. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  139080. * This corresponds to a photographic exposure.
  139081. */
  139082. get cameraExposure(): float;
  139083. /**
  139084. * The camera exposure used on this material.
  139085. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  139086. * This corresponds to a photographic exposure.
  139087. */
  139088. set cameraExposure(value: float);
  139089. /**
  139090. * Gets The camera contrast used on this material.
  139091. */
  139092. get cameraContrast(): float;
  139093. /**
  139094. * Sets The camera contrast used on this material.
  139095. */
  139096. set cameraContrast(value: float);
  139097. /**
  139098. * Gets the Color Grading 2D Lookup Texture.
  139099. */
  139100. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  139101. /**
  139102. * Sets the Color Grading 2D Lookup Texture.
  139103. */
  139104. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  139105. /**
  139106. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  139107. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  139108. * 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;
  139109. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  139110. */
  139111. get cameraColorCurves(): Nullable<ColorCurves>;
  139112. /**
  139113. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  139114. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  139115. * 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;
  139116. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  139117. */
  139118. set cameraColorCurves(value: Nullable<ColorCurves>);
  139119. /**
  139120. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  139121. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  139122. */
  139123. switchToBGR: boolean;
  139124. private _renderTargets;
  139125. private _reflectionControls;
  139126. private _white;
  139127. private _primaryShadowColor;
  139128. private _primaryHighlightColor;
  139129. /**
  139130. * Instantiates a Background Material in the given scene
  139131. * @param name The friendly name of the material
  139132. * @param scene The scene to add the material to
  139133. */
  139134. constructor(name: string, scene: Scene);
  139135. /**
  139136. * Gets a boolean indicating that current material needs to register RTT
  139137. */
  139138. get hasRenderTargetTextures(): boolean;
  139139. /**
  139140. * The entire material has been created in order to prevent overdraw.
  139141. * @returns false
  139142. */
  139143. needAlphaTesting(): boolean;
  139144. /**
  139145. * The entire material has been created in order to prevent overdraw.
  139146. * @returns true if blending is enable
  139147. */
  139148. needAlphaBlending(): boolean;
  139149. /**
  139150. * Checks wether the material is ready to be rendered for a given mesh.
  139151. * @param mesh The mesh to render
  139152. * @param subMesh The submesh to check against
  139153. * @param useInstances Specify wether or not the material is used with instances
  139154. * @returns true if all the dependencies are ready (Textures, Effects...)
  139155. */
  139156. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  139157. /**
  139158. * Compute the primary color according to the chosen perceptual color.
  139159. */
  139160. private _computePrimaryColorFromPerceptualColor;
  139161. /**
  139162. * Compute the highlights and shadow colors according to their chosen levels.
  139163. */
  139164. private _computePrimaryColors;
  139165. /**
  139166. * Build the uniform buffer used in the material.
  139167. */
  139168. buildUniformLayout(): void;
  139169. /**
  139170. * Unbind the material.
  139171. */
  139172. unbind(): void;
  139173. /**
  139174. * Bind only the world matrix to the material.
  139175. * @param world The world matrix to bind.
  139176. */
  139177. bindOnlyWorldMatrix(world: Matrix): void;
  139178. /**
  139179. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  139180. * @param world The world matrix to bind.
  139181. * @param subMesh The submesh to bind for.
  139182. */
  139183. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  139184. /**
  139185. * Checks to see if a texture is used in the material.
  139186. * @param texture - Base texture to use.
  139187. * @returns - Boolean specifying if a texture is used in the material.
  139188. */
  139189. hasTexture(texture: BaseTexture): boolean;
  139190. /**
  139191. * Dispose the material.
  139192. * @param forceDisposeEffect Force disposal of the associated effect.
  139193. * @param forceDisposeTextures Force disposal of the associated textures.
  139194. */
  139195. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  139196. /**
  139197. * Clones the material.
  139198. * @param name The cloned name.
  139199. * @returns The cloned material.
  139200. */
  139201. clone(name: string): BackgroundMaterial;
  139202. /**
  139203. * Serializes the current material to its JSON representation.
  139204. * @returns The JSON representation.
  139205. */
  139206. serialize(): any;
  139207. /**
  139208. * Gets the class name of the material
  139209. * @returns "BackgroundMaterial"
  139210. */
  139211. getClassName(): string;
  139212. /**
  139213. * Parse a JSON input to create back a background material.
  139214. * @param source The JSON data to parse
  139215. * @param scene The scene to create the parsed material in
  139216. * @param rootUrl The root url of the assets the material depends upon
  139217. * @returns the instantiated BackgroundMaterial.
  139218. */
  139219. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  139220. }
  139221. }
  139222. declare module BABYLON {
  139223. /**
  139224. * Represents the different options available during the creation of
  139225. * a Environment helper.
  139226. *
  139227. * This can control the default ground, skybox and image processing setup of your scene.
  139228. */
  139229. export interface IEnvironmentHelperOptions {
  139230. /**
  139231. * Specifies whether or not to create a ground.
  139232. * True by default.
  139233. */
  139234. createGround: boolean;
  139235. /**
  139236. * Specifies the ground size.
  139237. * 15 by default.
  139238. */
  139239. groundSize: number;
  139240. /**
  139241. * The texture used on the ground for the main color.
  139242. * Comes from the BabylonJS CDN by default.
  139243. *
  139244. * Remarks: Can be either a texture or a url.
  139245. */
  139246. groundTexture: string | BaseTexture;
  139247. /**
  139248. * The color mixed in the ground texture by default.
  139249. * BabylonJS clearColor by default.
  139250. */
  139251. groundColor: Color3;
  139252. /**
  139253. * Specifies the ground opacity.
  139254. * 1 by default.
  139255. */
  139256. groundOpacity: number;
  139257. /**
  139258. * Enables the ground to receive shadows.
  139259. * True by default.
  139260. */
  139261. enableGroundShadow: boolean;
  139262. /**
  139263. * Helps preventing the shadow to be fully black on the ground.
  139264. * 0.5 by default.
  139265. */
  139266. groundShadowLevel: number;
  139267. /**
  139268. * Creates a mirror texture attach to the ground.
  139269. * false by default.
  139270. */
  139271. enableGroundMirror: boolean;
  139272. /**
  139273. * Specifies the ground mirror size ratio.
  139274. * 0.3 by default as the default kernel is 64.
  139275. */
  139276. groundMirrorSizeRatio: number;
  139277. /**
  139278. * Specifies the ground mirror blur kernel size.
  139279. * 64 by default.
  139280. */
  139281. groundMirrorBlurKernel: number;
  139282. /**
  139283. * Specifies the ground mirror visibility amount.
  139284. * 1 by default
  139285. */
  139286. groundMirrorAmount: number;
  139287. /**
  139288. * Specifies the ground mirror reflectance weight.
  139289. * This uses the standard weight of the background material to setup the fresnel effect
  139290. * of the mirror.
  139291. * 1 by default.
  139292. */
  139293. groundMirrorFresnelWeight: number;
  139294. /**
  139295. * Specifies the ground mirror Falloff distance.
  139296. * This can helps reducing the size of the reflection.
  139297. * 0 by Default.
  139298. */
  139299. groundMirrorFallOffDistance: number;
  139300. /**
  139301. * Specifies the ground mirror texture type.
  139302. * Unsigned Int by Default.
  139303. */
  139304. groundMirrorTextureType: number;
  139305. /**
  139306. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  139307. * the shown objects.
  139308. */
  139309. groundYBias: number;
  139310. /**
  139311. * Specifies whether or not to create a skybox.
  139312. * True by default.
  139313. */
  139314. createSkybox: boolean;
  139315. /**
  139316. * Specifies the skybox size.
  139317. * 20 by default.
  139318. */
  139319. skyboxSize: number;
  139320. /**
  139321. * The texture used on the skybox for the main color.
  139322. * Comes from the BabylonJS CDN by default.
  139323. *
  139324. * Remarks: Can be either a texture or a url.
  139325. */
  139326. skyboxTexture: string | BaseTexture;
  139327. /**
  139328. * The color mixed in the skybox texture by default.
  139329. * BabylonJS clearColor by default.
  139330. */
  139331. skyboxColor: Color3;
  139332. /**
  139333. * The background rotation around the Y axis of the scene.
  139334. * This helps aligning the key lights of your scene with the background.
  139335. * 0 by default.
  139336. */
  139337. backgroundYRotation: number;
  139338. /**
  139339. * Compute automatically the size of the elements to best fit with the scene.
  139340. */
  139341. sizeAuto: boolean;
  139342. /**
  139343. * Default position of the rootMesh if autoSize is not true.
  139344. */
  139345. rootPosition: Vector3;
  139346. /**
  139347. * Sets up the image processing in the scene.
  139348. * true by default.
  139349. */
  139350. setupImageProcessing: boolean;
  139351. /**
  139352. * The texture used as your environment texture in the scene.
  139353. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  139354. *
  139355. * Remarks: Can be either a texture or a url.
  139356. */
  139357. environmentTexture: string | BaseTexture;
  139358. /**
  139359. * The value of the exposure to apply to the scene.
  139360. * 0.6 by default if setupImageProcessing is true.
  139361. */
  139362. cameraExposure: number;
  139363. /**
  139364. * The value of the contrast to apply to the scene.
  139365. * 1.6 by default if setupImageProcessing is true.
  139366. */
  139367. cameraContrast: number;
  139368. /**
  139369. * Specifies whether or not tonemapping should be enabled in the scene.
  139370. * true by default if setupImageProcessing is true.
  139371. */
  139372. toneMappingEnabled: boolean;
  139373. }
  139374. /**
  139375. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  139376. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  139377. * It also helps with the default setup of your imageProcessing configuration.
  139378. */
  139379. export class EnvironmentHelper {
  139380. /**
  139381. * Default ground texture URL.
  139382. */
  139383. private static _groundTextureCDNUrl;
  139384. /**
  139385. * Default skybox texture URL.
  139386. */
  139387. private static _skyboxTextureCDNUrl;
  139388. /**
  139389. * Default environment texture URL.
  139390. */
  139391. private static _environmentTextureCDNUrl;
  139392. /**
  139393. * Creates the default options for the helper.
  139394. */
  139395. private static _getDefaultOptions;
  139396. private _rootMesh;
  139397. /**
  139398. * Gets the root mesh created by the helper.
  139399. */
  139400. get rootMesh(): Mesh;
  139401. private _skybox;
  139402. /**
  139403. * Gets the skybox created by the helper.
  139404. */
  139405. get skybox(): Nullable<Mesh>;
  139406. private _skyboxTexture;
  139407. /**
  139408. * Gets the skybox texture created by the helper.
  139409. */
  139410. get skyboxTexture(): Nullable<BaseTexture>;
  139411. private _skyboxMaterial;
  139412. /**
  139413. * Gets the skybox material created by the helper.
  139414. */
  139415. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  139416. private _ground;
  139417. /**
  139418. * Gets the ground mesh created by the helper.
  139419. */
  139420. get ground(): Nullable<Mesh>;
  139421. private _groundTexture;
  139422. /**
  139423. * Gets the ground texture created by the helper.
  139424. */
  139425. get groundTexture(): Nullable<BaseTexture>;
  139426. private _groundMirror;
  139427. /**
  139428. * Gets the ground mirror created by the helper.
  139429. */
  139430. get groundMirror(): Nullable<MirrorTexture>;
  139431. /**
  139432. * Gets the ground mirror render list to helps pushing the meshes
  139433. * you wish in the ground reflection.
  139434. */
  139435. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  139436. private _groundMaterial;
  139437. /**
  139438. * Gets the ground material created by the helper.
  139439. */
  139440. get groundMaterial(): Nullable<BackgroundMaterial>;
  139441. /**
  139442. * Stores the creation options.
  139443. */
  139444. private readonly _scene;
  139445. private _options;
  139446. /**
  139447. * This observable will be notified with any error during the creation of the environment,
  139448. * mainly texture creation errors.
  139449. */
  139450. onErrorObservable: Observable<{
  139451. message?: string;
  139452. exception?: any;
  139453. }>;
  139454. /**
  139455. * constructor
  139456. * @param options Defines the options we want to customize the helper
  139457. * @param scene The scene to add the material to
  139458. */
  139459. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  139460. /**
  139461. * Updates the background according to the new options
  139462. * @param options
  139463. */
  139464. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  139465. /**
  139466. * Sets the primary color of all the available elements.
  139467. * @param color the main color to affect to the ground and the background
  139468. */
  139469. setMainColor(color: Color3): void;
  139470. /**
  139471. * Setup the image processing according to the specified options.
  139472. */
  139473. private _setupImageProcessing;
  139474. /**
  139475. * Setup the environment texture according to the specified options.
  139476. */
  139477. private _setupEnvironmentTexture;
  139478. /**
  139479. * Setup the background according to the specified options.
  139480. */
  139481. private _setupBackground;
  139482. /**
  139483. * Get the scene sizes according to the setup.
  139484. */
  139485. private _getSceneSize;
  139486. /**
  139487. * Setup the ground according to the specified options.
  139488. */
  139489. private _setupGround;
  139490. /**
  139491. * Setup the ground material according to the specified options.
  139492. */
  139493. private _setupGroundMaterial;
  139494. /**
  139495. * Setup the ground diffuse texture according to the specified options.
  139496. */
  139497. private _setupGroundDiffuseTexture;
  139498. /**
  139499. * Setup the ground mirror texture according to the specified options.
  139500. */
  139501. private _setupGroundMirrorTexture;
  139502. /**
  139503. * Setup the ground to receive the mirror texture.
  139504. */
  139505. private _setupMirrorInGroundMaterial;
  139506. /**
  139507. * Setup the skybox according to the specified options.
  139508. */
  139509. private _setupSkybox;
  139510. /**
  139511. * Setup the skybox material according to the specified options.
  139512. */
  139513. private _setupSkyboxMaterial;
  139514. /**
  139515. * Setup the skybox reflection texture according to the specified options.
  139516. */
  139517. private _setupSkyboxReflectionTexture;
  139518. private _errorHandler;
  139519. /**
  139520. * Dispose all the elements created by the Helper.
  139521. */
  139522. dispose(): void;
  139523. }
  139524. }
  139525. declare module BABYLON {
  139526. /**
  139527. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  139528. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  139529. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  139530. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139531. */
  139532. export abstract class TextureDome<T extends Texture> extends TransformNode {
  139533. protected onError: Nullable<(message?: string, exception?: any) => void>;
  139534. /**
  139535. * Define the source as a Monoscopic panoramic 360/180.
  139536. */
  139537. static readonly MODE_MONOSCOPIC: number;
  139538. /**
  139539. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  139540. */
  139541. static readonly MODE_TOPBOTTOM: number;
  139542. /**
  139543. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  139544. */
  139545. static readonly MODE_SIDEBYSIDE: number;
  139546. private _halfDome;
  139547. private _crossEye;
  139548. protected _useDirectMapping: boolean;
  139549. /**
  139550. * The texture being displayed on the sphere
  139551. */
  139552. protected _texture: T;
  139553. /**
  139554. * Gets the texture being displayed on the sphere
  139555. */
  139556. get texture(): T;
  139557. /**
  139558. * Sets the texture being displayed on the sphere
  139559. */
  139560. set texture(newTexture: T);
  139561. /**
  139562. * The skybox material
  139563. */
  139564. protected _material: BackgroundMaterial;
  139565. /**
  139566. * The surface used for the dome
  139567. */
  139568. protected _mesh: Mesh;
  139569. /**
  139570. * Gets the mesh used for the dome.
  139571. */
  139572. get mesh(): Mesh;
  139573. /**
  139574. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  139575. */
  139576. private _halfDomeMask;
  139577. /**
  139578. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  139579. * Also see the options.resolution property.
  139580. */
  139581. get fovMultiplier(): number;
  139582. set fovMultiplier(value: number);
  139583. protected _textureMode: number;
  139584. /**
  139585. * Gets or set the current texture mode for the texture. It can be:
  139586. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139587. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139588. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139589. */
  139590. get textureMode(): number;
  139591. /**
  139592. * Sets the current texture mode for the texture. It can be:
  139593. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139594. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139595. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139596. */
  139597. set textureMode(value: number);
  139598. /**
  139599. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  139600. */
  139601. get halfDome(): boolean;
  139602. /**
  139603. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  139604. */
  139605. set halfDome(enabled: boolean);
  139606. /**
  139607. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  139608. */
  139609. set crossEye(enabled: boolean);
  139610. /**
  139611. * Is it a cross-eye texture?
  139612. */
  139613. get crossEye(): boolean;
  139614. /**
  139615. * The background material of this dome.
  139616. */
  139617. get material(): BackgroundMaterial;
  139618. /**
  139619. * Oberserver used in Stereoscopic VR Mode.
  139620. */
  139621. private _onBeforeCameraRenderObserver;
  139622. /**
  139623. * Observable raised when an error occured while loading the 360 image
  139624. */
  139625. onLoadErrorObservable: Observable<string>;
  139626. /**
  139627. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  139628. * @param name Element's name, child elements will append suffixes for their own names.
  139629. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  139630. * @param options An object containing optional or exposed sub element properties
  139631. */
  139632. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  139633. resolution?: number;
  139634. clickToPlay?: boolean;
  139635. autoPlay?: boolean;
  139636. loop?: boolean;
  139637. size?: number;
  139638. poster?: string;
  139639. faceForward?: boolean;
  139640. useDirectMapping?: boolean;
  139641. halfDomeMode?: boolean;
  139642. crossEyeMode?: boolean;
  139643. generateMipMaps?: boolean;
  139644. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  139645. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  139646. protected _changeTextureMode(value: number): void;
  139647. /**
  139648. * Releases resources associated with this node.
  139649. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  139650. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  139651. */
  139652. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  139653. }
  139654. }
  139655. declare module BABYLON {
  139656. /**
  139657. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  139658. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  139659. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  139660. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139661. */
  139662. export class PhotoDome extends TextureDome<Texture> {
  139663. /**
  139664. * Define the image as a Monoscopic panoramic 360 image.
  139665. */
  139666. static readonly MODE_MONOSCOPIC: number;
  139667. /**
  139668. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  139669. */
  139670. static readonly MODE_TOPBOTTOM: number;
  139671. /**
  139672. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  139673. */
  139674. static readonly MODE_SIDEBYSIDE: number;
  139675. /**
  139676. * Gets or sets the texture being displayed on the sphere
  139677. */
  139678. get photoTexture(): Texture;
  139679. /**
  139680. * sets the texture being displayed on the sphere
  139681. */
  139682. set photoTexture(value: Texture);
  139683. /**
  139684. * Gets the current video mode for the video. It can be:
  139685. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139686. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139687. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139688. */
  139689. get imageMode(): number;
  139690. /**
  139691. * Sets the current video mode for the video. It can be:
  139692. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139693. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139694. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139695. */
  139696. set imageMode(value: number);
  139697. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  139698. }
  139699. }
  139700. declare module BABYLON {
  139701. /**
  139702. * Direct draw surface info
  139703. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  139704. */
  139705. export interface DDSInfo {
  139706. /**
  139707. * Width of the texture
  139708. */
  139709. width: number;
  139710. /**
  139711. * Width of the texture
  139712. */
  139713. height: number;
  139714. /**
  139715. * Number of Mipmaps for the texture
  139716. * @see https://en.wikipedia.org/wiki/Mipmap
  139717. */
  139718. mipmapCount: number;
  139719. /**
  139720. * If the textures format is a known fourCC format
  139721. * @see https://www.fourcc.org/
  139722. */
  139723. isFourCC: boolean;
  139724. /**
  139725. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  139726. */
  139727. isRGB: boolean;
  139728. /**
  139729. * If the texture is a lumincance format
  139730. */
  139731. isLuminance: boolean;
  139732. /**
  139733. * If this is a cube texture
  139734. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  139735. */
  139736. isCube: boolean;
  139737. /**
  139738. * If the texture is a compressed format eg. FOURCC_DXT1
  139739. */
  139740. isCompressed: boolean;
  139741. /**
  139742. * The dxgiFormat of the texture
  139743. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  139744. */
  139745. dxgiFormat: number;
  139746. /**
  139747. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  139748. */
  139749. textureType: number;
  139750. /**
  139751. * Sphericle polynomial created for the dds texture
  139752. */
  139753. sphericalPolynomial?: SphericalPolynomial;
  139754. }
  139755. /**
  139756. * Class used to provide DDS decompression tools
  139757. */
  139758. export class DDSTools {
  139759. /**
  139760. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  139761. */
  139762. static StoreLODInAlphaChannel: boolean;
  139763. /**
  139764. * Gets DDS information from an array buffer
  139765. * @param data defines the array buffer view to read data from
  139766. * @returns the DDS information
  139767. */
  139768. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  139769. private static _FloatView;
  139770. private static _Int32View;
  139771. private static _ToHalfFloat;
  139772. private static _FromHalfFloat;
  139773. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  139774. private static _GetHalfFloatRGBAArrayBuffer;
  139775. private static _GetFloatRGBAArrayBuffer;
  139776. private static _GetFloatAsUIntRGBAArrayBuffer;
  139777. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  139778. private static _GetRGBAArrayBuffer;
  139779. private static _ExtractLongWordOrder;
  139780. private static _GetRGBArrayBuffer;
  139781. private static _GetLuminanceArrayBuffer;
  139782. /**
  139783. * Uploads DDS Levels to a Babylon Texture
  139784. * @hidden
  139785. */
  139786. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  139787. }
  139788. interface ThinEngine {
  139789. /**
  139790. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  139791. * @param rootUrl defines the url where the file to load is located
  139792. * @param scene defines the current scene
  139793. * @param lodScale defines scale to apply to the mip map selection
  139794. * @param lodOffset defines offset to apply to the mip map selection
  139795. * @param onLoad defines an optional callback raised when the texture is loaded
  139796. * @param onError defines an optional callback raised if there is an issue to load the texture
  139797. * @param format defines the format of the data
  139798. * @param forcedExtension defines the extension to use to pick the right loader
  139799. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  139800. * @returns the cube texture as an InternalTexture
  139801. */
  139802. 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;
  139803. }
  139804. }
  139805. declare module BABYLON {
  139806. /**
  139807. * Implementation of the DDS Texture Loader.
  139808. * @hidden
  139809. */
  139810. export class _DDSTextureLoader implements IInternalTextureLoader {
  139811. /**
  139812. * Defines wether the loader supports cascade loading the different faces.
  139813. */
  139814. readonly supportCascades: boolean;
  139815. /**
  139816. * This returns if the loader support the current file information.
  139817. * @param extension defines the file extension of the file being loaded
  139818. * @returns true if the loader can load the specified file
  139819. */
  139820. canLoad(extension: string): boolean;
  139821. /**
  139822. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139823. * @param data contains the texture data
  139824. * @param texture defines the BabylonJS internal texture
  139825. * @param createPolynomials will be true if polynomials have been requested
  139826. * @param onLoad defines the callback to trigger once the texture is ready
  139827. * @param onError defines the callback to trigger in case of error
  139828. */
  139829. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139830. /**
  139831. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139832. * @param data contains the texture data
  139833. * @param texture defines the BabylonJS internal texture
  139834. * @param callback defines the method to call once ready to upload
  139835. */
  139836. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139837. }
  139838. }
  139839. declare module BABYLON {
  139840. /**
  139841. * Implementation of the ENV Texture Loader.
  139842. * @hidden
  139843. */
  139844. export class _ENVTextureLoader implements IInternalTextureLoader {
  139845. /**
  139846. * Defines wether the loader supports cascade loading the different faces.
  139847. */
  139848. readonly supportCascades: boolean;
  139849. /**
  139850. * This returns if the loader support the current file information.
  139851. * @param extension defines the file extension of the file being loaded
  139852. * @returns true if the loader can load the specified file
  139853. */
  139854. canLoad(extension: string): boolean;
  139855. /**
  139856. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139857. * @param data contains the texture data
  139858. * @param texture defines the BabylonJS internal texture
  139859. * @param createPolynomials will be true if polynomials have been requested
  139860. * @param onLoad defines the callback to trigger once the texture is ready
  139861. * @param onError defines the callback to trigger in case of error
  139862. */
  139863. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139864. /**
  139865. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139866. * @param data contains the texture data
  139867. * @param texture defines the BabylonJS internal texture
  139868. * @param callback defines the method to call once ready to upload
  139869. */
  139870. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139871. }
  139872. }
  139873. declare module BABYLON {
  139874. /**
  139875. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  139876. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  139877. */
  139878. export class KhronosTextureContainer {
  139879. /** contents of the KTX container file */
  139880. data: ArrayBufferView;
  139881. private static HEADER_LEN;
  139882. private static COMPRESSED_2D;
  139883. private static COMPRESSED_3D;
  139884. private static TEX_2D;
  139885. private static TEX_3D;
  139886. /**
  139887. * Gets the openGL type
  139888. */
  139889. glType: number;
  139890. /**
  139891. * Gets the openGL type size
  139892. */
  139893. glTypeSize: number;
  139894. /**
  139895. * Gets the openGL format
  139896. */
  139897. glFormat: number;
  139898. /**
  139899. * Gets the openGL internal format
  139900. */
  139901. glInternalFormat: number;
  139902. /**
  139903. * Gets the base internal format
  139904. */
  139905. glBaseInternalFormat: number;
  139906. /**
  139907. * Gets image width in pixel
  139908. */
  139909. pixelWidth: number;
  139910. /**
  139911. * Gets image height in pixel
  139912. */
  139913. pixelHeight: number;
  139914. /**
  139915. * Gets image depth in pixels
  139916. */
  139917. pixelDepth: number;
  139918. /**
  139919. * Gets the number of array elements
  139920. */
  139921. numberOfArrayElements: number;
  139922. /**
  139923. * Gets the number of faces
  139924. */
  139925. numberOfFaces: number;
  139926. /**
  139927. * Gets the number of mipmap levels
  139928. */
  139929. numberOfMipmapLevels: number;
  139930. /**
  139931. * Gets the bytes of key value data
  139932. */
  139933. bytesOfKeyValueData: number;
  139934. /**
  139935. * Gets the load type
  139936. */
  139937. loadType: number;
  139938. /**
  139939. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  139940. */
  139941. isInvalid: boolean;
  139942. /**
  139943. * Creates a new KhronosTextureContainer
  139944. * @param data contents of the KTX container file
  139945. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  139946. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  139947. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  139948. */
  139949. constructor(
  139950. /** contents of the KTX container file */
  139951. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  139952. /**
  139953. * Uploads KTX content to a Babylon Texture.
  139954. * It is assumed that the texture has already been created & is currently bound
  139955. * @hidden
  139956. */
  139957. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  139958. private _upload2DCompressedLevels;
  139959. /**
  139960. * Checks if the given data starts with a KTX file identifier.
  139961. * @param data the data to check
  139962. * @returns true if the data is a KTX file or false otherwise
  139963. */
  139964. static IsValid(data: ArrayBufferView): boolean;
  139965. }
  139966. }
  139967. declare module BABYLON {
  139968. /**
  139969. * Helper class to push actions to a pool of workers.
  139970. */
  139971. export class WorkerPool implements IDisposable {
  139972. private _workerInfos;
  139973. private _pendingActions;
  139974. /**
  139975. * Constructor
  139976. * @param workers Array of workers to use for actions
  139977. */
  139978. constructor(workers: Array<Worker>);
  139979. /**
  139980. * Terminates all workers and clears any pending actions.
  139981. */
  139982. dispose(): void;
  139983. /**
  139984. * Pushes an action to the worker pool. If all the workers are active, the action will be
  139985. * pended until a worker has completed its action.
  139986. * @param action The action to perform. Call onComplete when the action is complete.
  139987. */
  139988. push(action: (worker: Worker, onComplete: () => void) => void): void;
  139989. private _execute;
  139990. }
  139991. }
  139992. declare module BABYLON {
  139993. /**
  139994. * Class for loading KTX2 files
  139995. */
  139996. export class KhronosTextureContainer2 {
  139997. private static _WorkerPoolPromise?;
  139998. private static _Initialized;
  139999. private static _Ktx2Decoder;
  140000. /**
  140001. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  140002. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  140003. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  140004. * Urls you can change:
  140005. * URLConfig.jsDecoderModule
  140006. * URLConfig.wasmUASTCToASTC
  140007. * URLConfig.wasmUASTCToBC7
  140008. * URLConfig.wasmUASTCToRGBA_UNORM
  140009. * URLConfig.wasmUASTCToRGBA_SRGB
  140010. * URLConfig.jsMSCTranscoder
  140011. * URLConfig.wasmMSCTranscoder
  140012. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  140013. */
  140014. static URLConfig: {
  140015. jsDecoderModule: string;
  140016. wasmUASTCToASTC: null;
  140017. wasmUASTCToBC7: null;
  140018. wasmUASTCToRGBA_UNORM: null;
  140019. wasmUASTCToRGBA_SRGB: null;
  140020. jsMSCTranscoder: null;
  140021. wasmMSCTranscoder: null;
  140022. };
  140023. /**
  140024. * Default number of workers used to handle data decoding
  140025. */
  140026. static DefaultNumWorkers: number;
  140027. private static GetDefaultNumWorkers;
  140028. private _engine;
  140029. private static _CreateWorkerPool;
  140030. /**
  140031. * Constructor
  140032. * @param engine The engine to use
  140033. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  140034. */
  140035. constructor(engine: ThinEngine, numWorkers?: number);
  140036. /** @hidden */
  140037. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  140038. /**
  140039. * Stop all async operations and release resources.
  140040. */
  140041. dispose(): void;
  140042. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  140043. /**
  140044. * Checks if the given data starts with a KTX2 file identifier.
  140045. * @param data the data to check
  140046. * @returns true if the data is a KTX2 file or false otherwise
  140047. */
  140048. static IsValid(data: ArrayBufferView): boolean;
  140049. }
  140050. }
  140051. declare module BABYLON {
  140052. /**
  140053. * Implementation of the KTX Texture Loader.
  140054. * @hidden
  140055. */
  140056. export class _KTXTextureLoader implements IInternalTextureLoader {
  140057. /**
  140058. * Defines wether the loader supports cascade loading the different faces.
  140059. */
  140060. readonly supportCascades: boolean;
  140061. /**
  140062. * This returns if the loader support the current file information.
  140063. * @param extension defines the file extension of the file being loaded
  140064. * @param mimeType defines the optional mime type of the file being loaded
  140065. * @returns true if the loader can load the specified file
  140066. */
  140067. canLoad(extension: string, mimeType?: string): boolean;
  140068. /**
  140069. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140070. * @param data contains the texture data
  140071. * @param texture defines the BabylonJS internal texture
  140072. * @param createPolynomials will be true if polynomials have been requested
  140073. * @param onLoad defines the callback to trigger once the texture is ready
  140074. * @param onError defines the callback to trigger in case of error
  140075. */
  140076. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140077. /**
  140078. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140079. * @param data contains the texture data
  140080. * @param texture defines the BabylonJS internal texture
  140081. * @param callback defines the method to call once ready to upload
  140082. */
  140083. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  140084. }
  140085. }
  140086. declare module BABYLON {
  140087. /** @hidden */
  140088. export var _forceSceneHelpersToBundle: boolean;
  140089. interface Scene {
  140090. /**
  140091. * Creates a default light for the scene.
  140092. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  140093. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  140094. */
  140095. createDefaultLight(replace?: boolean): void;
  140096. /**
  140097. * Creates a default camera for the scene.
  140098. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  140099. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  140100. * @param replace has default false, when true replaces the active camera in the scene
  140101. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  140102. */
  140103. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  140104. /**
  140105. * Creates a default camera and a default light.
  140106. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  140107. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  140108. * @param replace has the default false, when true replaces the active camera/light in the scene
  140109. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  140110. */
  140111. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  140112. /**
  140113. * Creates a new sky box
  140114. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  140115. * @param environmentTexture defines the texture to use as environment texture
  140116. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  140117. * @param scale defines the overall scale of the skybox
  140118. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  140119. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  140120. * @returns a new mesh holding the sky box
  140121. */
  140122. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  140123. /**
  140124. * Creates a new environment
  140125. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  140126. * @param options defines the options you can use to configure the environment
  140127. * @returns the new EnvironmentHelper
  140128. */
  140129. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  140130. /**
  140131. * Creates a new VREXperienceHelper
  140132. * @see https://doc.babylonjs.com/how_to/webvr_helper
  140133. * @param webVROptions defines the options used to create the new VREXperienceHelper
  140134. * @returns a new VREXperienceHelper
  140135. */
  140136. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  140137. /**
  140138. * Creates a new WebXRDefaultExperience
  140139. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  140140. * @param options experience options
  140141. * @returns a promise for a new WebXRDefaultExperience
  140142. */
  140143. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  140144. }
  140145. }
  140146. declare module BABYLON {
  140147. /**
  140148. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  140149. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  140150. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  140151. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140152. */
  140153. export class VideoDome extends TextureDome<VideoTexture> {
  140154. /**
  140155. * Define the video source as a Monoscopic panoramic 360 video.
  140156. */
  140157. static readonly MODE_MONOSCOPIC: number;
  140158. /**
  140159. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  140160. */
  140161. static readonly MODE_TOPBOTTOM: number;
  140162. /**
  140163. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  140164. */
  140165. static readonly MODE_SIDEBYSIDE: number;
  140166. /**
  140167. * Get the video texture associated with this video dome
  140168. */
  140169. get videoTexture(): VideoTexture;
  140170. /**
  140171. * Get the video mode of this dome
  140172. */
  140173. get videoMode(): number;
  140174. /**
  140175. * Set the video mode of this dome.
  140176. * @see textureMode
  140177. */
  140178. set videoMode(value: number);
  140179. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  140180. }
  140181. }
  140182. declare module BABYLON {
  140183. /**
  140184. * This class can be used to get instrumentation data from a Babylon engine
  140185. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  140186. */
  140187. export class EngineInstrumentation implements IDisposable {
  140188. /**
  140189. * Define the instrumented engine.
  140190. */
  140191. engine: Engine;
  140192. private _captureGPUFrameTime;
  140193. private _gpuFrameTimeToken;
  140194. private _gpuFrameTime;
  140195. private _captureShaderCompilationTime;
  140196. private _shaderCompilationTime;
  140197. private _onBeginFrameObserver;
  140198. private _onEndFrameObserver;
  140199. private _onBeforeShaderCompilationObserver;
  140200. private _onAfterShaderCompilationObserver;
  140201. /**
  140202. * Gets the perf counter used for GPU frame time
  140203. */
  140204. get gpuFrameTimeCounter(): PerfCounter;
  140205. /**
  140206. * Gets the GPU frame time capture status
  140207. */
  140208. get captureGPUFrameTime(): boolean;
  140209. /**
  140210. * Enable or disable the GPU frame time capture
  140211. */
  140212. set captureGPUFrameTime(value: boolean);
  140213. /**
  140214. * Gets the perf counter used for shader compilation time
  140215. */
  140216. get shaderCompilationTimeCounter(): PerfCounter;
  140217. /**
  140218. * Gets the shader compilation time capture status
  140219. */
  140220. get captureShaderCompilationTime(): boolean;
  140221. /**
  140222. * Enable or disable the shader compilation time capture
  140223. */
  140224. set captureShaderCompilationTime(value: boolean);
  140225. /**
  140226. * Instantiates a new engine instrumentation.
  140227. * This class can be used to get instrumentation data from a Babylon engine
  140228. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  140229. * @param engine Defines the engine to instrument
  140230. */
  140231. constructor(
  140232. /**
  140233. * Define the instrumented engine.
  140234. */
  140235. engine: Engine);
  140236. /**
  140237. * Dispose and release associated resources.
  140238. */
  140239. dispose(): void;
  140240. }
  140241. }
  140242. declare module BABYLON {
  140243. /**
  140244. * This class can be used to get instrumentation data from a Babylon engine
  140245. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  140246. */
  140247. export class SceneInstrumentation implements IDisposable {
  140248. /**
  140249. * Defines the scene to instrument
  140250. */
  140251. scene: Scene;
  140252. private _captureActiveMeshesEvaluationTime;
  140253. private _activeMeshesEvaluationTime;
  140254. private _captureRenderTargetsRenderTime;
  140255. private _renderTargetsRenderTime;
  140256. private _captureFrameTime;
  140257. private _frameTime;
  140258. private _captureRenderTime;
  140259. private _renderTime;
  140260. private _captureInterFrameTime;
  140261. private _interFrameTime;
  140262. private _captureParticlesRenderTime;
  140263. private _particlesRenderTime;
  140264. private _captureSpritesRenderTime;
  140265. private _spritesRenderTime;
  140266. private _capturePhysicsTime;
  140267. private _physicsTime;
  140268. private _captureAnimationsTime;
  140269. private _animationsTime;
  140270. private _captureCameraRenderTime;
  140271. private _cameraRenderTime;
  140272. private _onBeforeActiveMeshesEvaluationObserver;
  140273. private _onAfterActiveMeshesEvaluationObserver;
  140274. private _onBeforeRenderTargetsRenderObserver;
  140275. private _onAfterRenderTargetsRenderObserver;
  140276. private _onAfterRenderObserver;
  140277. private _onBeforeDrawPhaseObserver;
  140278. private _onAfterDrawPhaseObserver;
  140279. private _onBeforeAnimationsObserver;
  140280. private _onBeforeParticlesRenderingObserver;
  140281. private _onAfterParticlesRenderingObserver;
  140282. private _onBeforeSpritesRenderingObserver;
  140283. private _onAfterSpritesRenderingObserver;
  140284. private _onBeforePhysicsObserver;
  140285. private _onAfterPhysicsObserver;
  140286. private _onAfterAnimationsObserver;
  140287. private _onBeforeCameraRenderObserver;
  140288. private _onAfterCameraRenderObserver;
  140289. /**
  140290. * Gets the perf counter used for active meshes evaluation time
  140291. */
  140292. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  140293. /**
  140294. * Gets the active meshes evaluation time capture status
  140295. */
  140296. get captureActiveMeshesEvaluationTime(): boolean;
  140297. /**
  140298. * Enable or disable the active meshes evaluation time capture
  140299. */
  140300. set captureActiveMeshesEvaluationTime(value: boolean);
  140301. /**
  140302. * Gets the perf counter used for render targets render time
  140303. */
  140304. get renderTargetsRenderTimeCounter(): PerfCounter;
  140305. /**
  140306. * Gets the render targets render time capture status
  140307. */
  140308. get captureRenderTargetsRenderTime(): boolean;
  140309. /**
  140310. * Enable or disable the render targets render time capture
  140311. */
  140312. set captureRenderTargetsRenderTime(value: boolean);
  140313. /**
  140314. * Gets the perf counter used for particles render time
  140315. */
  140316. get particlesRenderTimeCounter(): PerfCounter;
  140317. /**
  140318. * Gets the particles render time capture status
  140319. */
  140320. get captureParticlesRenderTime(): boolean;
  140321. /**
  140322. * Enable or disable the particles render time capture
  140323. */
  140324. set captureParticlesRenderTime(value: boolean);
  140325. /**
  140326. * Gets the perf counter used for sprites render time
  140327. */
  140328. get spritesRenderTimeCounter(): PerfCounter;
  140329. /**
  140330. * Gets the sprites render time capture status
  140331. */
  140332. get captureSpritesRenderTime(): boolean;
  140333. /**
  140334. * Enable or disable the sprites render time capture
  140335. */
  140336. set captureSpritesRenderTime(value: boolean);
  140337. /**
  140338. * Gets the perf counter used for physics time
  140339. */
  140340. get physicsTimeCounter(): PerfCounter;
  140341. /**
  140342. * Gets the physics time capture status
  140343. */
  140344. get capturePhysicsTime(): boolean;
  140345. /**
  140346. * Enable or disable the physics time capture
  140347. */
  140348. set capturePhysicsTime(value: boolean);
  140349. /**
  140350. * Gets the perf counter used for animations time
  140351. */
  140352. get animationsTimeCounter(): PerfCounter;
  140353. /**
  140354. * Gets the animations time capture status
  140355. */
  140356. get captureAnimationsTime(): boolean;
  140357. /**
  140358. * Enable or disable the animations time capture
  140359. */
  140360. set captureAnimationsTime(value: boolean);
  140361. /**
  140362. * Gets the perf counter used for frame time capture
  140363. */
  140364. get frameTimeCounter(): PerfCounter;
  140365. /**
  140366. * Gets the frame time capture status
  140367. */
  140368. get captureFrameTime(): boolean;
  140369. /**
  140370. * Enable or disable the frame time capture
  140371. */
  140372. set captureFrameTime(value: boolean);
  140373. /**
  140374. * Gets the perf counter used for inter-frames time capture
  140375. */
  140376. get interFrameTimeCounter(): PerfCounter;
  140377. /**
  140378. * Gets the inter-frames time capture status
  140379. */
  140380. get captureInterFrameTime(): boolean;
  140381. /**
  140382. * Enable or disable the inter-frames time capture
  140383. */
  140384. set captureInterFrameTime(value: boolean);
  140385. /**
  140386. * Gets the perf counter used for render time capture
  140387. */
  140388. get renderTimeCounter(): PerfCounter;
  140389. /**
  140390. * Gets the render time capture status
  140391. */
  140392. get captureRenderTime(): boolean;
  140393. /**
  140394. * Enable or disable the render time capture
  140395. */
  140396. set captureRenderTime(value: boolean);
  140397. /**
  140398. * Gets the perf counter used for camera render time capture
  140399. */
  140400. get cameraRenderTimeCounter(): PerfCounter;
  140401. /**
  140402. * Gets the camera render time capture status
  140403. */
  140404. get captureCameraRenderTime(): boolean;
  140405. /**
  140406. * Enable or disable the camera render time capture
  140407. */
  140408. set captureCameraRenderTime(value: boolean);
  140409. /**
  140410. * Gets the perf counter used for draw calls
  140411. */
  140412. get drawCallsCounter(): PerfCounter;
  140413. /**
  140414. * Instantiates a new scene instrumentation.
  140415. * This class can be used to get instrumentation data from a Babylon engine
  140416. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  140417. * @param scene Defines the scene to instrument
  140418. */
  140419. constructor(
  140420. /**
  140421. * Defines the scene to instrument
  140422. */
  140423. scene: Scene);
  140424. /**
  140425. * Dispose and release associated resources.
  140426. */
  140427. dispose(): void;
  140428. }
  140429. }
  140430. declare module BABYLON {
  140431. /** @hidden */
  140432. export var glowMapGenerationPixelShader: {
  140433. name: string;
  140434. shader: string;
  140435. };
  140436. }
  140437. declare module BABYLON {
  140438. /** @hidden */
  140439. export var glowMapGenerationVertexShader: {
  140440. name: string;
  140441. shader: string;
  140442. };
  140443. }
  140444. declare module BABYLON {
  140445. /**
  140446. * Effect layer options. This helps customizing the behaviour
  140447. * of the effect layer.
  140448. */
  140449. export interface IEffectLayerOptions {
  140450. /**
  140451. * Multiplication factor apply to the canvas size to compute the render target size
  140452. * used to generated the objects (the smaller the faster).
  140453. */
  140454. mainTextureRatio: number;
  140455. /**
  140456. * Enforces a fixed size texture to ensure effect stability across devices.
  140457. */
  140458. mainTextureFixedSize?: number;
  140459. /**
  140460. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  140461. */
  140462. alphaBlendingMode: number;
  140463. /**
  140464. * The camera attached to the layer.
  140465. */
  140466. camera: Nullable<Camera>;
  140467. /**
  140468. * The rendering group to draw the layer in.
  140469. */
  140470. renderingGroupId: number;
  140471. }
  140472. /**
  140473. * The effect layer Helps adding post process effect blended with the main pass.
  140474. *
  140475. * This can be for instance use to generate glow or higlight effects on the scene.
  140476. *
  140477. * The effect layer class can not be used directly and is intented to inherited from to be
  140478. * customized per effects.
  140479. */
  140480. export abstract class EffectLayer {
  140481. private _vertexBuffers;
  140482. private _indexBuffer;
  140483. private _cachedDefines;
  140484. private _effectLayerMapGenerationEffect;
  140485. private _effectLayerOptions;
  140486. private _mergeEffect;
  140487. protected _scene: Scene;
  140488. protected _engine: Engine;
  140489. protected _maxSize: number;
  140490. protected _mainTextureDesiredSize: ISize;
  140491. protected _mainTexture: RenderTargetTexture;
  140492. protected _shouldRender: boolean;
  140493. protected _postProcesses: PostProcess[];
  140494. protected _textures: BaseTexture[];
  140495. protected _emissiveTextureAndColor: {
  140496. texture: Nullable<BaseTexture>;
  140497. color: Color4;
  140498. };
  140499. /**
  140500. * The name of the layer
  140501. */
  140502. name: string;
  140503. /**
  140504. * The clear color of the texture used to generate the glow map.
  140505. */
  140506. neutralColor: Color4;
  140507. /**
  140508. * Specifies whether the highlight layer is enabled or not.
  140509. */
  140510. isEnabled: boolean;
  140511. /**
  140512. * Gets the camera attached to the layer.
  140513. */
  140514. get camera(): Nullable<Camera>;
  140515. /**
  140516. * Gets the rendering group id the layer should render in.
  140517. */
  140518. get renderingGroupId(): number;
  140519. set renderingGroupId(renderingGroupId: number);
  140520. /**
  140521. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  140522. */
  140523. disableBoundingBoxesFromEffectLayer: boolean;
  140524. /**
  140525. * An event triggered when the effect layer has been disposed.
  140526. */
  140527. onDisposeObservable: Observable<EffectLayer>;
  140528. /**
  140529. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  140530. */
  140531. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  140532. /**
  140533. * An event triggered when the generated texture is being merged in the scene.
  140534. */
  140535. onBeforeComposeObservable: Observable<EffectLayer>;
  140536. /**
  140537. * An event triggered when the mesh is rendered into the effect render target.
  140538. */
  140539. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  140540. /**
  140541. * An event triggered after the mesh has been rendered into the effect render target.
  140542. */
  140543. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  140544. /**
  140545. * An event triggered when the generated texture has been merged in the scene.
  140546. */
  140547. onAfterComposeObservable: Observable<EffectLayer>;
  140548. /**
  140549. * An event triggered when the efffect layer changes its size.
  140550. */
  140551. onSizeChangedObservable: Observable<EffectLayer>;
  140552. /** @hidden */
  140553. static _SceneComponentInitialization: (scene: Scene) => void;
  140554. /**
  140555. * Instantiates a new effect Layer and references it in the scene.
  140556. * @param name The name of the layer
  140557. * @param scene The scene to use the layer in
  140558. */
  140559. constructor(
  140560. /** The Friendly of the effect in the scene */
  140561. name: string, scene: Scene);
  140562. /**
  140563. * Get the effect name of the layer.
  140564. * @return The effect name
  140565. */
  140566. abstract getEffectName(): string;
  140567. /**
  140568. * Checks for the readiness of the element composing the layer.
  140569. * @param subMesh the mesh to check for
  140570. * @param useInstances specify whether or not to use instances to render the mesh
  140571. * @return true if ready otherwise, false
  140572. */
  140573. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140574. /**
  140575. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  140576. * @returns true if the effect requires stencil during the main canvas render pass.
  140577. */
  140578. abstract needStencil(): boolean;
  140579. /**
  140580. * Create the merge effect. This is the shader use to blit the information back
  140581. * to the main canvas at the end of the scene rendering.
  140582. * @returns The effect containing the shader used to merge the effect on the main canvas
  140583. */
  140584. protected abstract _createMergeEffect(): Effect;
  140585. /**
  140586. * Creates the render target textures and post processes used in the effect layer.
  140587. */
  140588. protected abstract _createTextureAndPostProcesses(): void;
  140589. /**
  140590. * Implementation specific of rendering the generating effect on the main canvas.
  140591. * @param effect The effect used to render through
  140592. */
  140593. protected abstract _internalRender(effect: Effect): void;
  140594. /**
  140595. * Sets the required values for both the emissive texture and and the main color.
  140596. */
  140597. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140598. /**
  140599. * Free any resources and references associated to a mesh.
  140600. * Internal use
  140601. * @param mesh The mesh to free.
  140602. */
  140603. abstract _disposeMesh(mesh: Mesh): void;
  140604. /**
  140605. * Serializes this layer (Glow or Highlight for example)
  140606. * @returns a serialized layer object
  140607. */
  140608. abstract serialize?(): any;
  140609. /**
  140610. * Initializes the effect layer with the required options.
  140611. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  140612. */
  140613. protected _init(options: Partial<IEffectLayerOptions>): void;
  140614. /**
  140615. * Generates the index buffer of the full screen quad blending to the main canvas.
  140616. */
  140617. private _generateIndexBuffer;
  140618. /**
  140619. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  140620. */
  140621. private _generateVertexBuffer;
  140622. /**
  140623. * Sets the main texture desired size which is the closest power of two
  140624. * of the engine canvas size.
  140625. */
  140626. private _setMainTextureSize;
  140627. /**
  140628. * Creates the main texture for the effect layer.
  140629. */
  140630. protected _createMainTexture(): void;
  140631. /**
  140632. * Adds specific effects defines.
  140633. * @param defines The defines to add specifics to.
  140634. */
  140635. protected _addCustomEffectDefines(defines: string[]): void;
  140636. /**
  140637. * Checks for the readiness of the element composing the layer.
  140638. * @param subMesh the mesh to check for
  140639. * @param useInstances specify whether or not to use instances to render the mesh
  140640. * @param emissiveTexture the associated emissive texture used to generate the glow
  140641. * @return true if ready otherwise, false
  140642. */
  140643. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  140644. /**
  140645. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  140646. */
  140647. render(): void;
  140648. /**
  140649. * Determine if a given mesh will be used in the current effect.
  140650. * @param mesh mesh to test
  140651. * @returns true if the mesh will be used
  140652. */
  140653. hasMesh(mesh: AbstractMesh): boolean;
  140654. /**
  140655. * Returns true if the layer contains information to display, otherwise false.
  140656. * @returns true if the glow layer should be rendered
  140657. */
  140658. shouldRender(): boolean;
  140659. /**
  140660. * Returns true if the mesh should render, otherwise false.
  140661. * @param mesh The mesh to render
  140662. * @returns true if it should render otherwise false
  140663. */
  140664. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  140665. /**
  140666. * Returns true if the mesh can be rendered, otherwise false.
  140667. * @param mesh The mesh to render
  140668. * @param material The material used on the mesh
  140669. * @returns true if it can be rendered otherwise false
  140670. */
  140671. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140672. /**
  140673. * Returns true if the mesh should render, otherwise false.
  140674. * @param mesh The mesh to render
  140675. * @returns true if it should render otherwise false
  140676. */
  140677. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  140678. /**
  140679. * Renders the submesh passed in parameter to the generation map.
  140680. */
  140681. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  140682. /**
  140683. * Defines whether the current material of the mesh should be use to render the effect.
  140684. * @param mesh defines the current mesh to render
  140685. */
  140686. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140687. /**
  140688. * Rebuild the required buffers.
  140689. * @hidden Internal use only.
  140690. */
  140691. _rebuild(): void;
  140692. /**
  140693. * Dispose only the render target textures and post process.
  140694. */
  140695. private _disposeTextureAndPostProcesses;
  140696. /**
  140697. * Dispose the highlight layer and free resources.
  140698. */
  140699. dispose(): void;
  140700. /**
  140701. * Gets the class name of the effect layer
  140702. * @returns the string with the class name of the effect layer
  140703. */
  140704. getClassName(): string;
  140705. /**
  140706. * Creates an effect layer from parsed effect layer data
  140707. * @param parsedEffectLayer defines effect layer data
  140708. * @param scene defines the current scene
  140709. * @param rootUrl defines the root URL containing the effect layer information
  140710. * @returns a parsed effect Layer
  140711. */
  140712. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  140713. }
  140714. }
  140715. declare module BABYLON {
  140716. interface AbstractScene {
  140717. /**
  140718. * The list of effect layers (highlights/glow) added to the scene
  140719. * @see https://doc.babylonjs.com/how_to/highlight_layer
  140720. * @see https://doc.babylonjs.com/how_to/glow_layer
  140721. */
  140722. effectLayers: Array<EffectLayer>;
  140723. /**
  140724. * Removes the given effect layer from this scene.
  140725. * @param toRemove defines the effect layer to remove
  140726. * @returns the index of the removed effect layer
  140727. */
  140728. removeEffectLayer(toRemove: EffectLayer): number;
  140729. /**
  140730. * Adds the given effect layer to this scene
  140731. * @param newEffectLayer defines the effect layer to add
  140732. */
  140733. addEffectLayer(newEffectLayer: EffectLayer): void;
  140734. }
  140735. /**
  140736. * Defines the layer scene component responsible to manage any effect layers
  140737. * in a given scene.
  140738. */
  140739. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  140740. /**
  140741. * The component name helpfull to identify the component in the list of scene components.
  140742. */
  140743. readonly name: string;
  140744. /**
  140745. * The scene the component belongs to.
  140746. */
  140747. scene: Scene;
  140748. private _engine;
  140749. private _renderEffects;
  140750. private _needStencil;
  140751. private _previousStencilState;
  140752. /**
  140753. * Creates a new instance of the component for the given scene
  140754. * @param scene Defines the scene to register the component in
  140755. */
  140756. constructor(scene: Scene);
  140757. /**
  140758. * Registers the component in a given scene
  140759. */
  140760. register(): void;
  140761. /**
  140762. * Rebuilds the elements related to this component in case of
  140763. * context lost for instance.
  140764. */
  140765. rebuild(): void;
  140766. /**
  140767. * Serializes the component data to the specified json object
  140768. * @param serializationObject The object to serialize to
  140769. */
  140770. serialize(serializationObject: any): void;
  140771. /**
  140772. * Adds all the elements from the container to the scene
  140773. * @param container the container holding the elements
  140774. */
  140775. addFromContainer(container: AbstractScene): void;
  140776. /**
  140777. * Removes all the elements in the container from the scene
  140778. * @param container contains the elements to remove
  140779. * @param dispose if the removed element should be disposed (default: false)
  140780. */
  140781. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140782. /**
  140783. * Disposes the component and the associated ressources.
  140784. */
  140785. dispose(): void;
  140786. private _isReadyForMesh;
  140787. private _renderMainTexture;
  140788. private _setStencil;
  140789. private _setStencilBack;
  140790. private _draw;
  140791. private _drawCamera;
  140792. private _drawRenderingGroup;
  140793. }
  140794. }
  140795. declare module BABYLON {
  140796. /** @hidden */
  140797. export var glowMapMergePixelShader: {
  140798. name: string;
  140799. shader: string;
  140800. };
  140801. }
  140802. declare module BABYLON {
  140803. /** @hidden */
  140804. export var glowMapMergeVertexShader: {
  140805. name: string;
  140806. shader: string;
  140807. };
  140808. }
  140809. declare module BABYLON {
  140810. interface AbstractScene {
  140811. /**
  140812. * Return a the first highlight layer of the scene with a given name.
  140813. * @param name The name of the highlight layer to look for.
  140814. * @return The highlight layer if found otherwise null.
  140815. */
  140816. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  140817. }
  140818. /**
  140819. * Glow layer options. This helps customizing the behaviour
  140820. * of the glow layer.
  140821. */
  140822. export interface IGlowLayerOptions {
  140823. /**
  140824. * Multiplication factor apply to the canvas size to compute the render target size
  140825. * used to generated the glowing objects (the smaller the faster).
  140826. */
  140827. mainTextureRatio: number;
  140828. /**
  140829. * Enforces a fixed size texture to ensure resize independant blur.
  140830. */
  140831. mainTextureFixedSize?: number;
  140832. /**
  140833. * How big is the kernel of the blur texture.
  140834. */
  140835. blurKernelSize: number;
  140836. /**
  140837. * The camera attached to the layer.
  140838. */
  140839. camera: Nullable<Camera>;
  140840. /**
  140841. * Enable MSAA by chosing the number of samples.
  140842. */
  140843. mainTextureSamples?: number;
  140844. /**
  140845. * The rendering group to draw the layer in.
  140846. */
  140847. renderingGroupId: number;
  140848. }
  140849. /**
  140850. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  140851. *
  140852. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  140853. *
  140854. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  140855. */
  140856. export class GlowLayer extends EffectLayer {
  140857. /**
  140858. * Effect Name of the layer.
  140859. */
  140860. static readonly EffectName: string;
  140861. /**
  140862. * The default blur kernel size used for the glow.
  140863. */
  140864. static DefaultBlurKernelSize: number;
  140865. /**
  140866. * The default texture size ratio used for the glow.
  140867. */
  140868. static DefaultTextureRatio: number;
  140869. /**
  140870. * Sets the kernel size of the blur.
  140871. */
  140872. set blurKernelSize(value: number);
  140873. /**
  140874. * Gets the kernel size of the blur.
  140875. */
  140876. get blurKernelSize(): number;
  140877. /**
  140878. * Sets the glow intensity.
  140879. */
  140880. set intensity(value: number);
  140881. /**
  140882. * Gets the glow intensity.
  140883. */
  140884. get intensity(): number;
  140885. private _options;
  140886. private _intensity;
  140887. private _horizontalBlurPostprocess1;
  140888. private _verticalBlurPostprocess1;
  140889. private _horizontalBlurPostprocess2;
  140890. private _verticalBlurPostprocess2;
  140891. private _blurTexture1;
  140892. private _blurTexture2;
  140893. private _postProcesses1;
  140894. private _postProcesses2;
  140895. private _includedOnlyMeshes;
  140896. private _excludedMeshes;
  140897. private _meshesUsingTheirOwnMaterials;
  140898. /**
  140899. * Callback used to let the user override the color selection on a per mesh basis
  140900. */
  140901. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  140902. /**
  140903. * Callback used to let the user override the texture selection on a per mesh basis
  140904. */
  140905. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  140906. /**
  140907. * Instantiates a new glow Layer and references it to the scene.
  140908. * @param name The name of the layer
  140909. * @param scene The scene to use the layer in
  140910. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  140911. */
  140912. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  140913. /**
  140914. * Get the effect name of the layer.
  140915. * @return The effect name
  140916. */
  140917. getEffectName(): string;
  140918. /**
  140919. * Create the merge effect. This is the shader use to blit the information back
  140920. * to the main canvas at the end of the scene rendering.
  140921. */
  140922. protected _createMergeEffect(): Effect;
  140923. /**
  140924. * Creates the render target textures and post processes used in the glow layer.
  140925. */
  140926. protected _createTextureAndPostProcesses(): void;
  140927. /**
  140928. * Checks for the readiness of the element composing the layer.
  140929. * @param subMesh the mesh to check for
  140930. * @param useInstances specify wether or not to use instances to render the mesh
  140931. * @param emissiveTexture the associated emissive texture used to generate the glow
  140932. * @return true if ready otherwise, false
  140933. */
  140934. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140935. /**
  140936. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  140937. */
  140938. needStencil(): boolean;
  140939. /**
  140940. * Returns true if the mesh can be rendered, otherwise false.
  140941. * @param mesh The mesh to render
  140942. * @param material The material used on the mesh
  140943. * @returns true if it can be rendered otherwise false
  140944. */
  140945. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140946. /**
  140947. * Implementation specific of rendering the generating effect on the main canvas.
  140948. * @param effect The effect used to render through
  140949. */
  140950. protected _internalRender(effect: Effect): void;
  140951. /**
  140952. * Sets the required values for both the emissive texture and and the main color.
  140953. */
  140954. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140955. /**
  140956. * Returns true if the mesh should render, otherwise false.
  140957. * @param mesh The mesh to render
  140958. * @returns true if it should render otherwise false
  140959. */
  140960. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140961. /**
  140962. * Adds specific effects defines.
  140963. * @param defines The defines to add specifics to.
  140964. */
  140965. protected _addCustomEffectDefines(defines: string[]): void;
  140966. /**
  140967. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  140968. * @param mesh The mesh to exclude from the glow layer
  140969. */
  140970. addExcludedMesh(mesh: Mesh): void;
  140971. /**
  140972. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  140973. * @param mesh The mesh to remove
  140974. */
  140975. removeExcludedMesh(mesh: Mesh): void;
  140976. /**
  140977. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  140978. * @param mesh The mesh to include in the glow layer
  140979. */
  140980. addIncludedOnlyMesh(mesh: Mesh): void;
  140981. /**
  140982. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  140983. * @param mesh The mesh to remove
  140984. */
  140985. removeIncludedOnlyMesh(mesh: Mesh): void;
  140986. /**
  140987. * Determine if a given mesh will be used in the glow layer
  140988. * @param mesh The mesh to test
  140989. * @returns true if the mesh will be highlighted by the current glow layer
  140990. */
  140991. hasMesh(mesh: AbstractMesh): boolean;
  140992. /**
  140993. * Defines whether the current material of the mesh should be use to render the effect.
  140994. * @param mesh defines the current mesh to render
  140995. */
  140996. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140997. /**
  140998. * Add a mesh to be rendered through its own material and not with emissive only.
  140999. * @param mesh The mesh for which we need to use its material
  141000. */
  141001. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  141002. /**
  141003. * Remove a mesh from being rendered through its own material and not with emissive only.
  141004. * @param mesh The mesh for which we need to not use its material
  141005. */
  141006. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  141007. /**
  141008. * Free any resources and references associated to a mesh.
  141009. * Internal use
  141010. * @param mesh The mesh to free.
  141011. * @hidden
  141012. */
  141013. _disposeMesh(mesh: Mesh): void;
  141014. /**
  141015. * Gets the class name of the effect layer
  141016. * @returns the string with the class name of the effect layer
  141017. */
  141018. getClassName(): string;
  141019. /**
  141020. * Serializes this glow layer
  141021. * @returns a serialized glow layer object
  141022. */
  141023. serialize(): any;
  141024. /**
  141025. * Creates a Glow Layer from parsed glow layer data
  141026. * @param parsedGlowLayer defines glow layer data
  141027. * @param scene defines the current scene
  141028. * @param rootUrl defines the root URL containing the glow layer information
  141029. * @returns a parsed Glow Layer
  141030. */
  141031. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  141032. }
  141033. }
  141034. declare module BABYLON {
  141035. /** @hidden */
  141036. export var glowBlurPostProcessPixelShader: {
  141037. name: string;
  141038. shader: string;
  141039. };
  141040. }
  141041. declare module BABYLON {
  141042. interface AbstractScene {
  141043. /**
  141044. * Return a the first highlight layer of the scene with a given name.
  141045. * @param name The name of the highlight layer to look for.
  141046. * @return The highlight layer if found otherwise null.
  141047. */
  141048. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  141049. }
  141050. /**
  141051. * Highlight layer options. This helps customizing the behaviour
  141052. * of the highlight layer.
  141053. */
  141054. export interface IHighlightLayerOptions {
  141055. /**
  141056. * Multiplication factor apply to the canvas size to compute the render target size
  141057. * used to generated the glowing objects (the smaller the faster).
  141058. */
  141059. mainTextureRatio: number;
  141060. /**
  141061. * Enforces a fixed size texture to ensure resize independant blur.
  141062. */
  141063. mainTextureFixedSize?: number;
  141064. /**
  141065. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  141066. * of the picture to blur (the smaller the faster).
  141067. */
  141068. blurTextureSizeRatio: number;
  141069. /**
  141070. * How big in texel of the blur texture is the vertical blur.
  141071. */
  141072. blurVerticalSize: number;
  141073. /**
  141074. * How big in texel of the blur texture is the horizontal blur.
  141075. */
  141076. blurHorizontalSize: number;
  141077. /**
  141078. * Alpha blending mode used to apply the blur. Default is combine.
  141079. */
  141080. alphaBlendingMode: number;
  141081. /**
  141082. * The camera attached to the layer.
  141083. */
  141084. camera: Nullable<Camera>;
  141085. /**
  141086. * Should we display highlight as a solid stroke?
  141087. */
  141088. isStroke?: boolean;
  141089. /**
  141090. * The rendering group to draw the layer in.
  141091. */
  141092. renderingGroupId: number;
  141093. }
  141094. /**
  141095. * The highlight layer Helps adding a glow effect around a mesh.
  141096. *
  141097. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  141098. * glowy meshes to your scene.
  141099. *
  141100. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  141101. */
  141102. export class HighlightLayer extends EffectLayer {
  141103. name: string;
  141104. /**
  141105. * Effect Name of the highlight layer.
  141106. */
  141107. static readonly EffectName: string;
  141108. /**
  141109. * The neutral color used during the preparation of the glow effect.
  141110. * This is black by default as the blend operation is a blend operation.
  141111. */
  141112. static NeutralColor: Color4;
  141113. /**
  141114. * Stencil value used for glowing meshes.
  141115. */
  141116. static GlowingMeshStencilReference: number;
  141117. /**
  141118. * Stencil value used for the other meshes in the scene.
  141119. */
  141120. static NormalMeshStencilReference: number;
  141121. /**
  141122. * Specifies whether or not the inner glow is ACTIVE in the layer.
  141123. */
  141124. innerGlow: boolean;
  141125. /**
  141126. * Specifies whether or not the outer glow is ACTIVE in the layer.
  141127. */
  141128. outerGlow: boolean;
  141129. /**
  141130. * Specifies the horizontal size of the blur.
  141131. */
  141132. set blurHorizontalSize(value: number);
  141133. /**
  141134. * Specifies the vertical size of the blur.
  141135. */
  141136. set blurVerticalSize(value: number);
  141137. /**
  141138. * Gets the horizontal size of the blur.
  141139. */
  141140. get blurHorizontalSize(): number;
  141141. /**
  141142. * Gets the vertical size of the blur.
  141143. */
  141144. get blurVerticalSize(): number;
  141145. /**
  141146. * An event triggered when the highlight layer is being blurred.
  141147. */
  141148. onBeforeBlurObservable: Observable<HighlightLayer>;
  141149. /**
  141150. * An event triggered when the highlight layer has been blurred.
  141151. */
  141152. onAfterBlurObservable: Observable<HighlightLayer>;
  141153. private _instanceGlowingMeshStencilReference;
  141154. private _options;
  141155. private _downSamplePostprocess;
  141156. private _horizontalBlurPostprocess;
  141157. private _verticalBlurPostprocess;
  141158. private _blurTexture;
  141159. private _meshes;
  141160. private _excludedMeshes;
  141161. /**
  141162. * Instantiates a new highlight Layer and references it to the scene..
  141163. * @param name The name of the layer
  141164. * @param scene The scene to use the layer in
  141165. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  141166. */
  141167. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  141168. /**
  141169. * Get the effect name of the layer.
  141170. * @return The effect name
  141171. */
  141172. getEffectName(): string;
  141173. /**
  141174. * Create the merge effect. This is the shader use to blit the information back
  141175. * to the main canvas at the end of the scene rendering.
  141176. */
  141177. protected _createMergeEffect(): Effect;
  141178. /**
  141179. * Creates the render target textures and post processes used in the highlight layer.
  141180. */
  141181. protected _createTextureAndPostProcesses(): void;
  141182. /**
  141183. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  141184. */
  141185. needStencil(): boolean;
  141186. /**
  141187. * Checks for the readiness of the element composing the layer.
  141188. * @param subMesh the mesh to check for
  141189. * @param useInstances specify wether or not to use instances to render the mesh
  141190. * @param emissiveTexture the associated emissive texture used to generate the glow
  141191. * @return true if ready otherwise, false
  141192. */
  141193. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141194. /**
  141195. * Implementation specific of rendering the generating effect on the main canvas.
  141196. * @param effect The effect used to render through
  141197. */
  141198. protected _internalRender(effect: Effect): void;
  141199. /**
  141200. * Returns true if the layer contains information to display, otherwise false.
  141201. */
  141202. shouldRender(): boolean;
  141203. /**
  141204. * Returns true if the mesh should render, otherwise false.
  141205. * @param mesh The mesh to render
  141206. * @returns true if it should render otherwise false
  141207. */
  141208. protected _shouldRenderMesh(mesh: Mesh): boolean;
  141209. /**
  141210. * Returns true if the mesh can be rendered, otherwise false.
  141211. * @param mesh The mesh to render
  141212. * @param material The material used on the mesh
  141213. * @returns true if it can be rendered otherwise false
  141214. */
  141215. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141216. /**
  141217. * Adds specific effects defines.
  141218. * @param defines The defines to add specifics to.
  141219. */
  141220. protected _addCustomEffectDefines(defines: string[]): void;
  141221. /**
  141222. * Sets the required values for both the emissive texture and and the main color.
  141223. */
  141224. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141225. /**
  141226. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  141227. * @param mesh The mesh to exclude from the highlight layer
  141228. */
  141229. addExcludedMesh(mesh: Mesh): void;
  141230. /**
  141231. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  141232. * @param mesh The mesh to highlight
  141233. */
  141234. removeExcludedMesh(mesh: Mesh): void;
  141235. /**
  141236. * Determine if a given mesh will be highlighted by the current HighlightLayer
  141237. * @param mesh mesh to test
  141238. * @returns true if the mesh will be highlighted by the current HighlightLayer
  141239. */
  141240. hasMesh(mesh: AbstractMesh): boolean;
  141241. /**
  141242. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  141243. * @param mesh The mesh to highlight
  141244. * @param color The color of the highlight
  141245. * @param glowEmissiveOnly Extract the glow from the emissive texture
  141246. */
  141247. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  141248. /**
  141249. * Remove a mesh from the highlight layer in order to make it stop glowing.
  141250. * @param mesh The mesh to highlight
  141251. */
  141252. removeMesh(mesh: Mesh): void;
  141253. /**
  141254. * Remove all the meshes currently referenced in the highlight layer
  141255. */
  141256. removeAllMeshes(): void;
  141257. /**
  141258. * Force the stencil to the normal expected value for none glowing parts
  141259. */
  141260. private _defaultStencilReference;
  141261. /**
  141262. * Free any resources and references associated to a mesh.
  141263. * Internal use
  141264. * @param mesh The mesh to free.
  141265. * @hidden
  141266. */
  141267. _disposeMesh(mesh: Mesh): void;
  141268. /**
  141269. * Dispose the highlight layer and free resources.
  141270. */
  141271. dispose(): void;
  141272. /**
  141273. * Gets the class name of the effect layer
  141274. * @returns the string with the class name of the effect layer
  141275. */
  141276. getClassName(): string;
  141277. /**
  141278. * Serializes this Highlight layer
  141279. * @returns a serialized Highlight layer object
  141280. */
  141281. serialize(): any;
  141282. /**
  141283. * Creates a Highlight layer from parsed Highlight layer data
  141284. * @param parsedHightlightLayer defines the Highlight layer data
  141285. * @param scene defines the current scene
  141286. * @param rootUrl defines the root URL containing the Highlight layer information
  141287. * @returns a parsed Highlight layer
  141288. */
  141289. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  141290. }
  141291. }
  141292. declare module BABYLON {
  141293. interface AbstractScene {
  141294. /**
  141295. * The list of layers (background and foreground) of the scene
  141296. */
  141297. layers: Array<Layer>;
  141298. }
  141299. /**
  141300. * Defines the layer scene component responsible to manage any layers
  141301. * in a given scene.
  141302. */
  141303. export class LayerSceneComponent implements ISceneComponent {
  141304. /**
  141305. * The component name helpfull to identify the component in the list of scene components.
  141306. */
  141307. readonly name: string;
  141308. /**
  141309. * The scene the component belongs to.
  141310. */
  141311. scene: Scene;
  141312. private _engine;
  141313. /**
  141314. * Creates a new instance of the component for the given scene
  141315. * @param scene Defines the scene to register the component in
  141316. */
  141317. constructor(scene: Scene);
  141318. /**
  141319. * Registers the component in a given scene
  141320. */
  141321. register(): void;
  141322. /**
  141323. * Rebuilds the elements related to this component in case of
  141324. * context lost for instance.
  141325. */
  141326. rebuild(): void;
  141327. /**
  141328. * Disposes the component and the associated ressources.
  141329. */
  141330. dispose(): void;
  141331. private _draw;
  141332. private _drawCameraPredicate;
  141333. private _drawCameraBackground;
  141334. private _drawCameraForeground;
  141335. private _drawRenderTargetPredicate;
  141336. private _drawRenderTargetBackground;
  141337. private _drawRenderTargetForeground;
  141338. /**
  141339. * Adds all the elements from the container to the scene
  141340. * @param container the container holding the elements
  141341. */
  141342. addFromContainer(container: AbstractScene): void;
  141343. /**
  141344. * Removes all the elements in the container from the scene
  141345. * @param container contains the elements to remove
  141346. * @param dispose if the removed element should be disposed (default: false)
  141347. */
  141348. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141349. }
  141350. }
  141351. declare module BABYLON {
  141352. /** @hidden */
  141353. export var layerPixelShader: {
  141354. name: string;
  141355. shader: string;
  141356. };
  141357. }
  141358. declare module BABYLON {
  141359. /** @hidden */
  141360. export var layerVertexShader: {
  141361. name: string;
  141362. shader: string;
  141363. };
  141364. }
  141365. declare module BABYLON {
  141366. /**
  141367. * This represents a full screen 2d layer.
  141368. * This can be useful to display a picture in the background of your scene for instance.
  141369. * @see https://www.babylonjs-playground.com/#08A2BS#1
  141370. */
  141371. export class Layer {
  141372. /**
  141373. * Define the name of the layer.
  141374. */
  141375. name: string;
  141376. /**
  141377. * Define the texture the layer should display.
  141378. */
  141379. texture: Nullable<Texture>;
  141380. /**
  141381. * Is the layer in background or foreground.
  141382. */
  141383. isBackground: boolean;
  141384. /**
  141385. * Define the color of the layer (instead of texture).
  141386. */
  141387. color: Color4;
  141388. /**
  141389. * Define the scale of the layer in order to zoom in out of the texture.
  141390. */
  141391. scale: Vector2;
  141392. /**
  141393. * Define an offset for the layer in order to shift the texture.
  141394. */
  141395. offset: Vector2;
  141396. /**
  141397. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  141398. */
  141399. alphaBlendingMode: number;
  141400. /**
  141401. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  141402. * Alpha test will not mix with the background color in case of transparency.
  141403. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  141404. */
  141405. alphaTest: boolean;
  141406. /**
  141407. * Define a mask to restrict the layer to only some of the scene cameras.
  141408. */
  141409. layerMask: number;
  141410. /**
  141411. * Define the list of render target the layer is visible into.
  141412. */
  141413. renderTargetTextures: RenderTargetTexture[];
  141414. /**
  141415. * Define if the layer is only used in renderTarget or if it also
  141416. * renders in the main frame buffer of the canvas.
  141417. */
  141418. renderOnlyInRenderTargetTextures: boolean;
  141419. private _scene;
  141420. private _vertexBuffers;
  141421. private _indexBuffer;
  141422. private _effect;
  141423. private _previousDefines;
  141424. /**
  141425. * An event triggered when the layer is disposed.
  141426. */
  141427. onDisposeObservable: Observable<Layer>;
  141428. private _onDisposeObserver;
  141429. /**
  141430. * Back compatibility with callback before the onDisposeObservable existed.
  141431. * The set callback will be triggered when the layer has been disposed.
  141432. */
  141433. set onDispose(callback: () => void);
  141434. /**
  141435. * An event triggered before rendering the scene
  141436. */
  141437. onBeforeRenderObservable: Observable<Layer>;
  141438. private _onBeforeRenderObserver;
  141439. /**
  141440. * Back compatibility with callback before the onBeforeRenderObservable existed.
  141441. * The set callback will be triggered just before rendering the layer.
  141442. */
  141443. set onBeforeRender(callback: () => void);
  141444. /**
  141445. * An event triggered after rendering the scene
  141446. */
  141447. onAfterRenderObservable: Observable<Layer>;
  141448. private _onAfterRenderObserver;
  141449. /**
  141450. * Back compatibility with callback before the onAfterRenderObservable existed.
  141451. * The set callback will be triggered just after rendering the layer.
  141452. */
  141453. set onAfterRender(callback: () => void);
  141454. /**
  141455. * Instantiates a new layer.
  141456. * This represents a full screen 2d layer.
  141457. * This can be useful to display a picture in the background of your scene for instance.
  141458. * @see https://www.babylonjs-playground.com/#08A2BS#1
  141459. * @param name Define the name of the layer in the scene
  141460. * @param imgUrl Define the url of the texture to display in the layer
  141461. * @param scene Define the scene the layer belongs to
  141462. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  141463. * @param color Defines a color for the layer
  141464. */
  141465. constructor(
  141466. /**
  141467. * Define the name of the layer.
  141468. */
  141469. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  141470. private _createIndexBuffer;
  141471. /** @hidden */
  141472. _rebuild(): void;
  141473. /**
  141474. * Renders the layer in the scene.
  141475. */
  141476. render(): void;
  141477. /**
  141478. * Disposes and releases the associated ressources.
  141479. */
  141480. dispose(): void;
  141481. }
  141482. }
  141483. declare module BABYLON {
  141484. /** @hidden */
  141485. export var lensFlarePixelShader: {
  141486. name: string;
  141487. shader: string;
  141488. };
  141489. }
  141490. declare module BABYLON {
  141491. /** @hidden */
  141492. export var lensFlareVertexShader: {
  141493. name: string;
  141494. shader: string;
  141495. };
  141496. }
  141497. declare module BABYLON {
  141498. /**
  141499. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  141500. * It is usually composed of several `lensFlare`.
  141501. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141502. */
  141503. export class LensFlareSystem {
  141504. /**
  141505. * Define the name of the lens flare system
  141506. */
  141507. name: string;
  141508. /**
  141509. * List of lens flares used in this system.
  141510. */
  141511. lensFlares: LensFlare[];
  141512. /**
  141513. * Define a limit from the border the lens flare can be visible.
  141514. */
  141515. borderLimit: number;
  141516. /**
  141517. * Define a viewport border we do not want to see the lens flare in.
  141518. */
  141519. viewportBorder: number;
  141520. /**
  141521. * Define a predicate which could limit the list of meshes able to occlude the effect.
  141522. */
  141523. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  141524. /**
  141525. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  141526. */
  141527. layerMask: number;
  141528. /**
  141529. * Define the id of the lens flare system in the scene.
  141530. * (equal to name by default)
  141531. */
  141532. id: string;
  141533. private _scene;
  141534. private _emitter;
  141535. private _vertexBuffers;
  141536. private _indexBuffer;
  141537. private _effect;
  141538. private _positionX;
  141539. private _positionY;
  141540. private _isEnabled;
  141541. /** @hidden */
  141542. static _SceneComponentInitialization: (scene: Scene) => void;
  141543. /**
  141544. * Instantiates a lens flare system.
  141545. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  141546. * It is usually composed of several `lensFlare`.
  141547. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141548. * @param name Define the name of the lens flare system in the scene
  141549. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  141550. * @param scene Define the scene the lens flare system belongs to
  141551. */
  141552. constructor(
  141553. /**
  141554. * Define the name of the lens flare system
  141555. */
  141556. name: string, emitter: any, scene: Scene);
  141557. /**
  141558. * Define if the lens flare system is enabled.
  141559. */
  141560. get isEnabled(): boolean;
  141561. set isEnabled(value: boolean);
  141562. /**
  141563. * Get the scene the effects belongs to.
  141564. * @returns the scene holding the lens flare system
  141565. */
  141566. getScene(): Scene;
  141567. /**
  141568. * Get the emitter of the lens flare system.
  141569. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  141570. * @returns the emitter of the lens flare system
  141571. */
  141572. getEmitter(): any;
  141573. /**
  141574. * Set the emitter of the lens flare system.
  141575. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  141576. * @param newEmitter Define the new emitter of the system
  141577. */
  141578. setEmitter(newEmitter: any): void;
  141579. /**
  141580. * Get the lens flare system emitter position.
  141581. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  141582. * @returns the position
  141583. */
  141584. getEmitterPosition(): Vector3;
  141585. /**
  141586. * @hidden
  141587. */
  141588. computeEffectivePosition(globalViewport: Viewport): boolean;
  141589. /** @hidden */
  141590. _isVisible(): boolean;
  141591. /**
  141592. * @hidden
  141593. */
  141594. render(): boolean;
  141595. /**
  141596. * Dispose and release the lens flare with its associated resources.
  141597. */
  141598. dispose(): void;
  141599. /**
  141600. * Parse a lens flare system from a JSON repressentation
  141601. * @param parsedLensFlareSystem Define the JSON to parse
  141602. * @param scene Define the scene the parsed system should be instantiated in
  141603. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  141604. * @returns the parsed system
  141605. */
  141606. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  141607. /**
  141608. * Serialize the current Lens Flare System into a JSON representation.
  141609. * @returns the serialized JSON
  141610. */
  141611. serialize(): any;
  141612. }
  141613. }
  141614. declare module BABYLON {
  141615. /**
  141616. * This represents one of the lens effect in a `lensFlareSystem`.
  141617. * It controls one of the indiviual texture used in the effect.
  141618. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141619. */
  141620. export class LensFlare {
  141621. /**
  141622. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  141623. */
  141624. size: number;
  141625. /**
  141626. * 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.
  141627. */
  141628. position: number;
  141629. /**
  141630. * Define the lens color.
  141631. */
  141632. color: Color3;
  141633. /**
  141634. * Define the lens texture.
  141635. */
  141636. texture: Nullable<Texture>;
  141637. /**
  141638. * Define the alpha mode to render this particular lens.
  141639. */
  141640. alphaMode: number;
  141641. private _system;
  141642. /**
  141643. * Creates a new Lens Flare.
  141644. * This represents one of the lens effect in a `lensFlareSystem`.
  141645. * It controls one of the indiviual texture used in the effect.
  141646. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141647. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  141648. * @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.
  141649. * @param color Define the lens color
  141650. * @param imgUrl Define the lens texture url
  141651. * @param system Define the `lensFlareSystem` this flare is part of
  141652. * @returns The newly created Lens Flare
  141653. */
  141654. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  141655. /**
  141656. * Instantiates a new Lens Flare.
  141657. * This represents one of the lens effect in a `lensFlareSystem`.
  141658. * It controls one of the indiviual texture used in the effect.
  141659. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141660. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  141661. * @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.
  141662. * @param color Define the lens color
  141663. * @param imgUrl Define the lens texture url
  141664. * @param system Define the `lensFlareSystem` this flare is part of
  141665. */
  141666. constructor(
  141667. /**
  141668. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  141669. */
  141670. size: number,
  141671. /**
  141672. * 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.
  141673. */
  141674. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  141675. /**
  141676. * Dispose and release the lens flare with its associated resources.
  141677. */
  141678. dispose(): void;
  141679. }
  141680. }
  141681. declare module BABYLON {
  141682. interface AbstractScene {
  141683. /**
  141684. * The list of lens flare system added to the scene
  141685. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141686. */
  141687. lensFlareSystems: Array<LensFlareSystem>;
  141688. /**
  141689. * Removes the given lens flare system from this scene.
  141690. * @param toRemove The lens flare system to remove
  141691. * @returns The index of the removed lens flare system
  141692. */
  141693. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  141694. /**
  141695. * Adds the given lens flare system to this scene
  141696. * @param newLensFlareSystem The lens flare system to add
  141697. */
  141698. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  141699. /**
  141700. * Gets a lens flare system using its name
  141701. * @param name defines the name to look for
  141702. * @returns the lens flare system or null if not found
  141703. */
  141704. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  141705. /**
  141706. * Gets a lens flare system using its id
  141707. * @param id defines the id to look for
  141708. * @returns the lens flare system or null if not found
  141709. */
  141710. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  141711. }
  141712. /**
  141713. * Defines the lens flare scene component responsible to manage any lens flares
  141714. * in a given scene.
  141715. */
  141716. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  141717. /**
  141718. * The component name helpfull to identify the component in the list of scene components.
  141719. */
  141720. readonly name: string;
  141721. /**
  141722. * The scene the component belongs to.
  141723. */
  141724. scene: Scene;
  141725. /**
  141726. * Creates a new instance of the component for the given scene
  141727. * @param scene Defines the scene to register the component in
  141728. */
  141729. constructor(scene: Scene);
  141730. /**
  141731. * Registers the component in a given scene
  141732. */
  141733. register(): void;
  141734. /**
  141735. * Rebuilds the elements related to this component in case of
  141736. * context lost for instance.
  141737. */
  141738. rebuild(): void;
  141739. /**
  141740. * Adds all the elements from the container to the scene
  141741. * @param container the container holding the elements
  141742. */
  141743. addFromContainer(container: AbstractScene): void;
  141744. /**
  141745. * Removes all the elements in the container from the scene
  141746. * @param container contains the elements to remove
  141747. * @param dispose if the removed element should be disposed (default: false)
  141748. */
  141749. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141750. /**
  141751. * Serializes the component data to the specified json object
  141752. * @param serializationObject The object to serialize to
  141753. */
  141754. serialize(serializationObject: any): void;
  141755. /**
  141756. * Disposes the component and the associated ressources.
  141757. */
  141758. dispose(): void;
  141759. private _draw;
  141760. }
  141761. }
  141762. declare module BABYLON {
  141763. /** @hidden */
  141764. export var depthPixelShader: {
  141765. name: string;
  141766. shader: string;
  141767. };
  141768. }
  141769. declare module BABYLON {
  141770. /** @hidden */
  141771. export var depthVertexShader: {
  141772. name: string;
  141773. shader: string;
  141774. };
  141775. }
  141776. declare module BABYLON {
  141777. /**
  141778. * This represents a depth renderer in Babylon.
  141779. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  141780. */
  141781. export class DepthRenderer {
  141782. private _scene;
  141783. private _depthMap;
  141784. private _effect;
  141785. private readonly _storeNonLinearDepth;
  141786. private readonly _clearColor;
  141787. /** Get if the depth renderer is using packed depth or not */
  141788. readonly isPacked: boolean;
  141789. private _cachedDefines;
  141790. private _camera;
  141791. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  141792. enabled: boolean;
  141793. /**
  141794. * Specifiess that the depth renderer will only be used within
  141795. * the camera it is created for.
  141796. * This can help forcing its rendering during the camera processing.
  141797. */
  141798. useOnlyInActiveCamera: boolean;
  141799. /** @hidden */
  141800. static _SceneComponentInitialization: (scene: Scene) => void;
  141801. /**
  141802. * Instantiates a depth renderer
  141803. * @param scene The scene the renderer belongs to
  141804. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  141805. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  141806. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  141807. */
  141808. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  141809. /**
  141810. * Creates the depth rendering effect and checks if the effect is ready.
  141811. * @param subMesh The submesh to be used to render the depth map of
  141812. * @param useInstances If multiple world instances should be used
  141813. * @returns if the depth renderer is ready to render the depth map
  141814. */
  141815. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141816. /**
  141817. * Gets the texture which the depth map will be written to.
  141818. * @returns The depth map texture
  141819. */
  141820. getDepthMap(): RenderTargetTexture;
  141821. /**
  141822. * Disposes of the depth renderer.
  141823. */
  141824. dispose(): void;
  141825. }
  141826. }
  141827. declare module BABYLON {
  141828. /** @hidden */
  141829. export var minmaxReduxPixelShader: {
  141830. name: string;
  141831. shader: string;
  141832. };
  141833. }
  141834. declare module BABYLON {
  141835. /**
  141836. * This class computes a min/max reduction from a texture: it means it computes the minimum
  141837. * and maximum values from all values of the texture.
  141838. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  141839. * The source values are read from the red channel of the texture.
  141840. */
  141841. export class MinMaxReducer {
  141842. /**
  141843. * Observable triggered when the computation has been performed
  141844. */
  141845. onAfterReductionPerformed: Observable<{
  141846. min: number;
  141847. max: number;
  141848. }>;
  141849. protected _camera: Camera;
  141850. protected _sourceTexture: Nullable<RenderTargetTexture>;
  141851. protected _reductionSteps: Nullable<Array<PostProcess>>;
  141852. protected _postProcessManager: PostProcessManager;
  141853. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  141854. protected _forceFullscreenViewport: boolean;
  141855. /**
  141856. * Creates a min/max reducer
  141857. * @param camera The camera to use for the post processes
  141858. */
  141859. constructor(camera: Camera);
  141860. /**
  141861. * Gets the texture used to read the values from.
  141862. */
  141863. get sourceTexture(): Nullable<RenderTargetTexture>;
  141864. /**
  141865. * Sets the source texture to read the values from.
  141866. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  141867. * because in such textures '1' value must not be taken into account to compute the maximum
  141868. * as this value is used to clear the texture.
  141869. * Note that the computation is not activated by calling this function, you must call activate() for that!
  141870. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  141871. * @param depthRedux Indicates if the texture is a depth texture or not
  141872. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  141873. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141874. */
  141875. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141876. /**
  141877. * Defines the refresh rate of the computation.
  141878. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141879. */
  141880. get refreshRate(): number;
  141881. set refreshRate(value: number);
  141882. protected _activated: boolean;
  141883. /**
  141884. * Gets the activation status of the reducer
  141885. */
  141886. get activated(): boolean;
  141887. /**
  141888. * Activates the reduction computation.
  141889. * When activated, the observers registered in onAfterReductionPerformed are
  141890. * called after the compuation is performed
  141891. */
  141892. activate(): void;
  141893. /**
  141894. * Deactivates the reduction computation.
  141895. */
  141896. deactivate(): void;
  141897. /**
  141898. * Disposes the min/max reducer
  141899. * @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.
  141900. */
  141901. dispose(disposeAll?: boolean): void;
  141902. }
  141903. }
  141904. declare module BABYLON {
  141905. /**
  141906. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  141907. */
  141908. export class DepthReducer extends MinMaxReducer {
  141909. private _depthRenderer;
  141910. private _depthRendererId;
  141911. /**
  141912. * Gets the depth renderer used for the computation.
  141913. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  141914. */
  141915. get depthRenderer(): Nullable<DepthRenderer>;
  141916. /**
  141917. * Creates a depth reducer
  141918. * @param camera The camera used to render the depth texture
  141919. */
  141920. constructor(camera: Camera);
  141921. /**
  141922. * Sets the depth renderer to use to generate the depth map
  141923. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  141924. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  141925. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141926. */
  141927. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  141928. /** @hidden */
  141929. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141930. /**
  141931. * Activates the reduction computation.
  141932. * When activated, the observers registered in onAfterReductionPerformed are
  141933. * called after the compuation is performed
  141934. */
  141935. activate(): void;
  141936. /**
  141937. * Deactivates the reduction computation.
  141938. */
  141939. deactivate(): void;
  141940. /**
  141941. * Disposes the depth reducer
  141942. * @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.
  141943. */
  141944. dispose(disposeAll?: boolean): void;
  141945. }
  141946. }
  141947. declare module BABYLON {
  141948. /**
  141949. * A CSM implementation allowing casting shadows on large scenes.
  141950. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141951. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  141952. */
  141953. export class CascadedShadowGenerator extends ShadowGenerator {
  141954. private static readonly frustumCornersNDCSpace;
  141955. /**
  141956. * Name of the CSM class
  141957. */
  141958. static CLASSNAME: string;
  141959. /**
  141960. * Defines the default number of cascades used by the CSM.
  141961. */
  141962. static readonly DEFAULT_CASCADES_COUNT: number;
  141963. /**
  141964. * Defines the minimum number of cascades used by the CSM.
  141965. */
  141966. static readonly MIN_CASCADES_COUNT: number;
  141967. /**
  141968. * Defines the maximum number of cascades used by the CSM.
  141969. */
  141970. static readonly MAX_CASCADES_COUNT: number;
  141971. protected _validateFilter(filter: number): number;
  141972. /**
  141973. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  141974. */
  141975. penumbraDarkness: number;
  141976. private _numCascades;
  141977. /**
  141978. * Gets or set the number of cascades used by the CSM.
  141979. */
  141980. get numCascades(): number;
  141981. set numCascades(value: number);
  141982. /**
  141983. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  141984. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  141985. */
  141986. stabilizeCascades: boolean;
  141987. private _freezeShadowCastersBoundingInfo;
  141988. private _freezeShadowCastersBoundingInfoObservable;
  141989. /**
  141990. * Enables or disables the shadow casters bounding info computation.
  141991. * If your shadow casters don't move, you can disable this feature.
  141992. * If it is enabled, the bounding box computation is done every frame.
  141993. */
  141994. get freezeShadowCastersBoundingInfo(): boolean;
  141995. set freezeShadowCastersBoundingInfo(freeze: boolean);
  141996. private _scbiMin;
  141997. private _scbiMax;
  141998. protected _computeShadowCastersBoundingInfo(): void;
  141999. protected _shadowCastersBoundingInfo: BoundingInfo;
  142000. /**
  142001. * Gets or sets the shadow casters bounding info.
  142002. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  142003. * so that the system won't overwrite the bounds you provide
  142004. */
  142005. get shadowCastersBoundingInfo(): BoundingInfo;
  142006. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  142007. protected _breaksAreDirty: boolean;
  142008. protected _minDistance: number;
  142009. protected _maxDistance: number;
  142010. /**
  142011. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  142012. *
  142013. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  142014. * If you don't know these values, simply leave them to their defaults and don't call this function.
  142015. * @param min minimal distance for the breaks (default to 0.)
  142016. * @param max maximal distance for the breaks (default to 1.)
  142017. */
  142018. setMinMaxDistance(min: number, max: number): void;
  142019. /** Gets the minimal distance used in the cascade break computation */
  142020. get minDistance(): number;
  142021. /** Gets the maximal distance used in the cascade break computation */
  142022. get maxDistance(): number;
  142023. /**
  142024. * Gets the class name of that object
  142025. * @returns "CascadedShadowGenerator"
  142026. */
  142027. getClassName(): string;
  142028. private _cascadeMinExtents;
  142029. private _cascadeMaxExtents;
  142030. /**
  142031. * Gets a cascade minimum extents
  142032. * @param cascadeIndex index of the cascade
  142033. * @returns the minimum cascade extents
  142034. */
  142035. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  142036. /**
  142037. * Gets a cascade maximum extents
  142038. * @param cascadeIndex index of the cascade
  142039. * @returns the maximum cascade extents
  142040. */
  142041. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  142042. private _cascades;
  142043. private _currentLayer;
  142044. private _viewSpaceFrustumsZ;
  142045. private _viewMatrices;
  142046. private _projectionMatrices;
  142047. private _transformMatrices;
  142048. private _transformMatricesAsArray;
  142049. private _frustumLengths;
  142050. private _lightSizeUVCorrection;
  142051. private _depthCorrection;
  142052. private _frustumCornersWorldSpace;
  142053. private _frustumCenter;
  142054. private _shadowCameraPos;
  142055. private _shadowMaxZ;
  142056. /**
  142057. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  142058. * It defaults to camera.maxZ
  142059. */
  142060. get shadowMaxZ(): number;
  142061. /**
  142062. * Sets the shadow max z distance.
  142063. */
  142064. set shadowMaxZ(value: number);
  142065. protected _debug: boolean;
  142066. /**
  142067. * Gets or sets the debug flag.
  142068. * When enabled, the cascades are materialized by different colors on the screen.
  142069. */
  142070. get debug(): boolean;
  142071. set debug(dbg: boolean);
  142072. private _depthClamp;
  142073. /**
  142074. * Gets or sets the depth clamping value.
  142075. *
  142076. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  142077. * to account for the shadow casters far away.
  142078. *
  142079. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  142080. */
  142081. get depthClamp(): boolean;
  142082. set depthClamp(value: boolean);
  142083. private _cascadeBlendPercentage;
  142084. /**
  142085. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  142086. * It defaults to 0.1 (10% blending).
  142087. */
  142088. get cascadeBlendPercentage(): number;
  142089. set cascadeBlendPercentage(value: number);
  142090. private _lambda;
  142091. /**
  142092. * Gets or set the lambda parameter.
  142093. * This parameter is used to split the camera frustum and create the cascades.
  142094. * 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.
  142095. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  142096. */
  142097. get lambda(): number;
  142098. set lambda(value: number);
  142099. /**
  142100. * Gets the view matrix corresponding to a given cascade
  142101. * @param cascadeNum cascade to retrieve the view matrix from
  142102. * @returns the cascade view matrix
  142103. */
  142104. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  142105. /**
  142106. * Gets the projection matrix corresponding to a given cascade
  142107. * @param cascadeNum cascade to retrieve the projection matrix from
  142108. * @returns the cascade projection matrix
  142109. */
  142110. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  142111. /**
  142112. * Gets the transformation matrix corresponding to a given cascade
  142113. * @param cascadeNum cascade to retrieve the transformation matrix from
  142114. * @returns the cascade transformation matrix
  142115. */
  142116. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  142117. private _depthRenderer;
  142118. /**
  142119. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  142120. *
  142121. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  142122. *
  142123. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  142124. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  142125. * @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
  142126. */
  142127. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  142128. private _depthReducer;
  142129. private _autoCalcDepthBounds;
  142130. /**
  142131. * Gets or sets the autoCalcDepthBounds property.
  142132. *
  142133. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  142134. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  142135. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  142136. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  142137. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  142138. */
  142139. get autoCalcDepthBounds(): boolean;
  142140. set autoCalcDepthBounds(value: boolean);
  142141. /**
  142142. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  142143. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  142144. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  142145. * for setting the refresh rate on the renderer yourself!
  142146. */
  142147. get autoCalcDepthBoundsRefreshRate(): number;
  142148. set autoCalcDepthBoundsRefreshRate(value: number);
  142149. /**
  142150. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  142151. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  142152. * you change the camera near/far planes!
  142153. */
  142154. splitFrustum(): void;
  142155. private _splitFrustum;
  142156. private _computeMatrices;
  142157. private _computeFrustumInWorldSpace;
  142158. private _computeCascadeFrustum;
  142159. /**
  142160. * Support test.
  142161. */
  142162. static get IsSupported(): boolean;
  142163. /** @hidden */
  142164. static _SceneComponentInitialization: (scene: Scene) => void;
  142165. /**
  142166. * Creates a Cascaded Shadow Generator object.
  142167. * A ShadowGenerator is the required tool to use the shadows.
  142168. * Each directional light casting shadows needs to use its own ShadowGenerator.
  142169. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  142170. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  142171. * @param light The directional light object generating the shadows.
  142172. * @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.
  142173. */
  142174. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  142175. protected _initializeGenerator(): void;
  142176. protected _createTargetRenderTexture(): void;
  142177. protected _initializeShadowMap(): void;
  142178. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  142179. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  142180. /**
  142181. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  142182. * @param defines Defines of the material we want to update
  142183. * @param lightIndex Index of the light in the enabled light list of the material
  142184. */
  142185. prepareDefines(defines: any, lightIndex: number): void;
  142186. /**
  142187. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  142188. * defined in the generator but impacting the effect).
  142189. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  142190. * @param effect The effect we are binfing the information for
  142191. */
  142192. bindShadowLight(lightIndex: string, effect: Effect): void;
  142193. /**
  142194. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  142195. * (eq to view projection * shadow projection matrices)
  142196. * @returns The transform matrix used to create the shadow map
  142197. */
  142198. getTransformMatrix(): Matrix;
  142199. /**
  142200. * Disposes the ShadowGenerator.
  142201. * Returns nothing.
  142202. */
  142203. dispose(): void;
  142204. /**
  142205. * Serializes the shadow generator setup to a json object.
  142206. * @returns The serialized JSON object
  142207. */
  142208. serialize(): any;
  142209. /**
  142210. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  142211. * @param parsedShadowGenerator The JSON object to parse
  142212. * @param scene The scene to create the shadow map for
  142213. * @returns The parsed shadow generator
  142214. */
  142215. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  142216. }
  142217. }
  142218. declare module BABYLON {
  142219. /**
  142220. * Defines the shadow generator component responsible to manage any shadow generators
  142221. * in a given scene.
  142222. */
  142223. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  142224. /**
  142225. * The component name helpfull to identify the component in the list of scene components.
  142226. */
  142227. readonly name: string;
  142228. /**
  142229. * The scene the component belongs to.
  142230. */
  142231. scene: Scene;
  142232. /**
  142233. * Creates a new instance of the component for the given scene
  142234. * @param scene Defines the scene to register the component in
  142235. */
  142236. constructor(scene: Scene);
  142237. /**
  142238. * Registers the component in a given scene
  142239. */
  142240. register(): void;
  142241. /**
  142242. * Rebuilds the elements related to this component in case of
  142243. * context lost for instance.
  142244. */
  142245. rebuild(): void;
  142246. /**
  142247. * Serializes the component data to the specified json object
  142248. * @param serializationObject The object to serialize to
  142249. */
  142250. serialize(serializationObject: any): void;
  142251. /**
  142252. * Adds all the elements from the container to the scene
  142253. * @param container the container holding the elements
  142254. */
  142255. addFromContainer(container: AbstractScene): void;
  142256. /**
  142257. * Removes all the elements in the container from the scene
  142258. * @param container contains the elements to remove
  142259. * @param dispose if the removed element should be disposed (default: false)
  142260. */
  142261. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  142262. /**
  142263. * Rebuilds the elements related to this component in case of
  142264. * context lost for instance.
  142265. */
  142266. dispose(): void;
  142267. private _gatherRenderTargets;
  142268. }
  142269. }
  142270. declare module BABYLON {
  142271. /**
  142272. * A point light is a light defined by an unique point in world space.
  142273. * The light is emitted in every direction from this point.
  142274. * A good example of a point light is a standard light bulb.
  142275. * Documentation: https://doc.babylonjs.com/babylon101/lights
  142276. */
  142277. export class PointLight extends ShadowLight {
  142278. private _shadowAngle;
  142279. /**
  142280. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142281. * This specifies what angle the shadow will use to be created.
  142282. *
  142283. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  142284. */
  142285. get shadowAngle(): number;
  142286. /**
  142287. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142288. * This specifies what angle the shadow will use to be created.
  142289. *
  142290. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  142291. */
  142292. set shadowAngle(value: number);
  142293. /**
  142294. * Gets the direction if it has been set.
  142295. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142296. */
  142297. get direction(): Vector3;
  142298. /**
  142299. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142300. */
  142301. set direction(value: Vector3);
  142302. /**
  142303. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  142304. * A PointLight emits the light in every direction.
  142305. * It can cast shadows.
  142306. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  142307. * ```javascript
  142308. * var pointLight = new PointLight("pl", camera.position, scene);
  142309. * ```
  142310. * Documentation : https://doc.babylonjs.com/babylon101/lights
  142311. * @param name The light friendly name
  142312. * @param position The position of the point light in the scene
  142313. * @param scene The scene the lights belongs to
  142314. */
  142315. constructor(name: string, position: Vector3, scene: Scene);
  142316. /**
  142317. * Returns the string "PointLight"
  142318. * @returns the class name
  142319. */
  142320. getClassName(): string;
  142321. /**
  142322. * Returns the integer 0.
  142323. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  142324. */
  142325. getTypeID(): number;
  142326. /**
  142327. * Specifies wether or not the shadowmap should be a cube texture.
  142328. * @returns true if the shadowmap needs to be a cube texture.
  142329. */
  142330. needCube(): boolean;
  142331. /**
  142332. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  142333. * @param faceIndex The index of the face we are computed the direction to generate shadow
  142334. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  142335. */
  142336. getShadowDirection(faceIndex?: number): Vector3;
  142337. /**
  142338. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  142339. * - fov = PI / 2
  142340. * - aspect ratio : 1.0
  142341. * - z-near and far equal to the active camera minZ and maxZ.
  142342. * Returns the PointLight.
  142343. */
  142344. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  142345. protected _buildUniformLayout(): void;
  142346. /**
  142347. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  142348. * @param effect The effect to update
  142349. * @param lightIndex The index of the light in the effect to update
  142350. * @returns The point light
  142351. */
  142352. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  142353. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  142354. /**
  142355. * Prepares the list of defines specific to the light type.
  142356. * @param defines the list of defines
  142357. * @param lightIndex defines the index of the light for the effect
  142358. */
  142359. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  142360. }
  142361. }
  142362. declare module BABYLON {
  142363. /**
  142364. * Header information of HDR texture files.
  142365. */
  142366. export interface HDRInfo {
  142367. /**
  142368. * The height of the texture in pixels.
  142369. */
  142370. height: number;
  142371. /**
  142372. * The width of the texture in pixels.
  142373. */
  142374. width: number;
  142375. /**
  142376. * The index of the beginning of the data in the binary file.
  142377. */
  142378. dataPosition: number;
  142379. }
  142380. /**
  142381. * This groups tools to convert HDR texture to native colors array.
  142382. */
  142383. export class HDRTools {
  142384. private static Ldexp;
  142385. private static Rgbe2float;
  142386. private static readStringLine;
  142387. /**
  142388. * Reads header information from an RGBE texture stored in a native array.
  142389. * More information on this format are available here:
  142390. * https://en.wikipedia.org/wiki/RGBE_image_format
  142391. *
  142392. * @param uint8array The binary file stored in native array.
  142393. * @return The header information.
  142394. */
  142395. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  142396. /**
  142397. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  142398. * This RGBE texture needs to store the information as a panorama.
  142399. *
  142400. * More information on this format are available here:
  142401. * https://en.wikipedia.org/wiki/RGBE_image_format
  142402. *
  142403. * @param buffer The binary file stored in an array buffer.
  142404. * @param size The expected size of the extracted cubemap.
  142405. * @return The Cube Map information.
  142406. */
  142407. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  142408. /**
  142409. * Returns the pixels data extracted from an RGBE texture.
  142410. * This pixels will be stored left to right up to down in the R G B order in one array.
  142411. *
  142412. * More information on this format are available here:
  142413. * https://en.wikipedia.org/wiki/RGBE_image_format
  142414. *
  142415. * @param uint8array The binary file stored in an array buffer.
  142416. * @param hdrInfo The header information of the file.
  142417. * @return The pixels data in RGB right to left up to down order.
  142418. */
  142419. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  142420. private static RGBE_ReadPixels_RLE;
  142421. private static RGBE_ReadPixels_NOT_RLE;
  142422. }
  142423. }
  142424. declare module BABYLON {
  142425. /**
  142426. * Effect Render Options
  142427. */
  142428. export interface IEffectRendererOptions {
  142429. /**
  142430. * Defines the vertices positions.
  142431. */
  142432. positions?: number[];
  142433. /**
  142434. * Defines the indices.
  142435. */
  142436. indices?: number[];
  142437. }
  142438. /**
  142439. * Helper class to render one or more effects.
  142440. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  142441. */
  142442. export class EffectRenderer {
  142443. private engine;
  142444. private static _DefaultOptions;
  142445. private _vertexBuffers;
  142446. private _indexBuffer;
  142447. private _fullscreenViewport;
  142448. /**
  142449. * Creates an effect renderer
  142450. * @param engine the engine to use for rendering
  142451. * @param options defines the options of the effect renderer
  142452. */
  142453. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  142454. /**
  142455. * Sets the current viewport in normalized coordinates 0-1
  142456. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  142457. */
  142458. setViewport(viewport?: Viewport): void;
  142459. /**
  142460. * Binds the embedded attributes buffer to the effect.
  142461. * @param effect Defines the effect to bind the attributes for
  142462. */
  142463. bindBuffers(effect: Effect): void;
  142464. /**
  142465. * Sets the current effect wrapper to use during draw.
  142466. * The effect needs to be ready before calling this api.
  142467. * This also sets the default full screen position attribute.
  142468. * @param effectWrapper Defines the effect to draw with
  142469. */
  142470. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  142471. /**
  142472. * Restores engine states
  142473. */
  142474. restoreStates(): void;
  142475. /**
  142476. * Draws a full screen quad.
  142477. */
  142478. draw(): void;
  142479. private isRenderTargetTexture;
  142480. /**
  142481. * renders one or more effects to a specified texture
  142482. * @param effectWrapper the effect to renderer
  142483. * @param outputTexture texture to draw to, if null it will render to the screen.
  142484. */
  142485. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  142486. /**
  142487. * Disposes of the effect renderer
  142488. */
  142489. dispose(): void;
  142490. }
  142491. /**
  142492. * Options to create an EffectWrapper
  142493. */
  142494. interface EffectWrapperCreationOptions {
  142495. /**
  142496. * Engine to use to create the effect
  142497. */
  142498. engine: ThinEngine;
  142499. /**
  142500. * Fragment shader for the effect
  142501. */
  142502. fragmentShader: string;
  142503. /**
  142504. * Use the shader store instead of direct source code
  142505. */
  142506. useShaderStore?: boolean;
  142507. /**
  142508. * Vertex shader for the effect
  142509. */
  142510. vertexShader?: string;
  142511. /**
  142512. * Attributes to use in the shader
  142513. */
  142514. attributeNames?: Array<string>;
  142515. /**
  142516. * Uniforms to use in the shader
  142517. */
  142518. uniformNames?: Array<string>;
  142519. /**
  142520. * Texture sampler names to use in the shader
  142521. */
  142522. samplerNames?: Array<string>;
  142523. /**
  142524. * Defines to use in the shader
  142525. */
  142526. defines?: Array<string>;
  142527. /**
  142528. * Callback when effect is compiled
  142529. */
  142530. onCompiled?: Nullable<(effect: Effect) => void>;
  142531. /**
  142532. * The friendly name of the effect displayed in Spector.
  142533. */
  142534. name?: string;
  142535. }
  142536. /**
  142537. * Wraps an effect to be used for rendering
  142538. */
  142539. export class EffectWrapper {
  142540. /**
  142541. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  142542. */
  142543. onApplyObservable: Observable<{}>;
  142544. /**
  142545. * The underlying effect
  142546. */
  142547. effect: Effect;
  142548. /**
  142549. * Creates an effect to be renderer
  142550. * @param creationOptions options to create the effect
  142551. */
  142552. constructor(creationOptions: EffectWrapperCreationOptions);
  142553. /**
  142554. * Disposes of the effect wrapper
  142555. */
  142556. dispose(): void;
  142557. }
  142558. }
  142559. declare module BABYLON {
  142560. /** @hidden */
  142561. export var hdrFilteringVertexShader: {
  142562. name: string;
  142563. shader: string;
  142564. };
  142565. }
  142566. declare module BABYLON {
  142567. /** @hidden */
  142568. export var hdrFilteringPixelShader: {
  142569. name: string;
  142570. shader: string;
  142571. };
  142572. }
  142573. declare module BABYLON {
  142574. /**
  142575. * Options for texture filtering
  142576. */
  142577. interface IHDRFilteringOptions {
  142578. /**
  142579. * Scales pixel intensity for the input HDR map.
  142580. */
  142581. hdrScale?: number;
  142582. /**
  142583. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  142584. */
  142585. quality?: number;
  142586. }
  142587. /**
  142588. * Filters HDR maps to get correct renderings of PBR reflections
  142589. */
  142590. export class HDRFiltering {
  142591. private _engine;
  142592. private _effectRenderer;
  142593. private _effectWrapper;
  142594. private _lodGenerationOffset;
  142595. private _lodGenerationScale;
  142596. /**
  142597. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  142598. * you care about baking speed.
  142599. */
  142600. quality: number;
  142601. /**
  142602. * Scales pixel intensity for the input HDR map.
  142603. */
  142604. hdrScale: number;
  142605. /**
  142606. * Instantiates HDR filter for reflection maps
  142607. *
  142608. * @param engine Thin engine
  142609. * @param options Options
  142610. */
  142611. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  142612. private _createRenderTarget;
  142613. private _prefilterInternal;
  142614. private _createEffect;
  142615. /**
  142616. * Get a value indicating if the filter is ready to be used
  142617. * @param texture Texture to filter
  142618. * @returns true if the filter is ready
  142619. */
  142620. isReady(texture: BaseTexture): boolean;
  142621. /**
  142622. * Prefilters a cube texture to have mipmap levels representing roughness values.
  142623. * Prefiltering will be invoked at the end of next rendering pass.
  142624. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  142625. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  142626. * @param texture Texture to filter
  142627. * @param onFinished Callback when filtering is done
  142628. * @return Promise called when prefiltering is done
  142629. */
  142630. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  142631. }
  142632. }
  142633. declare module BABYLON {
  142634. /**
  142635. * This represents a texture coming from an HDR input.
  142636. *
  142637. * The only supported format is currently panorama picture stored in RGBE format.
  142638. * Example of such files can be found on HDRLib: http://hdrlib.com/
  142639. */
  142640. export class HDRCubeTexture extends BaseTexture {
  142641. private static _facesMapping;
  142642. private _generateHarmonics;
  142643. private _noMipmap;
  142644. private _prefilterOnLoad;
  142645. private _textureMatrix;
  142646. private _size;
  142647. private _onLoad;
  142648. private _onError;
  142649. /**
  142650. * The texture URL.
  142651. */
  142652. url: string;
  142653. protected _isBlocking: boolean;
  142654. /**
  142655. * Sets wether or not the texture is blocking during loading.
  142656. */
  142657. set isBlocking(value: boolean);
  142658. /**
  142659. * Gets wether or not the texture is blocking during loading.
  142660. */
  142661. get isBlocking(): boolean;
  142662. protected _rotationY: number;
  142663. /**
  142664. * Sets texture matrix rotation angle around Y axis in radians.
  142665. */
  142666. set rotationY(value: number);
  142667. /**
  142668. * Gets texture matrix rotation angle around Y axis radians.
  142669. */
  142670. get rotationY(): number;
  142671. /**
  142672. * Gets or sets the center of the bounding box associated with the cube texture
  142673. * It must define where the camera used to render the texture was set
  142674. */
  142675. boundingBoxPosition: Vector3;
  142676. private _boundingBoxSize;
  142677. /**
  142678. * Gets or sets the size of the bounding box associated with the cube texture
  142679. * When defined, the cubemap will switch to local mode
  142680. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  142681. * @example https://www.babylonjs-playground.com/#RNASML
  142682. */
  142683. set boundingBoxSize(value: Vector3);
  142684. get boundingBoxSize(): Vector3;
  142685. /**
  142686. * Instantiates an HDRTexture from the following parameters.
  142687. *
  142688. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  142689. * @param sceneOrEngine The scene or engine the texture will be used in
  142690. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142691. * @param noMipmap Forces to not generate the mipmap if true
  142692. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  142693. * @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)
  142694. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  142695. */
  142696. 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>);
  142697. /**
  142698. * Get the current class name of the texture useful for serialization or dynamic coding.
  142699. * @returns "HDRCubeTexture"
  142700. */
  142701. getClassName(): string;
  142702. /**
  142703. * Occurs when the file is raw .hdr file.
  142704. */
  142705. private loadTexture;
  142706. clone(): HDRCubeTexture;
  142707. delayLoad(): void;
  142708. /**
  142709. * Get the texture reflection matrix used to rotate/transform the reflection.
  142710. * @returns the reflection matrix
  142711. */
  142712. getReflectionTextureMatrix(): Matrix;
  142713. /**
  142714. * Set the texture reflection matrix used to rotate/transform the reflection.
  142715. * @param value Define the reflection matrix to set
  142716. */
  142717. setReflectionTextureMatrix(value: Matrix): void;
  142718. /**
  142719. * Parses a JSON representation of an HDR Texture in order to create the texture
  142720. * @param parsedTexture Define the JSON representation
  142721. * @param scene Define the scene the texture should be created in
  142722. * @param rootUrl Define the root url in case we need to load relative dependencies
  142723. * @returns the newly created texture after parsing
  142724. */
  142725. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  142726. serialize(): any;
  142727. }
  142728. }
  142729. declare module BABYLON {
  142730. /**
  142731. * Class used to control physics engine
  142732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142733. */
  142734. export class PhysicsEngine implements IPhysicsEngine {
  142735. private _physicsPlugin;
  142736. /**
  142737. * Global value used to control the smallest number supported by the simulation
  142738. */
  142739. static Epsilon: number;
  142740. private _impostors;
  142741. private _joints;
  142742. private _subTimeStep;
  142743. /**
  142744. * Gets the gravity vector used by the simulation
  142745. */
  142746. gravity: Vector3;
  142747. /**
  142748. * Factory used to create the default physics plugin.
  142749. * @returns The default physics plugin
  142750. */
  142751. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  142752. /**
  142753. * Creates a new Physics Engine
  142754. * @param gravity defines the gravity vector used by the simulation
  142755. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  142756. */
  142757. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  142758. /**
  142759. * Sets the gravity vector used by the simulation
  142760. * @param gravity defines the gravity vector to use
  142761. */
  142762. setGravity(gravity: Vector3): void;
  142763. /**
  142764. * Set the time step of the physics engine.
  142765. * Default is 1/60.
  142766. * To slow it down, enter 1/600 for example.
  142767. * To speed it up, 1/30
  142768. * @param newTimeStep defines the new timestep to apply to this world.
  142769. */
  142770. setTimeStep(newTimeStep?: number): void;
  142771. /**
  142772. * Get the time step of the physics engine.
  142773. * @returns the current time step
  142774. */
  142775. getTimeStep(): number;
  142776. /**
  142777. * Set the sub time step of the physics engine.
  142778. * Default is 0 meaning there is no sub steps
  142779. * To increase physics resolution precision, set a small value (like 1 ms)
  142780. * @param subTimeStep defines the new sub timestep used for physics resolution.
  142781. */
  142782. setSubTimeStep(subTimeStep?: number): void;
  142783. /**
  142784. * Get the sub time step of the physics engine.
  142785. * @returns the current sub time step
  142786. */
  142787. getSubTimeStep(): number;
  142788. /**
  142789. * Release all resources
  142790. */
  142791. dispose(): void;
  142792. /**
  142793. * Gets the name of the current physics plugin
  142794. * @returns the name of the plugin
  142795. */
  142796. getPhysicsPluginName(): string;
  142797. /**
  142798. * Adding a new impostor for the impostor tracking.
  142799. * This will be done by the impostor itself.
  142800. * @param impostor the impostor to add
  142801. */
  142802. addImpostor(impostor: PhysicsImpostor): void;
  142803. /**
  142804. * Remove an impostor from the engine.
  142805. * This impostor and its mesh will not longer be updated by the physics engine.
  142806. * @param impostor the impostor to remove
  142807. */
  142808. removeImpostor(impostor: PhysicsImpostor): void;
  142809. /**
  142810. * Add a joint to the physics engine
  142811. * @param mainImpostor defines the main impostor to which the joint is added.
  142812. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  142813. * @param joint defines the joint that will connect both impostors.
  142814. */
  142815. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142816. /**
  142817. * Removes a joint from the simulation
  142818. * @param mainImpostor defines the impostor used with the joint
  142819. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  142820. * @param joint defines the joint to remove
  142821. */
  142822. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142823. /**
  142824. * Called by the scene. No need to call it.
  142825. * @param delta defines the timespam between frames
  142826. */
  142827. _step(delta: number): void;
  142828. /**
  142829. * Gets the current plugin used to run the simulation
  142830. * @returns current plugin
  142831. */
  142832. getPhysicsPlugin(): IPhysicsEnginePlugin;
  142833. /**
  142834. * Gets the list of physic impostors
  142835. * @returns an array of PhysicsImpostor
  142836. */
  142837. getImpostors(): Array<PhysicsImpostor>;
  142838. /**
  142839. * Gets the impostor for a physics enabled object
  142840. * @param object defines the object impersonated by the impostor
  142841. * @returns the PhysicsImpostor or null if not found
  142842. */
  142843. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  142844. /**
  142845. * Gets the impostor for a physics body object
  142846. * @param body defines physics body used by the impostor
  142847. * @returns the PhysicsImpostor or null if not found
  142848. */
  142849. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  142850. /**
  142851. * Does a raycast in the physics world
  142852. * @param from when should the ray start?
  142853. * @param to when should the ray end?
  142854. * @returns PhysicsRaycastResult
  142855. */
  142856. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142857. }
  142858. }
  142859. declare module BABYLON {
  142860. /** @hidden */
  142861. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  142862. private _useDeltaForWorldStep;
  142863. world: any;
  142864. name: string;
  142865. private _physicsMaterials;
  142866. private _fixedTimeStep;
  142867. private _cannonRaycastResult;
  142868. private _raycastResult;
  142869. private _physicsBodysToRemoveAfterStep;
  142870. private _firstFrame;
  142871. BJSCANNON: any;
  142872. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  142873. setGravity(gravity: Vector3): void;
  142874. setTimeStep(timeStep: number): void;
  142875. getTimeStep(): number;
  142876. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142877. private _removeMarkedPhysicsBodiesFromWorld;
  142878. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142879. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142880. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142881. private _processChildMeshes;
  142882. removePhysicsBody(impostor: PhysicsImpostor): void;
  142883. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142884. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142885. private _addMaterial;
  142886. private _checkWithEpsilon;
  142887. private _createShape;
  142888. private _createHeightmap;
  142889. private _minus90X;
  142890. private _plus90X;
  142891. private _tmpPosition;
  142892. private _tmpDeltaPosition;
  142893. private _tmpUnityRotation;
  142894. private _updatePhysicsBodyTransformation;
  142895. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142896. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142897. isSupported(): boolean;
  142898. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142899. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142900. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142901. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142902. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142903. getBodyMass(impostor: PhysicsImpostor): number;
  142904. getBodyFriction(impostor: PhysicsImpostor): number;
  142905. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142906. getBodyRestitution(impostor: PhysicsImpostor): number;
  142907. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142908. sleepBody(impostor: PhysicsImpostor): void;
  142909. wakeUpBody(impostor: PhysicsImpostor): void;
  142910. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  142911. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142912. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142913. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142914. getRadius(impostor: PhysicsImpostor): number;
  142915. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142916. dispose(): void;
  142917. private _extendNamespace;
  142918. /**
  142919. * Does a raycast in the physics world
  142920. * @param from when should the ray start?
  142921. * @param to when should the ray end?
  142922. * @returns PhysicsRaycastResult
  142923. */
  142924. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142925. }
  142926. }
  142927. declare module BABYLON {
  142928. /** @hidden */
  142929. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  142930. private _useDeltaForWorldStep;
  142931. world: any;
  142932. name: string;
  142933. BJSOIMO: any;
  142934. private _raycastResult;
  142935. private _fixedTimeStep;
  142936. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  142937. setGravity(gravity: Vector3): void;
  142938. setTimeStep(timeStep: number): void;
  142939. getTimeStep(): number;
  142940. private _tmpImpostorsArray;
  142941. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142942. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142943. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142944. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142945. private _tmpPositionVector;
  142946. removePhysicsBody(impostor: PhysicsImpostor): void;
  142947. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142948. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142949. isSupported(): boolean;
  142950. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142951. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142952. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142953. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142954. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142955. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142956. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142957. getBodyMass(impostor: PhysicsImpostor): number;
  142958. getBodyFriction(impostor: PhysicsImpostor): number;
  142959. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142960. getBodyRestitution(impostor: PhysicsImpostor): number;
  142961. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142962. sleepBody(impostor: PhysicsImpostor): void;
  142963. wakeUpBody(impostor: PhysicsImpostor): void;
  142964. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142965. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  142966. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  142967. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142968. getRadius(impostor: PhysicsImpostor): number;
  142969. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142970. dispose(): void;
  142971. /**
  142972. * Does a raycast in the physics world
  142973. * @param from when should the ray start?
  142974. * @param to when should the ray end?
  142975. * @returns PhysicsRaycastResult
  142976. */
  142977. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142978. }
  142979. }
  142980. declare module BABYLON {
  142981. /**
  142982. * AmmoJS Physics plugin
  142983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142984. * @see https://github.com/kripken/ammo.js/
  142985. */
  142986. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  142987. private _useDeltaForWorldStep;
  142988. /**
  142989. * Reference to the Ammo library
  142990. */
  142991. bjsAMMO: any;
  142992. /**
  142993. * Created ammoJS world which physics bodies are added to
  142994. */
  142995. world: any;
  142996. /**
  142997. * Name of the plugin
  142998. */
  142999. name: string;
  143000. private _timeStep;
  143001. private _fixedTimeStep;
  143002. private _maxSteps;
  143003. private _tmpQuaternion;
  143004. private _tmpAmmoTransform;
  143005. private _tmpAmmoQuaternion;
  143006. private _tmpAmmoConcreteContactResultCallback;
  143007. private _collisionConfiguration;
  143008. private _dispatcher;
  143009. private _overlappingPairCache;
  143010. private _solver;
  143011. private _softBodySolver;
  143012. private _tmpAmmoVectorA;
  143013. private _tmpAmmoVectorB;
  143014. private _tmpAmmoVectorC;
  143015. private _tmpAmmoVectorD;
  143016. private _tmpContactCallbackResult;
  143017. private _tmpAmmoVectorRCA;
  143018. private _tmpAmmoVectorRCB;
  143019. private _raycastResult;
  143020. private _tmpContactPoint;
  143021. private static readonly DISABLE_COLLISION_FLAG;
  143022. private static readonly KINEMATIC_FLAG;
  143023. private static readonly DISABLE_DEACTIVATION_FLAG;
  143024. /**
  143025. * Initializes the ammoJS plugin
  143026. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  143027. * @param ammoInjection can be used to inject your own ammo reference
  143028. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  143029. */
  143030. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  143031. /**
  143032. * Sets the gravity of the physics world (m/(s^2))
  143033. * @param gravity Gravity to set
  143034. */
  143035. setGravity(gravity: Vector3): void;
  143036. /**
  143037. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  143038. * @param timeStep timestep to use in seconds
  143039. */
  143040. setTimeStep(timeStep: number): void;
  143041. /**
  143042. * 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)
  143043. * @param fixedTimeStep fixedTimeStep to use in seconds
  143044. */
  143045. setFixedTimeStep(fixedTimeStep: number): void;
  143046. /**
  143047. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  143048. * @param maxSteps the maximum number of steps by the physics engine per frame
  143049. */
  143050. setMaxSteps(maxSteps: number): void;
  143051. /**
  143052. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  143053. * @returns the current timestep in seconds
  143054. */
  143055. getTimeStep(): number;
  143056. /**
  143057. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  143058. */
  143059. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  143060. private _isImpostorInContact;
  143061. private _isImpostorPairInContact;
  143062. private _stepSimulation;
  143063. /**
  143064. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  143065. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  143066. * After the step the babylon meshes are set to the position of the physics imposters
  143067. * @param delta amount of time to step forward
  143068. * @param impostors array of imposters to update before/after the step
  143069. */
  143070. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143071. /**
  143072. * Update babylon mesh to match physics world object
  143073. * @param impostor imposter to match
  143074. */
  143075. private _afterSoftStep;
  143076. /**
  143077. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  143078. * @param impostor imposter to match
  143079. */
  143080. private _ropeStep;
  143081. /**
  143082. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  143083. * @param impostor imposter to match
  143084. */
  143085. private _softbodyOrClothStep;
  143086. private _tmpMatrix;
  143087. /**
  143088. * Applies an impulse on the imposter
  143089. * @param impostor imposter to apply impulse to
  143090. * @param force amount of force to be applied to the imposter
  143091. * @param contactPoint the location to apply the impulse on the imposter
  143092. */
  143093. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143094. /**
  143095. * Applies a force on the imposter
  143096. * @param impostor imposter to apply force
  143097. * @param force amount of force to be applied to the imposter
  143098. * @param contactPoint the location to apply the force on the imposter
  143099. */
  143100. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143101. /**
  143102. * Creates a physics body using the plugin
  143103. * @param impostor the imposter to create the physics body on
  143104. */
  143105. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143106. /**
  143107. * Removes the physics body from the imposter and disposes of the body's memory
  143108. * @param impostor imposter to remove the physics body from
  143109. */
  143110. removePhysicsBody(impostor: PhysicsImpostor): void;
  143111. /**
  143112. * Generates a joint
  143113. * @param impostorJoint the imposter joint to create the joint with
  143114. */
  143115. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143116. /**
  143117. * Removes a joint
  143118. * @param impostorJoint the imposter joint to remove the joint from
  143119. */
  143120. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143121. private _addMeshVerts;
  143122. /**
  143123. * Initialise the soft body vertices to match its object's (mesh) vertices
  143124. * Softbody vertices (nodes) are in world space and to match this
  143125. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  143126. * @param impostor to create the softbody for
  143127. */
  143128. private _softVertexData;
  143129. /**
  143130. * Create an impostor's soft body
  143131. * @param impostor to create the softbody for
  143132. */
  143133. private _createSoftbody;
  143134. /**
  143135. * Create cloth for an impostor
  143136. * @param impostor to create the softbody for
  143137. */
  143138. private _createCloth;
  143139. /**
  143140. * Create rope for an impostor
  143141. * @param impostor to create the softbody for
  143142. */
  143143. private _createRope;
  143144. /**
  143145. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  143146. * @param impostor to create the custom physics shape for
  143147. */
  143148. private _createCustom;
  143149. private _addHullVerts;
  143150. private _createShape;
  143151. /**
  143152. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  143153. * @param impostor imposter containing the physics body and babylon object
  143154. */
  143155. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143156. /**
  143157. * Sets the babylon object's position/rotation from the physics body's position/rotation
  143158. * @param impostor imposter containing the physics body and babylon object
  143159. * @param newPosition new position
  143160. * @param newRotation new rotation
  143161. */
  143162. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143163. /**
  143164. * If this plugin is supported
  143165. * @returns true if its supported
  143166. */
  143167. isSupported(): boolean;
  143168. /**
  143169. * Sets the linear velocity of the physics body
  143170. * @param impostor imposter to set the velocity on
  143171. * @param velocity velocity to set
  143172. */
  143173. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143174. /**
  143175. * Sets the angular velocity of the physics body
  143176. * @param impostor imposter to set the velocity on
  143177. * @param velocity velocity to set
  143178. */
  143179. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143180. /**
  143181. * gets the linear velocity
  143182. * @param impostor imposter to get linear velocity from
  143183. * @returns linear velocity
  143184. */
  143185. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143186. /**
  143187. * gets the angular velocity
  143188. * @param impostor imposter to get angular velocity from
  143189. * @returns angular velocity
  143190. */
  143191. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143192. /**
  143193. * Sets the mass of physics body
  143194. * @param impostor imposter to set the mass on
  143195. * @param mass mass to set
  143196. */
  143197. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143198. /**
  143199. * Gets the mass of the physics body
  143200. * @param impostor imposter to get the mass from
  143201. * @returns mass
  143202. */
  143203. getBodyMass(impostor: PhysicsImpostor): number;
  143204. /**
  143205. * Gets friction of the impostor
  143206. * @param impostor impostor to get friction from
  143207. * @returns friction value
  143208. */
  143209. getBodyFriction(impostor: PhysicsImpostor): number;
  143210. /**
  143211. * Sets friction of the impostor
  143212. * @param impostor impostor to set friction on
  143213. * @param friction friction value
  143214. */
  143215. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143216. /**
  143217. * Gets restitution of the impostor
  143218. * @param impostor impostor to get restitution from
  143219. * @returns restitution value
  143220. */
  143221. getBodyRestitution(impostor: PhysicsImpostor): number;
  143222. /**
  143223. * Sets resitution of the impostor
  143224. * @param impostor impostor to set resitution on
  143225. * @param restitution resitution value
  143226. */
  143227. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143228. /**
  143229. * Gets pressure inside the impostor
  143230. * @param impostor impostor to get pressure from
  143231. * @returns pressure value
  143232. */
  143233. getBodyPressure(impostor: PhysicsImpostor): number;
  143234. /**
  143235. * Sets pressure inside a soft body impostor
  143236. * Cloth and rope must remain 0 pressure
  143237. * @param impostor impostor to set pressure on
  143238. * @param pressure pressure value
  143239. */
  143240. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  143241. /**
  143242. * Gets stiffness of the impostor
  143243. * @param impostor impostor to get stiffness from
  143244. * @returns pressure value
  143245. */
  143246. getBodyStiffness(impostor: PhysicsImpostor): number;
  143247. /**
  143248. * Sets stiffness of the impostor
  143249. * @param impostor impostor to set stiffness on
  143250. * @param stiffness stiffness value from 0 to 1
  143251. */
  143252. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  143253. /**
  143254. * Gets velocityIterations of the impostor
  143255. * @param impostor impostor to get velocity iterations from
  143256. * @returns velocityIterations value
  143257. */
  143258. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  143259. /**
  143260. * Sets velocityIterations of the impostor
  143261. * @param impostor impostor to set velocity iterations on
  143262. * @param velocityIterations velocityIterations value
  143263. */
  143264. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  143265. /**
  143266. * Gets positionIterations of the impostor
  143267. * @param impostor impostor to get position iterations from
  143268. * @returns positionIterations value
  143269. */
  143270. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  143271. /**
  143272. * Sets positionIterations of the impostor
  143273. * @param impostor impostor to set position on
  143274. * @param positionIterations positionIterations value
  143275. */
  143276. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  143277. /**
  143278. * Append an anchor to a cloth object
  143279. * @param impostor is the cloth impostor to add anchor to
  143280. * @param otherImpostor is the rigid impostor to anchor to
  143281. * @param width ratio across width from 0 to 1
  143282. * @param height ratio up height from 0 to 1
  143283. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  143284. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  143285. */
  143286. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  143287. /**
  143288. * Append an hook to a rope object
  143289. * @param impostor is the rope impostor to add hook to
  143290. * @param otherImpostor is the rigid impostor to hook to
  143291. * @param length ratio along the rope from 0 to 1
  143292. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  143293. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  143294. */
  143295. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  143296. /**
  143297. * Sleeps the physics body and stops it from being active
  143298. * @param impostor impostor to sleep
  143299. */
  143300. sleepBody(impostor: PhysicsImpostor): void;
  143301. /**
  143302. * Activates the physics body
  143303. * @param impostor impostor to activate
  143304. */
  143305. wakeUpBody(impostor: PhysicsImpostor): void;
  143306. /**
  143307. * Updates the distance parameters of the joint
  143308. * @param joint joint to update
  143309. * @param maxDistance maximum distance of the joint
  143310. * @param minDistance minimum distance of the joint
  143311. */
  143312. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  143313. /**
  143314. * Sets a motor on the joint
  143315. * @param joint joint to set motor on
  143316. * @param speed speed of the motor
  143317. * @param maxForce maximum force of the motor
  143318. * @param motorIndex index of the motor
  143319. */
  143320. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  143321. /**
  143322. * Sets the motors limit
  143323. * @param joint joint to set limit on
  143324. * @param upperLimit upper limit
  143325. * @param lowerLimit lower limit
  143326. */
  143327. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  143328. /**
  143329. * Syncs the position and rotation of a mesh with the impostor
  143330. * @param mesh mesh to sync
  143331. * @param impostor impostor to update the mesh with
  143332. */
  143333. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143334. /**
  143335. * Gets the radius of the impostor
  143336. * @param impostor impostor to get radius from
  143337. * @returns the radius
  143338. */
  143339. getRadius(impostor: PhysicsImpostor): number;
  143340. /**
  143341. * Gets the box size of the impostor
  143342. * @param impostor impostor to get box size from
  143343. * @param result the resulting box size
  143344. */
  143345. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143346. /**
  143347. * Disposes of the impostor
  143348. */
  143349. dispose(): void;
  143350. /**
  143351. * Does a raycast in the physics world
  143352. * @param from when should the ray start?
  143353. * @param to when should the ray end?
  143354. * @returns PhysicsRaycastResult
  143355. */
  143356. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143357. }
  143358. }
  143359. declare module BABYLON {
  143360. interface AbstractScene {
  143361. /**
  143362. * The list of reflection probes added to the scene
  143363. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  143364. */
  143365. reflectionProbes: Array<ReflectionProbe>;
  143366. /**
  143367. * Removes the given reflection probe from this scene.
  143368. * @param toRemove The reflection probe to remove
  143369. * @returns The index of the removed reflection probe
  143370. */
  143371. removeReflectionProbe(toRemove: ReflectionProbe): number;
  143372. /**
  143373. * Adds the given reflection probe to this scene.
  143374. * @param newReflectionProbe The reflection probe to add
  143375. */
  143376. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  143377. }
  143378. /**
  143379. * Class used to generate realtime reflection / refraction cube textures
  143380. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  143381. */
  143382. export class ReflectionProbe {
  143383. /** defines the name of the probe */
  143384. name: string;
  143385. private _scene;
  143386. private _renderTargetTexture;
  143387. private _projectionMatrix;
  143388. private _viewMatrix;
  143389. private _target;
  143390. private _add;
  143391. private _attachedMesh;
  143392. private _invertYAxis;
  143393. /** Gets or sets probe position (center of the cube map) */
  143394. position: Vector3;
  143395. /**
  143396. * Creates a new reflection probe
  143397. * @param name defines the name of the probe
  143398. * @param size defines the texture resolution (for each face)
  143399. * @param scene defines the hosting scene
  143400. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  143401. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  143402. */
  143403. constructor(
  143404. /** defines the name of the probe */
  143405. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  143406. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  143407. get samples(): number;
  143408. set samples(value: number);
  143409. /** Gets or sets the refresh rate to use (on every frame by default) */
  143410. get refreshRate(): number;
  143411. set refreshRate(value: number);
  143412. /**
  143413. * Gets the hosting scene
  143414. * @returns a Scene
  143415. */
  143416. getScene(): Scene;
  143417. /** Gets the internal CubeTexture used to render to */
  143418. get cubeTexture(): RenderTargetTexture;
  143419. /** Gets the list of meshes to render */
  143420. get renderList(): Nullable<AbstractMesh[]>;
  143421. /**
  143422. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  143423. * @param mesh defines the mesh to attach to
  143424. */
  143425. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  143426. /**
  143427. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  143428. * @param renderingGroupId The rendering group id corresponding to its index
  143429. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  143430. */
  143431. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  143432. /**
  143433. * Clean all associated resources
  143434. */
  143435. dispose(): void;
  143436. /**
  143437. * Converts the reflection probe information to a readable string for debug purpose.
  143438. * @param fullDetails Supports for multiple levels of logging within scene loading
  143439. * @returns the human readable reflection probe info
  143440. */
  143441. toString(fullDetails?: boolean): string;
  143442. /**
  143443. * Get the class name of the relfection probe.
  143444. * @returns "ReflectionProbe"
  143445. */
  143446. getClassName(): string;
  143447. /**
  143448. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  143449. * @returns The JSON representation of the texture
  143450. */
  143451. serialize(): any;
  143452. /**
  143453. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  143454. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  143455. * @param scene Define the scene the parsed reflection probe should be instantiated in
  143456. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  143457. * @returns The parsed reflection probe if successful
  143458. */
  143459. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  143460. }
  143461. }
  143462. declare module BABYLON {
  143463. /** @hidden */
  143464. export var _BabylonLoaderRegistered: boolean;
  143465. /**
  143466. * Helps setting up some configuration for the babylon file loader.
  143467. */
  143468. export class BabylonFileLoaderConfiguration {
  143469. /**
  143470. * The loader does not allow injecting custom physix engine into the plugins.
  143471. * Unfortunately in ES6, we need to manually inject them into the plugin.
  143472. * So you could set this variable to your engine import to make it work.
  143473. */
  143474. static LoaderInjectedPhysicsEngine: any;
  143475. }
  143476. }
  143477. declare module BABYLON {
  143478. /**
  143479. * The Physically based simple base material of BJS.
  143480. *
  143481. * This enables better naming and convention enforcements on top of the pbrMaterial.
  143482. * It is used as the base class for both the specGloss and metalRough conventions.
  143483. */
  143484. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  143485. /**
  143486. * Number of Simultaneous lights allowed on the material.
  143487. */
  143488. maxSimultaneousLights: number;
  143489. /**
  143490. * If sets to true, disables all the lights affecting the material.
  143491. */
  143492. disableLighting: boolean;
  143493. /**
  143494. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  143495. */
  143496. environmentTexture: BaseTexture;
  143497. /**
  143498. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  143499. */
  143500. invertNormalMapX: boolean;
  143501. /**
  143502. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  143503. */
  143504. invertNormalMapY: boolean;
  143505. /**
  143506. * Normal map used in the model.
  143507. */
  143508. normalTexture: BaseTexture;
  143509. /**
  143510. * Emissivie color used to self-illuminate the model.
  143511. */
  143512. emissiveColor: Color3;
  143513. /**
  143514. * Emissivie texture used to self-illuminate the model.
  143515. */
  143516. emissiveTexture: BaseTexture;
  143517. /**
  143518. * Occlusion Channel Strenght.
  143519. */
  143520. occlusionStrength: number;
  143521. /**
  143522. * Occlusion Texture of the material (adding extra occlusion effects).
  143523. */
  143524. occlusionTexture: BaseTexture;
  143525. /**
  143526. * Defines the alpha limits in alpha test mode.
  143527. */
  143528. alphaCutOff: number;
  143529. /**
  143530. * Gets the current double sided mode.
  143531. */
  143532. get doubleSided(): boolean;
  143533. /**
  143534. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  143535. */
  143536. set doubleSided(value: boolean);
  143537. /**
  143538. * Stores the pre-calculated light information of a mesh in a texture.
  143539. */
  143540. lightmapTexture: BaseTexture;
  143541. /**
  143542. * If true, the light map contains occlusion information instead of lighting info.
  143543. */
  143544. useLightmapAsShadowmap: boolean;
  143545. /**
  143546. * Instantiates a new PBRMaterial instance.
  143547. *
  143548. * @param name The material name
  143549. * @param scene The scene the material will be use in.
  143550. */
  143551. constructor(name: string, scene: Scene);
  143552. getClassName(): string;
  143553. }
  143554. }
  143555. declare module BABYLON {
  143556. /**
  143557. * The PBR material of BJS following the metal roughness convention.
  143558. *
  143559. * This fits to the PBR convention in the GLTF definition:
  143560. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  143561. */
  143562. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  143563. /**
  143564. * The base color has two different interpretations depending on the value of metalness.
  143565. * When the material is a metal, the base color is the specific measured reflectance value
  143566. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  143567. * of the material.
  143568. */
  143569. baseColor: Color3;
  143570. /**
  143571. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  143572. * well as opacity information in the alpha channel.
  143573. */
  143574. baseTexture: BaseTexture;
  143575. /**
  143576. * Specifies the metallic scalar value of the material.
  143577. * Can also be used to scale the metalness values of the metallic texture.
  143578. */
  143579. metallic: number;
  143580. /**
  143581. * Specifies the roughness scalar value of the material.
  143582. * Can also be used to scale the roughness values of the metallic texture.
  143583. */
  143584. roughness: number;
  143585. /**
  143586. * Texture containing both the metallic value in the B channel and the
  143587. * roughness value in the G channel to keep better precision.
  143588. */
  143589. metallicRoughnessTexture: BaseTexture;
  143590. /**
  143591. * Instantiates a new PBRMetalRoughnessMaterial instance.
  143592. *
  143593. * @param name The material name
  143594. * @param scene The scene the material will be use in.
  143595. */
  143596. constructor(name: string, scene: Scene);
  143597. /**
  143598. * Return the currrent class name of the material.
  143599. */
  143600. getClassName(): string;
  143601. /**
  143602. * Makes a duplicate of the current material.
  143603. * @param name - name to use for the new material.
  143604. */
  143605. clone(name: string): PBRMetallicRoughnessMaterial;
  143606. /**
  143607. * Serialize the material to a parsable JSON object.
  143608. */
  143609. serialize(): any;
  143610. /**
  143611. * Parses a JSON object correponding to the serialize function.
  143612. */
  143613. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  143614. }
  143615. }
  143616. declare module BABYLON {
  143617. /**
  143618. * The PBR material of BJS following the specular glossiness convention.
  143619. *
  143620. * This fits to the PBR convention in the GLTF definition:
  143621. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  143622. */
  143623. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  143624. /**
  143625. * Specifies the diffuse color of the material.
  143626. */
  143627. diffuseColor: Color3;
  143628. /**
  143629. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  143630. * channel.
  143631. */
  143632. diffuseTexture: BaseTexture;
  143633. /**
  143634. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  143635. */
  143636. specularColor: Color3;
  143637. /**
  143638. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  143639. */
  143640. glossiness: number;
  143641. /**
  143642. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  143643. */
  143644. specularGlossinessTexture: BaseTexture;
  143645. /**
  143646. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  143647. *
  143648. * @param name The material name
  143649. * @param scene The scene the material will be use in.
  143650. */
  143651. constructor(name: string, scene: Scene);
  143652. /**
  143653. * Return the currrent class name of the material.
  143654. */
  143655. getClassName(): string;
  143656. /**
  143657. * Makes a duplicate of the current material.
  143658. * @param name - name to use for the new material.
  143659. */
  143660. clone(name: string): PBRSpecularGlossinessMaterial;
  143661. /**
  143662. * Serialize the material to a parsable JSON object.
  143663. */
  143664. serialize(): any;
  143665. /**
  143666. * Parses a JSON object correponding to the serialize function.
  143667. */
  143668. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  143669. }
  143670. }
  143671. declare module BABYLON {
  143672. /**
  143673. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  143674. * It can help converting any input color in a desired output one. This can then be used to create effects
  143675. * from sepia, black and white to sixties or futuristic rendering...
  143676. *
  143677. * The only supported format is currently 3dl.
  143678. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  143679. */
  143680. export class ColorGradingTexture extends BaseTexture {
  143681. /**
  143682. * The texture URL.
  143683. */
  143684. url: string;
  143685. /**
  143686. * Empty line regex stored for GC.
  143687. */
  143688. private static _noneEmptyLineRegex;
  143689. private _textureMatrix;
  143690. private _onLoad;
  143691. /**
  143692. * Instantiates a ColorGradingTexture from the following parameters.
  143693. *
  143694. * @param url The location of the color gradind data (currently only supporting 3dl)
  143695. * @param sceneOrEngine The scene or engine the texture will be used in
  143696. * @param onLoad defines a callback triggered when the texture has been loaded
  143697. */
  143698. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  143699. /**
  143700. * Fires the onload event from the constructor if requested.
  143701. */
  143702. private _triggerOnLoad;
  143703. /**
  143704. * Returns the texture matrix used in most of the material.
  143705. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  143706. */
  143707. getTextureMatrix(): Matrix;
  143708. /**
  143709. * Occurs when the file being loaded is a .3dl LUT file.
  143710. */
  143711. private load3dlTexture;
  143712. /**
  143713. * Starts the loading process of the texture.
  143714. */
  143715. private loadTexture;
  143716. /**
  143717. * Clones the color gradind texture.
  143718. */
  143719. clone(): ColorGradingTexture;
  143720. /**
  143721. * Called during delayed load for textures.
  143722. */
  143723. delayLoad(): void;
  143724. /**
  143725. * Parses a color grading texture serialized by Babylon.
  143726. * @param parsedTexture The texture information being parsedTexture
  143727. * @param scene The scene to load the texture in
  143728. * @param rootUrl The root url of the data assets to load
  143729. * @return A color gradind texture
  143730. */
  143731. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  143732. /**
  143733. * Serializes the LUT texture to json format.
  143734. */
  143735. serialize(): any;
  143736. }
  143737. }
  143738. declare module BABYLON {
  143739. /**
  143740. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  143741. */
  143742. export class EquiRectangularCubeTexture extends BaseTexture {
  143743. /** The six faces of the cube. */
  143744. private static _FacesMapping;
  143745. private _noMipmap;
  143746. private _onLoad;
  143747. private _onError;
  143748. /** The size of the cubemap. */
  143749. private _size;
  143750. /** The buffer of the image. */
  143751. private _buffer;
  143752. /** The width of the input image. */
  143753. private _width;
  143754. /** The height of the input image. */
  143755. private _height;
  143756. /** The URL to the image. */
  143757. url: string;
  143758. /**
  143759. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  143760. * @param url The location of the image
  143761. * @param scene The scene the texture will be used in
  143762. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  143763. * @param noMipmap Forces to not generate the mipmap if true
  143764. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  143765. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  143766. * @param onLoad — defines a callback called when texture is loaded
  143767. * @param onError — defines a callback called if there is an error
  143768. */
  143769. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  143770. /**
  143771. * Load the image data, by putting the image on a canvas and extracting its buffer.
  143772. */
  143773. private loadImage;
  143774. /**
  143775. * Convert the image buffer into a cubemap and create a CubeTexture.
  143776. */
  143777. private loadTexture;
  143778. /**
  143779. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  143780. * @param buffer The ArrayBuffer that should be converted.
  143781. * @returns The buffer as Float32Array.
  143782. */
  143783. private getFloat32ArrayFromArrayBuffer;
  143784. /**
  143785. * Get the current class name of the texture useful for serialization or dynamic coding.
  143786. * @returns "EquiRectangularCubeTexture"
  143787. */
  143788. getClassName(): string;
  143789. /**
  143790. * Create a clone of the current EquiRectangularCubeTexture and return it.
  143791. * @returns A clone of the current EquiRectangularCubeTexture.
  143792. */
  143793. clone(): EquiRectangularCubeTexture;
  143794. }
  143795. }
  143796. declare module BABYLON {
  143797. /**
  143798. * Defines the options related to the creation of an HtmlElementTexture
  143799. */
  143800. export interface IHtmlElementTextureOptions {
  143801. /**
  143802. * Defines wether mip maps should be created or not.
  143803. */
  143804. generateMipMaps?: boolean;
  143805. /**
  143806. * Defines the sampling mode of the texture.
  143807. */
  143808. samplingMode?: number;
  143809. /**
  143810. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  143811. */
  143812. engine: Nullable<ThinEngine>;
  143813. /**
  143814. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  143815. */
  143816. scene: Nullable<Scene>;
  143817. }
  143818. /**
  143819. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  143820. * To be as efficient as possible depending on your constraints nothing aside the first upload
  143821. * is automatically managed.
  143822. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  143823. * in your application.
  143824. *
  143825. * As the update is not automatic, you need to call them manually.
  143826. */
  143827. export class HtmlElementTexture extends BaseTexture {
  143828. /**
  143829. * The texture URL.
  143830. */
  143831. element: HTMLVideoElement | HTMLCanvasElement;
  143832. private static readonly DefaultOptions;
  143833. private _textureMatrix;
  143834. private _isVideo;
  143835. private _generateMipMaps;
  143836. private _samplingMode;
  143837. /**
  143838. * Instantiates a HtmlElementTexture from the following parameters.
  143839. *
  143840. * @param name Defines the name of the texture
  143841. * @param element Defines the video or canvas the texture is filled with
  143842. * @param options Defines the other none mandatory texture creation options
  143843. */
  143844. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  143845. private _createInternalTexture;
  143846. /**
  143847. * Returns the texture matrix used in most of the material.
  143848. */
  143849. getTextureMatrix(): Matrix;
  143850. /**
  143851. * Updates the content of the texture.
  143852. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  143853. */
  143854. update(invertY?: Nullable<boolean>): void;
  143855. }
  143856. }
  143857. declare module BABYLON {
  143858. /**
  143859. * Based on jsTGALoader - Javascript loader for TGA file
  143860. * By Vincent Thibault
  143861. * @see http://blog.robrowser.com/javascript-tga-loader.html
  143862. */
  143863. export class TGATools {
  143864. private static _TYPE_INDEXED;
  143865. private static _TYPE_RGB;
  143866. private static _TYPE_GREY;
  143867. private static _TYPE_RLE_INDEXED;
  143868. private static _TYPE_RLE_RGB;
  143869. private static _TYPE_RLE_GREY;
  143870. private static _ORIGIN_MASK;
  143871. private static _ORIGIN_SHIFT;
  143872. private static _ORIGIN_BL;
  143873. private static _ORIGIN_BR;
  143874. private static _ORIGIN_UL;
  143875. private static _ORIGIN_UR;
  143876. /**
  143877. * Gets the header of a TGA file
  143878. * @param data defines the TGA data
  143879. * @returns the header
  143880. */
  143881. static GetTGAHeader(data: Uint8Array): any;
  143882. /**
  143883. * Uploads TGA content to a Babylon Texture
  143884. * @hidden
  143885. */
  143886. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  143887. /** @hidden */
  143888. 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;
  143889. /** @hidden */
  143890. 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;
  143891. /** @hidden */
  143892. 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;
  143893. /** @hidden */
  143894. 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;
  143895. /** @hidden */
  143896. 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;
  143897. /** @hidden */
  143898. 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;
  143899. }
  143900. }
  143901. declare module BABYLON {
  143902. /**
  143903. * Implementation of the TGA Texture Loader.
  143904. * @hidden
  143905. */
  143906. export class _TGATextureLoader implements IInternalTextureLoader {
  143907. /**
  143908. * Defines wether the loader supports cascade loading the different faces.
  143909. */
  143910. readonly supportCascades: boolean;
  143911. /**
  143912. * This returns if the loader support the current file information.
  143913. * @param extension defines the file extension of the file being loaded
  143914. * @returns true if the loader can load the specified file
  143915. */
  143916. canLoad(extension: string): boolean;
  143917. /**
  143918. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143919. * @param data contains the texture data
  143920. * @param texture defines the BabylonJS internal texture
  143921. * @param createPolynomials will be true if polynomials have been requested
  143922. * @param onLoad defines the callback to trigger once the texture is ready
  143923. * @param onError defines the callback to trigger in case of error
  143924. */
  143925. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143926. /**
  143927. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143928. * @param data contains the texture data
  143929. * @param texture defines the BabylonJS internal texture
  143930. * @param callback defines the method to call once ready to upload
  143931. */
  143932. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143933. }
  143934. }
  143935. declare module BABYLON {
  143936. /**
  143937. * Info about the .basis files
  143938. */
  143939. class BasisFileInfo {
  143940. /**
  143941. * If the file has alpha
  143942. */
  143943. hasAlpha: boolean;
  143944. /**
  143945. * Info about each image of the basis file
  143946. */
  143947. images: Array<{
  143948. levels: Array<{
  143949. width: number;
  143950. height: number;
  143951. transcodedPixels: ArrayBufferView;
  143952. }>;
  143953. }>;
  143954. }
  143955. /**
  143956. * Result of transcoding a basis file
  143957. */
  143958. class TranscodeResult {
  143959. /**
  143960. * Info about the .basis file
  143961. */
  143962. fileInfo: BasisFileInfo;
  143963. /**
  143964. * Format to use when loading the file
  143965. */
  143966. format: number;
  143967. }
  143968. /**
  143969. * Configuration options for the Basis transcoder
  143970. */
  143971. export class BasisTranscodeConfiguration {
  143972. /**
  143973. * Supported compression formats used to determine the supported output format of the transcoder
  143974. */
  143975. supportedCompressionFormats?: {
  143976. /**
  143977. * etc1 compression format
  143978. */
  143979. etc1?: boolean;
  143980. /**
  143981. * s3tc compression format
  143982. */
  143983. s3tc?: boolean;
  143984. /**
  143985. * pvrtc compression format
  143986. */
  143987. pvrtc?: boolean;
  143988. /**
  143989. * etc2 compression format
  143990. */
  143991. etc2?: boolean;
  143992. };
  143993. /**
  143994. * If mipmap levels should be loaded for transcoded images (Default: true)
  143995. */
  143996. loadMipmapLevels?: boolean;
  143997. /**
  143998. * Index of a single image to load (Default: all images)
  143999. */
  144000. loadSingleImage?: number;
  144001. }
  144002. /**
  144003. * Used to load .Basis files
  144004. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  144005. */
  144006. export class BasisTools {
  144007. private static _IgnoreSupportedFormats;
  144008. /**
  144009. * URL to use when loading the basis transcoder
  144010. */
  144011. static JSModuleURL: string;
  144012. /**
  144013. * URL to use when loading the wasm module for the transcoder
  144014. */
  144015. static WasmModuleURL: string;
  144016. /**
  144017. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  144018. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  144019. * @returns internal format corresponding to the Basis format
  144020. */
  144021. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  144022. private static _WorkerPromise;
  144023. private static _Worker;
  144024. private static _actionId;
  144025. private static _CreateWorkerAsync;
  144026. /**
  144027. * Transcodes a loaded image file to compressed pixel data
  144028. * @param data image data to transcode
  144029. * @param config configuration options for the transcoding
  144030. * @returns a promise resulting in the transcoded image
  144031. */
  144032. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  144033. /**
  144034. * Loads a texture from the transcode result
  144035. * @param texture texture load to
  144036. * @param transcodeResult the result of transcoding the basis file to load from
  144037. */
  144038. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  144039. }
  144040. }
  144041. declare module BABYLON {
  144042. /**
  144043. * Loader for .basis file format
  144044. */
  144045. export class _BasisTextureLoader implements IInternalTextureLoader {
  144046. /**
  144047. * Defines whether the loader supports cascade loading the different faces.
  144048. */
  144049. readonly supportCascades: boolean;
  144050. /**
  144051. * This returns if the loader support the current file information.
  144052. * @param extension defines the file extension of the file being loaded
  144053. * @returns true if the loader can load the specified file
  144054. */
  144055. canLoad(extension: string): boolean;
  144056. /**
  144057. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  144058. * @param data contains the texture data
  144059. * @param texture defines the BabylonJS internal texture
  144060. * @param createPolynomials will be true if polynomials have been requested
  144061. * @param onLoad defines the callback to trigger once the texture is ready
  144062. * @param onError defines the callback to trigger in case of error
  144063. */
  144064. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  144065. /**
  144066. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  144067. * @param data contains the texture data
  144068. * @param texture defines the BabylonJS internal texture
  144069. * @param callback defines the method to call once ready to upload
  144070. */
  144071. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  144072. }
  144073. }
  144074. declare module BABYLON {
  144075. /**
  144076. * Defines the basic options interface of a TexturePacker Frame
  144077. */
  144078. export interface ITexturePackerFrame {
  144079. /**
  144080. * The frame ID
  144081. */
  144082. id: number;
  144083. /**
  144084. * The frames Scale
  144085. */
  144086. scale: Vector2;
  144087. /**
  144088. * The Frames offset
  144089. */
  144090. offset: Vector2;
  144091. }
  144092. /**
  144093. * This is a support class for frame Data on texture packer sets.
  144094. */
  144095. export class TexturePackerFrame implements ITexturePackerFrame {
  144096. /**
  144097. * The frame ID
  144098. */
  144099. id: number;
  144100. /**
  144101. * The frames Scale
  144102. */
  144103. scale: Vector2;
  144104. /**
  144105. * The Frames offset
  144106. */
  144107. offset: Vector2;
  144108. /**
  144109. * Initializes a texture package frame.
  144110. * @param id The numerical frame identifier
  144111. * @param scale Scalar Vector2 for UV frame
  144112. * @param offset Vector2 for the frame position in UV units.
  144113. * @returns TexturePackerFrame
  144114. */
  144115. constructor(id: number, scale: Vector2, offset: Vector2);
  144116. }
  144117. }
  144118. declare module BABYLON {
  144119. /**
  144120. * Defines the basic options interface of a TexturePacker
  144121. */
  144122. export interface ITexturePackerOptions {
  144123. /**
  144124. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  144125. */
  144126. map?: string[];
  144127. /**
  144128. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  144129. */
  144130. uvsIn?: string;
  144131. /**
  144132. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  144133. */
  144134. uvsOut?: string;
  144135. /**
  144136. * number representing the layout style. Defaults to LAYOUT_STRIP
  144137. */
  144138. layout?: number;
  144139. /**
  144140. * number of columns if using custom column count layout(2). This defaults to 4.
  144141. */
  144142. colnum?: number;
  144143. /**
  144144. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  144145. */
  144146. updateInputMeshes?: boolean;
  144147. /**
  144148. * boolean flag to dispose all the source textures. Defaults to true.
  144149. */
  144150. disposeSources?: boolean;
  144151. /**
  144152. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  144153. */
  144154. fillBlanks?: boolean;
  144155. /**
  144156. * string value representing the context fill style color. Defaults to 'black'.
  144157. */
  144158. customFillColor?: string;
  144159. /**
  144160. * Width and Height Value of each Frame in the TexturePacker Sets
  144161. */
  144162. frameSize?: number;
  144163. /**
  144164. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  144165. */
  144166. paddingRatio?: number;
  144167. /**
  144168. * Number that declares the fill method for the padding gutter.
  144169. */
  144170. paddingMode?: number;
  144171. /**
  144172. * If in SUBUV_COLOR padding mode what color to use.
  144173. */
  144174. paddingColor?: Color3 | Color4;
  144175. }
  144176. /**
  144177. * Defines the basic interface of a TexturePacker JSON File
  144178. */
  144179. export interface ITexturePackerJSON {
  144180. /**
  144181. * The frame ID
  144182. */
  144183. name: string;
  144184. /**
  144185. * The base64 channel data
  144186. */
  144187. sets: any;
  144188. /**
  144189. * The options of the Packer
  144190. */
  144191. options: ITexturePackerOptions;
  144192. /**
  144193. * The frame data of the Packer
  144194. */
  144195. frames: Array<number>;
  144196. }
  144197. /**
  144198. * This is a support class that generates a series of packed texture sets.
  144199. * @see https://doc.babylonjs.com/babylon101/materials
  144200. */
  144201. export class TexturePacker {
  144202. /** Packer Layout Constant 0 */
  144203. static readonly LAYOUT_STRIP: number;
  144204. /** Packer Layout Constant 1 */
  144205. static readonly LAYOUT_POWER2: number;
  144206. /** Packer Layout Constant 2 */
  144207. static readonly LAYOUT_COLNUM: number;
  144208. /** Packer Layout Constant 0 */
  144209. static readonly SUBUV_WRAP: number;
  144210. /** Packer Layout Constant 1 */
  144211. static readonly SUBUV_EXTEND: number;
  144212. /** Packer Layout Constant 2 */
  144213. static readonly SUBUV_COLOR: number;
  144214. /** The Name of the Texture Package */
  144215. name: string;
  144216. /** The scene scope of the TexturePacker */
  144217. scene: Scene;
  144218. /** The Meshes to target */
  144219. meshes: AbstractMesh[];
  144220. /** Arguments passed with the Constructor */
  144221. options: ITexturePackerOptions;
  144222. /** The promise that is started upon initialization */
  144223. promise: Nullable<Promise<TexturePacker | string>>;
  144224. /** The Container object for the channel sets that are generated */
  144225. sets: object;
  144226. /** The Container array for the frames that are generated */
  144227. frames: TexturePackerFrame[];
  144228. /** The expected number of textures the system is parsing. */
  144229. private _expecting;
  144230. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  144231. private _paddingValue;
  144232. /**
  144233. * Initializes a texture package series from an array of meshes or a single mesh.
  144234. * @param name The name of the package
  144235. * @param meshes The target meshes to compose the package from
  144236. * @param options The arguments that texture packer should follow while building.
  144237. * @param scene The scene which the textures are scoped to.
  144238. * @returns TexturePacker
  144239. */
  144240. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  144241. /**
  144242. * Starts the package process
  144243. * @param resolve The promises resolution function
  144244. * @returns TexturePacker
  144245. */
  144246. private _createFrames;
  144247. /**
  144248. * Calculates the Size of the Channel Sets
  144249. * @returns Vector2
  144250. */
  144251. private _calculateSize;
  144252. /**
  144253. * Calculates the UV data for the frames.
  144254. * @param baseSize the base frameSize
  144255. * @param padding the base frame padding
  144256. * @param dtSize size of the Dynamic Texture for that channel
  144257. * @param dtUnits is 1/dtSize
  144258. * @param update flag to update the input meshes
  144259. */
  144260. private _calculateMeshUVFrames;
  144261. /**
  144262. * Calculates the frames Offset.
  144263. * @param index of the frame
  144264. * @returns Vector2
  144265. */
  144266. private _getFrameOffset;
  144267. /**
  144268. * Updates a Mesh to the frame data
  144269. * @param mesh that is the target
  144270. * @param frameID or the frame index
  144271. */
  144272. private _updateMeshUV;
  144273. /**
  144274. * Updates a Meshes materials to use the texture packer channels
  144275. * @param m is the mesh to target
  144276. * @param force all channels on the packer to be set.
  144277. */
  144278. private _updateTextureReferences;
  144279. /**
  144280. * Public method to set a Mesh to a frame
  144281. * @param m that is the target
  144282. * @param frameID or the frame index
  144283. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  144284. */
  144285. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  144286. /**
  144287. * Starts the async promise to compile the texture packer.
  144288. * @returns Promise<void>
  144289. */
  144290. processAsync(): Promise<void>;
  144291. /**
  144292. * Disposes all textures associated with this packer
  144293. */
  144294. dispose(): void;
  144295. /**
  144296. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  144297. * @param imageType is the image type to use.
  144298. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  144299. */
  144300. download(imageType?: string, quality?: number): void;
  144301. /**
  144302. * Public method to load a texturePacker JSON file.
  144303. * @param data of the JSON file in string format.
  144304. */
  144305. updateFromJSON(data: string): void;
  144306. }
  144307. }
  144308. declare module BABYLON {
  144309. /**
  144310. * 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.
  144311. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  144312. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  144313. */
  144314. export class CustomProceduralTexture extends ProceduralTexture {
  144315. private _animate;
  144316. private _time;
  144317. private _config;
  144318. private _texturePath;
  144319. /**
  144320. * Instantiates a new Custom Procedural Texture.
  144321. * 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.
  144322. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  144323. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  144324. * @param name Define the name of the texture
  144325. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  144326. * @param size Define the size of the texture to create
  144327. * @param scene Define the scene the texture belongs to
  144328. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  144329. * @param generateMipMaps Define if the texture should creates mip maps or not
  144330. */
  144331. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  144332. private _loadJson;
  144333. /**
  144334. * Is the texture ready to be used ? (rendered at least once)
  144335. * @returns true if ready, otherwise, false.
  144336. */
  144337. isReady(): boolean;
  144338. /**
  144339. * Render the texture to its associated render target.
  144340. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  144341. */
  144342. render(useCameraPostProcess?: boolean): void;
  144343. /**
  144344. * Update the list of dependant textures samplers in the shader.
  144345. */
  144346. updateTextures(): void;
  144347. /**
  144348. * Update the uniform values of the procedural texture in the shader.
  144349. */
  144350. updateShaderUniforms(): void;
  144351. /**
  144352. * Define if the texture animates or not.
  144353. */
  144354. get animate(): boolean;
  144355. set animate(value: boolean);
  144356. }
  144357. }
  144358. declare module BABYLON {
  144359. /** @hidden */
  144360. export var noisePixelShader: {
  144361. name: string;
  144362. shader: string;
  144363. };
  144364. }
  144365. declare module BABYLON {
  144366. /**
  144367. * Class used to generate noise procedural textures
  144368. */
  144369. export class NoiseProceduralTexture extends ProceduralTexture {
  144370. /** Gets or sets the start time (default is 0) */
  144371. time: number;
  144372. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  144373. brightness: number;
  144374. /** Defines the number of octaves to process */
  144375. octaves: number;
  144376. /** Defines the level of persistence (0.8 by default) */
  144377. persistence: number;
  144378. /** Gets or sets animation speed factor (default is 1) */
  144379. animationSpeedFactor: number;
  144380. /**
  144381. * Creates a new NoiseProceduralTexture
  144382. * @param name defines the name fo the texture
  144383. * @param size defines the size of the texture (default is 256)
  144384. * @param scene defines the hosting scene
  144385. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  144386. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  144387. */
  144388. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  144389. private _updateShaderUniforms;
  144390. protected _getDefines(): string;
  144391. /** Generate the current state of the procedural texture */
  144392. render(useCameraPostProcess?: boolean): void;
  144393. /**
  144394. * Serializes this noise procedural texture
  144395. * @returns a serialized noise procedural texture object
  144396. */
  144397. serialize(): any;
  144398. /**
  144399. * Clone the texture.
  144400. * @returns the cloned texture
  144401. */
  144402. clone(): NoiseProceduralTexture;
  144403. /**
  144404. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  144405. * @param parsedTexture defines parsed texture data
  144406. * @param scene defines the current scene
  144407. * @param rootUrl defines the root URL containing noise procedural texture information
  144408. * @returns a parsed NoiseProceduralTexture
  144409. */
  144410. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  144411. }
  144412. }
  144413. declare module BABYLON {
  144414. /**
  144415. * Raw cube texture where the raw buffers are passed in
  144416. */
  144417. export class RawCubeTexture extends CubeTexture {
  144418. /**
  144419. * Creates a cube texture where the raw buffers are passed in.
  144420. * @param scene defines the scene the texture is attached to
  144421. * @param data defines the array of data to use to create each face
  144422. * @param size defines the size of the textures
  144423. * @param format defines the format of the data
  144424. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  144425. * @param generateMipMaps defines if the engine should generate the mip levels
  144426. * @param invertY defines if data must be stored with Y axis inverted
  144427. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  144428. * @param compression defines the compression used (null by default)
  144429. */
  144430. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  144431. /**
  144432. * Updates the raw cube texture.
  144433. * @param data defines the data to store
  144434. * @param format defines the data format
  144435. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  144436. * @param invertY defines if data must be stored with Y axis inverted
  144437. * @param compression defines the compression used (null by default)
  144438. * @param level defines which level of the texture to update
  144439. */
  144440. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  144441. /**
  144442. * Updates a raw cube texture with RGBD encoded data.
  144443. * @param data defines the array of data [mipmap][face] to use to create each face
  144444. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  144445. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  144446. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  144447. * @returns a promsie that resolves when the operation is complete
  144448. */
  144449. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  144450. /**
  144451. * Clones the raw cube texture.
  144452. * @return a new cube texture
  144453. */
  144454. clone(): CubeTexture;
  144455. /** @hidden */
  144456. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  144457. }
  144458. }
  144459. declare module BABYLON {
  144460. /**
  144461. * Class used to store 2D array textures containing user data
  144462. */
  144463. export class RawTexture2DArray extends Texture {
  144464. /** Gets or sets the texture format to use */
  144465. format: number;
  144466. /**
  144467. * Create a new RawTexture2DArray
  144468. * @param data defines the data of the texture
  144469. * @param width defines the width of the texture
  144470. * @param height defines the height of the texture
  144471. * @param depth defines the number of layers of the texture
  144472. * @param format defines the texture format to use
  144473. * @param scene defines the hosting scene
  144474. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  144475. * @param invertY defines if texture must be stored with Y axis inverted
  144476. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  144477. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  144478. */
  144479. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  144480. /** Gets or sets the texture format to use */
  144481. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  144482. /**
  144483. * Update the texture with new data
  144484. * @param data defines the data to store in the texture
  144485. */
  144486. update(data: ArrayBufferView): void;
  144487. }
  144488. }
  144489. declare module BABYLON {
  144490. /**
  144491. * Class used to store 3D textures containing user data
  144492. */
  144493. export class RawTexture3D extends Texture {
  144494. /** Gets or sets the texture format to use */
  144495. format: number;
  144496. /**
  144497. * Create a new RawTexture3D
  144498. * @param data defines the data of the texture
  144499. * @param width defines the width of the texture
  144500. * @param height defines the height of the texture
  144501. * @param depth defines the depth of the texture
  144502. * @param format defines the texture format to use
  144503. * @param scene defines the hosting scene
  144504. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  144505. * @param invertY defines if texture must be stored with Y axis inverted
  144506. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  144507. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  144508. */
  144509. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  144510. /** Gets or sets the texture format to use */
  144511. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  144512. /**
  144513. * Update the texture with new data
  144514. * @param data defines the data to store in the texture
  144515. */
  144516. update(data: ArrayBufferView): void;
  144517. }
  144518. }
  144519. declare module BABYLON {
  144520. /**
  144521. * Creates a refraction texture used by refraction channel of the standard material.
  144522. * It is like a mirror but to see through a material.
  144523. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  144524. */
  144525. export class RefractionTexture extends RenderTargetTexture {
  144526. /**
  144527. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  144528. * 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.
  144529. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  144530. */
  144531. refractionPlane: Plane;
  144532. /**
  144533. * Define how deep under the surface we should see.
  144534. */
  144535. depth: number;
  144536. /**
  144537. * Creates a refraction texture used by refraction channel of the standard material.
  144538. * It is like a mirror but to see through a material.
  144539. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  144540. * @param name Define the texture name
  144541. * @param size Define the size of the underlying texture
  144542. * @param scene Define the scene the refraction belongs to
  144543. * @param generateMipMaps Define if we need to generate mips level for the refraction
  144544. */
  144545. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  144546. /**
  144547. * Clone the refraction texture.
  144548. * @returns the cloned texture
  144549. */
  144550. clone(): RefractionTexture;
  144551. /**
  144552. * Serialize the texture to a JSON representation you could use in Parse later on
  144553. * @returns the serialized JSON representation
  144554. */
  144555. serialize(): any;
  144556. }
  144557. }
  144558. declare module BABYLON {
  144559. /**
  144560. * Block used to add support for vertex skinning (bones)
  144561. */
  144562. export class BonesBlock extends NodeMaterialBlock {
  144563. /**
  144564. * Creates a new BonesBlock
  144565. * @param name defines the block name
  144566. */
  144567. constructor(name: string);
  144568. /**
  144569. * Initialize the block and prepare the context for build
  144570. * @param state defines the state that will be used for the build
  144571. */
  144572. initialize(state: NodeMaterialBuildState): void;
  144573. /**
  144574. * Gets the current class name
  144575. * @returns the class name
  144576. */
  144577. getClassName(): string;
  144578. /**
  144579. * Gets the matrix indices input component
  144580. */
  144581. get matricesIndices(): NodeMaterialConnectionPoint;
  144582. /**
  144583. * Gets the matrix weights input component
  144584. */
  144585. get matricesWeights(): NodeMaterialConnectionPoint;
  144586. /**
  144587. * Gets the extra matrix indices input component
  144588. */
  144589. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  144590. /**
  144591. * Gets the extra matrix weights input component
  144592. */
  144593. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  144594. /**
  144595. * Gets the world input component
  144596. */
  144597. get world(): NodeMaterialConnectionPoint;
  144598. /**
  144599. * Gets the output component
  144600. */
  144601. get output(): NodeMaterialConnectionPoint;
  144602. autoConfigure(material: NodeMaterial): void;
  144603. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  144604. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144605. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144606. protected _buildBlock(state: NodeMaterialBuildState): this;
  144607. }
  144608. }
  144609. declare module BABYLON {
  144610. /**
  144611. * Block used to add support for instances
  144612. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  144613. */
  144614. export class InstancesBlock extends NodeMaterialBlock {
  144615. /**
  144616. * Creates a new InstancesBlock
  144617. * @param name defines the block name
  144618. */
  144619. constructor(name: string);
  144620. /**
  144621. * Gets the current class name
  144622. * @returns the class name
  144623. */
  144624. getClassName(): string;
  144625. /**
  144626. * Gets the first world row input component
  144627. */
  144628. get world0(): NodeMaterialConnectionPoint;
  144629. /**
  144630. * Gets the second world row input component
  144631. */
  144632. get world1(): NodeMaterialConnectionPoint;
  144633. /**
  144634. * Gets the third world row input component
  144635. */
  144636. get world2(): NodeMaterialConnectionPoint;
  144637. /**
  144638. * Gets the forth world row input component
  144639. */
  144640. get world3(): NodeMaterialConnectionPoint;
  144641. /**
  144642. * Gets the world input component
  144643. */
  144644. get world(): NodeMaterialConnectionPoint;
  144645. /**
  144646. * Gets the output component
  144647. */
  144648. get output(): NodeMaterialConnectionPoint;
  144649. /**
  144650. * Gets the isntanceID component
  144651. */
  144652. get instanceID(): NodeMaterialConnectionPoint;
  144653. autoConfigure(material: NodeMaterial): void;
  144654. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  144655. protected _buildBlock(state: NodeMaterialBuildState): this;
  144656. }
  144657. }
  144658. declare module BABYLON {
  144659. /**
  144660. * Block used to add morph targets support to vertex shader
  144661. */
  144662. export class MorphTargetsBlock extends NodeMaterialBlock {
  144663. private _repeatableContentAnchor;
  144664. /**
  144665. * Create a new MorphTargetsBlock
  144666. * @param name defines the block name
  144667. */
  144668. constructor(name: string);
  144669. /**
  144670. * Gets the current class name
  144671. * @returns the class name
  144672. */
  144673. getClassName(): string;
  144674. /**
  144675. * Gets the position input component
  144676. */
  144677. get position(): NodeMaterialConnectionPoint;
  144678. /**
  144679. * Gets the normal input component
  144680. */
  144681. get normal(): NodeMaterialConnectionPoint;
  144682. /**
  144683. * Gets the tangent input component
  144684. */
  144685. get tangent(): NodeMaterialConnectionPoint;
  144686. /**
  144687. * Gets the tangent input component
  144688. */
  144689. get uv(): NodeMaterialConnectionPoint;
  144690. /**
  144691. * Gets the position output component
  144692. */
  144693. get positionOutput(): NodeMaterialConnectionPoint;
  144694. /**
  144695. * Gets the normal output component
  144696. */
  144697. get normalOutput(): NodeMaterialConnectionPoint;
  144698. /**
  144699. * Gets the tangent output component
  144700. */
  144701. get tangentOutput(): NodeMaterialConnectionPoint;
  144702. /**
  144703. * Gets the tangent output component
  144704. */
  144705. get uvOutput(): NodeMaterialConnectionPoint;
  144706. initialize(state: NodeMaterialBuildState): void;
  144707. autoConfigure(material: NodeMaterial): void;
  144708. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144709. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144710. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  144711. protected _buildBlock(state: NodeMaterialBuildState): this;
  144712. }
  144713. }
  144714. declare module BABYLON {
  144715. /**
  144716. * Block used to get data information from a light
  144717. */
  144718. export class LightInformationBlock extends NodeMaterialBlock {
  144719. private _lightDataUniformName;
  144720. private _lightColorUniformName;
  144721. private _lightTypeDefineName;
  144722. /**
  144723. * Gets or sets the light associated with this block
  144724. */
  144725. light: Nullable<Light>;
  144726. /**
  144727. * Creates a new LightInformationBlock
  144728. * @param name defines the block name
  144729. */
  144730. constructor(name: string);
  144731. /**
  144732. * Gets the current class name
  144733. * @returns the class name
  144734. */
  144735. getClassName(): string;
  144736. /**
  144737. * Gets the world position input component
  144738. */
  144739. get worldPosition(): NodeMaterialConnectionPoint;
  144740. /**
  144741. * Gets the direction output component
  144742. */
  144743. get direction(): NodeMaterialConnectionPoint;
  144744. /**
  144745. * Gets the direction output component
  144746. */
  144747. get color(): NodeMaterialConnectionPoint;
  144748. /**
  144749. * Gets the direction output component
  144750. */
  144751. get intensity(): NodeMaterialConnectionPoint;
  144752. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144754. protected _buildBlock(state: NodeMaterialBuildState): this;
  144755. serialize(): any;
  144756. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144757. }
  144758. }
  144759. declare module BABYLON {
  144760. /**
  144761. * Block used to add image processing support to fragment shader
  144762. */
  144763. export class ImageProcessingBlock extends NodeMaterialBlock {
  144764. /**
  144765. * Create a new ImageProcessingBlock
  144766. * @param name defines the block name
  144767. */
  144768. constructor(name: string);
  144769. /**
  144770. * Gets the current class name
  144771. * @returns the class name
  144772. */
  144773. getClassName(): string;
  144774. /**
  144775. * Gets the color input component
  144776. */
  144777. get color(): NodeMaterialConnectionPoint;
  144778. /**
  144779. * Gets the output component
  144780. */
  144781. get output(): NodeMaterialConnectionPoint;
  144782. /**
  144783. * Initialize the block and prepare the context for build
  144784. * @param state defines the state that will be used for the build
  144785. */
  144786. initialize(state: NodeMaterialBuildState): void;
  144787. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  144788. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144789. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144790. protected _buildBlock(state: NodeMaterialBuildState): this;
  144791. }
  144792. }
  144793. declare module BABYLON {
  144794. /**
  144795. * Block used to pertub normals based on a normal map
  144796. */
  144797. export class PerturbNormalBlock extends NodeMaterialBlock {
  144798. private _tangentSpaceParameterName;
  144799. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144800. invertX: boolean;
  144801. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  144802. invertY: boolean;
  144803. /**
  144804. * Create a new PerturbNormalBlock
  144805. * @param name defines the block name
  144806. */
  144807. constructor(name: string);
  144808. /**
  144809. * Gets the current class name
  144810. * @returns the class name
  144811. */
  144812. getClassName(): string;
  144813. /**
  144814. * Gets the world position input component
  144815. */
  144816. get worldPosition(): NodeMaterialConnectionPoint;
  144817. /**
  144818. * Gets the world normal input component
  144819. */
  144820. get worldNormal(): NodeMaterialConnectionPoint;
  144821. /**
  144822. * Gets the world tangent input component
  144823. */
  144824. get worldTangent(): NodeMaterialConnectionPoint;
  144825. /**
  144826. * Gets the uv input component
  144827. */
  144828. get uv(): NodeMaterialConnectionPoint;
  144829. /**
  144830. * Gets the normal map color input component
  144831. */
  144832. get normalMapColor(): NodeMaterialConnectionPoint;
  144833. /**
  144834. * Gets the strength input component
  144835. */
  144836. get strength(): NodeMaterialConnectionPoint;
  144837. /**
  144838. * Gets the output component
  144839. */
  144840. get output(): NodeMaterialConnectionPoint;
  144841. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144842. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144843. autoConfigure(material: NodeMaterial): void;
  144844. protected _buildBlock(state: NodeMaterialBuildState): this;
  144845. protected _dumpPropertiesCode(): string;
  144846. serialize(): any;
  144847. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144848. }
  144849. }
  144850. declare module BABYLON {
  144851. /**
  144852. * Block used to discard a pixel if a value is smaller than a cutoff
  144853. */
  144854. export class DiscardBlock extends NodeMaterialBlock {
  144855. /**
  144856. * Create a new DiscardBlock
  144857. * @param name defines the block name
  144858. */
  144859. constructor(name: string);
  144860. /**
  144861. * Gets the current class name
  144862. * @returns the class name
  144863. */
  144864. getClassName(): string;
  144865. /**
  144866. * Gets the color input component
  144867. */
  144868. get value(): NodeMaterialConnectionPoint;
  144869. /**
  144870. * Gets the cutoff input component
  144871. */
  144872. get cutoff(): NodeMaterialConnectionPoint;
  144873. protected _buildBlock(state: NodeMaterialBuildState): this;
  144874. }
  144875. }
  144876. declare module BABYLON {
  144877. /**
  144878. * Block used to test if the fragment shader is front facing
  144879. */
  144880. export class FrontFacingBlock extends NodeMaterialBlock {
  144881. /**
  144882. * Creates a new FrontFacingBlock
  144883. * @param name defines the block name
  144884. */
  144885. constructor(name: string);
  144886. /**
  144887. * Gets the current class name
  144888. * @returns the class name
  144889. */
  144890. getClassName(): string;
  144891. /**
  144892. * Gets the output component
  144893. */
  144894. get output(): NodeMaterialConnectionPoint;
  144895. protected _buildBlock(state: NodeMaterialBuildState): this;
  144896. }
  144897. }
  144898. declare module BABYLON {
  144899. /**
  144900. * Block used to get the derivative value on x and y of a given input
  144901. */
  144902. export class DerivativeBlock extends NodeMaterialBlock {
  144903. /**
  144904. * Create a new DerivativeBlock
  144905. * @param name defines the block name
  144906. */
  144907. constructor(name: string);
  144908. /**
  144909. * Gets the current class name
  144910. * @returns the class name
  144911. */
  144912. getClassName(): string;
  144913. /**
  144914. * Gets the input component
  144915. */
  144916. get input(): NodeMaterialConnectionPoint;
  144917. /**
  144918. * Gets the derivative output on x
  144919. */
  144920. get dx(): NodeMaterialConnectionPoint;
  144921. /**
  144922. * Gets the derivative output on y
  144923. */
  144924. get dy(): NodeMaterialConnectionPoint;
  144925. protected _buildBlock(state: NodeMaterialBuildState): this;
  144926. }
  144927. }
  144928. declare module BABYLON {
  144929. /**
  144930. * Block used to make gl_FragCoord available
  144931. */
  144932. export class FragCoordBlock extends NodeMaterialBlock {
  144933. /**
  144934. * Creates a new FragCoordBlock
  144935. * @param name defines the block name
  144936. */
  144937. constructor(name: string);
  144938. /**
  144939. * Gets the current class name
  144940. * @returns the class name
  144941. */
  144942. getClassName(): string;
  144943. /**
  144944. * Gets the xy component
  144945. */
  144946. get xy(): NodeMaterialConnectionPoint;
  144947. /**
  144948. * Gets the xyz component
  144949. */
  144950. get xyz(): NodeMaterialConnectionPoint;
  144951. /**
  144952. * Gets the xyzw component
  144953. */
  144954. get xyzw(): NodeMaterialConnectionPoint;
  144955. /**
  144956. * Gets the x component
  144957. */
  144958. get x(): NodeMaterialConnectionPoint;
  144959. /**
  144960. * Gets the y component
  144961. */
  144962. get y(): NodeMaterialConnectionPoint;
  144963. /**
  144964. * Gets the z component
  144965. */
  144966. get z(): NodeMaterialConnectionPoint;
  144967. /**
  144968. * Gets the w component
  144969. */
  144970. get output(): NodeMaterialConnectionPoint;
  144971. protected writeOutputs(state: NodeMaterialBuildState): string;
  144972. protected _buildBlock(state: NodeMaterialBuildState): this;
  144973. }
  144974. }
  144975. declare module BABYLON {
  144976. /**
  144977. * Block used to get the screen sizes
  144978. */
  144979. export class ScreenSizeBlock extends NodeMaterialBlock {
  144980. private _varName;
  144981. private _scene;
  144982. /**
  144983. * Creates a new ScreenSizeBlock
  144984. * @param name defines the block name
  144985. */
  144986. constructor(name: string);
  144987. /**
  144988. * Gets the current class name
  144989. * @returns the class name
  144990. */
  144991. getClassName(): string;
  144992. /**
  144993. * Gets the xy component
  144994. */
  144995. get xy(): NodeMaterialConnectionPoint;
  144996. /**
  144997. * Gets the x component
  144998. */
  144999. get x(): NodeMaterialConnectionPoint;
  145000. /**
  145001. * Gets the y component
  145002. */
  145003. get y(): NodeMaterialConnectionPoint;
  145004. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145005. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  145006. protected _buildBlock(state: NodeMaterialBuildState): this;
  145007. }
  145008. }
  145009. declare module BABYLON {
  145010. /**
  145011. * Block used to add support for scene fog
  145012. */
  145013. export class FogBlock extends NodeMaterialBlock {
  145014. private _fogDistanceName;
  145015. private _fogParameters;
  145016. /**
  145017. * Create a new FogBlock
  145018. * @param name defines the block name
  145019. */
  145020. constructor(name: string);
  145021. /**
  145022. * Gets the current class name
  145023. * @returns the class name
  145024. */
  145025. getClassName(): string;
  145026. /**
  145027. * Gets the world position input component
  145028. */
  145029. get worldPosition(): NodeMaterialConnectionPoint;
  145030. /**
  145031. * Gets the view input component
  145032. */
  145033. get view(): NodeMaterialConnectionPoint;
  145034. /**
  145035. * Gets the color input component
  145036. */
  145037. get input(): NodeMaterialConnectionPoint;
  145038. /**
  145039. * Gets the fog color input component
  145040. */
  145041. get fogColor(): NodeMaterialConnectionPoint;
  145042. /**
  145043. * Gets the output component
  145044. */
  145045. get output(): NodeMaterialConnectionPoint;
  145046. autoConfigure(material: NodeMaterial): void;
  145047. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145048. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145049. protected _buildBlock(state: NodeMaterialBuildState): this;
  145050. }
  145051. }
  145052. declare module BABYLON {
  145053. /**
  145054. * Block used to add light in the fragment shader
  145055. */
  145056. export class LightBlock extends NodeMaterialBlock {
  145057. private _lightId;
  145058. /**
  145059. * Gets or sets the light associated with this block
  145060. */
  145061. light: Nullable<Light>;
  145062. /**
  145063. * Create a new LightBlock
  145064. * @param name defines the block name
  145065. */
  145066. constructor(name: string);
  145067. /**
  145068. * Gets the current class name
  145069. * @returns the class name
  145070. */
  145071. getClassName(): string;
  145072. /**
  145073. * Gets the world position input component
  145074. */
  145075. get worldPosition(): NodeMaterialConnectionPoint;
  145076. /**
  145077. * Gets the world normal input component
  145078. */
  145079. get worldNormal(): NodeMaterialConnectionPoint;
  145080. /**
  145081. * Gets the camera (or eye) position component
  145082. */
  145083. get cameraPosition(): NodeMaterialConnectionPoint;
  145084. /**
  145085. * Gets the glossiness component
  145086. */
  145087. get glossiness(): NodeMaterialConnectionPoint;
  145088. /**
  145089. * Gets the glossinness power component
  145090. */
  145091. get glossPower(): NodeMaterialConnectionPoint;
  145092. /**
  145093. * Gets the diffuse color component
  145094. */
  145095. get diffuseColor(): NodeMaterialConnectionPoint;
  145096. /**
  145097. * Gets the specular color component
  145098. */
  145099. get specularColor(): NodeMaterialConnectionPoint;
  145100. /**
  145101. * Gets the view matrix component
  145102. */
  145103. get view(): NodeMaterialConnectionPoint;
  145104. /**
  145105. * Gets the diffuse output component
  145106. */
  145107. get diffuseOutput(): NodeMaterialConnectionPoint;
  145108. /**
  145109. * Gets the specular output component
  145110. */
  145111. get specularOutput(): NodeMaterialConnectionPoint;
  145112. /**
  145113. * Gets the shadow output component
  145114. */
  145115. get shadow(): NodeMaterialConnectionPoint;
  145116. autoConfigure(material: NodeMaterial): void;
  145117. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145118. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145119. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145120. private _injectVertexCode;
  145121. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145122. serialize(): any;
  145123. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145124. }
  145125. }
  145126. declare module BABYLON {
  145127. /**
  145128. * Block used to read a reflection texture from a sampler
  145129. */
  145130. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  145131. /**
  145132. * Create a new ReflectionTextureBlock
  145133. * @param name defines the block name
  145134. */
  145135. constructor(name: string);
  145136. /**
  145137. * Gets the current class name
  145138. * @returns the class name
  145139. */
  145140. getClassName(): string;
  145141. /**
  145142. * Gets the world position input component
  145143. */
  145144. get position(): NodeMaterialConnectionPoint;
  145145. /**
  145146. * Gets the world position input component
  145147. */
  145148. get worldPosition(): NodeMaterialConnectionPoint;
  145149. /**
  145150. * Gets the world normal input component
  145151. */
  145152. get worldNormal(): NodeMaterialConnectionPoint;
  145153. /**
  145154. * Gets the world input component
  145155. */
  145156. get world(): NodeMaterialConnectionPoint;
  145157. /**
  145158. * Gets the camera (or eye) position component
  145159. */
  145160. get cameraPosition(): NodeMaterialConnectionPoint;
  145161. /**
  145162. * Gets the view input component
  145163. */
  145164. get view(): NodeMaterialConnectionPoint;
  145165. /**
  145166. * Gets the rgb output component
  145167. */
  145168. get rgb(): NodeMaterialConnectionPoint;
  145169. /**
  145170. * Gets the rgba output component
  145171. */
  145172. get rgba(): NodeMaterialConnectionPoint;
  145173. /**
  145174. * Gets the r output component
  145175. */
  145176. get r(): NodeMaterialConnectionPoint;
  145177. /**
  145178. * Gets the g output component
  145179. */
  145180. get g(): NodeMaterialConnectionPoint;
  145181. /**
  145182. * Gets the b output component
  145183. */
  145184. get b(): NodeMaterialConnectionPoint;
  145185. /**
  145186. * Gets the a output component
  145187. */
  145188. get a(): NodeMaterialConnectionPoint;
  145189. autoConfigure(material: NodeMaterial): void;
  145190. protected _buildBlock(state: NodeMaterialBuildState): this;
  145191. }
  145192. }
  145193. declare module BABYLON {
  145194. /**
  145195. * Block used to add 2 vectors
  145196. */
  145197. export class AddBlock extends NodeMaterialBlock {
  145198. /**
  145199. * Creates a new AddBlock
  145200. * @param name defines the block name
  145201. */
  145202. constructor(name: string);
  145203. /**
  145204. * Gets the current class name
  145205. * @returns the class name
  145206. */
  145207. getClassName(): string;
  145208. /**
  145209. * Gets the left operand input component
  145210. */
  145211. get left(): NodeMaterialConnectionPoint;
  145212. /**
  145213. * Gets the right operand input component
  145214. */
  145215. get right(): NodeMaterialConnectionPoint;
  145216. /**
  145217. * Gets the output component
  145218. */
  145219. get output(): NodeMaterialConnectionPoint;
  145220. protected _buildBlock(state: NodeMaterialBuildState): this;
  145221. }
  145222. }
  145223. declare module BABYLON {
  145224. /**
  145225. * Block used to scale a vector by a float
  145226. */
  145227. export class ScaleBlock extends NodeMaterialBlock {
  145228. /**
  145229. * Creates a new ScaleBlock
  145230. * @param name defines the block name
  145231. */
  145232. constructor(name: string);
  145233. /**
  145234. * Gets the current class name
  145235. * @returns the class name
  145236. */
  145237. getClassName(): string;
  145238. /**
  145239. * Gets the input component
  145240. */
  145241. get input(): NodeMaterialConnectionPoint;
  145242. /**
  145243. * Gets the factor input component
  145244. */
  145245. get factor(): NodeMaterialConnectionPoint;
  145246. /**
  145247. * Gets the output component
  145248. */
  145249. get output(): NodeMaterialConnectionPoint;
  145250. protected _buildBlock(state: NodeMaterialBuildState): this;
  145251. }
  145252. }
  145253. declare module BABYLON {
  145254. /**
  145255. * Block used to clamp a float
  145256. */
  145257. export class ClampBlock extends NodeMaterialBlock {
  145258. /** Gets or sets the minimum range */
  145259. minimum: number;
  145260. /** Gets or sets the maximum range */
  145261. maximum: number;
  145262. /**
  145263. * Creates a new ClampBlock
  145264. * @param name defines the block name
  145265. */
  145266. constructor(name: string);
  145267. /**
  145268. * Gets the current class name
  145269. * @returns the class name
  145270. */
  145271. getClassName(): string;
  145272. /**
  145273. * Gets the value input component
  145274. */
  145275. get value(): NodeMaterialConnectionPoint;
  145276. /**
  145277. * Gets the output component
  145278. */
  145279. get output(): NodeMaterialConnectionPoint;
  145280. protected _buildBlock(state: NodeMaterialBuildState): this;
  145281. protected _dumpPropertiesCode(): string;
  145282. serialize(): any;
  145283. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145284. }
  145285. }
  145286. declare module BABYLON {
  145287. /**
  145288. * Block used to apply a cross product between 2 vectors
  145289. */
  145290. export class CrossBlock extends NodeMaterialBlock {
  145291. /**
  145292. * Creates a new CrossBlock
  145293. * @param name defines the block name
  145294. */
  145295. constructor(name: string);
  145296. /**
  145297. * Gets the current class name
  145298. * @returns the class name
  145299. */
  145300. getClassName(): string;
  145301. /**
  145302. * Gets the left operand input component
  145303. */
  145304. get left(): NodeMaterialConnectionPoint;
  145305. /**
  145306. * Gets the right operand input component
  145307. */
  145308. get right(): NodeMaterialConnectionPoint;
  145309. /**
  145310. * Gets the output component
  145311. */
  145312. get output(): NodeMaterialConnectionPoint;
  145313. protected _buildBlock(state: NodeMaterialBuildState): this;
  145314. }
  145315. }
  145316. declare module BABYLON {
  145317. /**
  145318. * Block used to apply a dot product between 2 vectors
  145319. */
  145320. export class DotBlock extends NodeMaterialBlock {
  145321. /**
  145322. * Creates a new DotBlock
  145323. * @param name defines the block name
  145324. */
  145325. constructor(name: string);
  145326. /**
  145327. * Gets the current class name
  145328. * @returns the class name
  145329. */
  145330. getClassName(): string;
  145331. /**
  145332. * Gets the left operand input component
  145333. */
  145334. get left(): NodeMaterialConnectionPoint;
  145335. /**
  145336. * Gets the right operand input component
  145337. */
  145338. get right(): NodeMaterialConnectionPoint;
  145339. /**
  145340. * Gets the output component
  145341. */
  145342. get output(): NodeMaterialConnectionPoint;
  145343. protected _buildBlock(state: NodeMaterialBuildState): this;
  145344. }
  145345. }
  145346. declare module BABYLON {
  145347. /**
  145348. * Block used to normalize a vector
  145349. */
  145350. export class NormalizeBlock extends NodeMaterialBlock {
  145351. /**
  145352. * Creates a new NormalizeBlock
  145353. * @param name defines the block name
  145354. */
  145355. constructor(name: string);
  145356. /**
  145357. * Gets the current class name
  145358. * @returns the class name
  145359. */
  145360. getClassName(): string;
  145361. /**
  145362. * Gets the input component
  145363. */
  145364. get input(): NodeMaterialConnectionPoint;
  145365. /**
  145366. * Gets the output component
  145367. */
  145368. get output(): NodeMaterialConnectionPoint;
  145369. protected _buildBlock(state: NodeMaterialBuildState): this;
  145370. }
  145371. }
  145372. declare module BABYLON {
  145373. /**
  145374. * Block used to create a Color3/4 out of individual inputs (one for each component)
  145375. */
  145376. export class ColorMergerBlock extends NodeMaterialBlock {
  145377. /**
  145378. * Create a new ColorMergerBlock
  145379. * @param name defines the block name
  145380. */
  145381. constructor(name: string);
  145382. /**
  145383. * Gets the current class name
  145384. * @returns the class name
  145385. */
  145386. getClassName(): string;
  145387. /**
  145388. * Gets the rgb component (input)
  145389. */
  145390. get rgbIn(): NodeMaterialConnectionPoint;
  145391. /**
  145392. * Gets the r component (input)
  145393. */
  145394. get r(): NodeMaterialConnectionPoint;
  145395. /**
  145396. * Gets the g component (input)
  145397. */
  145398. get g(): NodeMaterialConnectionPoint;
  145399. /**
  145400. * Gets the b component (input)
  145401. */
  145402. get b(): NodeMaterialConnectionPoint;
  145403. /**
  145404. * Gets the a component (input)
  145405. */
  145406. get a(): NodeMaterialConnectionPoint;
  145407. /**
  145408. * Gets the rgba component (output)
  145409. */
  145410. get rgba(): NodeMaterialConnectionPoint;
  145411. /**
  145412. * Gets the rgb component (output)
  145413. */
  145414. get rgbOut(): NodeMaterialConnectionPoint;
  145415. /**
  145416. * Gets the rgb component (output)
  145417. * @deprecated Please use rgbOut instead.
  145418. */
  145419. get rgb(): NodeMaterialConnectionPoint;
  145420. protected _buildBlock(state: NodeMaterialBuildState): this;
  145421. }
  145422. }
  145423. declare module BABYLON {
  145424. /**
  145425. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  145426. */
  145427. export class VectorSplitterBlock extends NodeMaterialBlock {
  145428. /**
  145429. * Create a new VectorSplitterBlock
  145430. * @param name defines the block name
  145431. */
  145432. constructor(name: string);
  145433. /**
  145434. * Gets the current class name
  145435. * @returns the class name
  145436. */
  145437. getClassName(): string;
  145438. /**
  145439. * Gets the xyzw component (input)
  145440. */
  145441. get xyzw(): NodeMaterialConnectionPoint;
  145442. /**
  145443. * Gets the xyz component (input)
  145444. */
  145445. get xyzIn(): NodeMaterialConnectionPoint;
  145446. /**
  145447. * Gets the xy component (input)
  145448. */
  145449. get xyIn(): NodeMaterialConnectionPoint;
  145450. /**
  145451. * Gets the xyz component (output)
  145452. */
  145453. get xyzOut(): NodeMaterialConnectionPoint;
  145454. /**
  145455. * Gets the xy component (output)
  145456. */
  145457. get xyOut(): NodeMaterialConnectionPoint;
  145458. /**
  145459. * Gets the x component (output)
  145460. */
  145461. get x(): NodeMaterialConnectionPoint;
  145462. /**
  145463. * Gets the y component (output)
  145464. */
  145465. get y(): NodeMaterialConnectionPoint;
  145466. /**
  145467. * Gets the z component (output)
  145468. */
  145469. get z(): NodeMaterialConnectionPoint;
  145470. /**
  145471. * Gets the w component (output)
  145472. */
  145473. get w(): NodeMaterialConnectionPoint;
  145474. protected _inputRename(name: string): string;
  145475. protected _outputRename(name: string): string;
  145476. protected _buildBlock(state: NodeMaterialBuildState): this;
  145477. }
  145478. }
  145479. declare module BABYLON {
  145480. /**
  145481. * Block used to lerp between 2 values
  145482. */
  145483. export class LerpBlock extends NodeMaterialBlock {
  145484. /**
  145485. * Creates a new LerpBlock
  145486. * @param name defines the block name
  145487. */
  145488. constructor(name: string);
  145489. /**
  145490. * Gets the current class name
  145491. * @returns the class name
  145492. */
  145493. getClassName(): string;
  145494. /**
  145495. * Gets the left operand input component
  145496. */
  145497. get left(): NodeMaterialConnectionPoint;
  145498. /**
  145499. * Gets the right operand input component
  145500. */
  145501. get right(): NodeMaterialConnectionPoint;
  145502. /**
  145503. * Gets the gradient operand input component
  145504. */
  145505. get gradient(): NodeMaterialConnectionPoint;
  145506. /**
  145507. * Gets the output component
  145508. */
  145509. get output(): NodeMaterialConnectionPoint;
  145510. protected _buildBlock(state: NodeMaterialBuildState): this;
  145511. }
  145512. }
  145513. declare module BABYLON {
  145514. /**
  145515. * Block used to divide 2 vectors
  145516. */
  145517. export class DivideBlock extends NodeMaterialBlock {
  145518. /**
  145519. * Creates a new DivideBlock
  145520. * @param name defines the block name
  145521. */
  145522. constructor(name: string);
  145523. /**
  145524. * Gets the current class name
  145525. * @returns the class name
  145526. */
  145527. getClassName(): string;
  145528. /**
  145529. * Gets the left operand input component
  145530. */
  145531. get left(): NodeMaterialConnectionPoint;
  145532. /**
  145533. * Gets the right operand input component
  145534. */
  145535. get right(): NodeMaterialConnectionPoint;
  145536. /**
  145537. * Gets the output component
  145538. */
  145539. get output(): NodeMaterialConnectionPoint;
  145540. protected _buildBlock(state: NodeMaterialBuildState): this;
  145541. }
  145542. }
  145543. declare module BABYLON {
  145544. /**
  145545. * Block used to subtract 2 vectors
  145546. */
  145547. export class SubtractBlock extends NodeMaterialBlock {
  145548. /**
  145549. * Creates a new SubtractBlock
  145550. * @param name defines the block name
  145551. */
  145552. constructor(name: string);
  145553. /**
  145554. * Gets the current class name
  145555. * @returns the class name
  145556. */
  145557. getClassName(): string;
  145558. /**
  145559. * Gets the left operand input component
  145560. */
  145561. get left(): NodeMaterialConnectionPoint;
  145562. /**
  145563. * Gets the right operand input component
  145564. */
  145565. get right(): NodeMaterialConnectionPoint;
  145566. /**
  145567. * Gets the output component
  145568. */
  145569. get output(): NodeMaterialConnectionPoint;
  145570. protected _buildBlock(state: NodeMaterialBuildState): this;
  145571. }
  145572. }
  145573. declare module BABYLON {
  145574. /**
  145575. * Block used to step a value
  145576. */
  145577. export class StepBlock extends NodeMaterialBlock {
  145578. /**
  145579. * Creates a new StepBlock
  145580. * @param name defines the block name
  145581. */
  145582. constructor(name: string);
  145583. /**
  145584. * Gets the current class name
  145585. * @returns the class name
  145586. */
  145587. getClassName(): string;
  145588. /**
  145589. * Gets the value operand input component
  145590. */
  145591. get value(): NodeMaterialConnectionPoint;
  145592. /**
  145593. * Gets the edge operand input component
  145594. */
  145595. get edge(): NodeMaterialConnectionPoint;
  145596. /**
  145597. * Gets the output component
  145598. */
  145599. get output(): NodeMaterialConnectionPoint;
  145600. protected _buildBlock(state: NodeMaterialBuildState): this;
  145601. }
  145602. }
  145603. declare module BABYLON {
  145604. /**
  145605. * Block used to get the opposite (1 - x) of a value
  145606. */
  145607. export class OneMinusBlock extends NodeMaterialBlock {
  145608. /**
  145609. * Creates a new OneMinusBlock
  145610. * @param name defines the block name
  145611. */
  145612. constructor(name: string);
  145613. /**
  145614. * Gets the current class name
  145615. * @returns the class name
  145616. */
  145617. getClassName(): string;
  145618. /**
  145619. * Gets the input component
  145620. */
  145621. get input(): NodeMaterialConnectionPoint;
  145622. /**
  145623. * Gets the output component
  145624. */
  145625. get output(): NodeMaterialConnectionPoint;
  145626. protected _buildBlock(state: NodeMaterialBuildState): this;
  145627. }
  145628. }
  145629. declare module BABYLON {
  145630. /**
  145631. * Block used to get the view direction
  145632. */
  145633. export class ViewDirectionBlock extends NodeMaterialBlock {
  145634. /**
  145635. * Creates a new ViewDirectionBlock
  145636. * @param name defines the block name
  145637. */
  145638. constructor(name: string);
  145639. /**
  145640. * Gets the current class name
  145641. * @returns the class name
  145642. */
  145643. getClassName(): string;
  145644. /**
  145645. * Gets the world position component
  145646. */
  145647. get worldPosition(): NodeMaterialConnectionPoint;
  145648. /**
  145649. * Gets the camera position component
  145650. */
  145651. get cameraPosition(): NodeMaterialConnectionPoint;
  145652. /**
  145653. * Gets the output component
  145654. */
  145655. get output(): NodeMaterialConnectionPoint;
  145656. autoConfigure(material: NodeMaterial): void;
  145657. protected _buildBlock(state: NodeMaterialBuildState): this;
  145658. }
  145659. }
  145660. declare module BABYLON {
  145661. /**
  145662. * Block used to compute fresnel value
  145663. */
  145664. export class FresnelBlock extends NodeMaterialBlock {
  145665. /**
  145666. * Create a new FresnelBlock
  145667. * @param name defines the block name
  145668. */
  145669. constructor(name: string);
  145670. /**
  145671. * Gets the current class name
  145672. * @returns the class name
  145673. */
  145674. getClassName(): string;
  145675. /**
  145676. * Gets the world normal input component
  145677. */
  145678. get worldNormal(): NodeMaterialConnectionPoint;
  145679. /**
  145680. * Gets the view direction input component
  145681. */
  145682. get viewDirection(): NodeMaterialConnectionPoint;
  145683. /**
  145684. * Gets the bias input component
  145685. */
  145686. get bias(): NodeMaterialConnectionPoint;
  145687. /**
  145688. * Gets the camera (or eye) position component
  145689. */
  145690. get power(): NodeMaterialConnectionPoint;
  145691. /**
  145692. * Gets the fresnel output component
  145693. */
  145694. get fresnel(): NodeMaterialConnectionPoint;
  145695. autoConfigure(material: NodeMaterial): void;
  145696. protected _buildBlock(state: NodeMaterialBuildState): this;
  145697. }
  145698. }
  145699. declare module BABYLON {
  145700. /**
  145701. * Block used to get the max of 2 values
  145702. */
  145703. export class MaxBlock extends NodeMaterialBlock {
  145704. /**
  145705. * Creates a new MaxBlock
  145706. * @param name defines the block name
  145707. */
  145708. constructor(name: string);
  145709. /**
  145710. * Gets the current class name
  145711. * @returns the class name
  145712. */
  145713. getClassName(): string;
  145714. /**
  145715. * Gets the left operand input component
  145716. */
  145717. get left(): NodeMaterialConnectionPoint;
  145718. /**
  145719. * Gets the right operand input component
  145720. */
  145721. get right(): NodeMaterialConnectionPoint;
  145722. /**
  145723. * Gets the output component
  145724. */
  145725. get output(): NodeMaterialConnectionPoint;
  145726. protected _buildBlock(state: NodeMaterialBuildState): this;
  145727. }
  145728. }
  145729. declare module BABYLON {
  145730. /**
  145731. * Block used to get the min of 2 values
  145732. */
  145733. export class MinBlock extends NodeMaterialBlock {
  145734. /**
  145735. * Creates a new MinBlock
  145736. * @param name defines the block name
  145737. */
  145738. constructor(name: string);
  145739. /**
  145740. * Gets the current class name
  145741. * @returns the class name
  145742. */
  145743. getClassName(): string;
  145744. /**
  145745. * Gets the left operand input component
  145746. */
  145747. get left(): NodeMaterialConnectionPoint;
  145748. /**
  145749. * Gets the right operand input component
  145750. */
  145751. get right(): NodeMaterialConnectionPoint;
  145752. /**
  145753. * Gets the output component
  145754. */
  145755. get output(): NodeMaterialConnectionPoint;
  145756. protected _buildBlock(state: NodeMaterialBuildState): this;
  145757. }
  145758. }
  145759. declare module BABYLON {
  145760. /**
  145761. * Block used to get the distance between 2 values
  145762. */
  145763. export class DistanceBlock extends NodeMaterialBlock {
  145764. /**
  145765. * Creates a new DistanceBlock
  145766. * @param name defines the block name
  145767. */
  145768. constructor(name: string);
  145769. /**
  145770. * Gets the current class name
  145771. * @returns the class name
  145772. */
  145773. getClassName(): string;
  145774. /**
  145775. * Gets the left operand input component
  145776. */
  145777. get left(): NodeMaterialConnectionPoint;
  145778. /**
  145779. * Gets the right operand input component
  145780. */
  145781. get right(): NodeMaterialConnectionPoint;
  145782. /**
  145783. * Gets the output component
  145784. */
  145785. get output(): NodeMaterialConnectionPoint;
  145786. protected _buildBlock(state: NodeMaterialBuildState): this;
  145787. }
  145788. }
  145789. declare module BABYLON {
  145790. /**
  145791. * Block used to get the length of a vector
  145792. */
  145793. export class LengthBlock extends NodeMaterialBlock {
  145794. /**
  145795. * Creates a new LengthBlock
  145796. * @param name defines the block name
  145797. */
  145798. constructor(name: string);
  145799. /**
  145800. * Gets the current class name
  145801. * @returns the class name
  145802. */
  145803. getClassName(): string;
  145804. /**
  145805. * Gets the value input component
  145806. */
  145807. get value(): NodeMaterialConnectionPoint;
  145808. /**
  145809. * Gets the output component
  145810. */
  145811. get output(): NodeMaterialConnectionPoint;
  145812. protected _buildBlock(state: NodeMaterialBuildState): this;
  145813. }
  145814. }
  145815. declare module BABYLON {
  145816. /**
  145817. * Block used to get negative version of a value (i.e. x * -1)
  145818. */
  145819. export class NegateBlock extends NodeMaterialBlock {
  145820. /**
  145821. * Creates a new NegateBlock
  145822. * @param name defines the block name
  145823. */
  145824. constructor(name: string);
  145825. /**
  145826. * Gets the current class name
  145827. * @returns the class name
  145828. */
  145829. getClassName(): string;
  145830. /**
  145831. * Gets the value input component
  145832. */
  145833. get value(): NodeMaterialConnectionPoint;
  145834. /**
  145835. * Gets the output component
  145836. */
  145837. get output(): NodeMaterialConnectionPoint;
  145838. protected _buildBlock(state: NodeMaterialBuildState): this;
  145839. }
  145840. }
  145841. declare module BABYLON {
  145842. /**
  145843. * Block used to get the value of the first parameter raised to the power of the second
  145844. */
  145845. export class PowBlock extends NodeMaterialBlock {
  145846. /**
  145847. * Creates a new PowBlock
  145848. * @param name defines the block name
  145849. */
  145850. constructor(name: string);
  145851. /**
  145852. * Gets the current class name
  145853. * @returns the class name
  145854. */
  145855. getClassName(): string;
  145856. /**
  145857. * Gets the value operand input component
  145858. */
  145859. get value(): NodeMaterialConnectionPoint;
  145860. /**
  145861. * Gets the power operand input component
  145862. */
  145863. get power(): NodeMaterialConnectionPoint;
  145864. /**
  145865. * Gets the output component
  145866. */
  145867. get output(): NodeMaterialConnectionPoint;
  145868. protected _buildBlock(state: NodeMaterialBuildState): this;
  145869. }
  145870. }
  145871. declare module BABYLON {
  145872. /**
  145873. * Block used to get a random number
  145874. */
  145875. export class RandomNumberBlock extends NodeMaterialBlock {
  145876. /**
  145877. * Creates a new RandomNumberBlock
  145878. * @param name defines the block name
  145879. */
  145880. constructor(name: string);
  145881. /**
  145882. * Gets the current class name
  145883. * @returns the class name
  145884. */
  145885. getClassName(): string;
  145886. /**
  145887. * Gets the seed input component
  145888. */
  145889. get seed(): NodeMaterialConnectionPoint;
  145890. /**
  145891. * Gets the output component
  145892. */
  145893. get output(): NodeMaterialConnectionPoint;
  145894. protected _buildBlock(state: NodeMaterialBuildState): this;
  145895. }
  145896. }
  145897. declare module BABYLON {
  145898. /**
  145899. * Block used to compute arc tangent of 2 values
  145900. */
  145901. export class ArcTan2Block extends NodeMaterialBlock {
  145902. /**
  145903. * Creates a new ArcTan2Block
  145904. * @param name defines the block name
  145905. */
  145906. constructor(name: string);
  145907. /**
  145908. * Gets the current class name
  145909. * @returns the class name
  145910. */
  145911. getClassName(): string;
  145912. /**
  145913. * Gets the x operand input component
  145914. */
  145915. get x(): NodeMaterialConnectionPoint;
  145916. /**
  145917. * Gets the y operand input component
  145918. */
  145919. get y(): NodeMaterialConnectionPoint;
  145920. /**
  145921. * Gets the output component
  145922. */
  145923. get output(): NodeMaterialConnectionPoint;
  145924. protected _buildBlock(state: NodeMaterialBuildState): this;
  145925. }
  145926. }
  145927. declare module BABYLON {
  145928. /**
  145929. * Block used to smooth step a value
  145930. */
  145931. export class SmoothStepBlock extends NodeMaterialBlock {
  145932. /**
  145933. * Creates a new SmoothStepBlock
  145934. * @param name defines the block name
  145935. */
  145936. constructor(name: string);
  145937. /**
  145938. * Gets the current class name
  145939. * @returns the class name
  145940. */
  145941. getClassName(): string;
  145942. /**
  145943. * Gets the value operand input component
  145944. */
  145945. get value(): NodeMaterialConnectionPoint;
  145946. /**
  145947. * Gets the first edge operand input component
  145948. */
  145949. get edge0(): NodeMaterialConnectionPoint;
  145950. /**
  145951. * Gets the second edge operand input component
  145952. */
  145953. get edge1(): NodeMaterialConnectionPoint;
  145954. /**
  145955. * Gets the output component
  145956. */
  145957. get output(): NodeMaterialConnectionPoint;
  145958. protected _buildBlock(state: NodeMaterialBuildState): this;
  145959. }
  145960. }
  145961. declare module BABYLON {
  145962. /**
  145963. * Block used to get the reciprocal (1 / x) of a value
  145964. */
  145965. export class ReciprocalBlock extends NodeMaterialBlock {
  145966. /**
  145967. * Creates a new ReciprocalBlock
  145968. * @param name defines the block name
  145969. */
  145970. constructor(name: string);
  145971. /**
  145972. * Gets the current class name
  145973. * @returns the class name
  145974. */
  145975. getClassName(): string;
  145976. /**
  145977. * Gets the input component
  145978. */
  145979. get input(): NodeMaterialConnectionPoint;
  145980. /**
  145981. * Gets the output component
  145982. */
  145983. get output(): NodeMaterialConnectionPoint;
  145984. protected _buildBlock(state: NodeMaterialBuildState): this;
  145985. }
  145986. }
  145987. declare module BABYLON {
  145988. /**
  145989. * Block used to replace a color by another one
  145990. */
  145991. export class ReplaceColorBlock extends NodeMaterialBlock {
  145992. /**
  145993. * Creates a new ReplaceColorBlock
  145994. * @param name defines the block name
  145995. */
  145996. constructor(name: string);
  145997. /**
  145998. * Gets the current class name
  145999. * @returns the class name
  146000. */
  146001. getClassName(): string;
  146002. /**
  146003. * Gets the value input component
  146004. */
  146005. get value(): NodeMaterialConnectionPoint;
  146006. /**
  146007. * Gets the reference input component
  146008. */
  146009. get reference(): NodeMaterialConnectionPoint;
  146010. /**
  146011. * Gets the distance input component
  146012. */
  146013. get distance(): NodeMaterialConnectionPoint;
  146014. /**
  146015. * Gets the replacement input component
  146016. */
  146017. get replacement(): NodeMaterialConnectionPoint;
  146018. /**
  146019. * Gets the output component
  146020. */
  146021. get output(): NodeMaterialConnectionPoint;
  146022. protected _buildBlock(state: NodeMaterialBuildState): this;
  146023. }
  146024. }
  146025. declare module BABYLON {
  146026. /**
  146027. * Block used to posterize a value
  146028. * @see https://en.wikipedia.org/wiki/Posterization
  146029. */
  146030. export class PosterizeBlock extends NodeMaterialBlock {
  146031. /**
  146032. * Creates a new PosterizeBlock
  146033. * @param name defines the block name
  146034. */
  146035. constructor(name: string);
  146036. /**
  146037. * Gets the current class name
  146038. * @returns the class name
  146039. */
  146040. getClassName(): string;
  146041. /**
  146042. * Gets the value input component
  146043. */
  146044. get value(): NodeMaterialConnectionPoint;
  146045. /**
  146046. * Gets the steps input component
  146047. */
  146048. get steps(): NodeMaterialConnectionPoint;
  146049. /**
  146050. * Gets the output component
  146051. */
  146052. get output(): NodeMaterialConnectionPoint;
  146053. protected _buildBlock(state: NodeMaterialBuildState): this;
  146054. }
  146055. }
  146056. declare module BABYLON {
  146057. /**
  146058. * Operations supported by the Wave block
  146059. */
  146060. export enum WaveBlockKind {
  146061. /** SawTooth */
  146062. SawTooth = 0,
  146063. /** Square */
  146064. Square = 1,
  146065. /** Triangle */
  146066. Triangle = 2
  146067. }
  146068. /**
  146069. * Block used to apply wave operation to floats
  146070. */
  146071. export class WaveBlock extends NodeMaterialBlock {
  146072. /**
  146073. * Gets or sets the kibnd of wave to be applied by the block
  146074. */
  146075. kind: WaveBlockKind;
  146076. /**
  146077. * Creates a new WaveBlock
  146078. * @param name defines the block name
  146079. */
  146080. constructor(name: string);
  146081. /**
  146082. * Gets the current class name
  146083. * @returns the class name
  146084. */
  146085. getClassName(): string;
  146086. /**
  146087. * Gets the input component
  146088. */
  146089. get input(): NodeMaterialConnectionPoint;
  146090. /**
  146091. * Gets the output component
  146092. */
  146093. get output(): NodeMaterialConnectionPoint;
  146094. protected _buildBlock(state: NodeMaterialBuildState): this;
  146095. serialize(): any;
  146096. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146097. }
  146098. }
  146099. declare module BABYLON {
  146100. /**
  146101. * Class used to store a color step for the GradientBlock
  146102. */
  146103. export class GradientBlockColorStep {
  146104. private _step;
  146105. /**
  146106. * Gets value indicating which step this color is associated with (between 0 and 1)
  146107. */
  146108. get step(): number;
  146109. /**
  146110. * Sets a value indicating which step this color is associated with (between 0 and 1)
  146111. */
  146112. set step(val: number);
  146113. private _color;
  146114. /**
  146115. * Gets the color associated with this step
  146116. */
  146117. get color(): Color3;
  146118. /**
  146119. * Sets the color associated with this step
  146120. */
  146121. set color(val: Color3);
  146122. /**
  146123. * Creates a new GradientBlockColorStep
  146124. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  146125. * @param color defines the color associated with this step
  146126. */
  146127. constructor(step: number, color: Color3);
  146128. }
  146129. /**
  146130. * Block used to return a color from a gradient based on an input value between 0 and 1
  146131. */
  146132. export class GradientBlock extends NodeMaterialBlock {
  146133. /**
  146134. * Gets or sets the list of color steps
  146135. */
  146136. colorSteps: GradientBlockColorStep[];
  146137. /** Gets an observable raised when the value is changed */
  146138. onValueChangedObservable: Observable<GradientBlock>;
  146139. /** calls observable when the value is changed*/
  146140. colorStepsUpdated(): void;
  146141. /**
  146142. * Creates a new GradientBlock
  146143. * @param name defines the block name
  146144. */
  146145. constructor(name: string);
  146146. /**
  146147. * Gets the current class name
  146148. * @returns the class name
  146149. */
  146150. getClassName(): string;
  146151. /**
  146152. * Gets the gradient input component
  146153. */
  146154. get gradient(): NodeMaterialConnectionPoint;
  146155. /**
  146156. * Gets the output component
  146157. */
  146158. get output(): NodeMaterialConnectionPoint;
  146159. private _writeColorConstant;
  146160. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146161. serialize(): any;
  146162. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146163. protected _dumpPropertiesCode(): string;
  146164. }
  146165. }
  146166. declare module BABYLON {
  146167. /**
  146168. * Block used to normalize lerp between 2 values
  146169. */
  146170. export class NLerpBlock extends NodeMaterialBlock {
  146171. /**
  146172. * Creates a new NLerpBlock
  146173. * @param name defines the block name
  146174. */
  146175. constructor(name: string);
  146176. /**
  146177. * Gets the current class name
  146178. * @returns the class name
  146179. */
  146180. getClassName(): string;
  146181. /**
  146182. * Gets the left operand input component
  146183. */
  146184. get left(): NodeMaterialConnectionPoint;
  146185. /**
  146186. * Gets the right operand input component
  146187. */
  146188. get right(): NodeMaterialConnectionPoint;
  146189. /**
  146190. * Gets the gradient operand input component
  146191. */
  146192. get gradient(): NodeMaterialConnectionPoint;
  146193. /**
  146194. * Gets the output component
  146195. */
  146196. get output(): NodeMaterialConnectionPoint;
  146197. protected _buildBlock(state: NodeMaterialBuildState): this;
  146198. }
  146199. }
  146200. declare module BABYLON {
  146201. /**
  146202. * block used to Generate a Worley Noise 3D Noise Pattern
  146203. */
  146204. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  146205. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  146206. manhattanDistance: boolean;
  146207. /**
  146208. * Creates a new WorleyNoise3DBlock
  146209. * @param name defines the block name
  146210. */
  146211. constructor(name: string);
  146212. /**
  146213. * Gets the current class name
  146214. * @returns the class name
  146215. */
  146216. getClassName(): string;
  146217. /**
  146218. * Gets the seed input component
  146219. */
  146220. get seed(): NodeMaterialConnectionPoint;
  146221. /**
  146222. * Gets the jitter input component
  146223. */
  146224. get jitter(): NodeMaterialConnectionPoint;
  146225. /**
  146226. * Gets the output component
  146227. */
  146228. get output(): NodeMaterialConnectionPoint;
  146229. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146230. /**
  146231. * Exposes the properties to the UI?
  146232. */
  146233. protected _dumpPropertiesCode(): string;
  146234. /**
  146235. * Exposes the properties to the Seralize?
  146236. */
  146237. serialize(): any;
  146238. /**
  146239. * Exposes the properties to the deseralize?
  146240. */
  146241. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146242. }
  146243. }
  146244. declare module BABYLON {
  146245. /**
  146246. * block used to Generate a Simplex Perlin 3d Noise Pattern
  146247. */
  146248. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  146249. /**
  146250. * Creates a new SimplexPerlin3DBlock
  146251. * @param name defines the block name
  146252. */
  146253. constructor(name: string);
  146254. /**
  146255. * Gets the current class name
  146256. * @returns the class name
  146257. */
  146258. getClassName(): string;
  146259. /**
  146260. * Gets the seed operand input component
  146261. */
  146262. get seed(): NodeMaterialConnectionPoint;
  146263. /**
  146264. * Gets the output component
  146265. */
  146266. get output(): NodeMaterialConnectionPoint;
  146267. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146268. }
  146269. }
  146270. declare module BABYLON {
  146271. /**
  146272. * Block used to blend normals
  146273. */
  146274. export class NormalBlendBlock extends NodeMaterialBlock {
  146275. /**
  146276. * Creates a new NormalBlendBlock
  146277. * @param name defines the block name
  146278. */
  146279. constructor(name: string);
  146280. /**
  146281. * Gets the current class name
  146282. * @returns the class name
  146283. */
  146284. getClassName(): string;
  146285. /**
  146286. * Gets the first input component
  146287. */
  146288. get normalMap0(): NodeMaterialConnectionPoint;
  146289. /**
  146290. * Gets the second input component
  146291. */
  146292. get normalMap1(): NodeMaterialConnectionPoint;
  146293. /**
  146294. * Gets the output component
  146295. */
  146296. get output(): NodeMaterialConnectionPoint;
  146297. protected _buildBlock(state: NodeMaterialBuildState): this;
  146298. }
  146299. }
  146300. declare module BABYLON {
  146301. /**
  146302. * Block used to rotate a 2d vector by a given angle
  146303. */
  146304. export class Rotate2dBlock extends NodeMaterialBlock {
  146305. /**
  146306. * Creates a new Rotate2dBlock
  146307. * @param name defines the block name
  146308. */
  146309. constructor(name: string);
  146310. /**
  146311. * Gets the current class name
  146312. * @returns the class name
  146313. */
  146314. getClassName(): string;
  146315. /**
  146316. * Gets the input vector
  146317. */
  146318. get input(): NodeMaterialConnectionPoint;
  146319. /**
  146320. * Gets the input angle
  146321. */
  146322. get angle(): NodeMaterialConnectionPoint;
  146323. /**
  146324. * Gets the output component
  146325. */
  146326. get output(): NodeMaterialConnectionPoint;
  146327. autoConfigure(material: NodeMaterial): void;
  146328. protected _buildBlock(state: NodeMaterialBuildState): this;
  146329. }
  146330. }
  146331. declare module BABYLON {
  146332. /**
  146333. * Block used to get the reflected vector from a direction and a normal
  146334. */
  146335. export class ReflectBlock extends NodeMaterialBlock {
  146336. /**
  146337. * Creates a new ReflectBlock
  146338. * @param name defines the block name
  146339. */
  146340. constructor(name: string);
  146341. /**
  146342. * Gets the current class name
  146343. * @returns the class name
  146344. */
  146345. getClassName(): string;
  146346. /**
  146347. * Gets the incident component
  146348. */
  146349. get incident(): NodeMaterialConnectionPoint;
  146350. /**
  146351. * Gets the normal component
  146352. */
  146353. get normal(): NodeMaterialConnectionPoint;
  146354. /**
  146355. * Gets the output component
  146356. */
  146357. get output(): NodeMaterialConnectionPoint;
  146358. protected _buildBlock(state: NodeMaterialBuildState): this;
  146359. }
  146360. }
  146361. declare module BABYLON {
  146362. /**
  146363. * Block used to get the refracted vector from a direction and a normal
  146364. */
  146365. export class RefractBlock extends NodeMaterialBlock {
  146366. /**
  146367. * Creates a new RefractBlock
  146368. * @param name defines the block name
  146369. */
  146370. constructor(name: string);
  146371. /**
  146372. * Gets the current class name
  146373. * @returns the class name
  146374. */
  146375. getClassName(): string;
  146376. /**
  146377. * Gets the incident component
  146378. */
  146379. get incident(): NodeMaterialConnectionPoint;
  146380. /**
  146381. * Gets the normal component
  146382. */
  146383. get normal(): NodeMaterialConnectionPoint;
  146384. /**
  146385. * Gets the index of refraction component
  146386. */
  146387. get ior(): NodeMaterialConnectionPoint;
  146388. /**
  146389. * Gets the output component
  146390. */
  146391. get output(): NodeMaterialConnectionPoint;
  146392. protected _buildBlock(state: NodeMaterialBuildState): this;
  146393. }
  146394. }
  146395. declare module BABYLON {
  146396. /**
  146397. * Block used to desaturate a color
  146398. */
  146399. export class DesaturateBlock extends NodeMaterialBlock {
  146400. /**
  146401. * Creates a new DesaturateBlock
  146402. * @param name defines the block name
  146403. */
  146404. constructor(name: string);
  146405. /**
  146406. * Gets the current class name
  146407. * @returns the class name
  146408. */
  146409. getClassName(): string;
  146410. /**
  146411. * Gets the color operand input component
  146412. */
  146413. get color(): NodeMaterialConnectionPoint;
  146414. /**
  146415. * Gets the level operand input component
  146416. */
  146417. get level(): NodeMaterialConnectionPoint;
  146418. /**
  146419. * Gets the output component
  146420. */
  146421. get output(): NodeMaterialConnectionPoint;
  146422. protected _buildBlock(state: NodeMaterialBuildState): this;
  146423. }
  146424. }
  146425. declare module BABYLON {
  146426. /**
  146427. * Block used to implement the ambient occlusion module of the PBR material
  146428. */
  146429. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  146430. /**
  146431. * Create a new AmbientOcclusionBlock
  146432. * @param name defines the block name
  146433. */
  146434. constructor(name: string);
  146435. /**
  146436. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  146437. */
  146438. useAmbientInGrayScale: boolean;
  146439. /**
  146440. * Initialize the block and prepare the context for build
  146441. * @param state defines the state that will be used for the build
  146442. */
  146443. initialize(state: NodeMaterialBuildState): void;
  146444. /**
  146445. * Gets the current class name
  146446. * @returns the class name
  146447. */
  146448. getClassName(): string;
  146449. /**
  146450. * Gets the texture input component
  146451. */
  146452. get texture(): NodeMaterialConnectionPoint;
  146453. /**
  146454. * Gets the texture intensity component
  146455. */
  146456. get intensity(): NodeMaterialConnectionPoint;
  146457. /**
  146458. * Gets the direct light intensity input component
  146459. */
  146460. get directLightIntensity(): NodeMaterialConnectionPoint;
  146461. /**
  146462. * Gets the ambient occlusion object output component
  146463. */
  146464. get ambientOcc(): NodeMaterialConnectionPoint;
  146465. /**
  146466. * Gets the main code of the block (fragment side)
  146467. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  146468. * @returns the shader code
  146469. */
  146470. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  146471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146472. protected _buildBlock(state: NodeMaterialBuildState): this;
  146473. protected _dumpPropertiesCode(): string;
  146474. serialize(): any;
  146475. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146476. }
  146477. }
  146478. declare module BABYLON {
  146479. /**
  146480. * Block used to implement the reflection module of the PBR material
  146481. */
  146482. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  146483. /** @hidden */
  146484. _defineLODReflectionAlpha: string;
  146485. /** @hidden */
  146486. _defineLinearSpecularReflection: string;
  146487. private _vEnvironmentIrradianceName;
  146488. /** @hidden */
  146489. _vReflectionMicrosurfaceInfosName: string;
  146490. /** @hidden */
  146491. _vReflectionInfosName: string;
  146492. /** @hidden */
  146493. _vReflectionFilteringInfoName: string;
  146494. private _scene;
  146495. /**
  146496. * The three properties below are set by the main PBR block prior to calling methods of this class.
  146497. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  146498. * It's less burden on the user side in the editor part.
  146499. */
  146500. /** @hidden */
  146501. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  146502. /** @hidden */
  146503. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  146504. /** @hidden */
  146505. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  146506. /**
  146507. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  146508. * diffuse part of the IBL.
  146509. */
  146510. useSphericalHarmonics: boolean;
  146511. /**
  146512. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  146513. */
  146514. forceIrradianceInFragment: boolean;
  146515. /**
  146516. * Create a new ReflectionBlock
  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 position input component
  146527. */
  146528. get position(): NodeMaterialConnectionPoint;
  146529. /**
  146530. * Gets the world position input component
  146531. */
  146532. get worldPosition(): NodeMaterialConnectionPoint;
  146533. /**
  146534. * Gets the world normal input component
  146535. */
  146536. get worldNormal(): NodeMaterialConnectionPoint;
  146537. /**
  146538. * Gets the world input component
  146539. */
  146540. get world(): NodeMaterialConnectionPoint;
  146541. /**
  146542. * Gets the camera (or eye) position component
  146543. */
  146544. get cameraPosition(): NodeMaterialConnectionPoint;
  146545. /**
  146546. * Gets the view input component
  146547. */
  146548. get view(): NodeMaterialConnectionPoint;
  146549. /**
  146550. * Gets the color input component
  146551. */
  146552. get color(): NodeMaterialConnectionPoint;
  146553. /**
  146554. * Gets the reflection object output component
  146555. */
  146556. get reflection(): NodeMaterialConnectionPoint;
  146557. /**
  146558. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  146559. */
  146560. get hasTexture(): boolean;
  146561. /**
  146562. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  146563. */
  146564. get reflectionColor(): string;
  146565. protected _getTexture(): Nullable<BaseTexture>;
  146566. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146567. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146568. /**
  146569. * Gets the code to inject in the vertex shader
  146570. * @param state current state of the node material building
  146571. * @returns the shader code
  146572. */
  146573. handleVertexSide(state: NodeMaterialBuildState): string;
  146574. /**
  146575. * Gets the main code of the block (fragment side)
  146576. * @param state current state of the node material building
  146577. * @param normalVarName name of the existing variable corresponding to the normal
  146578. * @returns the shader code
  146579. */
  146580. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  146581. protected _buildBlock(state: NodeMaterialBuildState): this;
  146582. protected _dumpPropertiesCode(): string;
  146583. serialize(): any;
  146584. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146585. }
  146586. }
  146587. declare module BABYLON {
  146588. /**
  146589. * Block used to implement the sheen module of the PBR material
  146590. */
  146591. export class SheenBlock extends NodeMaterialBlock {
  146592. /**
  146593. * Create a new SheenBlock
  146594. * @param name defines the block name
  146595. */
  146596. constructor(name: string);
  146597. /**
  146598. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  146599. * It allows the strength of the sheen effect to not depend on the base color of the material,
  146600. * making it easier to setup and tweak the effect
  146601. */
  146602. albedoScaling: boolean;
  146603. /**
  146604. * Defines if the sheen is linked to the sheen color.
  146605. */
  146606. linkSheenWithAlbedo: boolean;
  146607. /**
  146608. * Initialize the block and prepare the context for build
  146609. * @param state defines the state that will be used for the build
  146610. */
  146611. initialize(state: NodeMaterialBuildState): void;
  146612. /**
  146613. * Gets the current class name
  146614. * @returns the class name
  146615. */
  146616. getClassName(): string;
  146617. /**
  146618. * Gets the intensity input component
  146619. */
  146620. get intensity(): NodeMaterialConnectionPoint;
  146621. /**
  146622. * Gets the color input component
  146623. */
  146624. get color(): NodeMaterialConnectionPoint;
  146625. /**
  146626. * Gets the roughness input component
  146627. */
  146628. get roughness(): NodeMaterialConnectionPoint;
  146629. /**
  146630. * Gets the sheen object output component
  146631. */
  146632. get sheen(): NodeMaterialConnectionPoint;
  146633. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146634. /**
  146635. * Gets the main code of the block (fragment side)
  146636. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146637. * @returns the shader code
  146638. */
  146639. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  146640. protected _buildBlock(state: NodeMaterialBuildState): this;
  146641. protected _dumpPropertiesCode(): string;
  146642. serialize(): any;
  146643. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146644. }
  146645. }
  146646. declare module BABYLON {
  146647. /**
  146648. * Block used to implement the reflectivity module of the PBR material
  146649. */
  146650. export class ReflectivityBlock extends NodeMaterialBlock {
  146651. private _metallicReflectanceColor;
  146652. private _metallicF0Factor;
  146653. /** @hidden */
  146654. _vMetallicReflectanceFactorsName: string;
  146655. /**
  146656. * The property below is set by the main PBR block prior to calling methods of this class.
  146657. */
  146658. /** @hidden */
  146659. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  146660. /**
  146661. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  146662. */
  146663. useAmbientOcclusionFromMetallicTextureRed: boolean;
  146664. /**
  146665. * Specifies if the metallic texture contains the metallness information in its blue channel.
  146666. */
  146667. useMetallnessFromMetallicTextureBlue: boolean;
  146668. /**
  146669. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  146670. */
  146671. useRoughnessFromMetallicTextureAlpha: boolean;
  146672. /**
  146673. * Specifies if the metallic texture contains the roughness information in its green channel.
  146674. */
  146675. useRoughnessFromMetallicTextureGreen: boolean;
  146676. /**
  146677. * Create a new ReflectivityBlock
  146678. * @param name defines the block name
  146679. */
  146680. constructor(name: string);
  146681. /**
  146682. * Initialize the block and prepare the context for build
  146683. * @param state defines the state that will be used for the build
  146684. */
  146685. initialize(state: NodeMaterialBuildState): void;
  146686. /**
  146687. * Gets the current class name
  146688. * @returns the class name
  146689. */
  146690. getClassName(): string;
  146691. /**
  146692. * Gets the metallic input component
  146693. */
  146694. get metallic(): NodeMaterialConnectionPoint;
  146695. /**
  146696. * Gets the roughness input component
  146697. */
  146698. get roughness(): NodeMaterialConnectionPoint;
  146699. /**
  146700. * Gets the texture input component
  146701. */
  146702. get texture(): NodeMaterialConnectionPoint;
  146703. /**
  146704. * Gets the reflectivity object output component
  146705. */
  146706. get reflectivity(): NodeMaterialConnectionPoint;
  146707. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146708. /**
  146709. * Gets the main code of the block (fragment side)
  146710. * @param state current state of the node material building
  146711. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  146712. * @returns the shader code
  146713. */
  146714. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  146715. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146716. protected _buildBlock(state: NodeMaterialBuildState): this;
  146717. protected _dumpPropertiesCode(): string;
  146718. serialize(): any;
  146719. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146720. }
  146721. }
  146722. declare module BABYLON {
  146723. /**
  146724. * Block used to implement the anisotropy module of the PBR material
  146725. */
  146726. export class AnisotropyBlock extends NodeMaterialBlock {
  146727. /**
  146728. * The two properties below are set by the main PBR block prior to calling methods of this class.
  146729. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  146730. * It's less burden on the user side in the editor part.
  146731. */
  146732. /** @hidden */
  146733. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  146734. /** @hidden */
  146735. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  146736. /**
  146737. * Create a new AnisotropyBlock
  146738. * @param name defines the block name
  146739. */
  146740. constructor(name: string);
  146741. /**
  146742. * Initialize the block and prepare the context for build
  146743. * @param state defines the state that will be used for the build
  146744. */
  146745. initialize(state: NodeMaterialBuildState): void;
  146746. /**
  146747. * Gets the current class name
  146748. * @returns the class name
  146749. */
  146750. getClassName(): string;
  146751. /**
  146752. * Gets the intensity input component
  146753. */
  146754. get intensity(): NodeMaterialConnectionPoint;
  146755. /**
  146756. * Gets the direction input component
  146757. */
  146758. get direction(): NodeMaterialConnectionPoint;
  146759. /**
  146760. * Gets the texture input component
  146761. */
  146762. get texture(): NodeMaterialConnectionPoint;
  146763. /**
  146764. * Gets the uv input component
  146765. */
  146766. get uv(): NodeMaterialConnectionPoint;
  146767. /**
  146768. * Gets the worldTangent input component
  146769. */
  146770. get worldTangent(): NodeMaterialConnectionPoint;
  146771. /**
  146772. * Gets the anisotropy object output component
  146773. */
  146774. get anisotropy(): NodeMaterialConnectionPoint;
  146775. private _generateTBNSpace;
  146776. /**
  146777. * Gets the main code of the block (fragment side)
  146778. * @param state current state of the node material building
  146779. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146780. * @returns the shader code
  146781. */
  146782. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  146783. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146784. protected _buildBlock(state: NodeMaterialBuildState): this;
  146785. }
  146786. }
  146787. declare module BABYLON {
  146788. /**
  146789. * Block used to implement the clear coat module of the PBR material
  146790. */
  146791. export class ClearCoatBlock extends NodeMaterialBlock {
  146792. private _scene;
  146793. /**
  146794. * Create a new ClearCoatBlock
  146795. * @param name defines the block name
  146796. */
  146797. constructor(name: string);
  146798. /**
  146799. * Initialize the block and prepare the context for build
  146800. * @param state defines the state that will be used for the build
  146801. */
  146802. initialize(state: NodeMaterialBuildState): void;
  146803. /**
  146804. * Gets the current class name
  146805. * @returns the class name
  146806. */
  146807. getClassName(): string;
  146808. /**
  146809. * Gets the intensity input component
  146810. */
  146811. get intensity(): NodeMaterialConnectionPoint;
  146812. /**
  146813. * Gets the roughness input component
  146814. */
  146815. get roughness(): NodeMaterialConnectionPoint;
  146816. /**
  146817. * Gets the ior input component
  146818. */
  146819. get ior(): NodeMaterialConnectionPoint;
  146820. /**
  146821. * Gets the texture input component
  146822. */
  146823. get texture(): NodeMaterialConnectionPoint;
  146824. /**
  146825. * Gets the bump texture input component
  146826. */
  146827. get bumpTexture(): NodeMaterialConnectionPoint;
  146828. /**
  146829. * Gets the uv input component
  146830. */
  146831. get uv(): NodeMaterialConnectionPoint;
  146832. /**
  146833. * Gets the tint color input component
  146834. */
  146835. get tintColor(): NodeMaterialConnectionPoint;
  146836. /**
  146837. * Gets the tint "at distance" input component
  146838. */
  146839. get tintAtDistance(): NodeMaterialConnectionPoint;
  146840. /**
  146841. * Gets the tint thickness input component
  146842. */
  146843. get tintThickness(): NodeMaterialConnectionPoint;
  146844. /**
  146845. * Gets the world tangent input component
  146846. */
  146847. get worldTangent(): NodeMaterialConnectionPoint;
  146848. /**
  146849. * Gets the clear coat object output component
  146850. */
  146851. get clearcoat(): NodeMaterialConnectionPoint;
  146852. autoConfigure(material: NodeMaterial): void;
  146853. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146854. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146855. private _generateTBNSpace;
  146856. /**
  146857. * Gets the main code of the block (fragment side)
  146858. * @param state current state of the node material building
  146859. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  146860. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146861. * @param worldPosVarName name of the variable holding the world position
  146862. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146863. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  146864. * @param worldNormalVarName name of the variable holding the world normal
  146865. * @returns the shader code
  146866. */
  146867. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  146868. protected _buildBlock(state: NodeMaterialBuildState): this;
  146869. }
  146870. }
  146871. declare module BABYLON {
  146872. /**
  146873. * Block used to implement the sub surface module of the PBR material
  146874. */
  146875. export class SubSurfaceBlock extends NodeMaterialBlock {
  146876. /**
  146877. * Create a new SubSurfaceBlock
  146878. * @param name defines the block name
  146879. */
  146880. constructor(name: string);
  146881. /**
  146882. * Stores the intensity of the different subsurface effects in the thickness texture.
  146883. * * the green channel is the translucency intensity.
  146884. * * the blue channel is the scattering intensity.
  146885. * * the alpha channel is the refraction intensity.
  146886. */
  146887. useMaskFromThicknessTexture: boolean;
  146888. /**
  146889. * Initialize the block and prepare the context for build
  146890. * @param state defines the state that will be used for the build
  146891. */
  146892. initialize(state: NodeMaterialBuildState): void;
  146893. /**
  146894. * Gets the current class name
  146895. * @returns the class name
  146896. */
  146897. getClassName(): string;
  146898. /**
  146899. * Gets the min thickness input component
  146900. */
  146901. get minThickness(): NodeMaterialConnectionPoint;
  146902. /**
  146903. * Gets the max thickness input component
  146904. */
  146905. get maxThickness(): NodeMaterialConnectionPoint;
  146906. /**
  146907. * Gets the thickness texture component
  146908. */
  146909. get thicknessTexture(): NodeMaterialConnectionPoint;
  146910. /**
  146911. * Gets the tint color input component
  146912. */
  146913. get tintColor(): NodeMaterialConnectionPoint;
  146914. /**
  146915. * Gets the translucency intensity input component
  146916. */
  146917. get translucencyIntensity(): NodeMaterialConnectionPoint;
  146918. /**
  146919. * Gets the translucency diffusion distance input component
  146920. */
  146921. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  146922. /**
  146923. * Gets the refraction object parameters
  146924. */
  146925. get refraction(): NodeMaterialConnectionPoint;
  146926. /**
  146927. * Gets the sub surface object output component
  146928. */
  146929. get subsurface(): NodeMaterialConnectionPoint;
  146930. autoConfigure(material: NodeMaterial): void;
  146931. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146932. /**
  146933. * Gets the main code of the block (fragment side)
  146934. * @param state current state of the node material building
  146935. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  146936. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146937. * @param worldPosVarName name of the variable holding the world position
  146938. * @returns the shader code
  146939. */
  146940. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  146941. protected _buildBlock(state: NodeMaterialBuildState): this;
  146942. }
  146943. }
  146944. declare module BABYLON {
  146945. /**
  146946. * Block used to implement the PBR metallic/roughness model
  146947. */
  146948. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  146949. /**
  146950. * Gets or sets the light associated with this block
  146951. */
  146952. light: Nullable<Light>;
  146953. private _lightId;
  146954. private _scene;
  146955. private _environmentBRDFTexture;
  146956. private _environmentBrdfSamplerName;
  146957. private _vNormalWName;
  146958. private _invertNormalName;
  146959. /**
  146960. * Create a new ReflectionBlock
  146961. * @param name defines the block name
  146962. */
  146963. constructor(name: string);
  146964. /**
  146965. * Intensity of the direct lights e.g. the four lights available in your scene.
  146966. * This impacts both the direct diffuse and specular highlights.
  146967. */
  146968. directIntensity: number;
  146969. /**
  146970. * Intensity of the environment e.g. how much the environment will light the object
  146971. * either through harmonics for rough material or through the refelction for shiny ones.
  146972. */
  146973. environmentIntensity: number;
  146974. /**
  146975. * This is a special control allowing the reduction of the specular highlights coming from the
  146976. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  146977. */
  146978. specularIntensity: number;
  146979. /**
  146980. * Defines the falloff type used in this material.
  146981. * It by default is Physical.
  146982. */
  146983. lightFalloff: number;
  146984. /**
  146985. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  146986. */
  146987. useAlphaFromAlbedoTexture: boolean;
  146988. /**
  146989. * Specifies that alpha test should be used
  146990. */
  146991. useAlphaTest: boolean;
  146992. /**
  146993. * Defines the alpha limits in alpha test mode.
  146994. */
  146995. alphaTestCutoff: number;
  146996. /**
  146997. * Specifies that alpha blending should be used
  146998. */
  146999. useAlphaBlending: boolean;
  147000. /**
  147001. * Defines if the alpha value should be determined via the rgb values.
  147002. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  147003. */
  147004. opacityRGB: boolean;
  147005. /**
  147006. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  147007. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  147008. */
  147009. useRadianceOverAlpha: boolean;
  147010. /**
  147011. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  147012. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  147013. */
  147014. useSpecularOverAlpha: boolean;
  147015. /**
  147016. * Enables specular anti aliasing in the PBR shader.
  147017. * It will both interacts on the Geometry for analytical and IBL lighting.
  147018. * It also prefilter the roughness map based on the bump values.
  147019. */
  147020. enableSpecularAntiAliasing: boolean;
  147021. /**
  147022. * Enables realtime filtering on the texture.
  147023. */
  147024. realTimeFiltering: boolean;
  147025. /**
  147026. * Quality switch for realtime filtering
  147027. */
  147028. realTimeFilteringQuality: number;
  147029. /**
  147030. * Defines if the material uses energy conservation.
  147031. */
  147032. useEnergyConservation: boolean;
  147033. /**
  147034. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  147035. * too much the area relying on ambient texture to define their ambient occlusion.
  147036. */
  147037. useRadianceOcclusion: boolean;
  147038. /**
  147039. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  147040. * makes the reflect vector face the model (under horizon).
  147041. */
  147042. useHorizonOcclusion: boolean;
  147043. /**
  147044. * If set to true, no lighting calculations will be applied.
  147045. */
  147046. unlit: boolean;
  147047. /**
  147048. * Force normal to face away from face.
  147049. */
  147050. forceNormalForward: boolean;
  147051. /**
  147052. * Defines the material debug mode.
  147053. * It helps seeing only some components of the material while troubleshooting.
  147054. */
  147055. debugMode: number;
  147056. /**
  147057. * Specify from where on screen the debug mode should start.
  147058. * The value goes from -1 (full screen) to 1 (not visible)
  147059. * It helps with side by side comparison against the final render
  147060. * This defaults to 0
  147061. */
  147062. debugLimit: number;
  147063. /**
  147064. * As the default viewing range might not be enough (if the ambient is really small for instance)
  147065. * You can use the factor to better multiply the final value.
  147066. */
  147067. debugFactor: number;
  147068. /**
  147069. * Initialize the block and prepare the context for build
  147070. * @param state defines the state that will be used for the build
  147071. */
  147072. initialize(state: NodeMaterialBuildState): void;
  147073. /**
  147074. * Gets the current class name
  147075. * @returns the class name
  147076. */
  147077. getClassName(): string;
  147078. /**
  147079. * Gets the world position input component
  147080. */
  147081. get worldPosition(): NodeMaterialConnectionPoint;
  147082. /**
  147083. * Gets the world normal input component
  147084. */
  147085. get worldNormal(): NodeMaterialConnectionPoint;
  147086. /**
  147087. * Gets the perturbed normal input component
  147088. */
  147089. get perturbedNormal(): NodeMaterialConnectionPoint;
  147090. /**
  147091. * Gets the camera position input component
  147092. */
  147093. get cameraPosition(): NodeMaterialConnectionPoint;
  147094. /**
  147095. * Gets the base color input component
  147096. */
  147097. get baseColor(): NodeMaterialConnectionPoint;
  147098. /**
  147099. * Gets the opacity texture input component
  147100. */
  147101. get opacityTexture(): NodeMaterialConnectionPoint;
  147102. /**
  147103. * Gets the ambient color input component
  147104. */
  147105. get ambientColor(): NodeMaterialConnectionPoint;
  147106. /**
  147107. * Gets the reflectivity object parameters
  147108. */
  147109. get reflectivity(): NodeMaterialConnectionPoint;
  147110. /**
  147111. * Gets the ambient occlusion object parameters
  147112. */
  147113. get ambientOcc(): NodeMaterialConnectionPoint;
  147114. /**
  147115. * Gets the reflection object parameters
  147116. */
  147117. get reflection(): NodeMaterialConnectionPoint;
  147118. /**
  147119. * Gets the sheen object parameters
  147120. */
  147121. get sheen(): NodeMaterialConnectionPoint;
  147122. /**
  147123. * Gets the clear coat object parameters
  147124. */
  147125. get clearcoat(): NodeMaterialConnectionPoint;
  147126. /**
  147127. * Gets the sub surface object parameters
  147128. */
  147129. get subsurface(): NodeMaterialConnectionPoint;
  147130. /**
  147131. * Gets the anisotropy object parameters
  147132. */
  147133. get anisotropy(): NodeMaterialConnectionPoint;
  147134. /**
  147135. * Gets the view matrix parameter
  147136. */
  147137. get view(): NodeMaterialConnectionPoint;
  147138. /**
  147139. * Gets the ambient output component
  147140. */
  147141. get ambient(): NodeMaterialConnectionPoint;
  147142. /**
  147143. * Gets the diffuse output component
  147144. */
  147145. get diffuse(): NodeMaterialConnectionPoint;
  147146. /**
  147147. * Gets the specular output component
  147148. */
  147149. get specular(): NodeMaterialConnectionPoint;
  147150. /**
  147151. * Gets the sheen output component
  147152. */
  147153. get sheenDir(): NodeMaterialConnectionPoint;
  147154. /**
  147155. * Gets the clear coat output component
  147156. */
  147157. get clearcoatDir(): NodeMaterialConnectionPoint;
  147158. /**
  147159. * Gets the indirect diffuse output component
  147160. */
  147161. get diffuseIndirect(): NodeMaterialConnectionPoint;
  147162. /**
  147163. * Gets the indirect specular output component
  147164. */
  147165. get specularIndirect(): NodeMaterialConnectionPoint;
  147166. /**
  147167. * Gets the indirect sheen output component
  147168. */
  147169. get sheenIndirect(): NodeMaterialConnectionPoint;
  147170. /**
  147171. * Gets the indirect clear coat output component
  147172. */
  147173. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  147174. /**
  147175. * Gets the refraction output component
  147176. */
  147177. get refraction(): NodeMaterialConnectionPoint;
  147178. /**
  147179. * Gets the global lighting output component
  147180. */
  147181. get lighting(): NodeMaterialConnectionPoint;
  147182. /**
  147183. * Gets the shadow output component
  147184. */
  147185. get shadow(): NodeMaterialConnectionPoint;
  147186. /**
  147187. * Gets the alpha output component
  147188. */
  147189. get alpha(): NodeMaterialConnectionPoint;
  147190. autoConfigure(material: NodeMaterial): void;
  147191. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147192. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  147193. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  147194. private _injectVertexCode;
  147195. /**
  147196. * Gets the code corresponding to the albedo/opacity module
  147197. * @returns the shader code
  147198. */
  147199. getAlbedoOpacityCode(): string;
  147200. protected _buildBlock(state: NodeMaterialBuildState): this;
  147201. protected _dumpPropertiesCode(): string;
  147202. serialize(): any;
  147203. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147204. }
  147205. }
  147206. declare module BABYLON {
  147207. /**
  147208. * Block used to compute value of one parameter modulo another
  147209. */
  147210. export class ModBlock extends NodeMaterialBlock {
  147211. /**
  147212. * Creates a new ModBlock
  147213. * @param name defines the block name
  147214. */
  147215. constructor(name: string);
  147216. /**
  147217. * Gets the current class name
  147218. * @returns the class name
  147219. */
  147220. getClassName(): string;
  147221. /**
  147222. * Gets the left operand input component
  147223. */
  147224. get left(): NodeMaterialConnectionPoint;
  147225. /**
  147226. * Gets the right operand input component
  147227. */
  147228. get right(): NodeMaterialConnectionPoint;
  147229. /**
  147230. * Gets the output component
  147231. */
  147232. get output(): NodeMaterialConnectionPoint;
  147233. protected _buildBlock(state: NodeMaterialBuildState): this;
  147234. }
  147235. }
  147236. declare module BABYLON {
  147237. /**
  147238. * Configuration for Draco compression
  147239. */
  147240. export interface IDracoCompressionConfiguration {
  147241. /**
  147242. * Configuration for the decoder.
  147243. */
  147244. decoder: {
  147245. /**
  147246. * The url to the WebAssembly module.
  147247. */
  147248. wasmUrl?: string;
  147249. /**
  147250. * The url to the WebAssembly binary.
  147251. */
  147252. wasmBinaryUrl?: string;
  147253. /**
  147254. * The url to the fallback JavaScript module.
  147255. */
  147256. fallbackUrl?: string;
  147257. };
  147258. }
  147259. /**
  147260. * Draco compression (https://google.github.io/draco/)
  147261. *
  147262. * This class wraps the Draco module.
  147263. *
  147264. * **Encoder**
  147265. *
  147266. * The encoder is not currently implemented.
  147267. *
  147268. * **Decoder**
  147269. *
  147270. * 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.
  147271. *
  147272. * To update the configuration, use the following code:
  147273. * ```javascript
  147274. * DracoCompression.Configuration = {
  147275. * decoder: {
  147276. * wasmUrl: "<url to the WebAssembly library>",
  147277. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  147278. * fallbackUrl: "<url to the fallback JavaScript library>",
  147279. * }
  147280. * };
  147281. * ```
  147282. *
  147283. * 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.
  147284. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  147285. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  147286. *
  147287. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  147288. * ```javascript
  147289. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  147290. * ```
  147291. *
  147292. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  147293. */
  147294. export class DracoCompression implements IDisposable {
  147295. private _workerPoolPromise?;
  147296. private _decoderModulePromise?;
  147297. /**
  147298. * The configuration. Defaults to the following urls:
  147299. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  147300. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  147301. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  147302. */
  147303. static Configuration: IDracoCompressionConfiguration;
  147304. /**
  147305. * Returns true if the decoder configuration is available.
  147306. */
  147307. static get DecoderAvailable(): boolean;
  147308. /**
  147309. * Default number of workers to create when creating the draco compression object.
  147310. */
  147311. static DefaultNumWorkers: number;
  147312. private static GetDefaultNumWorkers;
  147313. private static _Default;
  147314. /**
  147315. * Default instance for the draco compression object.
  147316. */
  147317. static get Default(): DracoCompression;
  147318. /**
  147319. * Constructor
  147320. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  147321. */
  147322. constructor(numWorkers?: number);
  147323. /**
  147324. * Stop all async operations and release resources.
  147325. */
  147326. dispose(): void;
  147327. /**
  147328. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  147329. * @returns a promise that resolves when ready
  147330. */
  147331. whenReadyAsync(): Promise<void>;
  147332. /**
  147333. * Decode Draco compressed mesh data to vertex data.
  147334. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  147335. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  147336. * @returns A promise that resolves with the decoded vertex data
  147337. */
  147338. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  147339. [kind: string]: number;
  147340. }): Promise<VertexData>;
  147341. }
  147342. }
  147343. declare module BABYLON {
  147344. /**
  147345. * Class for building Constructive Solid Geometry
  147346. */
  147347. export class CSG {
  147348. private polygons;
  147349. /**
  147350. * The world matrix
  147351. */
  147352. matrix: Matrix;
  147353. /**
  147354. * Stores the position
  147355. */
  147356. position: Vector3;
  147357. /**
  147358. * Stores the rotation
  147359. */
  147360. rotation: Vector3;
  147361. /**
  147362. * Stores the rotation quaternion
  147363. */
  147364. rotationQuaternion: Nullable<Quaternion>;
  147365. /**
  147366. * Stores the scaling vector
  147367. */
  147368. scaling: Vector3;
  147369. /**
  147370. * Convert the Mesh to CSG
  147371. * @param mesh The Mesh to convert to CSG
  147372. * @returns A new CSG from the Mesh
  147373. */
  147374. static FromMesh(mesh: Mesh): CSG;
  147375. /**
  147376. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  147377. * @param polygons Polygons used to construct a CSG solid
  147378. */
  147379. private static FromPolygons;
  147380. /**
  147381. * Clones, or makes a deep copy, of the CSG
  147382. * @returns A new CSG
  147383. */
  147384. clone(): CSG;
  147385. /**
  147386. * Unions this CSG with another CSG
  147387. * @param csg The CSG to union against this CSG
  147388. * @returns The unioned CSG
  147389. */
  147390. union(csg: CSG): CSG;
  147391. /**
  147392. * Unions this CSG with another CSG in place
  147393. * @param csg The CSG to union against this CSG
  147394. */
  147395. unionInPlace(csg: CSG): void;
  147396. /**
  147397. * Subtracts this CSG with another CSG
  147398. * @param csg The CSG to subtract against this CSG
  147399. * @returns A new CSG
  147400. */
  147401. subtract(csg: CSG): CSG;
  147402. /**
  147403. * Subtracts this CSG with another CSG in place
  147404. * @param csg The CSG to subtact against this CSG
  147405. */
  147406. subtractInPlace(csg: CSG): void;
  147407. /**
  147408. * Intersect this CSG with another CSG
  147409. * @param csg The CSG to intersect against this CSG
  147410. * @returns A new CSG
  147411. */
  147412. intersect(csg: CSG): CSG;
  147413. /**
  147414. * Intersects this CSG with another CSG in place
  147415. * @param csg The CSG to intersect against this CSG
  147416. */
  147417. intersectInPlace(csg: CSG): void;
  147418. /**
  147419. * Return a new CSG solid with solid and empty space switched. This solid is
  147420. * not modified.
  147421. * @returns A new CSG solid with solid and empty space switched
  147422. */
  147423. inverse(): CSG;
  147424. /**
  147425. * Inverses the CSG in place
  147426. */
  147427. inverseInPlace(): void;
  147428. /**
  147429. * This is used to keep meshes transformations so they can be restored
  147430. * when we build back a Babylon Mesh
  147431. * NB : All CSG operations are performed in world coordinates
  147432. * @param csg The CSG to copy the transform attributes from
  147433. * @returns This CSG
  147434. */
  147435. copyTransformAttributes(csg: CSG): CSG;
  147436. /**
  147437. * Build Raw mesh from CSG
  147438. * Coordinates here are in world space
  147439. * @param name The name of the mesh geometry
  147440. * @param scene The Scene
  147441. * @param keepSubMeshes Specifies if the submeshes should be kept
  147442. * @returns A new Mesh
  147443. */
  147444. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  147445. /**
  147446. * Build Mesh from CSG taking material and transforms into account
  147447. * @param name The name of the Mesh
  147448. * @param material The material of the Mesh
  147449. * @param scene The Scene
  147450. * @param keepSubMeshes Specifies if submeshes should be kept
  147451. * @returns The new Mesh
  147452. */
  147453. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  147454. }
  147455. }
  147456. declare module BABYLON {
  147457. /**
  147458. * Class used to create a trail following a mesh
  147459. */
  147460. export class TrailMesh extends Mesh {
  147461. private _generator;
  147462. private _autoStart;
  147463. private _running;
  147464. private _diameter;
  147465. private _length;
  147466. private _sectionPolygonPointsCount;
  147467. private _sectionVectors;
  147468. private _sectionNormalVectors;
  147469. private _beforeRenderObserver;
  147470. /**
  147471. * @constructor
  147472. * @param name The value used by scene.getMeshByName() to do a lookup.
  147473. * @param generator The mesh or transform node to generate a trail.
  147474. * @param scene The scene to add this mesh to.
  147475. * @param diameter Diameter of trailing mesh. Default is 1.
  147476. * @param length Length of trailing mesh. Default is 60.
  147477. * @param autoStart Automatically start trailing mesh. Default true.
  147478. */
  147479. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  147480. /**
  147481. * "TrailMesh"
  147482. * @returns "TrailMesh"
  147483. */
  147484. getClassName(): string;
  147485. private _createMesh;
  147486. /**
  147487. * Start trailing mesh.
  147488. */
  147489. start(): void;
  147490. /**
  147491. * Stop trailing mesh.
  147492. */
  147493. stop(): void;
  147494. /**
  147495. * Update trailing mesh geometry.
  147496. */
  147497. update(): void;
  147498. /**
  147499. * Returns a new TrailMesh object.
  147500. * @param name is a string, the name given to the new mesh
  147501. * @param newGenerator use new generator object for cloned trail mesh
  147502. * @returns a new mesh
  147503. */
  147504. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  147505. /**
  147506. * Serializes this trail mesh
  147507. * @param serializationObject object to write serialization to
  147508. */
  147509. serialize(serializationObject: any): void;
  147510. /**
  147511. * Parses a serialized trail mesh
  147512. * @param parsedMesh the serialized mesh
  147513. * @param scene the scene to create the trail mesh in
  147514. * @returns the created trail mesh
  147515. */
  147516. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  147517. }
  147518. }
  147519. declare module BABYLON {
  147520. /**
  147521. * Class containing static functions to help procedurally build meshes
  147522. */
  147523. export class TiledBoxBuilder {
  147524. /**
  147525. * Creates a box mesh
  147526. * 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)
  147527. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147529. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147531. * @param name defines the name of the mesh
  147532. * @param options defines the options used to create the mesh
  147533. * @param scene defines the hosting scene
  147534. * @returns the box mesh
  147535. */
  147536. static CreateTiledBox(name: string, options: {
  147537. pattern?: number;
  147538. width?: number;
  147539. height?: number;
  147540. depth?: number;
  147541. tileSize?: number;
  147542. tileWidth?: number;
  147543. tileHeight?: number;
  147544. alignHorizontal?: number;
  147545. alignVertical?: number;
  147546. faceUV?: Vector4[];
  147547. faceColors?: Color4[];
  147548. sideOrientation?: number;
  147549. updatable?: boolean;
  147550. }, scene?: Nullable<Scene>): Mesh;
  147551. }
  147552. }
  147553. declare module BABYLON {
  147554. /**
  147555. * Class containing static functions to help procedurally build meshes
  147556. */
  147557. export class TorusKnotBuilder {
  147558. /**
  147559. * Creates a torus knot mesh
  147560. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  147561. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  147562. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  147563. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  147564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147567. * @param name defines the name of the mesh
  147568. * @param options defines the options used to create the mesh
  147569. * @param scene defines the hosting scene
  147570. * @returns the torus knot mesh
  147571. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  147572. */
  147573. static CreateTorusKnot(name: string, options: {
  147574. radius?: number;
  147575. tube?: number;
  147576. radialSegments?: number;
  147577. tubularSegments?: number;
  147578. p?: number;
  147579. q?: number;
  147580. updatable?: boolean;
  147581. sideOrientation?: number;
  147582. frontUVs?: Vector4;
  147583. backUVs?: Vector4;
  147584. }, scene: any): Mesh;
  147585. }
  147586. }
  147587. declare module BABYLON {
  147588. /**
  147589. * Polygon
  147590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  147591. */
  147592. export class Polygon {
  147593. /**
  147594. * Creates a rectangle
  147595. * @param xmin bottom X coord
  147596. * @param ymin bottom Y coord
  147597. * @param xmax top X coord
  147598. * @param ymax top Y coord
  147599. * @returns points that make the resulting rectation
  147600. */
  147601. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  147602. /**
  147603. * Creates a circle
  147604. * @param radius radius of circle
  147605. * @param cx scale in x
  147606. * @param cy scale in y
  147607. * @param numberOfSides number of sides that make up the circle
  147608. * @returns points that make the resulting circle
  147609. */
  147610. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  147611. /**
  147612. * Creates a polygon from input string
  147613. * @param input Input polygon data
  147614. * @returns the parsed points
  147615. */
  147616. static Parse(input: string): Vector2[];
  147617. /**
  147618. * Starts building a polygon from x and y coordinates
  147619. * @param x x coordinate
  147620. * @param y y coordinate
  147621. * @returns the started path2
  147622. */
  147623. static StartingAt(x: number, y: number): Path2;
  147624. }
  147625. /**
  147626. * Builds a polygon
  147627. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  147628. */
  147629. export class PolygonMeshBuilder {
  147630. private _points;
  147631. private _outlinepoints;
  147632. private _holes;
  147633. private _name;
  147634. private _scene;
  147635. private _epoints;
  147636. private _eholes;
  147637. private _addToepoint;
  147638. /**
  147639. * Babylon reference to the earcut plugin.
  147640. */
  147641. bjsEarcut: any;
  147642. /**
  147643. * Creates a PolygonMeshBuilder
  147644. * @param name name of the builder
  147645. * @param contours Path of the polygon
  147646. * @param scene scene to add to when creating the mesh
  147647. * @param earcutInjection can be used to inject your own earcut reference
  147648. */
  147649. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  147650. /**
  147651. * Adds a whole within the polygon
  147652. * @param hole Array of points defining the hole
  147653. * @returns this
  147654. */
  147655. addHole(hole: Vector2[]): PolygonMeshBuilder;
  147656. /**
  147657. * Creates the polygon
  147658. * @param updatable If the mesh should be updatable
  147659. * @param depth The depth of the mesh created
  147660. * @returns the created mesh
  147661. */
  147662. build(updatable?: boolean, depth?: number): Mesh;
  147663. /**
  147664. * Creates the polygon
  147665. * @param depth The depth of the mesh created
  147666. * @returns the created VertexData
  147667. */
  147668. buildVertexData(depth?: number): VertexData;
  147669. /**
  147670. * Adds a side to the polygon
  147671. * @param positions points that make the polygon
  147672. * @param normals normals of the polygon
  147673. * @param uvs uvs of the polygon
  147674. * @param indices indices of the polygon
  147675. * @param bounds bounds of the polygon
  147676. * @param points points of the polygon
  147677. * @param depth depth of the polygon
  147678. * @param flip flip of the polygon
  147679. */
  147680. private addSide;
  147681. }
  147682. }
  147683. declare module BABYLON {
  147684. /**
  147685. * Class containing static functions to help procedurally build meshes
  147686. */
  147687. export class PolygonBuilder {
  147688. /**
  147689. * Creates a polygon mesh
  147690. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147691. * * 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
  147692. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147694. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147695. * * Remember you can only change the shape positions, not their number when updating a polygon
  147696. * @param name defines the name of the mesh
  147697. * @param options defines the options used to create the mesh
  147698. * @param scene defines the hosting scene
  147699. * @param earcutInjection can be used to inject your own earcut reference
  147700. * @returns the polygon mesh
  147701. */
  147702. static CreatePolygon(name: string, options: {
  147703. shape: Vector3[];
  147704. holes?: Vector3[][];
  147705. depth?: number;
  147706. faceUV?: Vector4[];
  147707. faceColors?: Color4[];
  147708. updatable?: boolean;
  147709. sideOrientation?: number;
  147710. frontUVs?: Vector4;
  147711. backUVs?: Vector4;
  147712. wrap?: boolean;
  147713. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147714. /**
  147715. * Creates an extruded polygon mesh, with depth in the Y direction.
  147716. * * 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)
  147717. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147718. * @param name defines the name of the mesh
  147719. * @param options defines the options used to create the mesh
  147720. * @param scene defines the hosting scene
  147721. * @param earcutInjection can be used to inject your own earcut reference
  147722. * @returns the polygon mesh
  147723. */
  147724. static ExtrudePolygon(name: string, options: {
  147725. shape: Vector3[];
  147726. holes?: Vector3[][];
  147727. depth?: number;
  147728. faceUV?: Vector4[];
  147729. faceColors?: Color4[];
  147730. updatable?: boolean;
  147731. sideOrientation?: number;
  147732. frontUVs?: Vector4;
  147733. backUVs?: Vector4;
  147734. wrap?: boolean;
  147735. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147736. }
  147737. }
  147738. declare module BABYLON {
  147739. /**
  147740. * Class containing static functions to help procedurally build meshes
  147741. */
  147742. export class LatheBuilder {
  147743. /**
  147744. * Creates lathe mesh.
  147745. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147746. * * 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
  147747. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147748. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147749. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147750. * * 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
  147751. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147752. * * 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
  147753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147755. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147757. * @param name defines the name of the mesh
  147758. * @param options defines the options used to create the mesh
  147759. * @param scene defines the hosting scene
  147760. * @returns the lathe mesh
  147761. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147762. */
  147763. static CreateLathe(name: string, options: {
  147764. shape: Vector3[];
  147765. radius?: number;
  147766. tessellation?: number;
  147767. clip?: number;
  147768. arc?: number;
  147769. closed?: boolean;
  147770. updatable?: boolean;
  147771. sideOrientation?: number;
  147772. frontUVs?: Vector4;
  147773. backUVs?: Vector4;
  147774. cap?: number;
  147775. invertUV?: boolean;
  147776. }, scene?: Nullable<Scene>): Mesh;
  147777. }
  147778. }
  147779. declare module BABYLON {
  147780. /**
  147781. * Class containing static functions to help procedurally build meshes
  147782. */
  147783. export class TiledPlaneBuilder {
  147784. /**
  147785. * Creates a tiled plane mesh
  147786. * * The parameter `pattern` will, depending on value, do nothing or
  147787. * * * flip (reflect about central vertical) alternate tiles across and up
  147788. * * * flip every tile on alternate rows
  147789. * * * rotate (180 degs) alternate tiles across and up
  147790. * * * rotate every tile on alternate rows
  147791. * * * flip and rotate alternate tiles across and up
  147792. * * * flip and rotate every tile on alternate rows
  147793. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  147794. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  147795. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147796. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147797. * * 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)
  147798. * * 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)
  147799. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  147800. * @param name defines the name of the mesh
  147801. * @param options defines the options used to create the mesh
  147802. * @param scene defines the hosting scene
  147803. * @returns the box mesh
  147804. */
  147805. static CreateTiledPlane(name: string, options: {
  147806. pattern?: number;
  147807. tileSize?: number;
  147808. tileWidth?: number;
  147809. tileHeight?: number;
  147810. size?: number;
  147811. width?: number;
  147812. height?: number;
  147813. alignHorizontal?: number;
  147814. alignVertical?: number;
  147815. sideOrientation?: number;
  147816. frontUVs?: Vector4;
  147817. backUVs?: Vector4;
  147818. updatable?: boolean;
  147819. }, scene?: Nullable<Scene>): Mesh;
  147820. }
  147821. }
  147822. declare module BABYLON {
  147823. /**
  147824. * Class containing static functions to help procedurally build meshes
  147825. */
  147826. export class TubeBuilder {
  147827. /**
  147828. * Creates a tube mesh.
  147829. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147830. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147831. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147832. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147833. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147834. * * 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)
  147835. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147836. * * 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
  147837. * * 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
  147838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147839. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147840. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147842. * @param name defines the name of the mesh
  147843. * @param options defines the options used to create the mesh
  147844. * @param scene defines the hosting scene
  147845. * @returns the tube mesh
  147846. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147847. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147848. */
  147849. static CreateTube(name: string, options: {
  147850. path: Vector3[];
  147851. radius?: number;
  147852. tessellation?: number;
  147853. radiusFunction?: {
  147854. (i: number, distance: number): number;
  147855. };
  147856. cap?: number;
  147857. arc?: number;
  147858. updatable?: boolean;
  147859. sideOrientation?: number;
  147860. frontUVs?: Vector4;
  147861. backUVs?: Vector4;
  147862. instance?: Mesh;
  147863. invertUV?: boolean;
  147864. }, scene?: Nullable<Scene>): Mesh;
  147865. }
  147866. }
  147867. declare module BABYLON {
  147868. /**
  147869. * Class containing static functions to help procedurally build meshes
  147870. */
  147871. export class IcoSphereBuilder {
  147872. /**
  147873. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147874. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147875. * * 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`)
  147876. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147877. * * 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
  147878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147879. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147881. * @param name defines the name of the mesh
  147882. * @param options defines the options used to create the mesh
  147883. * @param scene defines the hosting scene
  147884. * @returns the icosahedron mesh
  147885. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147886. */
  147887. static CreateIcoSphere(name: string, options: {
  147888. radius?: number;
  147889. radiusX?: number;
  147890. radiusY?: number;
  147891. radiusZ?: number;
  147892. flat?: boolean;
  147893. subdivisions?: number;
  147894. sideOrientation?: number;
  147895. frontUVs?: Vector4;
  147896. backUVs?: Vector4;
  147897. updatable?: boolean;
  147898. }, scene?: Nullable<Scene>): Mesh;
  147899. }
  147900. }
  147901. declare module BABYLON {
  147902. /**
  147903. * Class containing static functions to help procedurally build meshes
  147904. */
  147905. export class DecalBuilder {
  147906. /**
  147907. * Creates a decal mesh.
  147908. * 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
  147909. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147910. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147911. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147912. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147913. * @param name defines the name of the mesh
  147914. * @param sourceMesh defines the mesh where the decal must be applied
  147915. * @param options defines the options used to create the mesh
  147916. * @param scene defines the hosting scene
  147917. * @returns the decal mesh
  147918. * @see https://doc.babylonjs.com/how_to/decals
  147919. */
  147920. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147921. position?: Vector3;
  147922. normal?: Vector3;
  147923. size?: Vector3;
  147924. angle?: number;
  147925. }): Mesh;
  147926. }
  147927. }
  147928. declare module BABYLON {
  147929. /**
  147930. * Class containing static functions to help procedurally build meshes
  147931. */
  147932. export class MeshBuilder {
  147933. /**
  147934. * Creates a box mesh
  147935. * * The parameter `size` sets the size (float) of each box side (default 1)
  147936. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  147937. * * 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)
  147938. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147940. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147942. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  147943. * @param name defines the name of the mesh
  147944. * @param options defines the options used to create the mesh
  147945. * @param scene defines the hosting scene
  147946. * @returns the box mesh
  147947. */
  147948. static CreateBox(name: string, options: {
  147949. size?: number;
  147950. width?: number;
  147951. height?: number;
  147952. depth?: number;
  147953. faceUV?: Vector4[];
  147954. faceColors?: Color4[];
  147955. sideOrientation?: number;
  147956. frontUVs?: Vector4;
  147957. backUVs?: Vector4;
  147958. wrap?: boolean;
  147959. topBaseAt?: number;
  147960. bottomBaseAt?: number;
  147961. updatable?: boolean;
  147962. }, scene?: Nullable<Scene>): Mesh;
  147963. /**
  147964. * Creates a tiled box mesh
  147965. * * faceTiles sets the pattern, tile size and number of tiles for a face
  147966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147967. * @param name defines the name of the mesh
  147968. * @param options defines the options used to create the mesh
  147969. * @param scene defines the hosting scene
  147970. * @returns the tiled box mesh
  147971. */
  147972. static CreateTiledBox(name: string, options: {
  147973. pattern?: number;
  147974. size?: number;
  147975. width?: number;
  147976. height?: number;
  147977. depth: number;
  147978. tileSize?: number;
  147979. tileWidth?: number;
  147980. tileHeight?: number;
  147981. faceUV?: Vector4[];
  147982. faceColors?: Color4[];
  147983. alignHorizontal?: number;
  147984. alignVertical?: number;
  147985. sideOrientation?: number;
  147986. updatable?: boolean;
  147987. }, scene?: Nullable<Scene>): Mesh;
  147988. /**
  147989. * Creates a sphere mesh
  147990. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  147991. * * 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`)
  147992. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  147993. * * 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
  147994. * * 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)
  147995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147998. * @param name defines the name of the mesh
  147999. * @param options defines the options used to create the mesh
  148000. * @param scene defines the hosting scene
  148001. * @returns the sphere mesh
  148002. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  148003. */
  148004. static CreateSphere(name: string, options: {
  148005. segments?: number;
  148006. diameter?: number;
  148007. diameterX?: number;
  148008. diameterY?: number;
  148009. diameterZ?: number;
  148010. arc?: number;
  148011. slice?: number;
  148012. sideOrientation?: number;
  148013. frontUVs?: Vector4;
  148014. backUVs?: Vector4;
  148015. updatable?: boolean;
  148016. }, scene?: Nullable<Scene>): Mesh;
  148017. /**
  148018. * Creates a plane polygonal mesh. By default, this is a disc
  148019. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  148020. * * 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
  148021. * * 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
  148022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148023. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148025. * @param name defines the name of the mesh
  148026. * @param options defines the options used to create the mesh
  148027. * @param scene defines the hosting scene
  148028. * @returns the plane polygonal mesh
  148029. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  148030. */
  148031. static CreateDisc(name: string, options: {
  148032. radius?: number;
  148033. tessellation?: number;
  148034. arc?: number;
  148035. updatable?: boolean;
  148036. sideOrientation?: number;
  148037. frontUVs?: Vector4;
  148038. backUVs?: Vector4;
  148039. }, scene?: Nullable<Scene>): Mesh;
  148040. /**
  148041. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148042. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148043. * * 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`)
  148044. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148045. * * 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
  148046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148049. * @param name defines the name of the mesh
  148050. * @param options defines the options used to create the mesh
  148051. * @param scene defines the hosting scene
  148052. * @returns the icosahedron mesh
  148053. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148054. */
  148055. static CreateIcoSphere(name: string, options: {
  148056. radius?: number;
  148057. radiusX?: number;
  148058. radiusY?: number;
  148059. radiusZ?: number;
  148060. flat?: boolean;
  148061. subdivisions?: number;
  148062. sideOrientation?: number;
  148063. frontUVs?: Vector4;
  148064. backUVs?: Vector4;
  148065. updatable?: boolean;
  148066. }, scene?: Nullable<Scene>): Mesh;
  148067. /**
  148068. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148069. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  148070. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  148071. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  148072. * * 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
  148073. * * 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
  148074. * * 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
  148075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148077. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148078. * * 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
  148079. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  148080. * * 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
  148081. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  148082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148083. * @param name defines the name of the mesh
  148084. * @param options defines the options used to create the mesh
  148085. * @param scene defines the hosting scene
  148086. * @returns the ribbon mesh
  148087. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  148088. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148089. */
  148090. static CreateRibbon(name: string, options: {
  148091. pathArray: Vector3[][];
  148092. closeArray?: boolean;
  148093. closePath?: boolean;
  148094. offset?: number;
  148095. updatable?: boolean;
  148096. sideOrientation?: number;
  148097. frontUVs?: Vector4;
  148098. backUVs?: Vector4;
  148099. instance?: Mesh;
  148100. invertUV?: boolean;
  148101. uvs?: Vector2[];
  148102. colors?: Color4[];
  148103. }, scene?: Nullable<Scene>): Mesh;
  148104. /**
  148105. * Creates a cylinder or a cone mesh
  148106. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  148107. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  148108. * * 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.
  148109. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  148110. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  148111. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  148112. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  148113. * * 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).
  148114. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  148115. * * 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).
  148116. * * 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
  148117. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  148118. * * 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
  148119. * * 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.
  148120. * * If `enclose` is false, a ring surface is one element.
  148121. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  148122. * * 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
  148123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148126. * @param name defines the name of the mesh
  148127. * @param options defines the options used to create the mesh
  148128. * @param scene defines the hosting scene
  148129. * @returns the cylinder mesh
  148130. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  148131. */
  148132. static CreateCylinder(name: string, options: {
  148133. height?: number;
  148134. diameterTop?: number;
  148135. diameterBottom?: number;
  148136. diameter?: number;
  148137. tessellation?: number;
  148138. subdivisions?: number;
  148139. arc?: number;
  148140. faceColors?: Color4[];
  148141. faceUV?: Vector4[];
  148142. updatable?: boolean;
  148143. hasRings?: boolean;
  148144. enclose?: boolean;
  148145. cap?: number;
  148146. sideOrientation?: number;
  148147. frontUVs?: Vector4;
  148148. backUVs?: Vector4;
  148149. }, scene?: Nullable<Scene>): Mesh;
  148150. /**
  148151. * Creates a torus mesh
  148152. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  148153. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  148154. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  148155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148156. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148158. * @param name defines the name of the mesh
  148159. * @param options defines the options used to create the mesh
  148160. * @param scene defines the hosting scene
  148161. * @returns the torus mesh
  148162. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  148163. */
  148164. static CreateTorus(name: string, options: {
  148165. diameter?: number;
  148166. thickness?: number;
  148167. tessellation?: number;
  148168. updatable?: boolean;
  148169. sideOrientation?: number;
  148170. frontUVs?: Vector4;
  148171. backUVs?: Vector4;
  148172. }, scene?: Nullable<Scene>): Mesh;
  148173. /**
  148174. * Creates a torus knot mesh
  148175. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  148176. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  148177. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  148178. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  148179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148182. * @param name defines the name of the mesh
  148183. * @param options defines the options used to create the mesh
  148184. * @param scene defines the hosting scene
  148185. * @returns the torus knot mesh
  148186. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  148187. */
  148188. static CreateTorusKnot(name: string, options: {
  148189. radius?: number;
  148190. tube?: number;
  148191. radialSegments?: number;
  148192. tubularSegments?: number;
  148193. p?: number;
  148194. q?: number;
  148195. updatable?: boolean;
  148196. sideOrientation?: number;
  148197. frontUVs?: Vector4;
  148198. backUVs?: Vector4;
  148199. }, scene?: Nullable<Scene>): Mesh;
  148200. /**
  148201. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  148202. * * 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
  148203. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  148204. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  148205. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  148206. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  148207. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  148208. * * 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
  148209. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  148210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148211. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  148212. * @param name defines the name of the new line system
  148213. * @param options defines the options used to create the line system
  148214. * @param scene defines the hosting scene
  148215. * @returns a new line system mesh
  148216. */
  148217. static CreateLineSystem(name: string, options: {
  148218. lines: Vector3[][];
  148219. updatable?: boolean;
  148220. instance?: Nullable<LinesMesh>;
  148221. colors?: Nullable<Color4[][]>;
  148222. useVertexAlpha?: boolean;
  148223. }, scene: Nullable<Scene>): LinesMesh;
  148224. /**
  148225. * Creates a line mesh
  148226. * 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
  148227. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  148228. * * The parameter `points` is an array successive Vector3
  148229. * * 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
  148230. * * The optional parameter `colors` is an array of successive Color4, one per line point
  148231. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  148232. * * When updating an instance, remember that only point positions can change, not the number of points
  148233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148234. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  148235. * @param name defines the name of the new line system
  148236. * @param options defines the options used to create the line system
  148237. * @param scene defines the hosting scene
  148238. * @returns a new line mesh
  148239. */
  148240. static CreateLines(name: string, options: {
  148241. points: Vector3[];
  148242. updatable?: boolean;
  148243. instance?: Nullable<LinesMesh>;
  148244. colors?: Color4[];
  148245. useVertexAlpha?: boolean;
  148246. }, scene?: Nullable<Scene>): LinesMesh;
  148247. /**
  148248. * Creates a dashed line mesh
  148249. * * 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
  148250. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  148251. * * The parameter `points` is an array successive Vector3
  148252. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  148253. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  148254. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  148255. * * 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
  148256. * * When updating an instance, remember that only point positions can change, not the number of points
  148257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148258. * @param name defines the name of the mesh
  148259. * @param options defines the options used to create the mesh
  148260. * @param scene defines the hosting scene
  148261. * @returns the dashed line mesh
  148262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  148263. */
  148264. static CreateDashedLines(name: string, options: {
  148265. points: Vector3[];
  148266. dashSize?: number;
  148267. gapSize?: number;
  148268. dashNb?: number;
  148269. updatable?: boolean;
  148270. instance?: LinesMesh;
  148271. }, scene?: Nullable<Scene>): LinesMesh;
  148272. /**
  148273. * 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.
  148274. * * 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.
  148275. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  148276. * * 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.
  148277. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  148278. * * 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
  148279. * * 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
  148280. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  148281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148283. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  148284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148285. * @param name defines the name of the mesh
  148286. * @param options defines the options used to create the mesh
  148287. * @param scene defines the hosting scene
  148288. * @returns the extruded shape mesh
  148289. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  148291. */
  148292. static ExtrudeShape(name: string, options: {
  148293. shape: Vector3[];
  148294. path: Vector3[];
  148295. scale?: number;
  148296. rotation?: number;
  148297. cap?: number;
  148298. updatable?: boolean;
  148299. sideOrientation?: number;
  148300. frontUVs?: Vector4;
  148301. backUVs?: Vector4;
  148302. instance?: Mesh;
  148303. invertUV?: boolean;
  148304. }, scene?: Nullable<Scene>): Mesh;
  148305. /**
  148306. * Creates an custom extruded shape mesh.
  148307. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  148308. * * 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.
  148309. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  148310. * * 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
  148311. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  148312. * * 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
  148313. * * It must returns a float value that will be the scale value applied to the shape on each path point
  148314. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  148315. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  148316. * * 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
  148317. * * 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
  148318. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  148319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148321. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148323. * @param name defines the name of the mesh
  148324. * @param options defines the options used to create the mesh
  148325. * @param scene defines the hosting scene
  148326. * @returns the custom extruded shape mesh
  148327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  148328. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  148330. */
  148331. static ExtrudeShapeCustom(name: string, options: {
  148332. shape: Vector3[];
  148333. path: Vector3[];
  148334. scaleFunction?: any;
  148335. rotationFunction?: any;
  148336. ribbonCloseArray?: boolean;
  148337. ribbonClosePath?: boolean;
  148338. cap?: number;
  148339. updatable?: boolean;
  148340. sideOrientation?: number;
  148341. frontUVs?: Vector4;
  148342. backUVs?: Vector4;
  148343. instance?: Mesh;
  148344. invertUV?: boolean;
  148345. }, scene?: Nullable<Scene>): Mesh;
  148346. /**
  148347. * Creates lathe mesh.
  148348. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  148349. * * 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
  148350. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  148351. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  148352. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  148353. * * 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
  148354. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  148355. * * 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
  148356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148358. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148360. * @param name defines the name of the mesh
  148361. * @param options defines the options used to create the mesh
  148362. * @param scene defines the hosting scene
  148363. * @returns the lathe mesh
  148364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  148365. */
  148366. static CreateLathe(name: string, options: {
  148367. shape: Vector3[];
  148368. radius?: number;
  148369. tessellation?: number;
  148370. clip?: number;
  148371. arc?: number;
  148372. closed?: boolean;
  148373. updatable?: boolean;
  148374. sideOrientation?: number;
  148375. frontUVs?: Vector4;
  148376. backUVs?: Vector4;
  148377. cap?: number;
  148378. invertUV?: boolean;
  148379. }, scene?: Nullable<Scene>): Mesh;
  148380. /**
  148381. * Creates a tiled plane mesh
  148382. * * You can set a limited pattern arrangement with the tiles
  148383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148386. * @param name defines the name of the mesh
  148387. * @param options defines the options used to create the mesh
  148388. * @param scene defines the hosting scene
  148389. * @returns the plane mesh
  148390. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  148391. */
  148392. static CreateTiledPlane(name: string, options: {
  148393. pattern?: number;
  148394. tileSize?: number;
  148395. tileWidth?: number;
  148396. tileHeight?: number;
  148397. size?: number;
  148398. width?: number;
  148399. height?: number;
  148400. alignHorizontal?: number;
  148401. alignVertical?: number;
  148402. sideOrientation?: number;
  148403. frontUVs?: Vector4;
  148404. backUVs?: Vector4;
  148405. updatable?: boolean;
  148406. }, scene?: Nullable<Scene>): Mesh;
  148407. /**
  148408. * Creates a plane mesh
  148409. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  148410. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  148411. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  148412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148415. * @param name defines the name of the mesh
  148416. * @param options defines the options used to create the mesh
  148417. * @param scene defines the hosting scene
  148418. * @returns the plane mesh
  148419. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  148420. */
  148421. static CreatePlane(name: string, options: {
  148422. size?: number;
  148423. width?: number;
  148424. height?: number;
  148425. sideOrientation?: number;
  148426. frontUVs?: Vector4;
  148427. backUVs?: Vector4;
  148428. updatable?: boolean;
  148429. sourcePlane?: Plane;
  148430. }, scene?: Nullable<Scene>): Mesh;
  148431. /**
  148432. * Creates a ground mesh
  148433. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  148434. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  148435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148436. * @param name defines the name of the mesh
  148437. * @param options defines the options used to create the mesh
  148438. * @param scene defines the hosting scene
  148439. * @returns the ground mesh
  148440. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  148441. */
  148442. static CreateGround(name: string, options: {
  148443. width?: number;
  148444. height?: number;
  148445. subdivisions?: number;
  148446. subdivisionsX?: number;
  148447. subdivisionsY?: number;
  148448. updatable?: boolean;
  148449. }, scene?: Nullable<Scene>): Mesh;
  148450. /**
  148451. * Creates a tiled ground mesh
  148452. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  148453. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  148454. * * 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
  148455. * * 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
  148456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148457. * @param name defines the name of the mesh
  148458. * @param options defines the options used to create the mesh
  148459. * @param scene defines the hosting scene
  148460. * @returns the tiled ground mesh
  148461. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  148462. */
  148463. static CreateTiledGround(name: string, options: {
  148464. xmin: number;
  148465. zmin: number;
  148466. xmax: number;
  148467. zmax: number;
  148468. subdivisions?: {
  148469. w: number;
  148470. h: number;
  148471. };
  148472. precision?: {
  148473. w: number;
  148474. h: number;
  148475. };
  148476. updatable?: boolean;
  148477. }, scene?: Nullable<Scene>): Mesh;
  148478. /**
  148479. * Creates a ground mesh from a height map
  148480. * * The parameter `url` sets the URL of the height map image resource.
  148481. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  148482. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  148483. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  148484. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  148485. * * 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.
  148486. * * 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).
  148487. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  148488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148489. * @param name defines the name of the mesh
  148490. * @param url defines the url to the height map
  148491. * @param options defines the options used to create the mesh
  148492. * @param scene defines the hosting scene
  148493. * @returns the ground mesh
  148494. * @see https://doc.babylonjs.com/babylon101/height_map
  148495. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  148496. */
  148497. static CreateGroundFromHeightMap(name: string, url: string, options: {
  148498. width?: number;
  148499. height?: number;
  148500. subdivisions?: number;
  148501. minHeight?: number;
  148502. maxHeight?: number;
  148503. colorFilter?: Color3;
  148504. alphaFilter?: number;
  148505. updatable?: boolean;
  148506. onReady?: (mesh: GroundMesh) => void;
  148507. }, scene?: Nullable<Scene>): GroundMesh;
  148508. /**
  148509. * Creates a polygon mesh
  148510. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  148511. * * 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
  148512. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  148513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  148515. * * Remember you can only change the shape positions, not their number when updating a polygon
  148516. * @param name defines the name of the mesh
  148517. * @param options defines the options used to create the mesh
  148518. * @param scene defines the hosting scene
  148519. * @param earcutInjection can be used to inject your own earcut reference
  148520. * @returns the polygon mesh
  148521. */
  148522. static CreatePolygon(name: string, options: {
  148523. shape: Vector3[];
  148524. holes?: Vector3[][];
  148525. depth?: number;
  148526. faceUV?: Vector4[];
  148527. faceColors?: Color4[];
  148528. updatable?: boolean;
  148529. sideOrientation?: number;
  148530. frontUVs?: Vector4;
  148531. backUVs?: Vector4;
  148532. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148533. /**
  148534. * Creates an extruded polygon mesh, with depth in the Y direction.
  148535. * * 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)
  148536. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148537. * @param name defines the name of the mesh
  148538. * @param options defines the options used to create the mesh
  148539. * @param scene defines the hosting scene
  148540. * @param earcutInjection can be used to inject your own earcut reference
  148541. * @returns the polygon mesh
  148542. */
  148543. static ExtrudePolygon(name: string, options: {
  148544. shape: Vector3[];
  148545. holes?: Vector3[][];
  148546. depth?: number;
  148547. faceUV?: Vector4[];
  148548. faceColors?: Color4[];
  148549. updatable?: boolean;
  148550. sideOrientation?: number;
  148551. frontUVs?: Vector4;
  148552. backUVs?: Vector4;
  148553. wrap?: boolean;
  148554. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148555. /**
  148556. * Creates a tube mesh.
  148557. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148558. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  148559. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  148560. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  148561. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  148562. * * 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)
  148563. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  148564. * * 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
  148565. * * 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
  148566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148568. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148570. * @param name defines the name of the mesh
  148571. * @param options defines the options used to create the mesh
  148572. * @param scene defines the hosting scene
  148573. * @returns the tube mesh
  148574. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148575. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  148576. */
  148577. static CreateTube(name: string, options: {
  148578. path: Vector3[];
  148579. radius?: number;
  148580. tessellation?: number;
  148581. radiusFunction?: {
  148582. (i: number, distance: number): number;
  148583. };
  148584. cap?: number;
  148585. arc?: number;
  148586. updatable?: boolean;
  148587. sideOrientation?: number;
  148588. frontUVs?: Vector4;
  148589. backUVs?: Vector4;
  148590. instance?: Mesh;
  148591. invertUV?: boolean;
  148592. }, scene?: Nullable<Scene>): Mesh;
  148593. /**
  148594. * Creates a polyhedron mesh
  148595. * * 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
  148596. * * The parameter `size` (positive float, default 1) sets the polygon size
  148597. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  148598. * * 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`
  148599. * * 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
  148600. * * 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)`)
  148601. * * 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
  148602. * * 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
  148603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148606. * @param name defines the name of the mesh
  148607. * @param options defines the options used to create the mesh
  148608. * @param scene defines the hosting scene
  148609. * @returns the polyhedron mesh
  148610. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  148611. */
  148612. static CreatePolyhedron(name: string, options: {
  148613. type?: number;
  148614. size?: number;
  148615. sizeX?: number;
  148616. sizeY?: number;
  148617. sizeZ?: number;
  148618. custom?: any;
  148619. faceUV?: Vector4[];
  148620. faceColors?: Color4[];
  148621. flat?: boolean;
  148622. updatable?: boolean;
  148623. sideOrientation?: number;
  148624. frontUVs?: Vector4;
  148625. backUVs?: Vector4;
  148626. }, scene?: Nullable<Scene>): Mesh;
  148627. /**
  148628. * Creates a decal mesh.
  148629. * 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
  148630. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  148631. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  148632. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  148633. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  148634. * @param name defines the name of the mesh
  148635. * @param sourceMesh defines the mesh where the decal must be applied
  148636. * @param options defines the options used to create the mesh
  148637. * @param scene defines the hosting scene
  148638. * @returns the decal mesh
  148639. * @see https://doc.babylonjs.com/how_to/decals
  148640. */
  148641. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  148642. position?: Vector3;
  148643. normal?: Vector3;
  148644. size?: Vector3;
  148645. angle?: number;
  148646. }): Mesh;
  148647. /**
  148648. * Creates a Capsule Mesh
  148649. * @param name defines the name of the mesh.
  148650. * @param options the constructors options used to shape the mesh.
  148651. * @param scene defines the scene the mesh is scoped to.
  148652. * @returns the capsule mesh
  148653. * @see https://doc.babylonjs.com/how_to/capsule_shape
  148654. */
  148655. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  148656. }
  148657. }
  148658. declare module BABYLON {
  148659. /**
  148660. * A simplifier interface for future simplification implementations
  148661. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148662. */
  148663. export interface ISimplifier {
  148664. /**
  148665. * Simplification of a given mesh according to the given settings.
  148666. * Since this requires computation, it is assumed that the function runs async.
  148667. * @param settings The settings of the simplification, including quality and distance
  148668. * @param successCallback A callback that will be called after the mesh was simplified.
  148669. * @param errorCallback in case of an error, this callback will be called. optional.
  148670. */
  148671. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  148672. }
  148673. /**
  148674. * Expected simplification settings.
  148675. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  148676. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148677. */
  148678. export interface ISimplificationSettings {
  148679. /**
  148680. * Gets or sets the expected quality
  148681. */
  148682. quality: number;
  148683. /**
  148684. * Gets or sets the distance when this optimized version should be used
  148685. */
  148686. distance: number;
  148687. /**
  148688. * Gets an already optimized mesh
  148689. */
  148690. optimizeMesh?: boolean;
  148691. }
  148692. /**
  148693. * Class used to specify simplification options
  148694. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148695. */
  148696. export class SimplificationSettings implements ISimplificationSettings {
  148697. /** expected quality */
  148698. quality: number;
  148699. /** distance when this optimized version should be used */
  148700. distance: number;
  148701. /** already optimized mesh */
  148702. optimizeMesh?: boolean | undefined;
  148703. /**
  148704. * Creates a SimplificationSettings
  148705. * @param quality expected quality
  148706. * @param distance distance when this optimized version should be used
  148707. * @param optimizeMesh already optimized mesh
  148708. */
  148709. constructor(
  148710. /** expected quality */
  148711. quality: number,
  148712. /** distance when this optimized version should be used */
  148713. distance: number,
  148714. /** already optimized mesh */
  148715. optimizeMesh?: boolean | undefined);
  148716. }
  148717. /**
  148718. * Interface used to define a simplification task
  148719. */
  148720. export interface ISimplificationTask {
  148721. /**
  148722. * Array of settings
  148723. */
  148724. settings: Array<ISimplificationSettings>;
  148725. /**
  148726. * Simplification type
  148727. */
  148728. simplificationType: SimplificationType;
  148729. /**
  148730. * Mesh to simplify
  148731. */
  148732. mesh: Mesh;
  148733. /**
  148734. * Callback called on success
  148735. */
  148736. successCallback?: () => void;
  148737. /**
  148738. * Defines if parallel processing can be used
  148739. */
  148740. parallelProcessing: boolean;
  148741. }
  148742. /**
  148743. * Queue used to order the simplification tasks
  148744. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148745. */
  148746. export class SimplificationQueue {
  148747. private _simplificationArray;
  148748. /**
  148749. * Gets a boolean indicating that the process is still running
  148750. */
  148751. running: boolean;
  148752. /**
  148753. * Creates a new queue
  148754. */
  148755. constructor();
  148756. /**
  148757. * Adds a new simplification task
  148758. * @param task defines a task to add
  148759. */
  148760. addTask(task: ISimplificationTask): void;
  148761. /**
  148762. * Execute next task
  148763. */
  148764. executeNext(): void;
  148765. /**
  148766. * Execute a simplification task
  148767. * @param task defines the task to run
  148768. */
  148769. runSimplification(task: ISimplificationTask): void;
  148770. private getSimplifier;
  148771. }
  148772. /**
  148773. * The implemented types of simplification
  148774. * At the moment only Quadratic Error Decimation is implemented
  148775. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148776. */
  148777. export enum SimplificationType {
  148778. /** Quadratic error decimation */
  148779. QUADRATIC = 0
  148780. }
  148781. /**
  148782. * An implementation of the Quadratic Error simplification algorithm.
  148783. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  148784. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  148785. * @author RaananW
  148786. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148787. */
  148788. export class QuadraticErrorSimplification implements ISimplifier {
  148789. private _mesh;
  148790. private triangles;
  148791. private vertices;
  148792. private references;
  148793. private _reconstructedMesh;
  148794. /** Gets or sets the number pf sync interations */
  148795. syncIterations: number;
  148796. /** Gets or sets the aggressiveness of the simplifier */
  148797. aggressiveness: number;
  148798. /** Gets or sets the number of allowed iterations for decimation */
  148799. decimationIterations: number;
  148800. /** Gets or sets the espilon to use for bounding box computation */
  148801. boundingBoxEpsilon: number;
  148802. /**
  148803. * Creates a new QuadraticErrorSimplification
  148804. * @param _mesh defines the target mesh
  148805. */
  148806. constructor(_mesh: Mesh);
  148807. /**
  148808. * Simplification of a given mesh according to the given settings.
  148809. * Since this requires computation, it is assumed that the function runs async.
  148810. * @param settings The settings of the simplification, including quality and distance
  148811. * @param successCallback A callback that will be called after the mesh was simplified.
  148812. */
  148813. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  148814. private runDecimation;
  148815. private initWithMesh;
  148816. private init;
  148817. private reconstructMesh;
  148818. private initDecimatedMesh;
  148819. private isFlipped;
  148820. private updateTriangles;
  148821. private identifyBorder;
  148822. private updateMesh;
  148823. private vertexError;
  148824. private calculateError;
  148825. }
  148826. }
  148827. declare module BABYLON {
  148828. interface Scene {
  148829. /** @hidden (Backing field) */
  148830. _simplificationQueue: SimplificationQueue;
  148831. /**
  148832. * Gets or sets the simplification queue attached to the scene
  148833. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148834. */
  148835. simplificationQueue: SimplificationQueue;
  148836. }
  148837. interface Mesh {
  148838. /**
  148839. * Simplify the mesh according to the given array of settings.
  148840. * Function will return immediately and will simplify async
  148841. * @param settings a collection of simplification settings
  148842. * @param parallelProcessing should all levels calculate parallel or one after the other
  148843. * @param simplificationType the type of simplification to run
  148844. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  148845. * @returns the current mesh
  148846. */
  148847. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  148848. }
  148849. /**
  148850. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  148851. * created in a scene
  148852. */
  148853. export class SimplicationQueueSceneComponent implements ISceneComponent {
  148854. /**
  148855. * The component name helpfull to identify the component in the list of scene components.
  148856. */
  148857. readonly name: string;
  148858. /**
  148859. * The scene the component belongs to.
  148860. */
  148861. scene: Scene;
  148862. /**
  148863. * Creates a new instance of the component for the given scene
  148864. * @param scene Defines the scene to register the component in
  148865. */
  148866. constructor(scene: Scene);
  148867. /**
  148868. * Registers the component in a given scene
  148869. */
  148870. register(): void;
  148871. /**
  148872. * Rebuilds the elements related to this component in case of
  148873. * context lost for instance.
  148874. */
  148875. rebuild(): void;
  148876. /**
  148877. * Disposes the component and the associated ressources
  148878. */
  148879. dispose(): void;
  148880. private _beforeCameraUpdate;
  148881. }
  148882. }
  148883. declare module BABYLON {
  148884. interface Mesh {
  148885. /**
  148886. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  148887. */
  148888. thinInstanceEnablePicking: boolean;
  148889. /**
  148890. * Creates a new thin instance
  148891. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  148892. * @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
  148893. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  148894. */
  148895. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  148896. /**
  148897. * Adds the transformation (matrix) of the current mesh as a thin instance
  148898. * @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
  148899. * @returns the thin instance index number
  148900. */
  148901. thinInstanceAddSelf(refresh: boolean): number;
  148902. /**
  148903. * Registers a custom attribute to be used with thin instances
  148904. * @param kind name of the attribute
  148905. * @param stride size in floats of the attribute
  148906. */
  148907. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  148908. /**
  148909. * Sets the matrix of a thin instance
  148910. * @param index index of the thin instance
  148911. * @param matrix matrix to set
  148912. * @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
  148913. */
  148914. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  148915. /**
  148916. * Sets the value of a custom attribute for a thin instance
  148917. * @param kind name of the attribute
  148918. * @param index index of the thin instance
  148919. * @param value value to set
  148920. * @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
  148921. */
  148922. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  148923. /**
  148924. * 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.
  148925. */
  148926. thinInstanceCount: number;
  148927. /**
  148928. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  148929. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  148930. * @param buffer buffer to set
  148931. * @param stride size in floats of each value of the buffer
  148932. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  148933. */
  148934. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  148935. /**
  148936. * Gets the list of world matrices
  148937. * @return an array containing all the world matrices from the thin instances
  148938. */
  148939. thinInstanceGetWorldMatrices(): Matrix[];
  148940. /**
  148941. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  148942. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  148943. */
  148944. thinInstanceBufferUpdated(kind: string): void;
  148945. /**
  148946. * Applies a partial update to a buffer directly on the GPU
  148947. * 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
  148948. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  148949. * @param data the data to set in the GPU buffer
  148950. * @param offset the offset in the GPU buffer where to update the data
  148951. */
  148952. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  148953. /**
  148954. * Refreshes the bounding info, taking into account all the thin instances defined
  148955. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  148956. */
  148957. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  148958. /** @hidden */
  148959. _thinInstanceInitializeUserStorage(): void;
  148960. /** @hidden */
  148961. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  148962. /** @hidden */
  148963. _userThinInstanceBuffersStorage: {
  148964. data: {
  148965. [key: string]: Float32Array;
  148966. };
  148967. sizes: {
  148968. [key: string]: number;
  148969. };
  148970. vertexBuffers: {
  148971. [key: string]: Nullable<VertexBuffer>;
  148972. };
  148973. strides: {
  148974. [key: string]: number;
  148975. };
  148976. };
  148977. }
  148978. }
  148979. declare module BABYLON {
  148980. /**
  148981. * Navigation plugin interface to add navigation constrained by a navigation mesh
  148982. */
  148983. export interface INavigationEnginePlugin {
  148984. /**
  148985. * plugin name
  148986. */
  148987. name: string;
  148988. /**
  148989. * Creates a navigation mesh
  148990. * @param meshes array of all the geometry used to compute the navigatio mesh
  148991. * @param parameters bunch of parameters used to filter geometry
  148992. */
  148993. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148994. /**
  148995. * Create a navigation mesh debug mesh
  148996. * @param scene is where the mesh will be added
  148997. * @returns debug display mesh
  148998. */
  148999. createDebugNavMesh(scene: Scene): Mesh;
  149000. /**
  149001. * Get a navigation mesh constrained position, closest to the parameter position
  149002. * @param position world position
  149003. * @returns the closest point to position constrained by the navigation mesh
  149004. */
  149005. getClosestPoint(position: Vector3): Vector3;
  149006. /**
  149007. * Get a navigation mesh constrained position, closest to the parameter position
  149008. * @param position world position
  149009. * @param result output the closest point to position constrained by the navigation mesh
  149010. */
  149011. getClosestPointToRef(position: Vector3, result: Vector3): void;
  149012. /**
  149013. * Get a navigation mesh constrained position, within a particular radius
  149014. * @param position world position
  149015. * @param maxRadius the maximum distance to the constrained world position
  149016. * @returns the closest point to position constrained by the navigation mesh
  149017. */
  149018. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  149019. /**
  149020. * Get a navigation mesh constrained position, within a particular radius
  149021. * @param position world position
  149022. * @param maxRadius the maximum distance to the constrained world position
  149023. * @param result output the closest point to position constrained by the navigation mesh
  149024. */
  149025. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  149026. /**
  149027. * Compute the final position from a segment made of destination-position
  149028. * @param position world position
  149029. * @param destination world position
  149030. * @returns the resulting point along the navmesh
  149031. */
  149032. moveAlong(position: Vector3, destination: Vector3): Vector3;
  149033. /**
  149034. * Compute the final position from a segment made of destination-position
  149035. * @param position world position
  149036. * @param destination world position
  149037. * @param result output the resulting point along the navmesh
  149038. */
  149039. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  149040. /**
  149041. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  149042. * @param start world position
  149043. * @param end world position
  149044. * @returns array containing world position composing the path
  149045. */
  149046. computePath(start: Vector3, end: Vector3): Vector3[];
  149047. /**
  149048. * If this plugin is supported
  149049. * @returns true if plugin is supported
  149050. */
  149051. isSupported(): boolean;
  149052. /**
  149053. * Create a new Crowd so you can add agents
  149054. * @param maxAgents the maximum agent count in the crowd
  149055. * @param maxAgentRadius the maximum radius an agent can have
  149056. * @param scene to attach the crowd to
  149057. * @returns the crowd you can add agents to
  149058. */
  149059. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  149060. /**
  149061. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149062. * The queries will try to find a solution within those bounds
  149063. * default is (1,1,1)
  149064. * @param extent x,y,z value that define the extent around the queries point of reference
  149065. */
  149066. setDefaultQueryExtent(extent: Vector3): void;
  149067. /**
  149068. * Get the Bounding box extent specified by setDefaultQueryExtent
  149069. * @returns the box extent values
  149070. */
  149071. getDefaultQueryExtent(): Vector3;
  149072. /**
  149073. * build the navmesh from a previously saved state using getNavmeshData
  149074. * @param data the Uint8Array returned by getNavmeshData
  149075. */
  149076. buildFromNavmeshData(data: Uint8Array): void;
  149077. /**
  149078. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  149079. * @returns data the Uint8Array that can be saved and reused
  149080. */
  149081. getNavmeshData(): Uint8Array;
  149082. /**
  149083. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149084. * @param result output the box extent values
  149085. */
  149086. getDefaultQueryExtentToRef(result: Vector3): void;
  149087. /**
  149088. * Release all resources
  149089. */
  149090. dispose(): void;
  149091. }
  149092. /**
  149093. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  149094. */
  149095. export interface ICrowd {
  149096. /**
  149097. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  149098. * You can attach anything to that node. The node position is updated in the scene update tick.
  149099. * @param pos world position that will be constrained by the navigation mesh
  149100. * @param parameters agent parameters
  149101. * @param transform hooked to the agent that will be update by the scene
  149102. * @returns agent index
  149103. */
  149104. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  149105. /**
  149106. * Returns the agent position in world space
  149107. * @param index agent index returned by addAgent
  149108. * @returns world space position
  149109. */
  149110. getAgentPosition(index: number): Vector3;
  149111. /**
  149112. * Gets the agent position result in world space
  149113. * @param index agent index returned by addAgent
  149114. * @param result output world space position
  149115. */
  149116. getAgentPositionToRef(index: number, result: Vector3): void;
  149117. /**
  149118. * Gets the agent velocity in world space
  149119. * @param index agent index returned by addAgent
  149120. * @returns world space velocity
  149121. */
  149122. getAgentVelocity(index: number): Vector3;
  149123. /**
  149124. * Gets the agent velocity result in world space
  149125. * @param index agent index returned by addAgent
  149126. * @param result output world space velocity
  149127. */
  149128. getAgentVelocityToRef(index: number, result: Vector3): void;
  149129. /**
  149130. * Gets the agent next target point on the path
  149131. * @param index agent index returned by addAgent
  149132. * @returns world space position
  149133. */
  149134. getAgentNextTargetPath(index: number): Vector3;
  149135. /**
  149136. * Gets the agent state
  149137. * @param index agent index returned by addAgent
  149138. * @returns agent state
  149139. */
  149140. getAgentState(index: number): number;
  149141. /**
  149142. * returns true if the agent in over an off mesh link connection
  149143. * @param index agent index returned by addAgent
  149144. * @returns true if over an off mesh link connection
  149145. */
  149146. overOffmeshConnection(index: number): boolean;
  149147. /**
  149148. * Gets the agent next target point on the path
  149149. * @param index agent index returned by addAgent
  149150. * @param result output world space position
  149151. */
  149152. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  149153. /**
  149154. * remove a particular agent previously created
  149155. * @param index agent index returned by addAgent
  149156. */
  149157. removeAgent(index: number): void;
  149158. /**
  149159. * get the list of all agents attached to this crowd
  149160. * @returns list of agent indices
  149161. */
  149162. getAgents(): number[];
  149163. /**
  149164. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  149165. * @param deltaTime in seconds
  149166. */
  149167. update(deltaTime: number): void;
  149168. /**
  149169. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  149170. * @param index agent index returned by addAgent
  149171. * @param destination targeted world position
  149172. */
  149173. agentGoto(index: number, destination: Vector3): void;
  149174. /**
  149175. * Teleport the agent to a new position
  149176. * @param index agent index returned by addAgent
  149177. * @param destination targeted world position
  149178. */
  149179. agentTeleport(index: number, destination: Vector3): void;
  149180. /**
  149181. * Update agent parameters
  149182. * @param index agent index returned by addAgent
  149183. * @param parameters agent parameters
  149184. */
  149185. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  149186. /**
  149187. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149188. * The queries will try to find a solution within those bounds
  149189. * default is (1,1,1)
  149190. * @param extent x,y,z value that define the extent around the queries point of reference
  149191. */
  149192. setDefaultQueryExtent(extent: Vector3): void;
  149193. /**
  149194. * Get the Bounding box extent specified by setDefaultQueryExtent
  149195. * @returns the box extent values
  149196. */
  149197. getDefaultQueryExtent(): Vector3;
  149198. /**
  149199. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149200. * @param result output the box extent values
  149201. */
  149202. getDefaultQueryExtentToRef(result: Vector3): void;
  149203. /**
  149204. * Release all resources
  149205. */
  149206. dispose(): void;
  149207. }
  149208. /**
  149209. * Configures an agent
  149210. */
  149211. export interface IAgentParameters {
  149212. /**
  149213. * Agent radius. [Limit: >= 0]
  149214. */
  149215. radius: number;
  149216. /**
  149217. * Agent height. [Limit: > 0]
  149218. */
  149219. height: number;
  149220. /**
  149221. * Maximum allowed acceleration. [Limit: >= 0]
  149222. */
  149223. maxAcceleration: number;
  149224. /**
  149225. * Maximum allowed speed. [Limit: >= 0]
  149226. */
  149227. maxSpeed: number;
  149228. /**
  149229. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  149230. */
  149231. collisionQueryRange: number;
  149232. /**
  149233. * The path visibility optimization range. [Limit: > 0]
  149234. */
  149235. pathOptimizationRange: number;
  149236. /**
  149237. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  149238. */
  149239. separationWeight: number;
  149240. }
  149241. /**
  149242. * Configures the navigation mesh creation
  149243. */
  149244. export interface INavMeshParameters {
  149245. /**
  149246. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  149247. */
  149248. cs: number;
  149249. /**
  149250. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  149251. */
  149252. ch: number;
  149253. /**
  149254. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  149255. */
  149256. walkableSlopeAngle: number;
  149257. /**
  149258. * Minimum floor to 'ceiling' height that will still allow the floor area to
  149259. * be considered walkable. [Limit: >= 3] [Units: vx]
  149260. */
  149261. walkableHeight: number;
  149262. /**
  149263. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  149264. */
  149265. walkableClimb: number;
  149266. /**
  149267. * The distance to erode/shrink the walkable area of the heightfield away from
  149268. * obstructions. [Limit: >=0] [Units: vx]
  149269. */
  149270. walkableRadius: number;
  149271. /**
  149272. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  149273. */
  149274. maxEdgeLen: number;
  149275. /**
  149276. * The maximum distance a simplfied contour's border edges should deviate
  149277. * the original raw contour. [Limit: >=0] [Units: vx]
  149278. */
  149279. maxSimplificationError: number;
  149280. /**
  149281. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  149282. */
  149283. minRegionArea: number;
  149284. /**
  149285. * Any regions with a span count smaller than this value will, if possible,
  149286. * be merged with larger regions. [Limit: >=0] [Units: vx]
  149287. */
  149288. mergeRegionArea: number;
  149289. /**
  149290. * The maximum number of vertices allowed for polygons generated during the
  149291. * contour to polygon conversion process. [Limit: >= 3]
  149292. */
  149293. maxVertsPerPoly: number;
  149294. /**
  149295. * Sets the sampling distance to use when generating the detail mesh.
  149296. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  149297. */
  149298. detailSampleDist: number;
  149299. /**
  149300. * The maximum distance the detail mesh surface should deviate from heightfield
  149301. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  149302. */
  149303. detailSampleMaxError: number;
  149304. }
  149305. }
  149306. declare module BABYLON {
  149307. /**
  149308. * RecastJS navigation plugin
  149309. */
  149310. export class RecastJSPlugin implements INavigationEnginePlugin {
  149311. /**
  149312. * Reference to the Recast library
  149313. */
  149314. bjsRECAST: any;
  149315. /**
  149316. * plugin name
  149317. */
  149318. name: string;
  149319. /**
  149320. * the first navmesh created. We might extend this to support multiple navmeshes
  149321. */
  149322. navMesh: any;
  149323. /**
  149324. * Initializes the recastJS plugin
  149325. * @param recastInjection can be used to inject your own recast reference
  149326. */
  149327. constructor(recastInjection?: any);
  149328. /**
  149329. * Creates a navigation mesh
  149330. * @param meshes array of all the geometry used to compute the navigatio mesh
  149331. * @param parameters bunch of parameters used to filter geometry
  149332. */
  149333. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  149334. /**
  149335. * Create a navigation mesh debug mesh
  149336. * @param scene is where the mesh will be added
  149337. * @returns debug display mesh
  149338. */
  149339. createDebugNavMesh(scene: Scene): Mesh;
  149340. /**
  149341. * Get a navigation mesh constrained position, closest to the parameter position
  149342. * @param position world position
  149343. * @returns the closest point to position constrained by the navigation mesh
  149344. */
  149345. getClosestPoint(position: Vector3): Vector3;
  149346. /**
  149347. * Get a navigation mesh constrained position, closest to the parameter position
  149348. * @param position world position
  149349. * @param result output the closest point to position constrained by the navigation mesh
  149350. */
  149351. getClosestPointToRef(position: Vector3, result: Vector3): void;
  149352. /**
  149353. * Get a navigation mesh constrained position, within a particular radius
  149354. * @param position world position
  149355. * @param maxRadius the maximum distance to the constrained world position
  149356. * @returns the closest point to position constrained by the navigation mesh
  149357. */
  149358. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  149359. /**
  149360. * Get a navigation mesh constrained position, within a particular radius
  149361. * @param position world position
  149362. * @param maxRadius the maximum distance to the constrained world position
  149363. * @param result output the closest point to position constrained by the navigation mesh
  149364. */
  149365. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  149366. /**
  149367. * Compute the final position from a segment made of destination-position
  149368. * @param position world position
  149369. * @param destination world position
  149370. * @returns the resulting point along the navmesh
  149371. */
  149372. moveAlong(position: Vector3, destination: Vector3): Vector3;
  149373. /**
  149374. * Compute the final position from a segment made of destination-position
  149375. * @param position world position
  149376. * @param destination world position
  149377. * @param result output the resulting point along the navmesh
  149378. */
  149379. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  149380. /**
  149381. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  149382. * @param start world position
  149383. * @param end world position
  149384. * @returns array containing world position composing the path
  149385. */
  149386. computePath(start: Vector3, end: Vector3): Vector3[];
  149387. /**
  149388. * Create a new Crowd so you can add agents
  149389. * @param maxAgents the maximum agent count in the crowd
  149390. * @param maxAgentRadius the maximum radius an agent can have
  149391. * @param scene to attach the crowd to
  149392. * @returns the crowd you can add agents to
  149393. */
  149394. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  149395. /**
  149396. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149397. * The queries will try to find a solution within those bounds
  149398. * default is (1,1,1)
  149399. * @param extent x,y,z value that define the extent around the queries point of reference
  149400. */
  149401. setDefaultQueryExtent(extent: Vector3): void;
  149402. /**
  149403. * Get the Bounding box extent specified by setDefaultQueryExtent
  149404. * @returns the box extent values
  149405. */
  149406. getDefaultQueryExtent(): Vector3;
  149407. /**
  149408. * build the navmesh from a previously saved state using getNavmeshData
  149409. * @param data the Uint8Array returned by getNavmeshData
  149410. */
  149411. buildFromNavmeshData(data: Uint8Array): void;
  149412. /**
  149413. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  149414. * @returns data the Uint8Array that can be saved and reused
  149415. */
  149416. getNavmeshData(): Uint8Array;
  149417. /**
  149418. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149419. * @param result output the box extent values
  149420. */
  149421. getDefaultQueryExtentToRef(result: Vector3): void;
  149422. /**
  149423. * Disposes
  149424. */
  149425. dispose(): void;
  149426. /**
  149427. * If this plugin is supported
  149428. * @returns true if plugin is supported
  149429. */
  149430. isSupported(): boolean;
  149431. }
  149432. /**
  149433. * Recast detour crowd implementation
  149434. */
  149435. export class RecastJSCrowd implements ICrowd {
  149436. /**
  149437. * Recast/detour plugin
  149438. */
  149439. bjsRECASTPlugin: RecastJSPlugin;
  149440. /**
  149441. * Link to the detour crowd
  149442. */
  149443. recastCrowd: any;
  149444. /**
  149445. * One transform per agent
  149446. */
  149447. transforms: TransformNode[];
  149448. /**
  149449. * All agents created
  149450. */
  149451. agents: number[];
  149452. /**
  149453. * Link to the scene is kept to unregister the crowd from the scene
  149454. */
  149455. private _scene;
  149456. /**
  149457. * Observer for crowd updates
  149458. */
  149459. private _onBeforeAnimationsObserver;
  149460. /**
  149461. * Constructor
  149462. * @param plugin recastJS plugin
  149463. * @param maxAgents the maximum agent count in the crowd
  149464. * @param maxAgentRadius the maximum radius an agent can have
  149465. * @param scene to attach the crowd to
  149466. * @returns the crowd you can add agents to
  149467. */
  149468. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  149469. /**
  149470. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  149471. * You can attach anything to that node. The node position is updated in the scene update tick.
  149472. * @param pos world position that will be constrained by the navigation mesh
  149473. * @param parameters agent parameters
  149474. * @param transform hooked to the agent that will be update by the scene
  149475. * @returns agent index
  149476. */
  149477. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  149478. /**
  149479. * Returns the agent position in world space
  149480. * @param index agent index returned by addAgent
  149481. * @returns world space position
  149482. */
  149483. getAgentPosition(index: number): Vector3;
  149484. /**
  149485. * Returns the agent position result in world space
  149486. * @param index agent index returned by addAgent
  149487. * @param result output world space position
  149488. */
  149489. getAgentPositionToRef(index: number, result: Vector3): void;
  149490. /**
  149491. * Returns the agent velocity in world space
  149492. * @param index agent index returned by addAgent
  149493. * @returns world space velocity
  149494. */
  149495. getAgentVelocity(index: number): Vector3;
  149496. /**
  149497. * Returns the agent velocity result in world space
  149498. * @param index agent index returned by addAgent
  149499. * @param result output world space velocity
  149500. */
  149501. getAgentVelocityToRef(index: number, result: Vector3): void;
  149502. /**
  149503. * Returns the agent next target point on the path
  149504. * @param index agent index returned by addAgent
  149505. * @returns world space position
  149506. */
  149507. getAgentNextTargetPath(index: number): Vector3;
  149508. /**
  149509. * Returns the agent next target point on the path
  149510. * @param index agent index returned by addAgent
  149511. * @param result output world space position
  149512. */
  149513. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  149514. /**
  149515. * Gets the agent state
  149516. * @param index agent index returned by addAgent
  149517. * @returns agent state
  149518. */
  149519. getAgentState(index: number): number;
  149520. /**
  149521. * returns true if the agent in over an off mesh link connection
  149522. * @param index agent index returned by addAgent
  149523. * @returns true if over an off mesh link connection
  149524. */
  149525. overOffmeshConnection(index: number): boolean;
  149526. /**
  149527. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  149528. * @param index agent index returned by addAgent
  149529. * @param destination targeted world position
  149530. */
  149531. agentGoto(index: number, destination: Vector3): void;
  149532. /**
  149533. * Teleport the agent to a new position
  149534. * @param index agent index returned by addAgent
  149535. * @param destination targeted world position
  149536. */
  149537. agentTeleport(index: number, destination: Vector3): void;
  149538. /**
  149539. * Update agent parameters
  149540. * @param index agent index returned by addAgent
  149541. * @param parameters agent parameters
  149542. */
  149543. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  149544. /**
  149545. * remove a particular agent previously created
  149546. * @param index agent index returned by addAgent
  149547. */
  149548. removeAgent(index: number): void;
  149549. /**
  149550. * get the list of all agents attached to this crowd
  149551. * @returns list of agent indices
  149552. */
  149553. getAgents(): number[];
  149554. /**
  149555. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  149556. * @param deltaTime in seconds
  149557. */
  149558. update(deltaTime: number): void;
  149559. /**
  149560. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149561. * The queries will try to find a solution within those bounds
  149562. * default is (1,1,1)
  149563. * @param extent x,y,z value that define the extent around the queries point of reference
  149564. */
  149565. setDefaultQueryExtent(extent: Vector3): void;
  149566. /**
  149567. * Get the Bounding box extent specified by setDefaultQueryExtent
  149568. * @returns the box extent values
  149569. */
  149570. getDefaultQueryExtent(): Vector3;
  149571. /**
  149572. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149573. * @param result output the box extent values
  149574. */
  149575. getDefaultQueryExtentToRef(result: Vector3): void;
  149576. /**
  149577. * Release all resources
  149578. */
  149579. dispose(): void;
  149580. }
  149581. }
  149582. declare module BABYLON {
  149583. /**
  149584. * Class used to enable access to IndexedDB
  149585. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  149586. */
  149587. export class Database implements IOfflineProvider {
  149588. private _callbackManifestChecked;
  149589. private _currentSceneUrl;
  149590. private _db;
  149591. private _enableSceneOffline;
  149592. private _enableTexturesOffline;
  149593. private _manifestVersionFound;
  149594. private _mustUpdateRessources;
  149595. private _hasReachedQuota;
  149596. private _isSupported;
  149597. private _idbFactory;
  149598. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  149599. private static IsUASupportingBlobStorage;
  149600. /**
  149601. * Gets a boolean indicating if Database storate is enabled (off by default)
  149602. */
  149603. static IDBStorageEnabled: boolean;
  149604. /**
  149605. * Gets a boolean indicating if scene must be saved in the database
  149606. */
  149607. get enableSceneOffline(): boolean;
  149608. /**
  149609. * Gets a boolean indicating if textures must be saved in the database
  149610. */
  149611. get enableTexturesOffline(): boolean;
  149612. /**
  149613. * Creates a new Database
  149614. * @param urlToScene defines the url to load the scene
  149615. * @param callbackManifestChecked defines the callback to use when manifest is checked
  149616. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  149617. */
  149618. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  149619. private static _ParseURL;
  149620. private static _ReturnFullUrlLocation;
  149621. private _checkManifestFile;
  149622. /**
  149623. * Open the database and make it available
  149624. * @param successCallback defines the callback to call on success
  149625. * @param errorCallback defines the callback to call on error
  149626. */
  149627. open(successCallback: () => void, errorCallback: () => void): void;
  149628. /**
  149629. * Loads an image from the database
  149630. * @param url defines the url to load from
  149631. * @param image defines the target DOM image
  149632. */
  149633. loadImage(url: string, image: HTMLImageElement): void;
  149634. private _loadImageFromDBAsync;
  149635. private _saveImageIntoDBAsync;
  149636. private _checkVersionFromDB;
  149637. private _loadVersionFromDBAsync;
  149638. private _saveVersionIntoDBAsync;
  149639. /**
  149640. * Loads a file from database
  149641. * @param url defines the URL to load from
  149642. * @param sceneLoaded defines a callback to call on success
  149643. * @param progressCallBack defines a callback to call when progress changed
  149644. * @param errorCallback defines a callback to call on error
  149645. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  149646. */
  149647. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  149648. private _loadFileAsync;
  149649. private _saveFileAsync;
  149650. /**
  149651. * Validates if xhr data is correct
  149652. * @param xhr defines the request to validate
  149653. * @param dataType defines the expected data type
  149654. * @returns true if data is correct
  149655. */
  149656. private static _ValidateXHRData;
  149657. }
  149658. }
  149659. declare module BABYLON {
  149660. /** @hidden */
  149661. export var gpuUpdateParticlesPixelShader: {
  149662. name: string;
  149663. shader: string;
  149664. };
  149665. }
  149666. declare module BABYLON {
  149667. /** @hidden */
  149668. export var gpuUpdateParticlesVertexShader: {
  149669. name: string;
  149670. shader: string;
  149671. };
  149672. }
  149673. declare module BABYLON {
  149674. /** @hidden */
  149675. export var clipPlaneFragmentDeclaration2: {
  149676. name: string;
  149677. shader: string;
  149678. };
  149679. }
  149680. declare module BABYLON {
  149681. /** @hidden */
  149682. export var gpuRenderParticlesPixelShader: {
  149683. name: string;
  149684. shader: string;
  149685. };
  149686. }
  149687. declare module BABYLON {
  149688. /** @hidden */
  149689. export var clipPlaneVertexDeclaration2: {
  149690. name: string;
  149691. shader: string;
  149692. };
  149693. }
  149694. declare module BABYLON {
  149695. /** @hidden */
  149696. export var gpuRenderParticlesVertexShader: {
  149697. name: string;
  149698. shader: string;
  149699. };
  149700. }
  149701. declare module BABYLON {
  149702. /**
  149703. * This represents a GPU particle system in Babylon
  149704. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  149705. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  149706. */
  149707. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  149708. /**
  149709. * The layer mask we are rendering the particles through.
  149710. */
  149711. layerMask: number;
  149712. private _capacity;
  149713. private _activeCount;
  149714. private _currentActiveCount;
  149715. private _accumulatedCount;
  149716. private _renderEffect;
  149717. private _updateEffect;
  149718. private _buffer0;
  149719. private _buffer1;
  149720. private _spriteBuffer;
  149721. private _updateVAO;
  149722. private _renderVAO;
  149723. private _targetIndex;
  149724. private _sourceBuffer;
  149725. private _targetBuffer;
  149726. private _currentRenderId;
  149727. private _started;
  149728. private _stopped;
  149729. private _timeDelta;
  149730. private _randomTexture;
  149731. private _randomTexture2;
  149732. private _attributesStrideSize;
  149733. private _updateEffectOptions;
  149734. private _randomTextureSize;
  149735. private _actualFrame;
  149736. private _customEffect;
  149737. private readonly _rawTextureWidth;
  149738. /**
  149739. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  149740. */
  149741. static get IsSupported(): boolean;
  149742. /**
  149743. * An event triggered when the system is disposed.
  149744. */
  149745. onDisposeObservable: Observable<IParticleSystem>;
  149746. /**
  149747. * An event triggered when the system is stopped
  149748. */
  149749. onStoppedObservable: Observable<IParticleSystem>;
  149750. /**
  149751. * Gets the maximum number of particles active at the same time.
  149752. * @returns The max number of active particles.
  149753. */
  149754. getCapacity(): number;
  149755. /**
  149756. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  149757. * to override the particles.
  149758. */
  149759. forceDepthWrite: boolean;
  149760. /**
  149761. * Gets or set the number of active particles
  149762. */
  149763. get activeParticleCount(): number;
  149764. set activeParticleCount(value: number);
  149765. private _preWarmDone;
  149766. /**
  149767. * Specifies if the particles are updated in emitter local space or world space.
  149768. */
  149769. isLocal: boolean;
  149770. /** Gets or sets a matrix to use to compute projection */
  149771. defaultProjectionMatrix: Matrix;
  149772. /**
  149773. * Is this system ready to be used/rendered
  149774. * @return true if the system is ready
  149775. */
  149776. isReady(): boolean;
  149777. /**
  149778. * Gets if the system has been started. (Note: this will still be true after stop is called)
  149779. * @returns True if it has been started, otherwise false.
  149780. */
  149781. isStarted(): boolean;
  149782. /**
  149783. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  149784. * @returns True if it has been stopped, otherwise false.
  149785. */
  149786. isStopped(): boolean;
  149787. /**
  149788. * Gets a boolean indicating that the system is stopping
  149789. * @returns true if the system is currently stopping
  149790. */
  149791. isStopping(): boolean;
  149792. /**
  149793. * Gets the number of particles active at the same time.
  149794. * @returns The number of active particles.
  149795. */
  149796. getActiveCount(): number;
  149797. /**
  149798. * Starts the particle system and begins to emit
  149799. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  149800. */
  149801. start(delay?: number): void;
  149802. /**
  149803. * Stops the particle system.
  149804. */
  149805. stop(): void;
  149806. /**
  149807. * Remove all active particles
  149808. */
  149809. reset(): void;
  149810. /**
  149811. * Returns the string "GPUParticleSystem"
  149812. * @returns a string containing the class name
  149813. */
  149814. getClassName(): string;
  149815. /**
  149816. * Gets the custom effect used to render the particles
  149817. * @param blendMode Blend mode for which the effect should be retrieved
  149818. * @returns The effect
  149819. */
  149820. getCustomEffect(blendMode?: number): Nullable<Effect>;
  149821. /**
  149822. * Sets the custom effect used to render the particles
  149823. * @param effect The effect to set
  149824. * @param blendMode Blend mode for which the effect should be set
  149825. */
  149826. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  149827. /** @hidden */
  149828. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  149829. /**
  149830. * Observable that will be called just before the particles are drawn
  149831. */
  149832. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  149833. /**
  149834. * Gets the name of the particle vertex shader
  149835. */
  149836. get vertexShaderName(): string;
  149837. private _colorGradientsTexture;
  149838. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  149839. /**
  149840. * Adds a new color gradient
  149841. * @param gradient defines the gradient to use (between 0 and 1)
  149842. * @param color1 defines the color to affect to the specified gradient
  149843. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  149844. * @returns the current particle system
  149845. */
  149846. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  149847. private _refreshColorGradient;
  149848. /** Force the system to rebuild all gradients that need to be resync */
  149849. forceRefreshGradients(): void;
  149850. /**
  149851. * Remove a specific color gradient
  149852. * @param gradient defines the gradient to remove
  149853. * @returns the current particle system
  149854. */
  149855. removeColorGradient(gradient: number): GPUParticleSystem;
  149856. private _angularSpeedGradientsTexture;
  149857. private _sizeGradientsTexture;
  149858. private _velocityGradientsTexture;
  149859. private _limitVelocityGradientsTexture;
  149860. private _dragGradientsTexture;
  149861. private _addFactorGradient;
  149862. /**
  149863. * Adds a new size gradient
  149864. * @param gradient defines the gradient to use (between 0 and 1)
  149865. * @param factor defines the size factor to affect to the specified gradient
  149866. * @returns the current particle system
  149867. */
  149868. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  149869. /**
  149870. * Remove a specific size gradient
  149871. * @param gradient defines the gradient to remove
  149872. * @returns the current particle system
  149873. */
  149874. removeSizeGradient(gradient: number): GPUParticleSystem;
  149875. private _refreshFactorGradient;
  149876. /**
  149877. * Adds a new angular speed gradient
  149878. * @param gradient defines the gradient to use (between 0 and 1)
  149879. * @param factor defines the angular speed to affect to the specified gradient
  149880. * @returns the current particle system
  149881. */
  149882. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  149883. /**
  149884. * Remove a specific angular speed gradient
  149885. * @param gradient defines the gradient to remove
  149886. * @returns the current particle system
  149887. */
  149888. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  149889. /**
  149890. * Adds a new velocity gradient
  149891. * @param gradient defines the gradient to use (between 0 and 1)
  149892. * @param factor defines the velocity to affect to the specified gradient
  149893. * @returns the current particle system
  149894. */
  149895. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  149896. /**
  149897. * Remove a specific velocity gradient
  149898. * @param gradient defines the gradient to remove
  149899. * @returns the current particle system
  149900. */
  149901. removeVelocityGradient(gradient: number): GPUParticleSystem;
  149902. /**
  149903. * Adds a new limit velocity gradient
  149904. * @param gradient defines the gradient to use (between 0 and 1)
  149905. * @param factor defines the limit velocity value to affect to the specified gradient
  149906. * @returns the current particle system
  149907. */
  149908. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  149909. /**
  149910. * Remove a specific limit velocity gradient
  149911. * @param gradient defines the gradient to remove
  149912. * @returns the current particle system
  149913. */
  149914. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  149915. /**
  149916. * Adds a new drag gradient
  149917. * @param gradient defines the gradient to use (between 0 and 1)
  149918. * @param factor defines the drag value to affect to the specified gradient
  149919. * @returns the current particle system
  149920. */
  149921. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  149922. /**
  149923. * Remove a specific drag gradient
  149924. * @param gradient defines the gradient to remove
  149925. * @returns the current particle system
  149926. */
  149927. removeDragGradient(gradient: number): GPUParticleSystem;
  149928. /**
  149929. * Not supported by GPUParticleSystem
  149930. * @param gradient defines the gradient to use (between 0 and 1)
  149931. * @param factor defines the emit rate value to affect to the specified gradient
  149932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149933. * @returns the current particle system
  149934. */
  149935. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149936. /**
  149937. * Not supported by GPUParticleSystem
  149938. * @param gradient defines the gradient to remove
  149939. * @returns the current particle system
  149940. */
  149941. removeEmitRateGradient(gradient: number): IParticleSystem;
  149942. /**
  149943. * Not supported by GPUParticleSystem
  149944. * @param gradient defines the gradient to use (between 0 and 1)
  149945. * @param factor defines the start size value to affect to the specified gradient
  149946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149947. * @returns the current particle system
  149948. */
  149949. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149950. /**
  149951. * Not supported by GPUParticleSystem
  149952. * @param gradient defines the gradient to remove
  149953. * @returns the current particle system
  149954. */
  149955. removeStartSizeGradient(gradient: number): IParticleSystem;
  149956. /**
  149957. * Not supported by GPUParticleSystem
  149958. * @param gradient defines the gradient to use (between 0 and 1)
  149959. * @param min defines the color remap minimal range
  149960. * @param max defines the color remap maximal range
  149961. * @returns the current particle system
  149962. */
  149963. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  149964. /**
  149965. * Not supported by GPUParticleSystem
  149966. * @param gradient defines the gradient to remove
  149967. * @returns the current particle system
  149968. */
  149969. removeColorRemapGradient(): IParticleSystem;
  149970. /**
  149971. * Not supported by GPUParticleSystem
  149972. * @param gradient defines the gradient to use (between 0 and 1)
  149973. * @param min defines the alpha remap minimal range
  149974. * @param max defines the alpha remap maximal range
  149975. * @returns the current particle system
  149976. */
  149977. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  149978. /**
  149979. * Not supported by GPUParticleSystem
  149980. * @param gradient defines the gradient to remove
  149981. * @returns the current particle system
  149982. */
  149983. removeAlphaRemapGradient(): IParticleSystem;
  149984. /**
  149985. * Not supported by GPUParticleSystem
  149986. * @param gradient defines the gradient to use (between 0 and 1)
  149987. * @param color defines the color to affect to the specified gradient
  149988. * @returns the current particle system
  149989. */
  149990. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  149991. /**
  149992. * Not supported by GPUParticleSystem
  149993. * @param gradient defines the gradient to remove
  149994. * @returns the current particle system
  149995. */
  149996. removeRampGradient(): IParticleSystem;
  149997. /**
  149998. * Not supported by GPUParticleSystem
  149999. * @returns the list of ramp gradients
  150000. */
  150001. getRampGradients(): Nullable<Array<Color3Gradient>>;
  150002. /**
  150003. * Not supported by GPUParticleSystem
  150004. * Gets or sets a boolean indicating that ramp gradients must be used
  150005. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  150006. */
  150007. get useRampGradients(): boolean;
  150008. set useRampGradients(value: boolean);
  150009. /**
  150010. * Not supported by GPUParticleSystem
  150011. * @param gradient defines the gradient to use (between 0 and 1)
  150012. * @param factor defines the life time factor to affect to the specified gradient
  150013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150014. * @returns the current particle system
  150015. */
  150016. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150017. /**
  150018. * Not supported by GPUParticleSystem
  150019. * @param gradient defines the gradient to remove
  150020. * @returns the current particle system
  150021. */
  150022. removeLifeTimeGradient(gradient: number): IParticleSystem;
  150023. /**
  150024. * Instantiates a GPU particle system.
  150025. * 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.
  150026. * @param name The name of the particle system
  150027. * @param options The options used to create the system
  150028. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  150029. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  150030. * @param customEffect a custom effect used to change the way particles are rendered by default
  150031. */
  150032. constructor(name: string, options: Partial<{
  150033. capacity: number;
  150034. randomTextureSize: number;
  150035. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  150036. protected _reset(): void;
  150037. private _createUpdateVAO;
  150038. private _createRenderVAO;
  150039. private _initialize;
  150040. /** @hidden */
  150041. _recreateUpdateEffect(): void;
  150042. private _getEffect;
  150043. /**
  150044. * Fill the defines array according to the current settings of the particle system
  150045. * @param defines Array to be updated
  150046. * @param blendMode blend mode to take into account when updating the array
  150047. */
  150048. fillDefines(defines: Array<string>, blendMode?: number): void;
  150049. /**
  150050. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  150051. * @param uniforms Uniforms array to fill
  150052. * @param attributes Attributes array to fill
  150053. * @param samplers Samplers array to fill
  150054. */
  150055. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  150056. /** @hidden */
  150057. _recreateRenderEffect(): Effect;
  150058. /**
  150059. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  150060. * @param preWarm defines if we are in the pre-warmimg phase
  150061. */
  150062. animate(preWarm?: boolean): void;
  150063. private _createFactorGradientTexture;
  150064. private _createSizeGradientTexture;
  150065. private _createAngularSpeedGradientTexture;
  150066. private _createVelocityGradientTexture;
  150067. private _createLimitVelocityGradientTexture;
  150068. private _createDragGradientTexture;
  150069. private _createColorGradientTexture;
  150070. /**
  150071. * Renders the particle system in its current state
  150072. * @param preWarm defines if the system should only update the particles but not render them
  150073. * @returns the current number of particles
  150074. */
  150075. render(preWarm?: boolean): number;
  150076. /**
  150077. * Rebuilds the particle system
  150078. */
  150079. rebuild(): void;
  150080. private _releaseBuffers;
  150081. private _releaseVAOs;
  150082. /**
  150083. * Disposes the particle system and free the associated resources
  150084. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  150085. */
  150086. dispose(disposeTexture?: boolean): void;
  150087. /**
  150088. * Clones the particle system.
  150089. * @param name The name of the cloned object
  150090. * @param newEmitter The new emitter to use
  150091. * @returns the cloned particle system
  150092. */
  150093. clone(name: string, newEmitter: any): GPUParticleSystem;
  150094. /**
  150095. * Serializes the particle system to a JSON object
  150096. * @param serializeTexture defines if the texture must be serialized as well
  150097. * @returns the JSON object
  150098. */
  150099. serialize(serializeTexture?: boolean): any;
  150100. /**
  150101. * Parses a JSON object to create a GPU particle system.
  150102. * @param parsedParticleSystem The JSON object to parse
  150103. * @param sceneOrEngine The scene or the engine to create the particle system in
  150104. * @param rootUrl The root url to use to load external dependencies like texture
  150105. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  150106. * @returns the parsed GPU particle system
  150107. */
  150108. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  150109. }
  150110. }
  150111. declare module BABYLON {
  150112. /**
  150113. * Represents a set of particle systems working together to create a specific effect
  150114. */
  150115. export class ParticleSystemSet implements IDisposable {
  150116. /**
  150117. * Gets or sets base Assets URL
  150118. */
  150119. static BaseAssetsUrl: string;
  150120. private _emitterCreationOptions;
  150121. private _emitterNode;
  150122. /**
  150123. * Gets the particle system list
  150124. */
  150125. systems: IParticleSystem[];
  150126. /**
  150127. * Gets the emitter node used with this set
  150128. */
  150129. get emitterNode(): Nullable<TransformNode>;
  150130. /**
  150131. * Creates a new emitter mesh as a sphere
  150132. * @param options defines the options used to create the sphere
  150133. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  150134. * @param scene defines the hosting scene
  150135. */
  150136. setEmitterAsSphere(options: {
  150137. diameter: number;
  150138. segments: number;
  150139. color: Color3;
  150140. }, renderingGroupId: number, scene: Scene): void;
  150141. /**
  150142. * Starts all particle systems of the set
  150143. * @param emitter defines an optional mesh to use as emitter for the particle systems
  150144. */
  150145. start(emitter?: AbstractMesh): void;
  150146. /**
  150147. * Release all associated resources
  150148. */
  150149. dispose(): void;
  150150. /**
  150151. * Serialize the set into a JSON compatible object
  150152. * @param serializeTexture defines if the texture must be serialized as well
  150153. * @returns a JSON compatible representation of the set
  150154. */
  150155. serialize(serializeTexture?: boolean): any;
  150156. /**
  150157. * Parse a new ParticleSystemSet from a serialized source
  150158. * @param data defines a JSON compatible representation of the set
  150159. * @param scene defines the hosting scene
  150160. * @param gpu defines if we want GPU particles or CPU particles
  150161. * @returns a new ParticleSystemSet
  150162. */
  150163. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  150164. }
  150165. }
  150166. declare module BABYLON {
  150167. /**
  150168. * This class is made for on one-liner static method to help creating particle system set.
  150169. */
  150170. export class ParticleHelper {
  150171. /**
  150172. * Gets or sets base Assets URL
  150173. */
  150174. static BaseAssetsUrl: string;
  150175. /** Define the Url to load snippets */
  150176. static SnippetUrl: string;
  150177. /**
  150178. * Create a default particle system that you can tweak
  150179. * @param emitter defines the emitter to use
  150180. * @param capacity defines the system capacity (default is 500 particles)
  150181. * @param scene defines the hosting scene
  150182. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  150183. * @returns the new Particle system
  150184. */
  150185. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  150186. /**
  150187. * This is the main static method (one-liner) of this helper to create different particle systems
  150188. * @param type This string represents the type to the particle system to create
  150189. * @param scene The scene where the particle system should live
  150190. * @param gpu If the system will use gpu
  150191. * @returns the ParticleSystemSet created
  150192. */
  150193. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  150194. /**
  150195. * Static function used to export a particle system to a ParticleSystemSet variable.
  150196. * Please note that the emitter shape is not exported
  150197. * @param systems defines the particle systems to export
  150198. * @returns the created particle system set
  150199. */
  150200. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  150201. /**
  150202. * Creates a particle system from a snippet saved in a remote file
  150203. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  150204. * @param url defines the url to load from
  150205. * @param scene defines the hosting scene
  150206. * @param gpu If the system will use gpu
  150207. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  150208. * @returns a promise that will resolve to the new particle system
  150209. */
  150210. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  150211. /**
  150212. * Creates a particle system from a snippet saved by the particle system editor
  150213. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  150214. * @param scene defines the hosting scene
  150215. * @param gpu If the system will use gpu
  150216. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  150217. * @returns a promise that will resolve to the new particle system
  150218. */
  150219. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  150220. }
  150221. }
  150222. declare module BABYLON {
  150223. interface Engine {
  150224. /**
  150225. * Create an effect to use with particle systems.
  150226. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  150227. * the particle system for which you want to create a custom effect in the last parameter
  150228. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  150229. * @param uniformsNames defines a list of attribute names
  150230. * @param samplers defines an array of string used to represent textures
  150231. * @param defines defines the string containing the defines to use to compile the shaders
  150232. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  150233. * @param onCompiled defines a function to call when the effect creation is successful
  150234. * @param onError defines a function to call when the effect creation has failed
  150235. * @param particleSystem the particle system you want to create the effect for
  150236. * @returns the new Effect
  150237. */
  150238. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  150239. }
  150240. interface Mesh {
  150241. /**
  150242. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  150243. * @returns an array of IParticleSystem
  150244. */
  150245. getEmittedParticleSystems(): IParticleSystem[];
  150246. /**
  150247. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  150248. * @returns an array of IParticleSystem
  150249. */
  150250. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  150251. }
  150252. }
  150253. declare module BABYLON {
  150254. /** Defines the 4 color options */
  150255. export enum PointColor {
  150256. /** color value */
  150257. Color = 2,
  150258. /** uv value */
  150259. UV = 1,
  150260. /** random value */
  150261. Random = 0,
  150262. /** stated value */
  150263. Stated = 3
  150264. }
  150265. /**
  150266. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  150267. * 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.
  150268. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  150269. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  150270. *
  150271. * Full documentation here : TO BE ENTERED
  150272. */
  150273. export class PointsCloudSystem implements IDisposable {
  150274. /**
  150275. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  150276. * Example : var p = SPS.particles[i];
  150277. */
  150278. particles: CloudPoint[];
  150279. /**
  150280. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  150281. */
  150282. nbParticles: number;
  150283. /**
  150284. * This a counter for your own usage. It's not set by any SPS functions.
  150285. */
  150286. counter: number;
  150287. /**
  150288. * The PCS name. This name is also given to the underlying mesh.
  150289. */
  150290. name: string;
  150291. /**
  150292. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  150293. */
  150294. mesh: Mesh;
  150295. /**
  150296. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  150297. * Please read :
  150298. */
  150299. vars: any;
  150300. /**
  150301. * @hidden
  150302. */
  150303. _size: number;
  150304. private _scene;
  150305. private _promises;
  150306. private _positions;
  150307. private _indices;
  150308. private _normals;
  150309. private _colors;
  150310. private _uvs;
  150311. private _indices32;
  150312. private _positions32;
  150313. private _colors32;
  150314. private _uvs32;
  150315. private _updatable;
  150316. private _isVisibilityBoxLocked;
  150317. private _alwaysVisible;
  150318. private _groups;
  150319. private _groupCounter;
  150320. private _computeParticleColor;
  150321. private _computeParticleTexture;
  150322. private _computeParticleRotation;
  150323. private _computeBoundingBox;
  150324. private _isReady;
  150325. /**
  150326. * Creates a PCS (Points Cloud System) object
  150327. * @param name (String) is the PCS name, this will be the underlying mesh name
  150328. * @param pointSize (number) is the size for each point
  150329. * @param scene (Scene) is the scene in which the PCS is added
  150330. * @param options defines the options of the PCS e.g.
  150331. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  150332. */
  150333. constructor(name: string, pointSize: number, scene: Scene, options?: {
  150334. updatable?: boolean;
  150335. });
  150336. /**
  150337. * Builds the PCS underlying mesh. Returns a standard Mesh.
  150338. * If no points were added to the PCS, the returned mesh is just a single point.
  150339. * @returns a promise for the created mesh
  150340. */
  150341. buildMeshAsync(): Promise<Mesh>;
  150342. /**
  150343. * @hidden
  150344. */
  150345. private _buildMesh;
  150346. private _addParticle;
  150347. private _randomUnitVector;
  150348. private _getColorIndicesForCoord;
  150349. private _setPointsColorOrUV;
  150350. private _colorFromTexture;
  150351. private _calculateDensity;
  150352. /**
  150353. * Adds points to the PCS in random positions within a unit sphere
  150354. * @param nb (positive integer) the number of particles to be created from this model
  150355. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  150356. * @returns the number of groups in the system
  150357. */
  150358. addPoints(nb: number, pointFunction?: any): number;
  150359. /**
  150360. * Adds points to the PCS from the surface of the model shape
  150361. * @param mesh is any Mesh object that will be used as a surface model for the points
  150362. * @param nb (positive integer) the number of particles to be created from this model
  150363. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  150364. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  150365. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  150366. * @returns the number of groups in the system
  150367. */
  150368. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  150369. /**
  150370. * Adds points to the PCS inside the model shape
  150371. * @param mesh is any Mesh object that will be used as a surface model for the points
  150372. * @param nb (positive integer) the number of particles to be created from this model
  150373. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  150374. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  150375. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  150376. * @returns the number of groups in the system
  150377. */
  150378. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  150379. /**
  150380. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  150381. * This method calls `updateParticle()` for each particle of the SPS.
  150382. * For an animated SPS, it is usually called within the render loop.
  150383. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  150384. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  150385. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  150386. * @returns the PCS.
  150387. */
  150388. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  150389. /**
  150390. * Disposes the PCS.
  150391. */
  150392. dispose(): void;
  150393. /**
  150394. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  150395. * doc :
  150396. * @returns the PCS.
  150397. */
  150398. refreshVisibleSize(): PointsCloudSystem;
  150399. /**
  150400. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  150401. * @param size the size (float) of the visibility box
  150402. * note : this doesn't lock the PCS mesh bounding box.
  150403. * doc :
  150404. */
  150405. setVisibilityBox(size: number): void;
  150406. /**
  150407. * Gets whether the PCS is always visible or not
  150408. * doc :
  150409. */
  150410. get isAlwaysVisible(): boolean;
  150411. /**
  150412. * Sets the PCS as always visible or not
  150413. * doc :
  150414. */
  150415. set isAlwaysVisible(val: boolean);
  150416. /**
  150417. * Tells to `setParticles()` to compute the particle rotations or not
  150418. * Default value : false. The PCS is faster when it's set to false
  150419. * Note : particle rotations are only applied to parent particles
  150420. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  150421. */
  150422. set computeParticleRotation(val: boolean);
  150423. /**
  150424. * Tells to `setParticles()` to compute the particle colors or not.
  150425. * Default value : true. The PCS is faster when it's set to false.
  150426. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  150427. */
  150428. set computeParticleColor(val: boolean);
  150429. set computeParticleTexture(val: boolean);
  150430. /**
  150431. * Gets if `setParticles()` computes the particle colors or not.
  150432. * Default value : false. The PCS is faster when it's set to false.
  150433. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  150434. */
  150435. get computeParticleColor(): boolean;
  150436. /**
  150437. * Gets if `setParticles()` computes the particle textures or not.
  150438. * Default value : false. The PCS is faster when it's set to false.
  150439. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  150440. */
  150441. get computeParticleTexture(): boolean;
  150442. /**
  150443. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  150444. */
  150445. set computeBoundingBox(val: boolean);
  150446. /**
  150447. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  150448. */
  150449. get computeBoundingBox(): boolean;
  150450. /**
  150451. * This function does nothing. It may be overwritten to set all the particle first values.
  150452. * The PCS doesn't call this function, you may have to call it by your own.
  150453. * doc :
  150454. */
  150455. initParticles(): void;
  150456. /**
  150457. * This function does nothing. It may be overwritten to recycle a particle
  150458. * The PCS doesn't call this function, you can to call it
  150459. * doc :
  150460. * @param particle The particle to recycle
  150461. * @returns the recycled particle
  150462. */
  150463. recycleParticle(particle: CloudPoint): CloudPoint;
  150464. /**
  150465. * Updates a particle : this function should be overwritten by the user.
  150466. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  150467. * doc :
  150468. * @example : just set a particle position or velocity and recycle conditions
  150469. * @param particle The particle to update
  150470. * @returns the updated particle
  150471. */
  150472. updateParticle(particle: CloudPoint): CloudPoint;
  150473. /**
  150474. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  150475. * This does nothing and may be overwritten by the user.
  150476. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  150477. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  150478. * @param update the boolean update value actually passed to setParticles()
  150479. */
  150480. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  150481. /**
  150482. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  150483. * This will be passed three parameters.
  150484. * This does nothing and may be overwritten by the user.
  150485. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  150486. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  150487. * @param update the boolean update value actually passed to setParticles()
  150488. */
  150489. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  150490. }
  150491. }
  150492. declare module BABYLON {
  150493. /**
  150494. * Represents one particle of a points cloud system.
  150495. */
  150496. export class CloudPoint {
  150497. /**
  150498. * particle global index
  150499. */
  150500. idx: number;
  150501. /**
  150502. * The color of the particle
  150503. */
  150504. color: Nullable<Color4>;
  150505. /**
  150506. * The world space position of the particle.
  150507. */
  150508. position: Vector3;
  150509. /**
  150510. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  150511. */
  150512. rotation: Vector3;
  150513. /**
  150514. * The world space rotation quaternion of the particle.
  150515. */
  150516. rotationQuaternion: Nullable<Quaternion>;
  150517. /**
  150518. * The uv of the particle.
  150519. */
  150520. uv: Nullable<Vector2>;
  150521. /**
  150522. * The current speed of the particle.
  150523. */
  150524. velocity: Vector3;
  150525. /**
  150526. * The pivot point in the particle local space.
  150527. */
  150528. pivot: Vector3;
  150529. /**
  150530. * Must the particle be translated from its pivot point in its local space ?
  150531. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  150532. * Default : false
  150533. */
  150534. translateFromPivot: boolean;
  150535. /**
  150536. * Index of this particle in the global "positions" array (Internal use)
  150537. * @hidden
  150538. */
  150539. _pos: number;
  150540. /**
  150541. * @hidden Index of this particle in the global "indices" array (Internal use)
  150542. */
  150543. _ind: number;
  150544. /**
  150545. * Group this particle belongs to
  150546. */
  150547. _group: PointsGroup;
  150548. /**
  150549. * Group id of this particle
  150550. */
  150551. groupId: number;
  150552. /**
  150553. * Index of the particle in its group id (Internal use)
  150554. */
  150555. idxInGroup: number;
  150556. /**
  150557. * @hidden Particle BoundingInfo object (Internal use)
  150558. */
  150559. _boundingInfo: BoundingInfo;
  150560. /**
  150561. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  150562. */
  150563. _pcs: PointsCloudSystem;
  150564. /**
  150565. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  150566. */
  150567. _stillInvisible: boolean;
  150568. /**
  150569. * @hidden Last computed particle rotation matrix
  150570. */
  150571. _rotationMatrix: number[];
  150572. /**
  150573. * Parent particle Id, if any.
  150574. * Default null.
  150575. */
  150576. parentId: Nullable<number>;
  150577. /**
  150578. * @hidden Internal global position in the PCS.
  150579. */
  150580. _globalPosition: Vector3;
  150581. /**
  150582. * Creates a Point Cloud object.
  150583. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  150584. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  150585. * @param group (PointsGroup) is the group the particle belongs to
  150586. * @param groupId (integer) is the group identifier in the PCS.
  150587. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  150588. * @param pcs defines the PCS it is associated to
  150589. */
  150590. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  150591. /**
  150592. * get point size
  150593. */
  150594. get size(): Vector3;
  150595. /**
  150596. * Set point size
  150597. */
  150598. set size(scale: Vector3);
  150599. /**
  150600. * Legacy support, changed quaternion to rotationQuaternion
  150601. */
  150602. get quaternion(): Nullable<Quaternion>;
  150603. /**
  150604. * Legacy support, changed quaternion to rotationQuaternion
  150605. */
  150606. set quaternion(q: Nullable<Quaternion>);
  150607. /**
  150608. * Returns a boolean. True if the particle intersects a mesh, else false
  150609. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  150610. * @param target is the object (point or mesh) what the intersection is computed against
  150611. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  150612. * @returns true if it intersects
  150613. */
  150614. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  150615. /**
  150616. * get the rotation matrix of the particle
  150617. * @hidden
  150618. */
  150619. getRotationMatrix(m: Matrix): void;
  150620. }
  150621. /**
  150622. * Represents a group of points in a points cloud system
  150623. * * PCS internal tool, don't use it manually.
  150624. */
  150625. export class PointsGroup {
  150626. /**
  150627. * The group id
  150628. * @hidden
  150629. */
  150630. groupID: number;
  150631. /**
  150632. * image data for group (internal use)
  150633. * @hidden
  150634. */
  150635. _groupImageData: Nullable<ArrayBufferView>;
  150636. /**
  150637. * Image Width (internal use)
  150638. * @hidden
  150639. */
  150640. _groupImgWidth: number;
  150641. /**
  150642. * Image Height (internal use)
  150643. * @hidden
  150644. */
  150645. _groupImgHeight: number;
  150646. /**
  150647. * Custom position function (internal use)
  150648. * @hidden
  150649. */
  150650. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  150651. /**
  150652. * density per facet for surface points
  150653. * @hidden
  150654. */
  150655. _groupDensity: number[];
  150656. /**
  150657. * Only when points are colored by texture carries pointer to texture list array
  150658. * @hidden
  150659. */
  150660. _textureNb: number;
  150661. /**
  150662. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  150663. * PCS internal tool, don't use it manually.
  150664. * @hidden
  150665. */
  150666. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  150667. }
  150668. }
  150669. declare module BABYLON {
  150670. interface Scene {
  150671. /** @hidden (Backing field) */
  150672. _physicsEngine: Nullable<IPhysicsEngine>;
  150673. /** @hidden */
  150674. _physicsTimeAccumulator: number;
  150675. /**
  150676. * Gets the current physics engine
  150677. * @returns a IPhysicsEngine or null if none attached
  150678. */
  150679. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  150680. /**
  150681. * Enables physics to the current scene
  150682. * @param gravity defines the scene's gravity for the physics engine
  150683. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  150684. * @return a boolean indicating if the physics engine was initialized
  150685. */
  150686. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  150687. /**
  150688. * Disables and disposes the physics engine associated with the scene
  150689. */
  150690. disablePhysicsEngine(): void;
  150691. /**
  150692. * Gets a boolean indicating if there is an active physics engine
  150693. * @returns a boolean indicating if there is an active physics engine
  150694. */
  150695. isPhysicsEnabled(): boolean;
  150696. /**
  150697. * Deletes a physics compound impostor
  150698. * @param compound defines the compound to delete
  150699. */
  150700. deleteCompoundImpostor(compound: any): void;
  150701. /**
  150702. * An event triggered when physic simulation is about to be run
  150703. */
  150704. onBeforePhysicsObservable: Observable<Scene>;
  150705. /**
  150706. * An event triggered when physic simulation has been done
  150707. */
  150708. onAfterPhysicsObservable: Observable<Scene>;
  150709. }
  150710. interface AbstractMesh {
  150711. /** @hidden */
  150712. _physicsImpostor: Nullable<PhysicsImpostor>;
  150713. /**
  150714. * Gets or sets impostor used for physic simulation
  150715. * @see https://doc.babylonjs.com/features/physics_engine
  150716. */
  150717. physicsImpostor: Nullable<PhysicsImpostor>;
  150718. /**
  150719. * Gets the current physics impostor
  150720. * @see https://doc.babylonjs.com/features/physics_engine
  150721. * @returns a physics impostor or null
  150722. */
  150723. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  150724. /** Apply a physic impulse to the mesh
  150725. * @param force defines the force to apply
  150726. * @param contactPoint defines where to apply the force
  150727. * @returns the current mesh
  150728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  150729. */
  150730. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  150731. /**
  150732. * Creates a physic joint between two meshes
  150733. * @param otherMesh defines the other mesh to use
  150734. * @param pivot1 defines the pivot to use on this mesh
  150735. * @param pivot2 defines the pivot to use on the other mesh
  150736. * @param options defines additional options (can be plugin dependent)
  150737. * @returns the current mesh
  150738. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  150739. */
  150740. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  150741. /** @hidden */
  150742. _disposePhysicsObserver: Nullable<Observer<Node>>;
  150743. }
  150744. /**
  150745. * Defines the physics engine scene component responsible to manage a physics engine
  150746. */
  150747. export class PhysicsEngineSceneComponent implements ISceneComponent {
  150748. /**
  150749. * The component name helpful to identify the component in the list of scene components.
  150750. */
  150751. readonly name: string;
  150752. /**
  150753. * The scene the component belongs to.
  150754. */
  150755. scene: Scene;
  150756. /**
  150757. * Creates a new instance of the component for the given scene
  150758. * @param scene Defines the scene to register the component in
  150759. */
  150760. constructor(scene: Scene);
  150761. /**
  150762. * Registers the component in a given scene
  150763. */
  150764. register(): void;
  150765. /**
  150766. * Rebuilds the elements related to this component in case of
  150767. * context lost for instance.
  150768. */
  150769. rebuild(): void;
  150770. /**
  150771. * Disposes the component and the associated ressources
  150772. */
  150773. dispose(): void;
  150774. }
  150775. }
  150776. declare module BABYLON {
  150777. /**
  150778. * A helper for physics simulations
  150779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150780. */
  150781. export class PhysicsHelper {
  150782. private _scene;
  150783. private _physicsEngine;
  150784. /**
  150785. * Initializes the Physics helper
  150786. * @param scene Babylon.js scene
  150787. */
  150788. constructor(scene: Scene);
  150789. /**
  150790. * Applies a radial explosion impulse
  150791. * @param origin the origin of the explosion
  150792. * @param radiusOrEventOptions the radius or the options of radial explosion
  150793. * @param strength the explosion strength
  150794. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150795. * @returns A physics radial explosion event, or null
  150796. */
  150797. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  150798. /**
  150799. * Applies a radial explosion force
  150800. * @param origin the origin of the explosion
  150801. * @param radiusOrEventOptions the radius or the options of radial explosion
  150802. * @param strength the explosion strength
  150803. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150804. * @returns A physics radial explosion event, or null
  150805. */
  150806. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  150807. /**
  150808. * Creates a gravitational field
  150809. * @param origin the origin of the explosion
  150810. * @param radiusOrEventOptions the radius or the options of radial explosion
  150811. * @param strength the explosion strength
  150812. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150813. * @returns A physics gravitational field event, or null
  150814. */
  150815. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  150816. /**
  150817. * Creates a physics updraft event
  150818. * @param origin the origin of the updraft
  150819. * @param radiusOrEventOptions the radius or the options of the updraft
  150820. * @param strength the strength of the updraft
  150821. * @param height the height of the updraft
  150822. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  150823. * @returns A physics updraft event, or null
  150824. */
  150825. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  150826. /**
  150827. * Creates a physics vortex event
  150828. * @param origin the of the vortex
  150829. * @param radiusOrEventOptions the radius or the options of the vortex
  150830. * @param strength the strength of the vortex
  150831. * @param height the height of the vortex
  150832. * @returns a Physics vortex event, or null
  150833. * A physics vortex event or null
  150834. */
  150835. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  150836. }
  150837. /**
  150838. * Represents a physics radial explosion event
  150839. */
  150840. class PhysicsRadialExplosionEvent {
  150841. private _scene;
  150842. private _options;
  150843. private _sphere;
  150844. private _dataFetched;
  150845. /**
  150846. * Initializes a radial explosioin event
  150847. * @param _scene BabylonJS scene
  150848. * @param _options The options for the vortex event
  150849. */
  150850. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  150851. /**
  150852. * Returns the data related to the radial explosion event (sphere).
  150853. * @returns The radial explosion event data
  150854. */
  150855. getData(): PhysicsRadialExplosionEventData;
  150856. /**
  150857. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  150858. * @param impostor A physics imposter
  150859. * @param origin the origin of the explosion
  150860. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  150861. */
  150862. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  150863. /**
  150864. * Triggers affecterd impostors callbacks
  150865. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  150866. */
  150867. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  150868. /**
  150869. * Disposes the sphere.
  150870. * @param force Specifies if the sphere should be disposed by force
  150871. */
  150872. dispose(force?: boolean): void;
  150873. /*** Helpers ***/
  150874. private _prepareSphere;
  150875. private _intersectsWithSphere;
  150876. }
  150877. /**
  150878. * Represents a gravitational field event
  150879. */
  150880. class PhysicsGravitationalFieldEvent {
  150881. private _physicsHelper;
  150882. private _scene;
  150883. private _origin;
  150884. private _options;
  150885. private _tickCallback;
  150886. private _sphere;
  150887. private _dataFetched;
  150888. /**
  150889. * Initializes the physics gravitational field event
  150890. * @param _physicsHelper A physics helper
  150891. * @param _scene BabylonJS scene
  150892. * @param _origin The origin position of the gravitational field event
  150893. * @param _options The options for the vortex event
  150894. */
  150895. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  150896. /**
  150897. * Returns the data related to the gravitational field event (sphere).
  150898. * @returns A gravitational field event
  150899. */
  150900. getData(): PhysicsGravitationalFieldEventData;
  150901. /**
  150902. * Enables the gravitational field.
  150903. */
  150904. enable(): void;
  150905. /**
  150906. * Disables the gravitational field.
  150907. */
  150908. disable(): void;
  150909. /**
  150910. * Disposes the sphere.
  150911. * @param force The force to dispose from the gravitational field event
  150912. */
  150913. dispose(force?: boolean): void;
  150914. private _tick;
  150915. }
  150916. /**
  150917. * Represents a physics updraft event
  150918. */
  150919. class PhysicsUpdraftEvent {
  150920. private _scene;
  150921. private _origin;
  150922. private _options;
  150923. private _physicsEngine;
  150924. private _originTop;
  150925. private _originDirection;
  150926. private _tickCallback;
  150927. private _cylinder;
  150928. private _cylinderPosition;
  150929. private _dataFetched;
  150930. /**
  150931. * Initializes the physics updraft event
  150932. * @param _scene BabylonJS scene
  150933. * @param _origin The origin position of the updraft
  150934. * @param _options The options for the updraft event
  150935. */
  150936. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  150937. /**
  150938. * Returns the data related to the updraft event (cylinder).
  150939. * @returns A physics updraft event
  150940. */
  150941. getData(): PhysicsUpdraftEventData;
  150942. /**
  150943. * Enables the updraft.
  150944. */
  150945. enable(): void;
  150946. /**
  150947. * Disables the updraft.
  150948. */
  150949. disable(): void;
  150950. /**
  150951. * Disposes the cylinder.
  150952. * @param force Specifies if the updraft should be disposed by force
  150953. */
  150954. dispose(force?: boolean): void;
  150955. private getImpostorHitData;
  150956. private _tick;
  150957. /*** Helpers ***/
  150958. private _prepareCylinder;
  150959. private _intersectsWithCylinder;
  150960. }
  150961. /**
  150962. * Represents a physics vortex event
  150963. */
  150964. class PhysicsVortexEvent {
  150965. private _scene;
  150966. private _origin;
  150967. private _options;
  150968. private _physicsEngine;
  150969. private _originTop;
  150970. private _tickCallback;
  150971. private _cylinder;
  150972. private _cylinderPosition;
  150973. private _dataFetched;
  150974. /**
  150975. * Initializes the physics vortex event
  150976. * @param _scene The BabylonJS scene
  150977. * @param _origin The origin position of the vortex
  150978. * @param _options The options for the vortex event
  150979. */
  150980. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  150981. /**
  150982. * Returns the data related to the vortex event (cylinder).
  150983. * @returns The physics vortex event data
  150984. */
  150985. getData(): PhysicsVortexEventData;
  150986. /**
  150987. * Enables the vortex.
  150988. */
  150989. enable(): void;
  150990. /**
  150991. * Disables the cortex.
  150992. */
  150993. disable(): void;
  150994. /**
  150995. * Disposes the sphere.
  150996. * @param force
  150997. */
  150998. dispose(force?: boolean): void;
  150999. private getImpostorHitData;
  151000. private _tick;
  151001. /*** Helpers ***/
  151002. private _prepareCylinder;
  151003. private _intersectsWithCylinder;
  151004. }
  151005. /**
  151006. * Options fot the radial explosion event
  151007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151008. */
  151009. export class PhysicsRadialExplosionEventOptions {
  151010. /**
  151011. * The radius of the sphere for the radial explosion.
  151012. */
  151013. radius: number;
  151014. /**
  151015. * The strenth of the explosion.
  151016. */
  151017. strength: number;
  151018. /**
  151019. * The strenght of the force in correspondence to the distance of the affected object
  151020. */
  151021. falloff: PhysicsRadialImpulseFalloff;
  151022. /**
  151023. * Sphere options for the radial explosion.
  151024. */
  151025. sphere: {
  151026. segments: number;
  151027. diameter: number;
  151028. };
  151029. /**
  151030. * Sphere options for the radial explosion.
  151031. */
  151032. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  151033. }
  151034. /**
  151035. * Options fot the updraft event
  151036. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151037. */
  151038. export class PhysicsUpdraftEventOptions {
  151039. /**
  151040. * The radius of the cylinder for the vortex
  151041. */
  151042. radius: number;
  151043. /**
  151044. * The strenth of the updraft.
  151045. */
  151046. strength: number;
  151047. /**
  151048. * The height of the cylinder for the updraft.
  151049. */
  151050. height: number;
  151051. /**
  151052. * The mode for the the updraft.
  151053. */
  151054. updraftMode: PhysicsUpdraftMode;
  151055. }
  151056. /**
  151057. * Options fot the vortex event
  151058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151059. */
  151060. export class PhysicsVortexEventOptions {
  151061. /**
  151062. * The radius of the cylinder for the vortex
  151063. */
  151064. radius: number;
  151065. /**
  151066. * The strenth of the vortex.
  151067. */
  151068. strength: number;
  151069. /**
  151070. * The height of the cylinder for the vortex.
  151071. */
  151072. height: number;
  151073. /**
  151074. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  151075. */
  151076. centripetalForceThreshold: number;
  151077. /**
  151078. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  151079. */
  151080. centripetalForceMultiplier: number;
  151081. /**
  151082. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  151083. */
  151084. centrifugalForceMultiplier: number;
  151085. /**
  151086. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  151087. */
  151088. updraftForceMultiplier: number;
  151089. }
  151090. /**
  151091. * The strenght of the force in correspondence to the distance of the affected object
  151092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151093. */
  151094. export enum PhysicsRadialImpulseFalloff {
  151095. /** Defines that impulse is constant in strength across it's whole radius */
  151096. Constant = 0,
  151097. /** Defines that impulse gets weaker if it's further from the origin */
  151098. Linear = 1
  151099. }
  151100. /**
  151101. * The strength of the force in correspondence to the distance of the affected object
  151102. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151103. */
  151104. export enum PhysicsUpdraftMode {
  151105. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  151106. Center = 0,
  151107. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  151108. Perpendicular = 1
  151109. }
  151110. /**
  151111. * Interface for a physics hit data
  151112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151113. */
  151114. export interface PhysicsHitData {
  151115. /**
  151116. * The force applied at the contact point
  151117. */
  151118. force: Vector3;
  151119. /**
  151120. * The contact point
  151121. */
  151122. contactPoint: Vector3;
  151123. /**
  151124. * The distance from the origin to the contact point
  151125. */
  151126. distanceFromOrigin: number;
  151127. }
  151128. /**
  151129. * Interface for radial explosion event data
  151130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151131. */
  151132. export interface PhysicsRadialExplosionEventData {
  151133. /**
  151134. * A sphere used for the radial explosion event
  151135. */
  151136. sphere: Mesh;
  151137. }
  151138. /**
  151139. * Interface for gravitational field event data
  151140. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151141. */
  151142. export interface PhysicsGravitationalFieldEventData {
  151143. /**
  151144. * A sphere mesh used for the gravitational field event
  151145. */
  151146. sphere: Mesh;
  151147. }
  151148. /**
  151149. * Interface for updraft event data
  151150. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151151. */
  151152. export interface PhysicsUpdraftEventData {
  151153. /**
  151154. * A cylinder used for the updraft event
  151155. */
  151156. cylinder: Mesh;
  151157. }
  151158. /**
  151159. * Interface for vortex event data
  151160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151161. */
  151162. export interface PhysicsVortexEventData {
  151163. /**
  151164. * A cylinder used for the vortex event
  151165. */
  151166. cylinder: Mesh;
  151167. }
  151168. /**
  151169. * Interface for an affected physics impostor
  151170. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151171. */
  151172. export interface PhysicsAffectedImpostorWithData {
  151173. /**
  151174. * The impostor affected by the effect
  151175. */
  151176. impostor: PhysicsImpostor;
  151177. /**
  151178. * The data about the hit/horce from the explosion
  151179. */
  151180. hitData: PhysicsHitData;
  151181. }
  151182. }
  151183. declare module BABYLON {
  151184. /** @hidden */
  151185. export var blackAndWhitePixelShader: {
  151186. name: string;
  151187. shader: string;
  151188. };
  151189. }
  151190. declare module BABYLON {
  151191. /**
  151192. * Post process used to render in black and white
  151193. */
  151194. export class BlackAndWhitePostProcess extends PostProcess {
  151195. /**
  151196. * Linear about to convert he result to black and white (default: 1)
  151197. */
  151198. degree: number;
  151199. /**
  151200. * Gets a string identifying the name of the class
  151201. * @returns "BlackAndWhitePostProcess" string
  151202. */
  151203. getClassName(): string;
  151204. /**
  151205. * Creates a black and white post process
  151206. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  151207. * @param name The name of the effect.
  151208. * @param options The required width/height ratio to downsize to before computing the render pass.
  151209. * @param camera The camera to apply the render pass to.
  151210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151211. * @param engine The engine which the post process will be applied. (default: current engine)
  151212. * @param reusable If the post process can be reused on the same frame. (default: false)
  151213. */
  151214. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151215. /** @hidden */
  151216. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  151217. }
  151218. }
  151219. declare module BABYLON {
  151220. /**
  151221. * This represents a set of one or more post processes in Babylon.
  151222. * A post process can be used to apply a shader to a texture after it is rendered.
  151223. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151224. */
  151225. export class PostProcessRenderEffect {
  151226. private _postProcesses;
  151227. private _getPostProcesses;
  151228. private _singleInstance;
  151229. private _cameras;
  151230. private _indicesForCamera;
  151231. /**
  151232. * Name of the effect
  151233. * @hidden
  151234. */
  151235. _name: string;
  151236. /**
  151237. * Instantiates a post process render effect.
  151238. * A post process can be used to apply a shader to a texture after it is rendered.
  151239. * @param engine The engine the effect is tied to
  151240. * @param name The name of the effect
  151241. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  151242. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  151243. */
  151244. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  151245. /**
  151246. * Checks if all the post processes in the effect are supported.
  151247. */
  151248. get isSupported(): boolean;
  151249. /**
  151250. * Updates the current state of the effect
  151251. * @hidden
  151252. */
  151253. _update(): void;
  151254. /**
  151255. * Attaches the effect on cameras
  151256. * @param cameras The camera to attach to.
  151257. * @hidden
  151258. */
  151259. _attachCameras(cameras: Camera): void;
  151260. /**
  151261. * Attaches the effect on cameras
  151262. * @param cameras The camera to attach to.
  151263. * @hidden
  151264. */
  151265. _attachCameras(cameras: Camera[]): void;
  151266. /**
  151267. * Detaches the effect on cameras
  151268. * @param cameras The camera to detatch from.
  151269. * @hidden
  151270. */
  151271. _detachCameras(cameras: Camera): void;
  151272. /**
  151273. * Detatches the effect on cameras
  151274. * @param cameras The camera to detatch from.
  151275. * @hidden
  151276. */
  151277. _detachCameras(cameras: Camera[]): void;
  151278. /**
  151279. * Enables the effect on given cameras
  151280. * @param cameras The camera to enable.
  151281. * @hidden
  151282. */
  151283. _enable(cameras: Camera): void;
  151284. /**
  151285. * Enables the effect on given cameras
  151286. * @param cameras The camera to enable.
  151287. * @hidden
  151288. */
  151289. _enable(cameras: Nullable<Camera[]>): void;
  151290. /**
  151291. * Disables the effect on the given cameras
  151292. * @param cameras The camera to disable.
  151293. * @hidden
  151294. */
  151295. _disable(cameras: Camera): void;
  151296. /**
  151297. * Disables the effect on the given cameras
  151298. * @param cameras The camera to disable.
  151299. * @hidden
  151300. */
  151301. _disable(cameras: Nullable<Camera[]>): void;
  151302. /**
  151303. * Gets a list of the post processes contained in the effect.
  151304. * @param camera The camera to get the post processes on.
  151305. * @returns The list of the post processes in the effect.
  151306. */
  151307. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  151308. }
  151309. }
  151310. declare module BABYLON {
  151311. /** @hidden */
  151312. export var extractHighlightsPixelShader: {
  151313. name: string;
  151314. shader: string;
  151315. };
  151316. }
  151317. declare module BABYLON {
  151318. /**
  151319. * 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.
  151320. */
  151321. export class ExtractHighlightsPostProcess extends PostProcess {
  151322. /**
  151323. * The luminance threshold, pixels below this value will be set to black.
  151324. */
  151325. threshold: number;
  151326. /** @hidden */
  151327. _exposure: number;
  151328. /**
  151329. * Post process which has the input texture to be used when performing highlight extraction
  151330. * @hidden
  151331. */
  151332. _inputPostProcess: Nullable<PostProcess>;
  151333. /**
  151334. * Gets a string identifying the name of the class
  151335. * @returns "ExtractHighlightsPostProcess" string
  151336. */
  151337. getClassName(): string;
  151338. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151339. }
  151340. }
  151341. declare module BABYLON {
  151342. /** @hidden */
  151343. export var bloomMergePixelShader: {
  151344. name: string;
  151345. shader: string;
  151346. };
  151347. }
  151348. declare module BABYLON {
  151349. /**
  151350. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  151351. */
  151352. export class BloomMergePostProcess extends PostProcess {
  151353. /** Weight of the bloom to be added to the original input. */
  151354. weight: number;
  151355. /**
  151356. * Gets a string identifying the name of the class
  151357. * @returns "BloomMergePostProcess" string
  151358. */
  151359. getClassName(): string;
  151360. /**
  151361. * Creates a new instance of @see BloomMergePostProcess
  151362. * @param name The name of the effect.
  151363. * @param originalFromInput Post process which's input will be used for the merge.
  151364. * @param blurred Blurred highlights post process which's output will be used.
  151365. * @param weight Weight of the bloom to be added to the original input.
  151366. * @param options The required width/height ratio to downsize to before computing the render pass.
  151367. * @param camera The camera to apply the render pass to.
  151368. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151369. * @param engine The engine which the post process will be applied. (default: current engine)
  151370. * @param reusable If the post process can be reused on the same frame. (default: false)
  151371. * @param textureType Type of textures used when performing the post process. (default: 0)
  151372. * @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)
  151373. */
  151374. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  151375. /** Weight of the bloom to be added to the original input. */
  151376. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151377. }
  151378. }
  151379. declare module BABYLON {
  151380. /**
  151381. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  151382. */
  151383. export class BloomEffect extends PostProcessRenderEffect {
  151384. private bloomScale;
  151385. /**
  151386. * @hidden Internal
  151387. */
  151388. _effects: Array<PostProcess>;
  151389. /**
  151390. * @hidden Internal
  151391. */
  151392. _downscale: ExtractHighlightsPostProcess;
  151393. private _blurX;
  151394. private _blurY;
  151395. private _merge;
  151396. /**
  151397. * The luminance threshold to find bright areas of the image to bloom.
  151398. */
  151399. get threshold(): number;
  151400. set threshold(value: number);
  151401. /**
  151402. * The strength of the bloom.
  151403. */
  151404. get weight(): number;
  151405. set weight(value: number);
  151406. /**
  151407. * Specifies the size of the bloom blur kernel, relative to the final output size
  151408. */
  151409. get kernel(): number;
  151410. set kernel(value: number);
  151411. /**
  151412. * Creates a new instance of @see BloomEffect
  151413. * @param scene The scene the effect belongs to.
  151414. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  151415. * @param bloomKernel The size of the kernel to be used when applying the blur.
  151416. * @param bloomWeight The the strength of bloom.
  151417. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  151418. * @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)
  151419. */
  151420. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  151421. /**
  151422. * Disposes each of the internal effects for a given camera.
  151423. * @param camera The camera to dispose the effect on.
  151424. */
  151425. disposeEffects(camera: Camera): void;
  151426. /**
  151427. * @hidden Internal
  151428. */
  151429. _updateEffects(): void;
  151430. /**
  151431. * Internal
  151432. * @returns if all the contained post processes are ready.
  151433. * @hidden
  151434. */
  151435. _isReady(): boolean;
  151436. }
  151437. }
  151438. declare module BABYLON {
  151439. /** @hidden */
  151440. export var chromaticAberrationPixelShader: {
  151441. name: string;
  151442. shader: string;
  151443. };
  151444. }
  151445. declare module BABYLON {
  151446. /**
  151447. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  151448. */
  151449. export class ChromaticAberrationPostProcess extends PostProcess {
  151450. /**
  151451. * The amount of seperation of rgb channels (default: 30)
  151452. */
  151453. aberrationAmount: number;
  151454. /**
  151455. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  151456. */
  151457. radialIntensity: number;
  151458. /**
  151459. * 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))
  151460. */
  151461. direction: Vector2;
  151462. /**
  151463. * 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))
  151464. */
  151465. centerPosition: Vector2;
  151466. /** The width of the screen to apply the effect on */
  151467. screenWidth: number;
  151468. /** The height of the screen to apply the effect on */
  151469. screenHeight: number;
  151470. /**
  151471. * Gets a string identifying the name of the class
  151472. * @returns "ChromaticAberrationPostProcess" string
  151473. */
  151474. getClassName(): string;
  151475. /**
  151476. * Creates a new instance ChromaticAberrationPostProcess
  151477. * @param name The name of the effect.
  151478. * @param screenWidth The width of the screen to apply the effect on.
  151479. * @param screenHeight The height of the screen to apply the effect on.
  151480. * @param options The required width/height ratio to downsize to before computing the render pass.
  151481. * @param camera The camera to apply the render pass to.
  151482. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151483. * @param engine The engine which the post process will be applied. (default: current engine)
  151484. * @param reusable If the post process can be reused on the same frame. (default: false)
  151485. * @param textureType Type of textures used when performing the post process. (default: 0)
  151486. * @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)
  151487. */
  151488. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151489. /** @hidden */
  151490. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  151491. }
  151492. }
  151493. declare module BABYLON {
  151494. /** @hidden */
  151495. export var circleOfConfusionPixelShader: {
  151496. name: string;
  151497. shader: string;
  151498. };
  151499. }
  151500. declare module BABYLON {
  151501. /**
  151502. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  151503. */
  151504. export class CircleOfConfusionPostProcess extends PostProcess {
  151505. /**
  151506. * 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.
  151507. */
  151508. lensSize: number;
  151509. /**
  151510. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  151511. */
  151512. fStop: number;
  151513. /**
  151514. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  151515. */
  151516. focusDistance: number;
  151517. /**
  151518. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  151519. */
  151520. focalLength: number;
  151521. /**
  151522. * Gets a string identifying the name of the class
  151523. * @returns "CircleOfConfusionPostProcess" string
  151524. */
  151525. getClassName(): string;
  151526. private _depthTexture;
  151527. /**
  151528. * Creates a new instance CircleOfConfusionPostProcess
  151529. * @param name The name of the effect.
  151530. * @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.
  151531. * @param options The required width/height ratio to downsize to before computing the render pass.
  151532. * @param camera The camera to apply the render pass to.
  151533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151534. * @param engine The engine which the post process will be applied. (default: current engine)
  151535. * @param reusable If the post process can be reused on the same frame. (default: false)
  151536. * @param textureType Type of textures used when performing the post process. (default: 0)
  151537. * @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)
  151538. */
  151539. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151540. /**
  151541. * 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.
  151542. */
  151543. set depthTexture(value: RenderTargetTexture);
  151544. }
  151545. }
  151546. declare module BABYLON {
  151547. /** @hidden */
  151548. export var colorCorrectionPixelShader: {
  151549. name: string;
  151550. shader: string;
  151551. };
  151552. }
  151553. declare module BABYLON {
  151554. /**
  151555. *
  151556. * This post-process allows the modification of rendered colors by using
  151557. * a 'look-up table' (LUT). This effect is also called Color Grading.
  151558. *
  151559. * The object needs to be provided an url to a texture containing the color
  151560. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  151561. * Use an image editing software to tweak the LUT to match your needs.
  151562. *
  151563. * For an example of a color LUT, see here:
  151564. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  151565. * For explanations on color grading, see here:
  151566. * @see http://udn.epicgames.com/Three/ColorGrading.html
  151567. *
  151568. */
  151569. export class ColorCorrectionPostProcess extends PostProcess {
  151570. private _colorTableTexture;
  151571. /**
  151572. * Gets the color table url used to create the LUT texture
  151573. */
  151574. colorTableUrl: string;
  151575. /**
  151576. * Gets a string identifying the name of the class
  151577. * @returns "ColorCorrectionPostProcess" string
  151578. */
  151579. getClassName(): string;
  151580. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151581. /** @hidden */
  151582. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  151583. }
  151584. }
  151585. declare module BABYLON {
  151586. /** @hidden */
  151587. export var convolutionPixelShader: {
  151588. name: string;
  151589. shader: string;
  151590. };
  151591. }
  151592. declare module BABYLON {
  151593. /**
  151594. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  151595. * input texture to perform effects such as edge detection or sharpening
  151596. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  151597. */
  151598. export class ConvolutionPostProcess extends PostProcess {
  151599. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  151600. kernel: number[];
  151601. /**
  151602. * Gets a string identifying the name of the class
  151603. * @returns "ConvolutionPostProcess" string
  151604. */
  151605. getClassName(): string;
  151606. /**
  151607. * Creates a new instance ConvolutionPostProcess
  151608. * @param name The name of the effect.
  151609. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  151610. * @param options The required width/height ratio to downsize to before computing the render pass.
  151611. * @param camera The camera to apply the render pass to.
  151612. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151613. * @param engine The engine which the post process will be applied. (default: current engine)
  151614. * @param reusable If the post process can be reused on the same frame. (default: false)
  151615. * @param textureType Type of textures used when performing the post process. (default: 0)
  151616. */
  151617. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151618. /** @hidden */
  151619. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  151620. /**
  151621. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151622. */
  151623. static EdgeDetect0Kernel: number[];
  151624. /**
  151625. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151626. */
  151627. static EdgeDetect1Kernel: number[];
  151628. /**
  151629. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151630. */
  151631. static EdgeDetect2Kernel: number[];
  151632. /**
  151633. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151634. */
  151635. static SharpenKernel: number[];
  151636. /**
  151637. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151638. */
  151639. static EmbossKernel: number[];
  151640. /**
  151641. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151642. */
  151643. static GaussianKernel: number[];
  151644. }
  151645. }
  151646. declare module BABYLON {
  151647. /**
  151648. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  151649. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  151650. * based on samples that have a large difference in distance than the center pixel.
  151651. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  151652. */
  151653. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  151654. /**
  151655. * The direction the blur should be applied
  151656. */
  151657. direction: Vector2;
  151658. /**
  151659. * Gets a string identifying the name of the class
  151660. * @returns "DepthOfFieldBlurPostProcess" string
  151661. */
  151662. getClassName(): string;
  151663. /**
  151664. * Creates a new instance CircleOfConfusionPostProcess
  151665. * @param name The name of the effect.
  151666. * @param scene The scene the effect belongs to.
  151667. * @param direction The direction the blur should be applied.
  151668. * @param kernel The size of the kernel used to blur.
  151669. * @param options The required width/height ratio to downsize to before computing the render pass.
  151670. * @param camera The camera to apply the render pass to.
  151671. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  151672. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  151673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151674. * @param engine The engine which the post process will be applied. (default: current engine)
  151675. * @param reusable If the post process can be reused on the same frame. (default: false)
  151676. * @param textureType Type of textures used when performing the post process. (default: 0)
  151677. * @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)
  151678. */
  151679. 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);
  151680. }
  151681. }
  151682. declare module BABYLON {
  151683. /** @hidden */
  151684. export var depthOfFieldMergePixelShader: {
  151685. name: string;
  151686. shader: string;
  151687. };
  151688. }
  151689. declare module BABYLON {
  151690. /**
  151691. * Options to be set when merging outputs from the default pipeline.
  151692. */
  151693. export class DepthOfFieldMergePostProcessOptions {
  151694. /**
  151695. * The original image to merge on top of
  151696. */
  151697. originalFromInput: PostProcess;
  151698. /**
  151699. * Parameters to perform the merge of the depth of field effect
  151700. */
  151701. depthOfField?: {
  151702. circleOfConfusion: PostProcess;
  151703. blurSteps: Array<PostProcess>;
  151704. };
  151705. /**
  151706. * Parameters to perform the merge of bloom effect
  151707. */
  151708. bloom?: {
  151709. blurred: PostProcess;
  151710. weight: number;
  151711. };
  151712. }
  151713. /**
  151714. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  151715. */
  151716. export class DepthOfFieldMergePostProcess extends PostProcess {
  151717. private blurSteps;
  151718. /**
  151719. * Gets a string identifying the name of the class
  151720. * @returns "DepthOfFieldMergePostProcess" string
  151721. */
  151722. getClassName(): string;
  151723. /**
  151724. * Creates a new instance of DepthOfFieldMergePostProcess
  151725. * @param name The name of the effect.
  151726. * @param originalFromInput Post process which's input will be used for the merge.
  151727. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  151728. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  151729. * @param options The required width/height ratio to downsize to before computing the render pass.
  151730. * @param camera The camera to apply the render pass to.
  151731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151732. * @param engine The engine which the post process will be applied. (default: current engine)
  151733. * @param reusable If the post process can be reused on the same frame. (default: false)
  151734. * @param textureType Type of textures used when performing the post process. (default: 0)
  151735. * @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)
  151736. */
  151737. 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);
  151738. /**
  151739. * Updates the effect with the current post process compile time values and recompiles the shader.
  151740. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  151741. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  151742. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  151743. * @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
  151744. * @param onCompiled Called when the shader has been compiled.
  151745. * @param onError Called if there is an error when compiling a shader.
  151746. */
  151747. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  151748. }
  151749. }
  151750. declare module BABYLON {
  151751. /**
  151752. * Specifies the level of max blur that should be applied when using the depth of field effect
  151753. */
  151754. export enum DepthOfFieldEffectBlurLevel {
  151755. /**
  151756. * Subtle blur
  151757. */
  151758. Low = 0,
  151759. /**
  151760. * Medium blur
  151761. */
  151762. Medium = 1,
  151763. /**
  151764. * Large blur
  151765. */
  151766. High = 2
  151767. }
  151768. /**
  151769. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  151770. */
  151771. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  151772. private _circleOfConfusion;
  151773. /**
  151774. * @hidden Internal, blurs from high to low
  151775. */
  151776. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  151777. private _depthOfFieldBlurY;
  151778. private _dofMerge;
  151779. /**
  151780. * @hidden Internal post processes in depth of field effect
  151781. */
  151782. _effects: Array<PostProcess>;
  151783. /**
  151784. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  151785. */
  151786. set focalLength(value: number);
  151787. get focalLength(): number;
  151788. /**
  151789. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  151790. */
  151791. set fStop(value: number);
  151792. get fStop(): number;
  151793. /**
  151794. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  151795. */
  151796. set focusDistance(value: number);
  151797. get focusDistance(): number;
  151798. /**
  151799. * 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.
  151800. */
  151801. set lensSize(value: number);
  151802. get lensSize(): number;
  151803. /**
  151804. * Creates a new instance DepthOfFieldEffect
  151805. * @param scene The scene the effect belongs to.
  151806. * @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.
  151807. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  151808. * @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)
  151809. */
  151810. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  151811. /**
  151812. * Get the current class name of the current effet
  151813. * @returns "DepthOfFieldEffect"
  151814. */
  151815. getClassName(): string;
  151816. /**
  151817. * 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.
  151818. */
  151819. set depthTexture(value: RenderTargetTexture);
  151820. /**
  151821. * Disposes each of the internal effects for a given camera.
  151822. * @param camera The camera to dispose the effect on.
  151823. */
  151824. disposeEffects(camera: Camera): void;
  151825. /**
  151826. * @hidden Internal
  151827. */
  151828. _updateEffects(): void;
  151829. /**
  151830. * Internal
  151831. * @returns if all the contained post processes are ready.
  151832. * @hidden
  151833. */
  151834. _isReady(): boolean;
  151835. }
  151836. }
  151837. declare module BABYLON {
  151838. /** @hidden */
  151839. export var displayPassPixelShader: {
  151840. name: string;
  151841. shader: string;
  151842. };
  151843. }
  151844. declare module BABYLON {
  151845. /**
  151846. * DisplayPassPostProcess which produces an output the same as it's input
  151847. */
  151848. export class DisplayPassPostProcess extends PostProcess {
  151849. /**
  151850. * Gets a string identifying the name of the class
  151851. * @returns "DisplayPassPostProcess" string
  151852. */
  151853. getClassName(): string;
  151854. /**
  151855. * Creates the DisplayPassPostProcess
  151856. * @param name The name of the effect.
  151857. * @param options The required width/height ratio to downsize to before computing the render pass.
  151858. * @param camera The camera to apply the render pass to.
  151859. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151860. * @param engine The engine which the post process will be applied. (default: current engine)
  151861. * @param reusable If the post process can be reused on the same frame. (default: false)
  151862. */
  151863. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151864. /** @hidden */
  151865. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  151866. }
  151867. }
  151868. declare module BABYLON {
  151869. /** @hidden */
  151870. export var filterPixelShader: {
  151871. name: string;
  151872. shader: string;
  151873. };
  151874. }
  151875. declare module BABYLON {
  151876. /**
  151877. * Applies a kernel filter to the image
  151878. */
  151879. export class FilterPostProcess extends PostProcess {
  151880. /** The matrix to be applied to the image */
  151881. kernelMatrix: Matrix;
  151882. /**
  151883. * Gets a string identifying the name of the class
  151884. * @returns "FilterPostProcess" string
  151885. */
  151886. getClassName(): string;
  151887. /**
  151888. *
  151889. * @param name The name of the effect.
  151890. * @param kernelMatrix The matrix to be applied to the image
  151891. * @param options The required width/height ratio to downsize to before computing the render pass.
  151892. * @param camera The camera to apply the render pass to.
  151893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151894. * @param engine The engine which the post process will be applied. (default: current engine)
  151895. * @param reusable If the post process can be reused on the same frame. (default: false)
  151896. */
  151897. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151898. /** @hidden */
  151899. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  151900. }
  151901. }
  151902. declare module BABYLON {
  151903. /** @hidden */
  151904. export var fxaaPixelShader: {
  151905. name: string;
  151906. shader: string;
  151907. };
  151908. }
  151909. declare module BABYLON {
  151910. /** @hidden */
  151911. export var fxaaVertexShader: {
  151912. name: string;
  151913. shader: string;
  151914. };
  151915. }
  151916. declare module BABYLON {
  151917. /**
  151918. * Fxaa post process
  151919. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  151920. */
  151921. export class FxaaPostProcess extends PostProcess {
  151922. /**
  151923. * Gets a string identifying the name of the class
  151924. * @returns "FxaaPostProcess" string
  151925. */
  151926. getClassName(): string;
  151927. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151928. private _getDefines;
  151929. /** @hidden */
  151930. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  151931. }
  151932. }
  151933. declare module BABYLON {
  151934. /** @hidden */
  151935. export var grainPixelShader: {
  151936. name: string;
  151937. shader: string;
  151938. };
  151939. }
  151940. declare module BABYLON {
  151941. /**
  151942. * The GrainPostProcess adds noise to the image at mid luminance levels
  151943. */
  151944. export class GrainPostProcess extends PostProcess {
  151945. /**
  151946. * The intensity of the grain added (default: 30)
  151947. */
  151948. intensity: number;
  151949. /**
  151950. * If the grain should be randomized on every frame
  151951. */
  151952. animated: boolean;
  151953. /**
  151954. * Gets a string identifying the name of the class
  151955. * @returns "GrainPostProcess" string
  151956. */
  151957. getClassName(): string;
  151958. /**
  151959. * Creates a new instance of @see GrainPostProcess
  151960. * @param name The name of the effect.
  151961. * @param options The required width/height ratio to downsize to before computing the render pass.
  151962. * @param camera The camera to apply the render pass to.
  151963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151964. * @param engine The engine which the post process will be applied. (default: current engine)
  151965. * @param reusable If the post process can be reused on the same frame. (default: false)
  151966. * @param textureType Type of textures used when performing the post process. (default: 0)
  151967. * @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)
  151968. */
  151969. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151970. /** @hidden */
  151971. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  151972. }
  151973. }
  151974. declare module BABYLON {
  151975. /** @hidden */
  151976. export var highlightsPixelShader: {
  151977. name: string;
  151978. shader: string;
  151979. };
  151980. }
  151981. declare module BABYLON {
  151982. /**
  151983. * Extracts highlights from the image
  151984. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  151985. */
  151986. export class HighlightsPostProcess extends PostProcess {
  151987. /**
  151988. * Gets a string identifying the name of the class
  151989. * @returns "HighlightsPostProcess" string
  151990. */
  151991. getClassName(): string;
  151992. /**
  151993. * Extracts highlights from the image
  151994. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  151995. * @param name The name of the effect.
  151996. * @param options The required width/height ratio to downsize to before computing the render pass.
  151997. * @param camera The camera to apply the render pass to.
  151998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151999. * @param engine The engine which the post process will be applied. (default: current engine)
  152000. * @param reusable If the post process can be reused on the same frame. (default: false)
  152001. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  152002. */
  152003. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152004. }
  152005. }
  152006. declare module BABYLON {
  152007. /**
  152008. * Contains all parameters needed for the prepass to perform
  152009. * motion blur
  152010. */
  152011. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  152012. /**
  152013. * Is motion blur enabled
  152014. */
  152015. enabled: boolean;
  152016. /**
  152017. * Name of the configuration
  152018. */
  152019. name: string;
  152020. /**
  152021. * Textures that should be present in the MRT for this effect to work
  152022. */
  152023. readonly texturesRequired: number[];
  152024. }
  152025. }
  152026. declare module BABYLON {
  152027. interface Scene {
  152028. /** @hidden (Backing field) */
  152029. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152030. /**
  152031. * Gets or Sets the current geometry buffer associated to the scene.
  152032. */
  152033. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152034. /**
  152035. * Enables a GeometryBufferRender and associates it with the scene
  152036. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  152037. * @returns the GeometryBufferRenderer
  152038. */
  152039. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  152040. /**
  152041. * Disables the GeometryBufferRender associated with the scene
  152042. */
  152043. disableGeometryBufferRenderer(): void;
  152044. }
  152045. /**
  152046. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152047. * in several rendering techniques.
  152048. */
  152049. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  152050. /**
  152051. * The component name helpful to identify the component in the list of scene components.
  152052. */
  152053. readonly name: string;
  152054. /**
  152055. * The scene the component belongs to.
  152056. */
  152057. scene: Scene;
  152058. /**
  152059. * Creates a new instance of the component for the given scene
  152060. * @param scene Defines the scene to register the component in
  152061. */
  152062. constructor(scene: Scene);
  152063. /**
  152064. * Registers the component in a given scene
  152065. */
  152066. register(): void;
  152067. /**
  152068. * Rebuilds the elements related to this component in case of
  152069. * context lost for instance.
  152070. */
  152071. rebuild(): void;
  152072. /**
  152073. * Disposes the component and the associated ressources
  152074. */
  152075. dispose(): void;
  152076. private _gatherRenderTargets;
  152077. }
  152078. }
  152079. declare module BABYLON {
  152080. /** @hidden */
  152081. export var motionBlurPixelShader: {
  152082. name: string;
  152083. shader: string;
  152084. };
  152085. }
  152086. declare module BABYLON {
  152087. /**
  152088. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  152089. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  152090. * As an example, all you have to do is to create the post-process:
  152091. * var mb = new BABYLON.MotionBlurPostProcess(
  152092. * 'mb', // The name of the effect.
  152093. * scene, // The scene containing the objects to blur according to their velocity.
  152094. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  152095. * camera // The camera to apply the render pass to.
  152096. * );
  152097. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  152098. */
  152099. export class MotionBlurPostProcess extends PostProcess {
  152100. /**
  152101. * Defines how much the image is blurred by the movement. Default value is equal to 1
  152102. */
  152103. motionStrength: number;
  152104. /**
  152105. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  152106. */
  152107. get motionBlurSamples(): number;
  152108. /**
  152109. * Sets the number of iterations to be used for motion blur quality
  152110. */
  152111. set motionBlurSamples(samples: number);
  152112. private _motionBlurSamples;
  152113. private _forceGeometryBuffer;
  152114. private _geometryBufferRenderer;
  152115. private _prePassRenderer;
  152116. /**
  152117. * Gets a string identifying the name of the class
  152118. * @returns "MotionBlurPostProcess" string
  152119. */
  152120. getClassName(): string;
  152121. /**
  152122. * Creates a new instance MotionBlurPostProcess
  152123. * @param name The name of the effect.
  152124. * @param scene The scene containing the objects to blur according to their velocity.
  152125. * @param options The required width/height ratio to downsize to before computing the render pass.
  152126. * @param camera The camera to apply the render pass to.
  152127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152128. * @param engine The engine which the post process will be applied. (default: current engine)
  152129. * @param reusable If the post process can be reused on the same frame. (default: false)
  152130. * @param textureType Type of textures used when performing the post process. (default: 0)
  152131. * @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)
  152132. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152133. */
  152134. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152135. /**
  152136. * Excludes the given skinned mesh from computing bones velocities.
  152137. * 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.
  152138. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  152139. */
  152140. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  152141. /**
  152142. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  152143. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  152144. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  152145. */
  152146. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  152147. /**
  152148. * Disposes the post process.
  152149. * @param camera The camera to dispose the post process on.
  152150. */
  152151. dispose(camera?: Camera): void;
  152152. /** @hidden */
  152153. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  152154. }
  152155. }
  152156. declare module BABYLON {
  152157. /** @hidden */
  152158. export var refractionPixelShader: {
  152159. name: string;
  152160. shader: string;
  152161. };
  152162. }
  152163. declare module BABYLON {
  152164. /**
  152165. * Post process which applies a refractin texture
  152166. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  152167. */
  152168. export class RefractionPostProcess extends PostProcess {
  152169. private _refTexture;
  152170. private _ownRefractionTexture;
  152171. /** the base color of the refraction (used to taint the rendering) */
  152172. color: Color3;
  152173. /** simulated refraction depth */
  152174. depth: number;
  152175. /** the coefficient of the base color (0 to remove base color tainting) */
  152176. colorLevel: number;
  152177. /** Gets the url used to load the refraction texture */
  152178. refractionTextureUrl: string;
  152179. /**
  152180. * Gets or sets the refraction texture
  152181. * Please note that you are responsible for disposing the texture if you set it manually
  152182. */
  152183. get refractionTexture(): Texture;
  152184. set refractionTexture(value: Texture);
  152185. /**
  152186. * Gets a string identifying the name of the class
  152187. * @returns "RefractionPostProcess" string
  152188. */
  152189. getClassName(): string;
  152190. /**
  152191. * Initializes the RefractionPostProcess
  152192. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  152193. * @param name The name of the effect.
  152194. * @param refractionTextureUrl Url of the refraction texture to use
  152195. * @param color the base color of the refraction (used to taint the rendering)
  152196. * @param depth simulated refraction depth
  152197. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  152198. * @param camera The camera to apply the render pass to.
  152199. * @param options The required width/height ratio to downsize to before computing the render pass.
  152200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152201. * @param engine The engine which the post process will be applied. (default: current engine)
  152202. * @param reusable If the post process can be reused on the same frame. (default: false)
  152203. */
  152204. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152205. /**
  152206. * Disposes of the post process
  152207. * @param camera Camera to dispose post process on
  152208. */
  152209. dispose(camera: Camera): void;
  152210. /** @hidden */
  152211. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  152212. }
  152213. }
  152214. declare module BABYLON {
  152215. /** @hidden */
  152216. export var sharpenPixelShader: {
  152217. name: string;
  152218. shader: string;
  152219. };
  152220. }
  152221. declare module BABYLON {
  152222. /**
  152223. * The SharpenPostProcess applies a sharpen kernel to every pixel
  152224. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  152225. */
  152226. export class SharpenPostProcess extends PostProcess {
  152227. /**
  152228. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  152229. */
  152230. colorAmount: number;
  152231. /**
  152232. * How much sharpness should be applied (default: 0.3)
  152233. */
  152234. edgeAmount: number;
  152235. /**
  152236. * Gets a string identifying the name of the class
  152237. * @returns "SharpenPostProcess" string
  152238. */
  152239. getClassName(): string;
  152240. /**
  152241. * Creates a new instance ConvolutionPostProcess
  152242. * @param name The name of the effect.
  152243. * @param options The required width/height ratio to downsize to before computing the render pass.
  152244. * @param camera The camera to apply the render pass to.
  152245. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152246. * @param engine The engine which the post process will be applied. (default: current engine)
  152247. * @param reusable If the post process can be reused on the same frame. (default: false)
  152248. * @param textureType Type of textures used when performing the post process. (default: 0)
  152249. * @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)
  152250. */
  152251. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152252. /** @hidden */
  152253. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  152254. }
  152255. }
  152256. declare module BABYLON {
  152257. /**
  152258. * PostProcessRenderPipeline
  152259. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152260. */
  152261. export class PostProcessRenderPipeline {
  152262. private engine;
  152263. private _renderEffects;
  152264. private _renderEffectsForIsolatedPass;
  152265. /**
  152266. * List of inspectable custom properties (used by the Inspector)
  152267. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  152268. */
  152269. inspectableCustomProperties: IInspectable[];
  152270. /**
  152271. * @hidden
  152272. */
  152273. protected _cameras: Camera[];
  152274. /** @hidden */
  152275. _name: string;
  152276. /**
  152277. * Gets pipeline name
  152278. */
  152279. get name(): string;
  152280. /** Gets the list of attached cameras */
  152281. get cameras(): Camera[];
  152282. /**
  152283. * Initializes a PostProcessRenderPipeline
  152284. * @param engine engine to add the pipeline to
  152285. * @param name name of the pipeline
  152286. */
  152287. constructor(engine: Engine, name: string);
  152288. /**
  152289. * Gets the class name
  152290. * @returns "PostProcessRenderPipeline"
  152291. */
  152292. getClassName(): string;
  152293. /**
  152294. * If all the render effects in the pipeline are supported
  152295. */
  152296. get isSupported(): boolean;
  152297. /**
  152298. * Adds an effect to the pipeline
  152299. * @param renderEffect the effect to add
  152300. */
  152301. addEffect(renderEffect: PostProcessRenderEffect): void;
  152302. /** @hidden */
  152303. _rebuild(): void;
  152304. /** @hidden */
  152305. _enableEffect(renderEffectName: string, cameras: Camera): void;
  152306. /** @hidden */
  152307. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  152308. /** @hidden */
  152309. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  152310. /** @hidden */
  152311. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  152312. /** @hidden */
  152313. _attachCameras(cameras: Camera, unique: boolean): void;
  152314. /** @hidden */
  152315. _attachCameras(cameras: Camera[], unique: boolean): void;
  152316. /** @hidden */
  152317. _detachCameras(cameras: Camera): void;
  152318. /** @hidden */
  152319. _detachCameras(cameras: Nullable<Camera[]>): void;
  152320. /** @hidden */
  152321. _update(): void;
  152322. /** @hidden */
  152323. _reset(): void;
  152324. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  152325. /**
  152326. * Sets the required values to the prepass renderer.
  152327. * @param prePassRenderer defines the prepass renderer to setup.
  152328. * @returns true if the pre pass is needed.
  152329. */
  152330. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  152331. /**
  152332. * Disposes of the pipeline
  152333. */
  152334. dispose(): void;
  152335. }
  152336. }
  152337. declare module BABYLON {
  152338. /**
  152339. * PostProcessRenderPipelineManager class
  152340. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152341. */
  152342. export class PostProcessRenderPipelineManager {
  152343. private _renderPipelines;
  152344. /**
  152345. * Initializes a PostProcessRenderPipelineManager
  152346. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152347. */
  152348. constructor();
  152349. /**
  152350. * Gets the list of supported render pipelines
  152351. */
  152352. get supportedPipelines(): PostProcessRenderPipeline[];
  152353. /**
  152354. * Adds a pipeline to the manager
  152355. * @param renderPipeline The pipeline to add
  152356. */
  152357. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  152358. /**
  152359. * Attaches a camera to the pipeline
  152360. * @param renderPipelineName The name of the pipeline to attach to
  152361. * @param cameras the camera to attach
  152362. * @param unique if the camera can be attached multiple times to the pipeline
  152363. */
  152364. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  152365. /**
  152366. * Detaches a camera from the pipeline
  152367. * @param renderPipelineName The name of the pipeline to detach from
  152368. * @param cameras the camera to detach
  152369. */
  152370. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  152371. /**
  152372. * Enables an effect by name on a pipeline
  152373. * @param renderPipelineName the name of the pipeline to enable the effect in
  152374. * @param renderEffectName the name of the effect to enable
  152375. * @param cameras the cameras that the effect should be enabled on
  152376. */
  152377. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  152378. /**
  152379. * Disables an effect by name on a pipeline
  152380. * @param renderPipelineName the name of the pipeline to disable the effect in
  152381. * @param renderEffectName the name of the effect to disable
  152382. * @param cameras the cameras that the effect should be disabled on
  152383. */
  152384. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  152385. /**
  152386. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  152387. */
  152388. update(): void;
  152389. /** @hidden */
  152390. _rebuild(): void;
  152391. /**
  152392. * Disposes of the manager and pipelines
  152393. */
  152394. dispose(): void;
  152395. }
  152396. }
  152397. declare module BABYLON {
  152398. interface Scene {
  152399. /** @hidden (Backing field) */
  152400. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  152401. /**
  152402. * Gets the postprocess render pipeline manager
  152403. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152404. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  152405. */
  152406. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  152407. }
  152408. /**
  152409. * Defines the Render Pipeline scene component responsible to rendering pipelines
  152410. */
  152411. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  152412. /**
  152413. * The component name helpfull to identify the component in the list of scene components.
  152414. */
  152415. readonly name: string;
  152416. /**
  152417. * The scene the component belongs to.
  152418. */
  152419. scene: Scene;
  152420. /**
  152421. * Creates a new instance of the component for the given scene
  152422. * @param scene Defines the scene to register the component in
  152423. */
  152424. constructor(scene: Scene);
  152425. /**
  152426. * Registers the component in a given scene
  152427. */
  152428. register(): void;
  152429. /**
  152430. * Rebuilds the elements related to this component in case of
  152431. * context lost for instance.
  152432. */
  152433. rebuild(): void;
  152434. /**
  152435. * Disposes the component and the associated ressources
  152436. */
  152437. dispose(): void;
  152438. private _gatherRenderTargets;
  152439. }
  152440. }
  152441. declare module BABYLON {
  152442. /**
  152443. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  152444. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  152445. */
  152446. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152447. private _scene;
  152448. private _camerasToBeAttached;
  152449. /**
  152450. * ID of the sharpen post process,
  152451. */
  152452. private readonly SharpenPostProcessId;
  152453. /**
  152454. * @ignore
  152455. * ID of the image processing post process;
  152456. */
  152457. readonly ImageProcessingPostProcessId: string;
  152458. /**
  152459. * @ignore
  152460. * ID of the Fast Approximate Anti-Aliasing post process;
  152461. */
  152462. readonly FxaaPostProcessId: string;
  152463. /**
  152464. * ID of the chromatic aberration post process,
  152465. */
  152466. private readonly ChromaticAberrationPostProcessId;
  152467. /**
  152468. * ID of the grain post process
  152469. */
  152470. private readonly GrainPostProcessId;
  152471. /**
  152472. * Sharpen post process which will apply a sharpen convolution to enhance edges
  152473. */
  152474. sharpen: SharpenPostProcess;
  152475. private _sharpenEffect;
  152476. private bloom;
  152477. /**
  152478. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  152479. */
  152480. depthOfField: DepthOfFieldEffect;
  152481. /**
  152482. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152483. */
  152484. fxaa: FxaaPostProcess;
  152485. /**
  152486. * Image post processing pass used to perform operations such as tone mapping or color grading.
  152487. */
  152488. imageProcessing: ImageProcessingPostProcess;
  152489. /**
  152490. * Chromatic aberration post process which will shift rgb colors in the image
  152491. */
  152492. chromaticAberration: ChromaticAberrationPostProcess;
  152493. private _chromaticAberrationEffect;
  152494. /**
  152495. * Grain post process which add noise to the image
  152496. */
  152497. grain: GrainPostProcess;
  152498. private _grainEffect;
  152499. /**
  152500. * Glow post process which adds a glow to emissive areas of the image
  152501. */
  152502. private _glowLayer;
  152503. /**
  152504. * Animations which can be used to tweak settings over a period of time
  152505. */
  152506. animations: Animation[];
  152507. private _imageProcessingConfigurationObserver;
  152508. private _sharpenEnabled;
  152509. private _bloomEnabled;
  152510. private _depthOfFieldEnabled;
  152511. private _depthOfFieldBlurLevel;
  152512. private _fxaaEnabled;
  152513. private _imageProcessingEnabled;
  152514. private _defaultPipelineTextureType;
  152515. private _bloomScale;
  152516. private _chromaticAberrationEnabled;
  152517. private _grainEnabled;
  152518. private _buildAllowed;
  152519. /**
  152520. * Gets active scene
  152521. */
  152522. get scene(): Scene;
  152523. /**
  152524. * Enable or disable the sharpen process from the pipeline
  152525. */
  152526. set sharpenEnabled(enabled: boolean);
  152527. get sharpenEnabled(): boolean;
  152528. private _resizeObserver;
  152529. private _hardwareScaleLevel;
  152530. private _bloomKernel;
  152531. /**
  152532. * Specifies the size of the bloom blur kernel, relative to the final output size
  152533. */
  152534. get bloomKernel(): number;
  152535. set bloomKernel(value: number);
  152536. /**
  152537. * Specifies the weight of the bloom in the final rendering
  152538. */
  152539. private _bloomWeight;
  152540. /**
  152541. * Specifies the luma threshold for the area that will be blurred by the bloom
  152542. */
  152543. private _bloomThreshold;
  152544. private _hdr;
  152545. /**
  152546. * The strength of the bloom.
  152547. */
  152548. set bloomWeight(value: number);
  152549. get bloomWeight(): number;
  152550. /**
  152551. * The strength of the bloom.
  152552. */
  152553. set bloomThreshold(value: number);
  152554. get bloomThreshold(): number;
  152555. /**
  152556. * The scale of the bloom, lower value will provide better performance.
  152557. */
  152558. set bloomScale(value: number);
  152559. get bloomScale(): number;
  152560. /**
  152561. * Enable or disable the bloom from the pipeline
  152562. */
  152563. set bloomEnabled(enabled: boolean);
  152564. get bloomEnabled(): boolean;
  152565. private _rebuildBloom;
  152566. /**
  152567. * If the depth of field is enabled.
  152568. */
  152569. get depthOfFieldEnabled(): boolean;
  152570. set depthOfFieldEnabled(enabled: boolean);
  152571. /**
  152572. * Blur level of the depth of field effect. (Higher blur will effect performance)
  152573. */
  152574. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  152575. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  152576. /**
  152577. * If the anti aliasing is enabled.
  152578. */
  152579. set fxaaEnabled(enabled: boolean);
  152580. get fxaaEnabled(): boolean;
  152581. private _samples;
  152582. /**
  152583. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152584. */
  152585. set samples(sampleCount: number);
  152586. get samples(): number;
  152587. /**
  152588. * If image processing is enabled.
  152589. */
  152590. set imageProcessingEnabled(enabled: boolean);
  152591. get imageProcessingEnabled(): boolean;
  152592. /**
  152593. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  152594. */
  152595. set glowLayerEnabled(enabled: boolean);
  152596. get glowLayerEnabled(): boolean;
  152597. /**
  152598. * Gets the glow layer (or null if not defined)
  152599. */
  152600. get glowLayer(): Nullable<GlowLayer>;
  152601. /**
  152602. * Enable or disable the chromaticAberration process from the pipeline
  152603. */
  152604. set chromaticAberrationEnabled(enabled: boolean);
  152605. get chromaticAberrationEnabled(): boolean;
  152606. /**
  152607. * Enable or disable the grain process from the pipeline
  152608. */
  152609. set grainEnabled(enabled: boolean);
  152610. get grainEnabled(): boolean;
  152611. /**
  152612. * @constructor
  152613. * @param name - The rendering pipeline name (default: "")
  152614. * @param hdr - If high dynamic range textures should be used (default: true)
  152615. * @param scene - The scene linked to this pipeline (default: the last created scene)
  152616. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  152617. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  152618. */
  152619. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  152620. /**
  152621. * Get the class name
  152622. * @returns "DefaultRenderingPipeline"
  152623. */
  152624. getClassName(): string;
  152625. /**
  152626. * Force the compilation of the entire pipeline.
  152627. */
  152628. prepare(): void;
  152629. private _hasCleared;
  152630. private _prevPostProcess;
  152631. private _prevPrevPostProcess;
  152632. private _setAutoClearAndTextureSharing;
  152633. private _depthOfFieldSceneObserver;
  152634. private _buildPipeline;
  152635. private _disposePostProcesses;
  152636. /**
  152637. * Adds a camera to the pipeline
  152638. * @param camera the camera to be added
  152639. */
  152640. addCamera(camera: Camera): void;
  152641. /**
  152642. * Removes a camera from the pipeline
  152643. * @param camera the camera to remove
  152644. */
  152645. removeCamera(camera: Camera): void;
  152646. /**
  152647. * Dispose of the pipeline and stop all post processes
  152648. */
  152649. dispose(): void;
  152650. /**
  152651. * Serialize the rendering pipeline (Used when exporting)
  152652. * @returns the serialized object
  152653. */
  152654. serialize(): any;
  152655. /**
  152656. * Parse the serialized pipeline
  152657. * @param source Source pipeline.
  152658. * @param scene The scene to load the pipeline to.
  152659. * @param rootUrl The URL of the serialized pipeline.
  152660. * @returns An instantiated pipeline from the serialized object.
  152661. */
  152662. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  152663. }
  152664. }
  152665. declare module BABYLON {
  152666. /** @hidden */
  152667. export var lensHighlightsPixelShader: {
  152668. name: string;
  152669. shader: string;
  152670. };
  152671. }
  152672. declare module BABYLON {
  152673. /** @hidden */
  152674. export var depthOfFieldPixelShader: {
  152675. name: string;
  152676. shader: string;
  152677. };
  152678. }
  152679. declare module BABYLON {
  152680. /**
  152681. * BABYLON.JS Chromatic Aberration GLSL Shader
  152682. * Author: Olivier Guyot
  152683. * Separates very slightly R, G and B colors on the edges of the screen
  152684. * Inspired by Francois Tarlier & Martins Upitis
  152685. */
  152686. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  152687. /**
  152688. * @ignore
  152689. * The chromatic aberration PostProcess id in the pipeline
  152690. */
  152691. LensChromaticAberrationEffect: string;
  152692. /**
  152693. * @ignore
  152694. * The highlights enhancing PostProcess id in the pipeline
  152695. */
  152696. HighlightsEnhancingEffect: string;
  152697. /**
  152698. * @ignore
  152699. * The depth-of-field PostProcess id in the pipeline
  152700. */
  152701. LensDepthOfFieldEffect: string;
  152702. private _scene;
  152703. private _depthTexture;
  152704. private _grainTexture;
  152705. private _chromaticAberrationPostProcess;
  152706. private _highlightsPostProcess;
  152707. private _depthOfFieldPostProcess;
  152708. private _edgeBlur;
  152709. private _grainAmount;
  152710. private _chromaticAberration;
  152711. private _distortion;
  152712. private _highlightsGain;
  152713. private _highlightsThreshold;
  152714. private _dofDistance;
  152715. private _dofAperture;
  152716. private _dofDarken;
  152717. private _dofPentagon;
  152718. private _blurNoise;
  152719. /**
  152720. * @constructor
  152721. *
  152722. * Effect parameters are as follow:
  152723. * {
  152724. * chromatic_aberration: number; // from 0 to x (1 for realism)
  152725. * edge_blur: number; // from 0 to x (1 for realism)
  152726. * distortion: number; // from 0 to x (1 for realism)
  152727. * grain_amount: number; // from 0 to 1
  152728. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  152729. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  152730. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  152731. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  152732. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  152733. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  152734. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  152735. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  152736. * }
  152737. * Note: if an effect parameter is unset, effect is disabled
  152738. *
  152739. * @param name The rendering pipeline name
  152740. * @param parameters - An object containing all parameters (see above)
  152741. * @param scene The scene linked to this pipeline
  152742. * @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)
  152743. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152744. */
  152745. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  152746. /**
  152747. * Get the class name
  152748. * @returns "LensRenderingPipeline"
  152749. */
  152750. getClassName(): string;
  152751. /**
  152752. * Gets associated scene
  152753. */
  152754. get scene(): Scene;
  152755. /**
  152756. * Gets or sets the edge blur
  152757. */
  152758. get edgeBlur(): number;
  152759. set edgeBlur(value: number);
  152760. /**
  152761. * Gets or sets the grain amount
  152762. */
  152763. get grainAmount(): number;
  152764. set grainAmount(value: number);
  152765. /**
  152766. * Gets or sets the chromatic aberration amount
  152767. */
  152768. get chromaticAberration(): number;
  152769. set chromaticAberration(value: number);
  152770. /**
  152771. * Gets or sets the depth of field aperture
  152772. */
  152773. get dofAperture(): number;
  152774. set dofAperture(value: number);
  152775. /**
  152776. * Gets or sets the edge distortion
  152777. */
  152778. get edgeDistortion(): number;
  152779. set edgeDistortion(value: number);
  152780. /**
  152781. * Gets or sets the depth of field distortion
  152782. */
  152783. get dofDistortion(): number;
  152784. set dofDistortion(value: number);
  152785. /**
  152786. * Gets or sets the darken out of focus amount
  152787. */
  152788. get darkenOutOfFocus(): number;
  152789. set darkenOutOfFocus(value: number);
  152790. /**
  152791. * Gets or sets a boolean indicating if blur noise is enabled
  152792. */
  152793. get blurNoise(): boolean;
  152794. set blurNoise(value: boolean);
  152795. /**
  152796. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  152797. */
  152798. get pentagonBokeh(): boolean;
  152799. set pentagonBokeh(value: boolean);
  152800. /**
  152801. * Gets or sets the highlight grain amount
  152802. */
  152803. get highlightsGain(): number;
  152804. set highlightsGain(value: number);
  152805. /**
  152806. * Gets or sets the highlight threshold
  152807. */
  152808. get highlightsThreshold(): number;
  152809. set highlightsThreshold(value: number);
  152810. /**
  152811. * Sets the amount of blur at the edges
  152812. * @param amount blur amount
  152813. */
  152814. setEdgeBlur(amount: number): void;
  152815. /**
  152816. * Sets edge blur to 0
  152817. */
  152818. disableEdgeBlur(): void;
  152819. /**
  152820. * Sets the amout of grain
  152821. * @param amount Amount of grain
  152822. */
  152823. setGrainAmount(amount: number): void;
  152824. /**
  152825. * Set grain amount to 0
  152826. */
  152827. disableGrain(): void;
  152828. /**
  152829. * Sets the chromatic aberration amount
  152830. * @param amount amount of chromatic aberration
  152831. */
  152832. setChromaticAberration(amount: number): void;
  152833. /**
  152834. * Sets chromatic aberration amount to 0
  152835. */
  152836. disableChromaticAberration(): void;
  152837. /**
  152838. * Sets the EdgeDistortion amount
  152839. * @param amount amount of EdgeDistortion
  152840. */
  152841. setEdgeDistortion(amount: number): void;
  152842. /**
  152843. * Sets edge distortion to 0
  152844. */
  152845. disableEdgeDistortion(): void;
  152846. /**
  152847. * Sets the FocusDistance amount
  152848. * @param amount amount of FocusDistance
  152849. */
  152850. setFocusDistance(amount: number): void;
  152851. /**
  152852. * Disables depth of field
  152853. */
  152854. disableDepthOfField(): void;
  152855. /**
  152856. * Sets the Aperture amount
  152857. * @param amount amount of Aperture
  152858. */
  152859. setAperture(amount: number): void;
  152860. /**
  152861. * Sets the DarkenOutOfFocus amount
  152862. * @param amount amount of DarkenOutOfFocus
  152863. */
  152864. setDarkenOutOfFocus(amount: number): void;
  152865. private _pentagonBokehIsEnabled;
  152866. /**
  152867. * Creates a pentagon bokeh effect
  152868. */
  152869. enablePentagonBokeh(): void;
  152870. /**
  152871. * Disables the pentagon bokeh effect
  152872. */
  152873. disablePentagonBokeh(): void;
  152874. /**
  152875. * Enables noise blur
  152876. */
  152877. enableNoiseBlur(): void;
  152878. /**
  152879. * Disables noise blur
  152880. */
  152881. disableNoiseBlur(): void;
  152882. /**
  152883. * Sets the HighlightsGain amount
  152884. * @param amount amount of HighlightsGain
  152885. */
  152886. setHighlightsGain(amount: number): void;
  152887. /**
  152888. * Sets the HighlightsThreshold amount
  152889. * @param amount amount of HighlightsThreshold
  152890. */
  152891. setHighlightsThreshold(amount: number): void;
  152892. /**
  152893. * Disables highlights
  152894. */
  152895. disableHighlights(): void;
  152896. /**
  152897. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  152898. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  152899. */
  152900. dispose(disableDepthRender?: boolean): void;
  152901. private _createChromaticAberrationPostProcess;
  152902. private _createHighlightsPostProcess;
  152903. private _createDepthOfFieldPostProcess;
  152904. private _createGrainTexture;
  152905. }
  152906. }
  152907. declare module BABYLON {
  152908. /**
  152909. * Contains all parameters needed for the prepass to perform
  152910. * screen space subsurface scattering
  152911. */
  152912. export class SSAO2Configuration implements PrePassEffectConfiguration {
  152913. /**
  152914. * Is subsurface enabled
  152915. */
  152916. enabled: boolean;
  152917. /**
  152918. * Name of the configuration
  152919. */
  152920. name: string;
  152921. /**
  152922. * Textures that should be present in the MRT for this effect to work
  152923. */
  152924. readonly texturesRequired: number[];
  152925. }
  152926. }
  152927. declare module BABYLON {
  152928. /** @hidden */
  152929. export var ssao2PixelShader: {
  152930. name: string;
  152931. shader: string;
  152932. };
  152933. }
  152934. declare module BABYLON {
  152935. /** @hidden */
  152936. export var ssaoCombinePixelShader: {
  152937. name: string;
  152938. shader: string;
  152939. };
  152940. }
  152941. declare module BABYLON {
  152942. /**
  152943. * Render pipeline to produce ssao effect
  152944. */
  152945. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  152946. /**
  152947. * @ignore
  152948. * The PassPostProcess id in the pipeline that contains the original scene color
  152949. */
  152950. SSAOOriginalSceneColorEffect: string;
  152951. /**
  152952. * @ignore
  152953. * The SSAO PostProcess id in the pipeline
  152954. */
  152955. SSAORenderEffect: string;
  152956. /**
  152957. * @ignore
  152958. * The horizontal blur PostProcess id in the pipeline
  152959. */
  152960. SSAOBlurHRenderEffect: string;
  152961. /**
  152962. * @ignore
  152963. * The vertical blur PostProcess id in the pipeline
  152964. */
  152965. SSAOBlurVRenderEffect: string;
  152966. /**
  152967. * @ignore
  152968. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152969. */
  152970. SSAOCombineRenderEffect: string;
  152971. /**
  152972. * The output strength of the SSAO post-process. Default value is 1.0.
  152973. */
  152974. totalStrength: number;
  152975. /**
  152976. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  152977. */
  152978. maxZ: number;
  152979. /**
  152980. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  152981. */
  152982. minZAspect: number;
  152983. private _samples;
  152984. /**
  152985. * Number of samples used for the SSAO calculations. Default value is 8
  152986. */
  152987. set samples(n: number);
  152988. get samples(): number;
  152989. private _textureSamples;
  152990. /**
  152991. * Number of samples to use for antialiasing
  152992. */
  152993. set textureSamples(n: number);
  152994. get textureSamples(): number;
  152995. /**
  152996. * Force rendering the geometry through geometry buffer
  152997. */
  152998. private _forceGeometryBuffer;
  152999. /**
  153000. * Ratio object used for SSAO ratio and blur ratio
  153001. */
  153002. private _ratio;
  153003. /**
  153004. * Dynamically generated sphere sampler.
  153005. */
  153006. private _sampleSphere;
  153007. /**
  153008. * Blur filter offsets
  153009. */
  153010. private _samplerOffsets;
  153011. private _expensiveBlur;
  153012. /**
  153013. * If bilateral blur should be used
  153014. */
  153015. set expensiveBlur(b: boolean);
  153016. get expensiveBlur(): boolean;
  153017. /**
  153018. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  153019. */
  153020. radius: number;
  153021. /**
  153022. * The base color of the SSAO post-process
  153023. * The final result is "base + ssao" between [0, 1]
  153024. */
  153025. base: number;
  153026. /**
  153027. * Support test.
  153028. */
  153029. static get IsSupported(): boolean;
  153030. private _scene;
  153031. private _randomTexture;
  153032. private _originalColorPostProcess;
  153033. private _ssaoPostProcess;
  153034. private _blurHPostProcess;
  153035. private _blurVPostProcess;
  153036. private _ssaoCombinePostProcess;
  153037. private _prePassRenderer;
  153038. /**
  153039. * Gets active scene
  153040. */
  153041. get scene(): Scene;
  153042. /**
  153043. * @constructor
  153044. * @param name The rendering pipeline name
  153045. * @param scene The scene linked to this pipeline
  153046. * @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 }
  153047. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153048. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  153049. */
  153050. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  153051. /**
  153052. * Get the class name
  153053. * @returns "SSAO2RenderingPipeline"
  153054. */
  153055. getClassName(): string;
  153056. /**
  153057. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  153058. */
  153059. dispose(disableGeometryBufferRenderer?: boolean): void;
  153060. private _createBlurPostProcess;
  153061. /** @hidden */
  153062. _rebuild(): void;
  153063. private _bits;
  153064. private _radicalInverse_VdC;
  153065. private _hammersley;
  153066. private _hemisphereSample_uniform;
  153067. private _generateHemisphere;
  153068. private _getDefinesForSSAO;
  153069. private _createSSAOPostProcess;
  153070. private _createSSAOCombinePostProcess;
  153071. private _createRandomTexture;
  153072. /**
  153073. * Serialize the rendering pipeline (Used when exporting)
  153074. * @returns the serialized object
  153075. */
  153076. serialize(): any;
  153077. /**
  153078. * Parse the serialized pipeline
  153079. * @param source Source pipeline.
  153080. * @param scene The scene to load the pipeline to.
  153081. * @param rootUrl The URL of the serialized pipeline.
  153082. * @returns An instantiated pipeline from the serialized object.
  153083. */
  153084. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  153085. }
  153086. }
  153087. declare module BABYLON {
  153088. /** @hidden */
  153089. export var ssaoPixelShader: {
  153090. name: string;
  153091. shader: string;
  153092. };
  153093. }
  153094. declare module BABYLON {
  153095. /**
  153096. * Render pipeline to produce ssao effect
  153097. */
  153098. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  153099. /**
  153100. * @ignore
  153101. * The PassPostProcess id in the pipeline that contains the original scene color
  153102. */
  153103. SSAOOriginalSceneColorEffect: string;
  153104. /**
  153105. * @ignore
  153106. * The SSAO PostProcess id in the pipeline
  153107. */
  153108. SSAORenderEffect: string;
  153109. /**
  153110. * @ignore
  153111. * The horizontal blur PostProcess id in the pipeline
  153112. */
  153113. SSAOBlurHRenderEffect: string;
  153114. /**
  153115. * @ignore
  153116. * The vertical blur PostProcess id in the pipeline
  153117. */
  153118. SSAOBlurVRenderEffect: string;
  153119. /**
  153120. * @ignore
  153121. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  153122. */
  153123. SSAOCombineRenderEffect: string;
  153124. /**
  153125. * The output strength of the SSAO post-process. Default value is 1.0.
  153126. */
  153127. totalStrength: number;
  153128. /**
  153129. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  153130. */
  153131. radius: number;
  153132. /**
  153133. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  153134. * Must not be equal to fallOff and superior to fallOff.
  153135. * Default value is 0.0075
  153136. */
  153137. area: number;
  153138. /**
  153139. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  153140. * Must not be equal to area and inferior to area.
  153141. * Default value is 0.000001
  153142. */
  153143. fallOff: number;
  153144. /**
  153145. * The base color of the SSAO post-process
  153146. * The final result is "base + ssao" between [0, 1]
  153147. */
  153148. base: number;
  153149. private _scene;
  153150. private _depthTexture;
  153151. private _randomTexture;
  153152. private _originalColorPostProcess;
  153153. private _ssaoPostProcess;
  153154. private _blurHPostProcess;
  153155. private _blurVPostProcess;
  153156. private _ssaoCombinePostProcess;
  153157. private _firstUpdate;
  153158. /**
  153159. * Gets active scene
  153160. */
  153161. get scene(): Scene;
  153162. /**
  153163. * @constructor
  153164. * @param name - The rendering pipeline name
  153165. * @param scene - The scene linked to this pipeline
  153166. * @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 }
  153167. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  153168. */
  153169. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  153170. /**
  153171. * Get the class name
  153172. * @returns "SSAORenderingPipeline"
  153173. */
  153174. getClassName(): string;
  153175. /**
  153176. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  153177. */
  153178. dispose(disableDepthRender?: boolean): void;
  153179. private _createBlurPostProcess;
  153180. /** @hidden */
  153181. _rebuild(): void;
  153182. private _createSSAOPostProcess;
  153183. private _createSSAOCombinePostProcess;
  153184. private _createRandomTexture;
  153185. }
  153186. }
  153187. declare module BABYLON {
  153188. /**
  153189. * Contains all parameters needed for the prepass to perform
  153190. * screen space reflections
  153191. */
  153192. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  153193. /**
  153194. * Is ssr enabled
  153195. */
  153196. enabled: boolean;
  153197. /**
  153198. * Name of the configuration
  153199. */
  153200. name: string;
  153201. /**
  153202. * Textures that should be present in the MRT for this effect to work
  153203. */
  153204. readonly texturesRequired: number[];
  153205. }
  153206. }
  153207. declare module BABYLON {
  153208. /** @hidden */
  153209. export var screenSpaceReflectionPixelShader: {
  153210. name: string;
  153211. shader: string;
  153212. };
  153213. }
  153214. declare module BABYLON {
  153215. /**
  153216. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  153217. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  153218. */
  153219. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  153220. /**
  153221. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  153222. */
  153223. threshold: number;
  153224. /**
  153225. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  153226. */
  153227. strength: number;
  153228. /**
  153229. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  153230. */
  153231. reflectionSpecularFalloffExponent: number;
  153232. /**
  153233. * 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]
  153234. */
  153235. step: number;
  153236. /**
  153237. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  153238. */
  153239. roughnessFactor: number;
  153240. private _forceGeometryBuffer;
  153241. private _geometryBufferRenderer;
  153242. private _prePassRenderer;
  153243. private _enableSmoothReflections;
  153244. private _reflectionSamples;
  153245. private _smoothSteps;
  153246. /**
  153247. * Gets a string identifying the name of the class
  153248. * @returns "ScreenSpaceReflectionPostProcess" string
  153249. */
  153250. getClassName(): string;
  153251. /**
  153252. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  153253. * @param name The name of the effect.
  153254. * @param scene The scene containing the objects to calculate reflections.
  153255. * @param options The required width/height ratio to downsize to before computing the render pass.
  153256. * @param camera The camera to apply the render pass to.
  153257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153258. * @param engine The engine which the post process will be applied. (default: current engine)
  153259. * @param reusable If the post process can be reused on the same frame. (default: false)
  153260. * @param textureType Type of textures used when performing the post process. (default: 0)
  153261. * @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)
  153262. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  153263. */
  153264. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  153265. /**
  153266. * Gets wether or not smoothing reflections is enabled.
  153267. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  153268. */
  153269. get enableSmoothReflections(): boolean;
  153270. /**
  153271. * Sets wether or not smoothing reflections is enabled.
  153272. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  153273. */
  153274. set enableSmoothReflections(enabled: boolean);
  153275. /**
  153276. * Gets the number of samples taken while computing reflections. More samples count is high,
  153277. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  153278. */
  153279. get reflectionSamples(): number;
  153280. /**
  153281. * Sets the number of samples taken while computing reflections. More samples count is high,
  153282. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  153283. */
  153284. set reflectionSamples(samples: number);
  153285. /**
  153286. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  153287. * more the post-process will require GPU power and can generate a drop in FPS.
  153288. * Default value (5.0) work pretty well in all cases but can be adjusted.
  153289. */
  153290. get smoothSteps(): number;
  153291. set smoothSteps(steps: number);
  153292. private _updateEffectDefines;
  153293. /** @hidden */
  153294. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  153295. }
  153296. }
  153297. declare module BABYLON {
  153298. /** @hidden */
  153299. export var standardPixelShader: {
  153300. name: string;
  153301. shader: string;
  153302. };
  153303. }
  153304. declare module BABYLON {
  153305. /**
  153306. * Standard rendering pipeline
  153307. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  153308. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  153309. */
  153310. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  153311. /**
  153312. * Public members
  153313. */
  153314. /**
  153315. * Post-process which contains the original scene color before the pipeline applies all the effects
  153316. */
  153317. originalPostProcess: Nullable<PostProcess>;
  153318. /**
  153319. * Post-process used to down scale an image x4
  153320. */
  153321. downSampleX4PostProcess: Nullable<PostProcess>;
  153322. /**
  153323. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  153324. */
  153325. brightPassPostProcess: Nullable<PostProcess>;
  153326. /**
  153327. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  153328. */
  153329. blurHPostProcesses: PostProcess[];
  153330. /**
  153331. * Post-process array storing all the vertical blur post-processes used by the pipeline
  153332. */
  153333. blurVPostProcesses: PostProcess[];
  153334. /**
  153335. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  153336. */
  153337. textureAdderPostProcess: Nullable<PostProcess>;
  153338. /**
  153339. * Post-process used to create volumetric lighting effect
  153340. */
  153341. volumetricLightPostProcess: Nullable<PostProcess>;
  153342. /**
  153343. * Post-process used to smooth the previous volumetric light post-process on the X axis
  153344. */
  153345. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  153346. /**
  153347. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  153348. */
  153349. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  153350. /**
  153351. * Post-process used to merge the volumetric light effect and the real scene color
  153352. */
  153353. volumetricLightMergePostProces: Nullable<PostProcess>;
  153354. /**
  153355. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  153356. */
  153357. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  153358. /**
  153359. * Base post-process used to calculate the average luminance of the final image for HDR
  153360. */
  153361. luminancePostProcess: Nullable<PostProcess>;
  153362. /**
  153363. * Post-processes used to create down sample post-processes in order to get
  153364. * the average luminance of the final image for HDR
  153365. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  153366. */
  153367. luminanceDownSamplePostProcesses: PostProcess[];
  153368. /**
  153369. * Post-process used to create a HDR effect (light adaptation)
  153370. */
  153371. hdrPostProcess: Nullable<PostProcess>;
  153372. /**
  153373. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  153374. */
  153375. textureAdderFinalPostProcess: Nullable<PostProcess>;
  153376. /**
  153377. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  153378. */
  153379. lensFlareFinalPostProcess: Nullable<PostProcess>;
  153380. /**
  153381. * Post-process used to merge the final HDR post-process and the real scene color
  153382. */
  153383. hdrFinalPostProcess: Nullable<PostProcess>;
  153384. /**
  153385. * Post-process used to create a lens flare effect
  153386. */
  153387. lensFlarePostProcess: Nullable<PostProcess>;
  153388. /**
  153389. * Post-process that merges the result of the lens flare post-process and the real scene color
  153390. */
  153391. lensFlareComposePostProcess: Nullable<PostProcess>;
  153392. /**
  153393. * Post-process used to create a motion blur effect
  153394. */
  153395. motionBlurPostProcess: Nullable<PostProcess>;
  153396. /**
  153397. * Post-process used to create a depth of field effect
  153398. */
  153399. depthOfFieldPostProcess: Nullable<PostProcess>;
  153400. /**
  153401. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  153402. */
  153403. fxaaPostProcess: Nullable<FxaaPostProcess>;
  153404. /**
  153405. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  153406. */
  153407. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  153408. /**
  153409. * Represents the brightness threshold in order to configure the illuminated surfaces
  153410. */
  153411. brightThreshold: number;
  153412. /**
  153413. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  153414. */
  153415. blurWidth: number;
  153416. /**
  153417. * Sets if the blur for highlighted surfaces must be only horizontal
  153418. */
  153419. horizontalBlur: boolean;
  153420. /**
  153421. * Gets the overall exposure used by the pipeline
  153422. */
  153423. get exposure(): number;
  153424. /**
  153425. * Sets the overall exposure used by the pipeline
  153426. */
  153427. set exposure(value: number);
  153428. /**
  153429. * Texture used typically to simulate "dirty" on camera lens
  153430. */
  153431. lensTexture: Nullable<Texture>;
  153432. /**
  153433. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  153434. */
  153435. volumetricLightCoefficient: number;
  153436. /**
  153437. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  153438. */
  153439. volumetricLightPower: number;
  153440. /**
  153441. * Used the set the blur intensity to smooth the volumetric lights
  153442. */
  153443. volumetricLightBlurScale: number;
  153444. /**
  153445. * Light (spot or directional) used to generate the volumetric lights rays
  153446. * The source light must have a shadow generate so the pipeline can get its
  153447. * depth map
  153448. */
  153449. sourceLight: Nullable<SpotLight | DirectionalLight>;
  153450. /**
  153451. * For eye adaptation, represents the minimum luminance the eye can see
  153452. */
  153453. hdrMinimumLuminance: number;
  153454. /**
  153455. * For eye adaptation, represents the decrease luminance speed
  153456. */
  153457. hdrDecreaseRate: number;
  153458. /**
  153459. * For eye adaptation, represents the increase luminance speed
  153460. */
  153461. hdrIncreaseRate: number;
  153462. /**
  153463. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  153464. */
  153465. get hdrAutoExposure(): boolean;
  153466. /**
  153467. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  153468. */
  153469. set hdrAutoExposure(value: boolean);
  153470. /**
  153471. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  153472. */
  153473. lensColorTexture: Nullable<Texture>;
  153474. /**
  153475. * The overall strengh for the lens flare effect
  153476. */
  153477. lensFlareStrength: number;
  153478. /**
  153479. * Dispersion coefficient for lens flare ghosts
  153480. */
  153481. lensFlareGhostDispersal: number;
  153482. /**
  153483. * Main lens flare halo width
  153484. */
  153485. lensFlareHaloWidth: number;
  153486. /**
  153487. * Based on the lens distortion effect, defines how much the lens flare result
  153488. * is distorted
  153489. */
  153490. lensFlareDistortionStrength: number;
  153491. /**
  153492. * Configures the blur intensity used for for lens flare (halo)
  153493. */
  153494. lensFlareBlurWidth: number;
  153495. /**
  153496. * Lens star texture must be used to simulate rays on the flares and is available
  153497. * in the documentation
  153498. */
  153499. lensStarTexture: Nullable<Texture>;
  153500. /**
  153501. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  153502. * flare effect by taking account of the dirt texture
  153503. */
  153504. lensFlareDirtTexture: Nullable<Texture>;
  153505. /**
  153506. * Represents the focal length for the depth of field effect
  153507. */
  153508. depthOfFieldDistance: number;
  153509. /**
  153510. * Represents the blur intensity for the blurred part of the depth of field effect
  153511. */
  153512. depthOfFieldBlurWidth: number;
  153513. /**
  153514. * Gets how much the image is blurred by the movement while using the motion blur post-process
  153515. */
  153516. get motionStrength(): number;
  153517. /**
  153518. * Sets how much the image is blurred by the movement while using the motion blur post-process
  153519. */
  153520. set motionStrength(strength: number);
  153521. /**
  153522. * Gets wether or not the motion blur post-process is object based or screen based.
  153523. */
  153524. get objectBasedMotionBlur(): boolean;
  153525. /**
  153526. * Sets wether or not the motion blur post-process should be object based or screen based
  153527. */
  153528. set objectBasedMotionBlur(value: boolean);
  153529. /**
  153530. * List of animations for the pipeline (IAnimatable implementation)
  153531. */
  153532. animations: Animation[];
  153533. /**
  153534. * Private members
  153535. */
  153536. private _scene;
  153537. private _currentDepthOfFieldSource;
  153538. private _basePostProcess;
  153539. private _fixedExposure;
  153540. private _currentExposure;
  153541. private _hdrAutoExposure;
  153542. private _hdrCurrentLuminance;
  153543. private _motionStrength;
  153544. private _isObjectBasedMotionBlur;
  153545. private _floatTextureType;
  153546. private _camerasToBeAttached;
  153547. private _ratio;
  153548. private _bloomEnabled;
  153549. private _depthOfFieldEnabled;
  153550. private _vlsEnabled;
  153551. private _lensFlareEnabled;
  153552. private _hdrEnabled;
  153553. private _motionBlurEnabled;
  153554. private _fxaaEnabled;
  153555. private _screenSpaceReflectionsEnabled;
  153556. private _motionBlurSamples;
  153557. private _volumetricLightStepsCount;
  153558. private _samples;
  153559. /**
  153560. * @ignore
  153561. * Specifies if the bloom pipeline is enabled
  153562. */
  153563. get BloomEnabled(): boolean;
  153564. set BloomEnabled(enabled: boolean);
  153565. /**
  153566. * @ignore
  153567. * Specifies if the depth of field pipeline is enabed
  153568. */
  153569. get DepthOfFieldEnabled(): boolean;
  153570. set DepthOfFieldEnabled(enabled: boolean);
  153571. /**
  153572. * @ignore
  153573. * Specifies if the lens flare pipeline is enabed
  153574. */
  153575. get LensFlareEnabled(): boolean;
  153576. set LensFlareEnabled(enabled: boolean);
  153577. /**
  153578. * @ignore
  153579. * Specifies if the HDR pipeline is enabled
  153580. */
  153581. get HDREnabled(): boolean;
  153582. set HDREnabled(enabled: boolean);
  153583. /**
  153584. * @ignore
  153585. * Specifies if the volumetric lights scattering effect is enabled
  153586. */
  153587. get VLSEnabled(): boolean;
  153588. set VLSEnabled(enabled: boolean);
  153589. /**
  153590. * @ignore
  153591. * Specifies if the motion blur effect is enabled
  153592. */
  153593. get MotionBlurEnabled(): boolean;
  153594. set MotionBlurEnabled(enabled: boolean);
  153595. /**
  153596. * Specifies if anti-aliasing is enabled
  153597. */
  153598. get fxaaEnabled(): boolean;
  153599. set fxaaEnabled(enabled: boolean);
  153600. /**
  153601. * Specifies if screen space reflections are enabled.
  153602. */
  153603. get screenSpaceReflectionsEnabled(): boolean;
  153604. set screenSpaceReflectionsEnabled(enabled: boolean);
  153605. /**
  153606. * Specifies the number of steps used to calculate the volumetric lights
  153607. * Typically in interval [50, 200]
  153608. */
  153609. get volumetricLightStepsCount(): number;
  153610. set volumetricLightStepsCount(count: number);
  153611. /**
  153612. * Specifies the number of samples used for the motion blur effect
  153613. * Typically in interval [16, 64]
  153614. */
  153615. get motionBlurSamples(): number;
  153616. set motionBlurSamples(samples: number);
  153617. /**
  153618. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  153619. */
  153620. get samples(): number;
  153621. set samples(sampleCount: number);
  153622. /**
  153623. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  153624. * @constructor
  153625. * @param name The rendering pipeline name
  153626. * @param scene The scene linked to this pipeline
  153627. * @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)
  153628. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  153629. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153630. */
  153631. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  153632. private _buildPipeline;
  153633. private _createDownSampleX4PostProcess;
  153634. private _createBrightPassPostProcess;
  153635. private _createBlurPostProcesses;
  153636. private _createTextureAdderPostProcess;
  153637. private _createVolumetricLightPostProcess;
  153638. private _createLuminancePostProcesses;
  153639. private _createHdrPostProcess;
  153640. private _createLensFlarePostProcess;
  153641. private _createDepthOfFieldPostProcess;
  153642. private _createMotionBlurPostProcess;
  153643. private _getDepthTexture;
  153644. private _disposePostProcesses;
  153645. /**
  153646. * Dispose of the pipeline and stop all post processes
  153647. */
  153648. dispose(): void;
  153649. /**
  153650. * Serialize the rendering pipeline (Used when exporting)
  153651. * @returns the serialized object
  153652. */
  153653. serialize(): any;
  153654. /**
  153655. * Parse the serialized pipeline
  153656. * @param source Source pipeline.
  153657. * @param scene The scene to load the pipeline to.
  153658. * @param rootUrl The URL of the serialized pipeline.
  153659. * @returns An instantiated pipeline from the serialized object.
  153660. */
  153661. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  153662. /**
  153663. * Luminance steps
  153664. */
  153665. static LuminanceSteps: number;
  153666. }
  153667. }
  153668. declare module BABYLON {
  153669. /** @hidden */
  153670. export var stereoscopicInterlacePixelShader: {
  153671. name: string;
  153672. shader: string;
  153673. };
  153674. }
  153675. declare module BABYLON {
  153676. /**
  153677. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  153678. */
  153679. export class StereoscopicInterlacePostProcessI extends PostProcess {
  153680. private _stepSize;
  153681. private _passedProcess;
  153682. /**
  153683. * Gets a string identifying the name of the class
  153684. * @returns "StereoscopicInterlacePostProcessI" string
  153685. */
  153686. getClassName(): string;
  153687. /**
  153688. * Initializes a StereoscopicInterlacePostProcessI
  153689. * @param name The name of the effect.
  153690. * @param rigCameras The rig cameras to be appled to the post process
  153691. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  153692. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  153693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153694. * @param engine The engine which the post process will be applied. (default: current engine)
  153695. * @param reusable If the post process can be reused on the same frame. (default: false)
  153696. */
  153697. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  153698. }
  153699. /**
  153700. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  153701. */
  153702. export class StereoscopicInterlacePostProcess extends PostProcess {
  153703. private _stepSize;
  153704. private _passedProcess;
  153705. /**
  153706. * Gets a string identifying the name of the class
  153707. * @returns "StereoscopicInterlacePostProcess" string
  153708. */
  153709. getClassName(): string;
  153710. /**
  153711. * Initializes a StereoscopicInterlacePostProcess
  153712. * @param name The name of the effect.
  153713. * @param rigCameras The rig cameras to be appled to the post process
  153714. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  153715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153716. * @param engine The engine which the post process will be applied. (default: current engine)
  153717. * @param reusable If the post process can be reused on the same frame. (default: false)
  153718. */
  153719. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  153720. }
  153721. }
  153722. declare module BABYLON {
  153723. /** @hidden */
  153724. export var tonemapPixelShader: {
  153725. name: string;
  153726. shader: string;
  153727. };
  153728. }
  153729. declare module BABYLON {
  153730. /** Defines operator used for tonemapping */
  153731. export enum TonemappingOperator {
  153732. /** Hable */
  153733. Hable = 0,
  153734. /** Reinhard */
  153735. Reinhard = 1,
  153736. /** HejiDawson */
  153737. HejiDawson = 2,
  153738. /** Photographic */
  153739. Photographic = 3
  153740. }
  153741. /**
  153742. * Defines a post process to apply tone mapping
  153743. */
  153744. export class TonemapPostProcess extends PostProcess {
  153745. private _operator;
  153746. /** Defines the required exposure adjustement */
  153747. exposureAdjustment: number;
  153748. /**
  153749. * Gets a string identifying the name of the class
  153750. * @returns "TonemapPostProcess" string
  153751. */
  153752. getClassName(): string;
  153753. /**
  153754. * Creates a new TonemapPostProcess
  153755. * @param name defines the name of the postprocess
  153756. * @param _operator defines the operator to use
  153757. * @param exposureAdjustment defines the required exposure adjustement
  153758. * @param camera defines the camera to use (can be null)
  153759. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  153760. * @param engine defines the hosting engine (can be ignore if camera is set)
  153761. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  153762. */
  153763. constructor(name: string, _operator: TonemappingOperator,
  153764. /** Defines the required exposure adjustement */
  153765. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  153766. }
  153767. }
  153768. declare module BABYLON {
  153769. /** @hidden */
  153770. export var volumetricLightScatteringPixelShader: {
  153771. name: string;
  153772. shader: string;
  153773. };
  153774. }
  153775. declare module BABYLON {
  153776. /** @hidden */
  153777. export var volumetricLightScatteringPassVertexShader: {
  153778. name: string;
  153779. shader: string;
  153780. };
  153781. }
  153782. declare module BABYLON {
  153783. /** @hidden */
  153784. export var volumetricLightScatteringPassPixelShader: {
  153785. name: string;
  153786. shader: string;
  153787. };
  153788. }
  153789. declare module BABYLON {
  153790. /**
  153791. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  153792. */
  153793. export class VolumetricLightScatteringPostProcess extends PostProcess {
  153794. private _volumetricLightScatteringPass;
  153795. private _volumetricLightScatteringRTT;
  153796. private _viewPort;
  153797. private _screenCoordinates;
  153798. private _cachedDefines;
  153799. /**
  153800. * If not undefined, the mesh position is computed from the attached node position
  153801. */
  153802. attachedNode: {
  153803. position: Vector3;
  153804. };
  153805. /**
  153806. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  153807. */
  153808. customMeshPosition: Vector3;
  153809. /**
  153810. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  153811. */
  153812. useCustomMeshPosition: boolean;
  153813. /**
  153814. * If the post-process should inverse the light scattering direction
  153815. */
  153816. invert: boolean;
  153817. /**
  153818. * The internal mesh used by the post-process
  153819. */
  153820. mesh: Mesh;
  153821. /**
  153822. * @hidden
  153823. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  153824. */
  153825. get useDiffuseColor(): boolean;
  153826. set useDiffuseColor(useDiffuseColor: boolean);
  153827. /**
  153828. * Array containing the excluded meshes not rendered in the internal pass
  153829. */
  153830. excludedMeshes: AbstractMesh[];
  153831. /**
  153832. * Controls the overall intensity of the post-process
  153833. */
  153834. exposure: number;
  153835. /**
  153836. * Dissipates each sample's contribution in range [0, 1]
  153837. */
  153838. decay: number;
  153839. /**
  153840. * Controls the overall intensity of each sample
  153841. */
  153842. weight: number;
  153843. /**
  153844. * Controls the density of each sample
  153845. */
  153846. density: number;
  153847. /**
  153848. * @constructor
  153849. * @param name The post-process name
  153850. * @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)
  153851. * @param camera The camera that the post-process will be attached to
  153852. * @param mesh The mesh used to create the light scattering
  153853. * @param samples The post-process quality, default 100
  153854. * @param samplingModeThe post-process filtering mode
  153855. * @param engine The babylon engine
  153856. * @param reusable If the post-process is reusable
  153857. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  153858. */
  153859. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  153860. /**
  153861. * Returns the string "VolumetricLightScatteringPostProcess"
  153862. * @returns "VolumetricLightScatteringPostProcess"
  153863. */
  153864. getClassName(): string;
  153865. private _isReady;
  153866. /**
  153867. * Sets the new light position for light scattering effect
  153868. * @param position The new custom light position
  153869. */
  153870. setCustomMeshPosition(position: Vector3): void;
  153871. /**
  153872. * Returns the light position for light scattering effect
  153873. * @return Vector3 The custom light position
  153874. */
  153875. getCustomMeshPosition(): Vector3;
  153876. /**
  153877. * Disposes the internal assets and detaches the post-process from the camera
  153878. */
  153879. dispose(camera: Camera): void;
  153880. /**
  153881. * Returns the render target texture used by the post-process
  153882. * @return the render target texture used by the post-process
  153883. */
  153884. getPass(): RenderTargetTexture;
  153885. private _meshExcluded;
  153886. private _createPass;
  153887. private _updateMeshScreenCoordinates;
  153888. /**
  153889. * Creates a default mesh for the Volumeric Light Scattering post-process
  153890. * @param name The mesh name
  153891. * @param scene The scene where to create the mesh
  153892. * @return the default mesh
  153893. */
  153894. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  153895. }
  153896. }
  153897. declare module BABYLON {
  153898. /** @hidden */
  153899. export var screenSpaceCurvaturePixelShader: {
  153900. name: string;
  153901. shader: string;
  153902. };
  153903. }
  153904. declare module BABYLON {
  153905. /**
  153906. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  153907. */
  153908. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  153909. /**
  153910. * Defines how much ridge the curvature effect displays.
  153911. */
  153912. ridge: number;
  153913. /**
  153914. * Defines how much valley the curvature effect displays.
  153915. */
  153916. valley: number;
  153917. private _geometryBufferRenderer;
  153918. /**
  153919. * Gets a string identifying the name of the class
  153920. * @returns "ScreenSpaceCurvaturePostProcess" string
  153921. */
  153922. getClassName(): string;
  153923. /**
  153924. * Creates a new instance ScreenSpaceCurvaturePostProcess
  153925. * @param name The name of the effect.
  153926. * @param scene The scene containing the objects to blur according to their velocity.
  153927. * @param options The required width/height ratio to downsize to before computing the render pass.
  153928. * @param camera The camera to apply the render pass to.
  153929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153930. * @param engine The engine which the post process will be applied. (default: current engine)
  153931. * @param reusable If the post process can be reused on the same frame. (default: false)
  153932. * @param textureType Type of textures used when performing the post process. (default: 0)
  153933. * @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)
  153934. */
  153935. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  153936. /**
  153937. * Support test.
  153938. */
  153939. static get IsSupported(): boolean;
  153940. /** @hidden */
  153941. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  153942. }
  153943. }
  153944. declare module BABYLON {
  153945. interface Scene {
  153946. /** @hidden (Backing field) */
  153947. _boundingBoxRenderer: BoundingBoxRenderer;
  153948. /** @hidden (Backing field) */
  153949. _forceShowBoundingBoxes: boolean;
  153950. /**
  153951. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  153952. */
  153953. forceShowBoundingBoxes: boolean;
  153954. /**
  153955. * Gets the bounding box renderer associated with the scene
  153956. * @returns a BoundingBoxRenderer
  153957. */
  153958. getBoundingBoxRenderer(): BoundingBoxRenderer;
  153959. }
  153960. interface AbstractMesh {
  153961. /** @hidden (Backing field) */
  153962. _showBoundingBox: boolean;
  153963. /**
  153964. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  153965. */
  153966. showBoundingBox: boolean;
  153967. }
  153968. /**
  153969. * Component responsible of rendering the bounding box of the meshes in a scene.
  153970. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  153971. */
  153972. export class BoundingBoxRenderer implements ISceneComponent {
  153973. /**
  153974. * The component name helpfull to identify the component in the list of scene components.
  153975. */
  153976. readonly name: string;
  153977. /**
  153978. * The scene the component belongs to.
  153979. */
  153980. scene: Scene;
  153981. /**
  153982. * Color of the bounding box lines placed in front of an object
  153983. */
  153984. frontColor: Color3;
  153985. /**
  153986. * Color of the bounding box lines placed behind an object
  153987. */
  153988. backColor: Color3;
  153989. /**
  153990. * Defines if the renderer should show the back lines or not
  153991. */
  153992. showBackLines: boolean;
  153993. /**
  153994. * Observable raised before rendering a bounding box
  153995. */
  153996. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  153997. /**
  153998. * Observable raised after rendering a bounding box
  153999. */
  154000. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  154001. /**
  154002. * Observable raised after resources are created
  154003. */
  154004. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  154005. /**
  154006. * When false, no bounding boxes will be rendered
  154007. */
  154008. enabled: boolean;
  154009. /**
  154010. * @hidden
  154011. */
  154012. renderList: SmartArray<BoundingBox>;
  154013. private _colorShader;
  154014. private _vertexBuffers;
  154015. private _indexBuffer;
  154016. private _fillIndexBuffer;
  154017. private _fillIndexData;
  154018. /**
  154019. * Instantiates a new bounding box renderer in a scene.
  154020. * @param scene the scene the renderer renders in
  154021. */
  154022. constructor(scene: Scene);
  154023. /**
  154024. * Registers the component in a given scene
  154025. */
  154026. register(): void;
  154027. private _evaluateSubMesh;
  154028. private _preActiveMesh;
  154029. private _prepareResources;
  154030. private _createIndexBuffer;
  154031. /**
  154032. * Rebuilds the elements related to this component in case of
  154033. * context lost for instance.
  154034. */
  154035. rebuild(): void;
  154036. /**
  154037. * @hidden
  154038. */
  154039. reset(): void;
  154040. /**
  154041. * Render the bounding boxes of a specific rendering group
  154042. * @param renderingGroupId defines the rendering group to render
  154043. */
  154044. render(renderingGroupId: number): void;
  154045. /**
  154046. * In case of occlusion queries, we can render the occlusion bounding box through this method
  154047. * @param mesh Define the mesh to render the occlusion bounding box for
  154048. */
  154049. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  154050. /**
  154051. * Dispose and release the resources attached to this renderer.
  154052. */
  154053. dispose(): void;
  154054. }
  154055. }
  154056. declare module BABYLON {
  154057. interface Scene {
  154058. /** @hidden (Backing field) */
  154059. _depthRenderer: {
  154060. [id: string]: DepthRenderer;
  154061. };
  154062. /**
  154063. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  154064. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  154065. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  154066. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  154067. * @returns the created depth renderer
  154068. */
  154069. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  154070. /**
  154071. * Disables a depth renderer for a given camera
  154072. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  154073. */
  154074. disableDepthRenderer(camera?: Nullable<Camera>): void;
  154075. }
  154076. /**
  154077. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  154078. * in several rendering techniques.
  154079. */
  154080. export class DepthRendererSceneComponent implements ISceneComponent {
  154081. /**
  154082. * The component name helpfull to identify the component in the list of scene components.
  154083. */
  154084. readonly name: string;
  154085. /**
  154086. * The scene the component belongs to.
  154087. */
  154088. scene: Scene;
  154089. /**
  154090. * Creates a new instance of the component for the given scene
  154091. * @param scene Defines the scene to register the component in
  154092. */
  154093. constructor(scene: Scene);
  154094. /**
  154095. * Registers the component in a given scene
  154096. */
  154097. register(): void;
  154098. /**
  154099. * Rebuilds the elements related to this component in case of
  154100. * context lost for instance.
  154101. */
  154102. rebuild(): void;
  154103. /**
  154104. * Disposes the component and the associated ressources
  154105. */
  154106. dispose(): void;
  154107. private _gatherRenderTargets;
  154108. private _gatherActiveCameraRenderTargets;
  154109. }
  154110. }
  154111. declare module BABYLON {
  154112. interface AbstractScene {
  154113. /** @hidden (Backing field) */
  154114. _prePassRenderer: Nullable<PrePassRenderer>;
  154115. /**
  154116. * Gets or Sets the current prepass renderer associated to the scene.
  154117. */
  154118. prePassRenderer: Nullable<PrePassRenderer>;
  154119. /**
  154120. * Enables the prepass and associates it with the scene
  154121. * @returns the PrePassRenderer
  154122. */
  154123. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  154124. /**
  154125. * Disables the prepass associated with the scene
  154126. */
  154127. disablePrePassRenderer(): void;
  154128. }
  154129. /**
  154130. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  154131. * in several rendering techniques.
  154132. */
  154133. export class PrePassRendererSceneComponent implements ISceneComponent {
  154134. /**
  154135. * The component name helpful to identify the component in the list of scene components.
  154136. */
  154137. readonly name: string;
  154138. /**
  154139. * The scene the component belongs to.
  154140. */
  154141. scene: Scene;
  154142. /**
  154143. * Creates a new instance of the component for the given scene
  154144. * @param scene Defines the scene to register the component in
  154145. */
  154146. constructor(scene: Scene);
  154147. /**
  154148. * Registers the component in a given scene
  154149. */
  154150. register(): void;
  154151. private _beforeCameraDraw;
  154152. private _afterCameraDraw;
  154153. private _beforeClearStage;
  154154. /**
  154155. * Rebuilds the elements related to this component in case of
  154156. * context lost for instance.
  154157. */
  154158. rebuild(): void;
  154159. /**
  154160. * Disposes the component and the associated ressources
  154161. */
  154162. dispose(): void;
  154163. }
  154164. }
  154165. declare module BABYLON {
  154166. /** @hidden */
  154167. export var fibonacci: {
  154168. name: string;
  154169. shader: string;
  154170. };
  154171. }
  154172. declare module BABYLON {
  154173. /** @hidden */
  154174. export var diffusionProfile: {
  154175. name: string;
  154176. shader: string;
  154177. };
  154178. }
  154179. declare module BABYLON {
  154180. /** @hidden */
  154181. export var subSurfaceScatteringPixelShader: {
  154182. name: string;
  154183. shader: string;
  154184. };
  154185. }
  154186. declare module BABYLON {
  154187. /**
  154188. * Sub surface scattering post process
  154189. */
  154190. export class SubSurfaceScatteringPostProcess extends PostProcess {
  154191. /**
  154192. * Gets a string identifying the name of the class
  154193. * @returns "SubSurfaceScatteringPostProcess" string
  154194. */
  154195. getClassName(): string;
  154196. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  154197. }
  154198. }
  154199. declare module BABYLON {
  154200. /**
  154201. * Contains all parameters needed for the prepass to perform
  154202. * screen space subsurface scattering
  154203. */
  154204. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  154205. /** @hidden */
  154206. static _SceneComponentInitialization: (scene: Scene) => void;
  154207. private _ssDiffusionS;
  154208. private _ssFilterRadii;
  154209. private _ssDiffusionD;
  154210. /**
  154211. * Post process to attach for screen space subsurface scattering
  154212. */
  154213. postProcess: SubSurfaceScatteringPostProcess;
  154214. /**
  154215. * Diffusion profile color for subsurface scattering
  154216. */
  154217. get ssDiffusionS(): number[];
  154218. /**
  154219. * Diffusion profile max color channel value for subsurface scattering
  154220. */
  154221. get ssDiffusionD(): number[];
  154222. /**
  154223. * Diffusion profile filter radius for subsurface scattering
  154224. */
  154225. get ssFilterRadii(): number[];
  154226. /**
  154227. * Is subsurface enabled
  154228. */
  154229. enabled: boolean;
  154230. /**
  154231. * Name of the configuration
  154232. */
  154233. name: string;
  154234. /**
  154235. * Diffusion profile colors for subsurface scattering
  154236. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  154237. * See ...
  154238. * Note that you can only store up to 5 of them
  154239. */
  154240. ssDiffusionProfileColors: Color3[];
  154241. /**
  154242. * Defines the ratio real world => scene units.
  154243. * Used for subsurface scattering
  154244. */
  154245. metersPerUnit: number;
  154246. /**
  154247. * Textures that should be present in the MRT for this effect to work
  154248. */
  154249. readonly texturesRequired: number[];
  154250. private _scene;
  154251. /**
  154252. * Builds a subsurface configuration object
  154253. * @param scene The scene
  154254. */
  154255. constructor(scene: Scene);
  154256. /**
  154257. * Adds a new diffusion profile.
  154258. * Useful for more realistic subsurface scattering on diverse materials.
  154259. * @param color The color of the diffusion profile. Should be the average color of the material.
  154260. * @return The index of the diffusion profile for the material subsurface configuration
  154261. */
  154262. addDiffusionProfile(color: Color3): number;
  154263. /**
  154264. * Creates the sss post process
  154265. * @return The created post process
  154266. */
  154267. createPostProcess(): SubSurfaceScatteringPostProcess;
  154268. /**
  154269. * Deletes all diffusion profiles.
  154270. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  154271. */
  154272. clearAllDiffusionProfiles(): void;
  154273. /**
  154274. * Disposes this object
  154275. */
  154276. dispose(): void;
  154277. /**
  154278. * @hidden
  154279. * https://zero-radiance.github.io/post/sampling-diffusion/
  154280. *
  154281. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  154282. * ------------------------------------------------------------------------------------
  154283. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  154284. * PDF[r, phi, s] = r * R[r, phi, s]
  154285. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  154286. * ------------------------------------------------------------------------------------
  154287. * We importance sample the color channel with the widest scattering distance.
  154288. */
  154289. getDiffusionProfileParameters(color: Color3): number;
  154290. /**
  154291. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  154292. * 'u' is the random number (the value of the CDF): [0, 1).
  154293. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  154294. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  154295. */
  154296. private _sampleBurleyDiffusionProfile;
  154297. }
  154298. }
  154299. declare module BABYLON {
  154300. interface AbstractScene {
  154301. /** @hidden (Backing field) */
  154302. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  154303. /**
  154304. * Gets or Sets the current prepass renderer associated to the scene.
  154305. */
  154306. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  154307. /**
  154308. * Enables the subsurface effect for prepass
  154309. * @returns the SubSurfaceConfiguration
  154310. */
  154311. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  154312. /**
  154313. * Disables the subsurface effect for prepass
  154314. */
  154315. disableSubSurfaceForPrePass(): void;
  154316. }
  154317. /**
  154318. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  154319. * in several rendering techniques.
  154320. */
  154321. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  154322. /**
  154323. * The component name helpful to identify the component in the list of scene components.
  154324. */
  154325. readonly name: string;
  154326. /**
  154327. * The scene the component belongs to.
  154328. */
  154329. scene: Scene;
  154330. /**
  154331. * Creates a new instance of the component for the given scene
  154332. * @param scene Defines the scene to register the component in
  154333. */
  154334. constructor(scene: Scene);
  154335. /**
  154336. * Registers the component in a given scene
  154337. */
  154338. register(): void;
  154339. /**
  154340. * Serializes the component data to the specified json object
  154341. * @param serializationObject The object to serialize to
  154342. */
  154343. serialize(serializationObject: any): void;
  154344. /**
  154345. * Adds all the elements from the container to the scene
  154346. * @param container the container holding the elements
  154347. */
  154348. addFromContainer(container: AbstractScene): void;
  154349. /**
  154350. * Removes all the elements in the container from the scene
  154351. * @param container contains the elements to remove
  154352. * @param dispose if the removed element should be disposed (default: false)
  154353. */
  154354. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  154355. /**
  154356. * Rebuilds the elements related to this component in case of
  154357. * context lost for instance.
  154358. */
  154359. rebuild(): void;
  154360. /**
  154361. * Disposes the component and the associated ressources
  154362. */
  154363. dispose(): void;
  154364. }
  154365. }
  154366. declare module BABYLON {
  154367. /** @hidden */
  154368. export var outlinePixelShader: {
  154369. name: string;
  154370. shader: string;
  154371. };
  154372. }
  154373. declare module BABYLON {
  154374. /** @hidden */
  154375. export var outlineVertexShader: {
  154376. name: string;
  154377. shader: string;
  154378. };
  154379. }
  154380. declare module BABYLON {
  154381. interface Scene {
  154382. /** @hidden */
  154383. _outlineRenderer: OutlineRenderer;
  154384. /**
  154385. * Gets the outline renderer associated with the scene
  154386. * @returns a OutlineRenderer
  154387. */
  154388. getOutlineRenderer(): OutlineRenderer;
  154389. }
  154390. interface AbstractMesh {
  154391. /** @hidden (Backing field) */
  154392. _renderOutline: boolean;
  154393. /**
  154394. * Gets or sets a boolean indicating if the outline must be rendered as well
  154395. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  154396. */
  154397. renderOutline: boolean;
  154398. /** @hidden (Backing field) */
  154399. _renderOverlay: boolean;
  154400. /**
  154401. * Gets or sets a boolean indicating if the overlay must be rendered as well
  154402. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  154403. */
  154404. renderOverlay: boolean;
  154405. }
  154406. /**
  154407. * This class is responsible to draw bothe outline/overlay of meshes.
  154408. * It should not be used directly but through the available method on mesh.
  154409. */
  154410. export class OutlineRenderer implements ISceneComponent {
  154411. /**
  154412. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  154413. */
  154414. private static _StencilReference;
  154415. /**
  154416. * The name of the component. Each component must have a unique name.
  154417. */
  154418. name: string;
  154419. /**
  154420. * The scene the component belongs to.
  154421. */
  154422. scene: Scene;
  154423. /**
  154424. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  154425. */
  154426. zOffset: number;
  154427. private _engine;
  154428. private _effect;
  154429. private _cachedDefines;
  154430. private _savedDepthWrite;
  154431. /**
  154432. * Instantiates a new outline renderer. (There could be only one per scene).
  154433. * @param scene Defines the scene it belongs to
  154434. */
  154435. constructor(scene: Scene);
  154436. /**
  154437. * Register the component to one instance of a scene.
  154438. */
  154439. register(): void;
  154440. /**
  154441. * Rebuilds the elements related to this component in case of
  154442. * context lost for instance.
  154443. */
  154444. rebuild(): void;
  154445. /**
  154446. * Disposes the component and the associated ressources.
  154447. */
  154448. dispose(): void;
  154449. /**
  154450. * Renders the outline in the canvas.
  154451. * @param subMesh Defines the sumesh to render
  154452. * @param batch Defines the batch of meshes in case of instances
  154453. * @param useOverlay Defines if the rendering is for the overlay or the outline
  154454. */
  154455. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  154456. /**
  154457. * Returns whether or not the outline renderer is ready for a given submesh.
  154458. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  154459. * @param subMesh Defines the submesh to check readyness for
  154460. * @param useInstances Defines wheter wee are trying to render instances or not
  154461. * @returns true if ready otherwise false
  154462. */
  154463. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  154464. private _beforeRenderingMesh;
  154465. private _afterRenderingMesh;
  154466. }
  154467. }
  154468. declare module BABYLON {
  154469. /**
  154470. * Defines the basic options interface of a Sprite Frame Source Size.
  154471. */
  154472. export interface ISpriteJSONSpriteSourceSize {
  154473. /**
  154474. * number of the original width of the Frame
  154475. */
  154476. w: number;
  154477. /**
  154478. * number of the original height of the Frame
  154479. */
  154480. h: number;
  154481. }
  154482. /**
  154483. * Defines the basic options interface of a Sprite Frame Data.
  154484. */
  154485. export interface ISpriteJSONSpriteFrameData {
  154486. /**
  154487. * number of the x offset of the Frame
  154488. */
  154489. x: number;
  154490. /**
  154491. * number of the y offset of the Frame
  154492. */
  154493. y: number;
  154494. /**
  154495. * number of the width of the Frame
  154496. */
  154497. w: number;
  154498. /**
  154499. * number of the height of the Frame
  154500. */
  154501. h: number;
  154502. }
  154503. /**
  154504. * Defines the basic options interface of a JSON Sprite.
  154505. */
  154506. export interface ISpriteJSONSprite {
  154507. /**
  154508. * string name of the Frame
  154509. */
  154510. filename: string;
  154511. /**
  154512. * ISpriteJSONSpriteFrame basic object of the frame data
  154513. */
  154514. frame: ISpriteJSONSpriteFrameData;
  154515. /**
  154516. * boolean to flag is the frame was rotated.
  154517. */
  154518. rotated: boolean;
  154519. /**
  154520. * boolean to flag is the frame was trimmed.
  154521. */
  154522. trimmed: boolean;
  154523. /**
  154524. * ISpriteJSONSpriteFrame basic object of the source data
  154525. */
  154526. spriteSourceSize: ISpriteJSONSpriteFrameData;
  154527. /**
  154528. * ISpriteJSONSpriteFrame basic object of the source data
  154529. */
  154530. sourceSize: ISpriteJSONSpriteSourceSize;
  154531. }
  154532. /**
  154533. * Defines the basic options interface of a JSON atlas.
  154534. */
  154535. export interface ISpriteJSONAtlas {
  154536. /**
  154537. * Array of objects that contain the frame data.
  154538. */
  154539. frames: Array<ISpriteJSONSprite>;
  154540. /**
  154541. * object basic object containing the sprite meta data.
  154542. */
  154543. meta?: object;
  154544. }
  154545. }
  154546. declare module BABYLON {
  154547. /** @hidden */
  154548. export var spriteMapPixelShader: {
  154549. name: string;
  154550. shader: string;
  154551. };
  154552. }
  154553. declare module BABYLON {
  154554. /** @hidden */
  154555. export var spriteMapVertexShader: {
  154556. name: string;
  154557. shader: string;
  154558. };
  154559. }
  154560. declare module BABYLON {
  154561. /**
  154562. * Defines the basic options interface of a SpriteMap
  154563. */
  154564. export interface ISpriteMapOptions {
  154565. /**
  154566. * Vector2 of the number of cells in the grid.
  154567. */
  154568. stageSize?: Vector2;
  154569. /**
  154570. * Vector2 of the size of the output plane in World Units.
  154571. */
  154572. outputSize?: Vector2;
  154573. /**
  154574. * Vector3 of the position of the output plane in World Units.
  154575. */
  154576. outputPosition?: Vector3;
  154577. /**
  154578. * Vector3 of the rotation of the output plane.
  154579. */
  154580. outputRotation?: Vector3;
  154581. /**
  154582. * number of layers that the system will reserve in resources.
  154583. */
  154584. layerCount?: number;
  154585. /**
  154586. * number of max animation frames a single cell will reserve in resources.
  154587. */
  154588. maxAnimationFrames?: number;
  154589. /**
  154590. * number cell index of the base tile when the system compiles.
  154591. */
  154592. baseTile?: number;
  154593. /**
  154594. * boolean flip the sprite after its been repositioned by the framing data.
  154595. */
  154596. flipU?: boolean;
  154597. /**
  154598. * Vector3 scalar of the global RGB values of the SpriteMap.
  154599. */
  154600. colorMultiply?: Vector3;
  154601. }
  154602. /**
  154603. * Defines the IDisposable interface in order to be cleanable from resources.
  154604. */
  154605. export interface ISpriteMap extends IDisposable {
  154606. /**
  154607. * String name of the SpriteMap.
  154608. */
  154609. name: string;
  154610. /**
  154611. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  154612. */
  154613. atlasJSON: ISpriteJSONAtlas;
  154614. /**
  154615. * Texture of the SpriteMap.
  154616. */
  154617. spriteSheet: Texture;
  154618. /**
  154619. * The parameters to initialize the SpriteMap with.
  154620. */
  154621. options: ISpriteMapOptions;
  154622. }
  154623. /**
  154624. * Class used to manage a grid restricted sprite deployment on an Output plane.
  154625. */
  154626. export class SpriteMap implements ISpriteMap {
  154627. /** The Name of the spriteMap */
  154628. name: string;
  154629. /** The JSON file with the frame and meta data */
  154630. atlasJSON: ISpriteJSONAtlas;
  154631. /** The systems Sprite Sheet Texture */
  154632. spriteSheet: Texture;
  154633. /** Arguments passed with the Constructor */
  154634. options: ISpriteMapOptions;
  154635. /** Public Sprite Storage array, parsed from atlasJSON */
  154636. sprites: Array<ISpriteJSONSprite>;
  154637. /** Returns the Number of Sprites in the System */
  154638. get spriteCount(): number;
  154639. /** Returns the Position of Output Plane*/
  154640. get position(): Vector3;
  154641. /** Returns the Position of Output Plane*/
  154642. set position(v: Vector3);
  154643. /** Returns the Rotation of Output Plane*/
  154644. get rotation(): Vector3;
  154645. /** Returns the Rotation of Output Plane*/
  154646. set rotation(v: Vector3);
  154647. /** Sets the AnimationMap*/
  154648. get animationMap(): RawTexture;
  154649. /** Sets the AnimationMap*/
  154650. set animationMap(v: RawTexture);
  154651. /** Scene that the SpriteMap was created in */
  154652. private _scene;
  154653. /** Texture Buffer of Float32 that holds tile frame data*/
  154654. private _frameMap;
  154655. /** Texture Buffers of Float32 that holds tileMap data*/
  154656. private _tileMaps;
  154657. /** Texture Buffer of Float32 that holds Animation Data*/
  154658. private _animationMap;
  154659. /** Custom ShaderMaterial Central to the System*/
  154660. private _material;
  154661. /** Custom ShaderMaterial Central to the System*/
  154662. private _output;
  154663. /** Systems Time Ticker*/
  154664. private _time;
  154665. /**
  154666. * Creates a new SpriteMap
  154667. * @param name defines the SpriteMaps Name
  154668. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  154669. * @param spriteSheet is the Texture that the Sprites are on.
  154670. * @param options a basic deployment configuration
  154671. * @param scene The Scene that the map is deployed on
  154672. */
  154673. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  154674. /**
  154675. * Returns tileID location
  154676. * @returns Vector2 the cell position ID
  154677. */
  154678. getTileID(): Vector2;
  154679. /**
  154680. * Gets the UV location of the mouse over the SpriteMap.
  154681. * @returns Vector2 the UV position of the mouse interaction
  154682. */
  154683. getMousePosition(): Vector2;
  154684. /**
  154685. * Creates the "frame" texture Buffer
  154686. * -------------------------------------
  154687. * Structure of frames
  154688. * "filename": "Falling-Water-2.png",
  154689. * "frame": {"x":69,"y":103,"w":24,"h":32},
  154690. * "rotated": true,
  154691. * "trimmed": true,
  154692. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  154693. * "sourceSize": {"w":32,"h":32}
  154694. * @returns RawTexture of the frameMap
  154695. */
  154696. private _createFrameBuffer;
  154697. /**
  154698. * Creates the tileMap texture Buffer
  154699. * @param buffer normally and array of numbers, or a false to generate from scratch
  154700. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  154701. * @returns RawTexture of the tileMap
  154702. */
  154703. private _createTileBuffer;
  154704. /**
  154705. * Modifies the data of the tileMaps
  154706. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  154707. * @param pos is the iVector2 Coordinates of the Tile
  154708. * @param tile The SpriteIndex of the new Tile
  154709. */
  154710. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  154711. /**
  154712. * Creates the animationMap texture Buffer
  154713. * @param buffer normally and array of numbers, or a false to generate from scratch
  154714. * @returns RawTexture of the animationMap
  154715. */
  154716. private _createTileAnimationBuffer;
  154717. /**
  154718. * Modifies the data of the animationMap
  154719. * @param cellID is the Index of the Sprite
  154720. * @param _frame is the target Animation frame
  154721. * @param toCell is the Target Index of the next frame of the animation
  154722. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  154723. * @param speed is a global scalar of the time variable on the map.
  154724. */
  154725. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  154726. /**
  154727. * Exports the .tilemaps file
  154728. */
  154729. saveTileMaps(): void;
  154730. /**
  154731. * Imports the .tilemaps file
  154732. * @param url of the .tilemaps file
  154733. */
  154734. loadTileMaps(url: string): void;
  154735. /**
  154736. * Release associated resources
  154737. */
  154738. dispose(): void;
  154739. }
  154740. }
  154741. declare module BABYLON {
  154742. /**
  154743. * Class used to manage multiple sprites of different sizes on the same spritesheet
  154744. * @see https://doc.babylonjs.com/babylon101/sprites
  154745. */
  154746. export class SpritePackedManager extends SpriteManager {
  154747. /** defines the packed manager's name */
  154748. name: string;
  154749. /**
  154750. * Creates a new sprite manager from a packed sprite sheet
  154751. * @param name defines the manager's name
  154752. * @param imgUrl defines the sprite sheet url
  154753. * @param capacity defines the maximum allowed number of sprites
  154754. * @param scene defines the hosting scene
  154755. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  154756. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  154757. * @param samplingMode defines the smapling mode to use with spritesheet
  154758. * @param fromPacked set to true; do not alter
  154759. */
  154760. constructor(
  154761. /** defines the packed manager's name */
  154762. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  154763. }
  154764. }
  154765. declare module BABYLON {
  154766. /**
  154767. * Defines the list of states available for a task inside a AssetsManager
  154768. */
  154769. export enum AssetTaskState {
  154770. /**
  154771. * Initialization
  154772. */
  154773. INIT = 0,
  154774. /**
  154775. * Running
  154776. */
  154777. RUNNING = 1,
  154778. /**
  154779. * Done
  154780. */
  154781. DONE = 2,
  154782. /**
  154783. * Error
  154784. */
  154785. ERROR = 3
  154786. }
  154787. /**
  154788. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  154789. */
  154790. export abstract class AbstractAssetTask {
  154791. /**
  154792. * Task name
  154793. */ name: string;
  154794. /**
  154795. * Callback called when the task is successful
  154796. */
  154797. onSuccess: (task: any) => void;
  154798. /**
  154799. * Callback called when the task is not successful
  154800. */
  154801. onError: (task: any, message?: string, exception?: any) => void;
  154802. /**
  154803. * Creates a new AssetsManager
  154804. * @param name defines the name of the task
  154805. */
  154806. constructor(
  154807. /**
  154808. * Task name
  154809. */ name: string);
  154810. private _isCompleted;
  154811. private _taskState;
  154812. private _errorObject;
  154813. /**
  154814. * Get if the task is completed
  154815. */
  154816. get isCompleted(): boolean;
  154817. /**
  154818. * Gets the current state of the task
  154819. */
  154820. get taskState(): AssetTaskState;
  154821. /**
  154822. * Gets the current error object (if task is in error)
  154823. */
  154824. get errorObject(): {
  154825. message?: string;
  154826. exception?: any;
  154827. };
  154828. /**
  154829. * Internal only
  154830. * @hidden
  154831. */
  154832. _setErrorObject(message?: string, exception?: any): void;
  154833. /**
  154834. * Execute the current task
  154835. * @param scene defines the scene where you want your assets to be loaded
  154836. * @param onSuccess is a callback called when the task is successfully executed
  154837. * @param onError is a callback called if an error occurs
  154838. */
  154839. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154840. /**
  154841. * Execute the current task
  154842. * @param scene defines the scene where you want your assets to be loaded
  154843. * @param onSuccess is a callback called when the task is successfully executed
  154844. * @param onError is a callback called if an error occurs
  154845. */
  154846. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154847. /**
  154848. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  154849. * This can be used with failed tasks that have the reason for failure fixed.
  154850. */
  154851. reset(): void;
  154852. private onErrorCallback;
  154853. private onDoneCallback;
  154854. }
  154855. /**
  154856. * Define the interface used by progress events raised during assets loading
  154857. */
  154858. export interface IAssetsProgressEvent {
  154859. /**
  154860. * Defines the number of remaining tasks to process
  154861. */
  154862. remainingCount: number;
  154863. /**
  154864. * Defines the total number of tasks
  154865. */
  154866. totalCount: number;
  154867. /**
  154868. * Defines the task that was just processed
  154869. */
  154870. task: AbstractAssetTask;
  154871. }
  154872. /**
  154873. * Class used to share progress information about assets loading
  154874. */
  154875. export class AssetsProgressEvent implements IAssetsProgressEvent {
  154876. /**
  154877. * Defines the number of remaining tasks to process
  154878. */
  154879. remainingCount: number;
  154880. /**
  154881. * Defines the total number of tasks
  154882. */
  154883. totalCount: number;
  154884. /**
  154885. * Defines the task that was just processed
  154886. */
  154887. task: AbstractAssetTask;
  154888. /**
  154889. * Creates a AssetsProgressEvent
  154890. * @param remainingCount defines the number of remaining tasks to process
  154891. * @param totalCount defines the total number of tasks
  154892. * @param task defines the task that was just processed
  154893. */
  154894. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  154895. }
  154896. /**
  154897. * Define a task used by AssetsManager to load assets into a container
  154898. */
  154899. export class ContainerAssetTask extends AbstractAssetTask {
  154900. /**
  154901. * Defines the name of the task
  154902. */
  154903. name: string;
  154904. /**
  154905. * Defines the list of mesh's names you want to load
  154906. */
  154907. meshesNames: any;
  154908. /**
  154909. * Defines the root url to use as a base to load your meshes and associated resources
  154910. */
  154911. rootUrl: string;
  154912. /**
  154913. * Defines the filename or File of the scene to load from
  154914. */
  154915. sceneFilename: string | File;
  154916. /**
  154917. * Get the loaded asset container
  154918. */
  154919. loadedContainer: AssetContainer;
  154920. /**
  154921. * Gets the list of loaded meshes
  154922. */
  154923. loadedMeshes: Array<AbstractMesh>;
  154924. /**
  154925. * Gets the list of loaded particle systems
  154926. */
  154927. loadedParticleSystems: Array<IParticleSystem>;
  154928. /**
  154929. * Gets the list of loaded skeletons
  154930. */
  154931. loadedSkeletons: Array<Skeleton>;
  154932. /**
  154933. * Gets the list of loaded animation groups
  154934. */
  154935. loadedAnimationGroups: Array<AnimationGroup>;
  154936. /**
  154937. * Callback called when the task is successful
  154938. */
  154939. onSuccess: (task: ContainerAssetTask) => void;
  154940. /**
  154941. * Callback called when the task is successful
  154942. */
  154943. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  154944. /**
  154945. * Creates a new ContainerAssetTask
  154946. * @param name defines the name of the task
  154947. * @param meshesNames defines the list of mesh's names you want to load
  154948. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  154949. * @param sceneFilename defines the filename or File of the scene to load from
  154950. */
  154951. constructor(
  154952. /**
  154953. * Defines the name of the task
  154954. */
  154955. name: string,
  154956. /**
  154957. * Defines the list of mesh's names you want to load
  154958. */
  154959. meshesNames: any,
  154960. /**
  154961. * Defines the root url to use as a base to load your meshes and associated resources
  154962. */
  154963. rootUrl: string,
  154964. /**
  154965. * Defines the filename or File of the scene to load from
  154966. */
  154967. sceneFilename: string | File);
  154968. /**
  154969. * Execute the current task
  154970. * @param scene defines the scene where you want your assets to be loaded
  154971. * @param onSuccess is a callback called when the task is successfully executed
  154972. * @param onError is a callback called if an error occurs
  154973. */
  154974. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154975. }
  154976. /**
  154977. * Define a task used by AssetsManager to load meshes
  154978. */
  154979. export class MeshAssetTask extends AbstractAssetTask {
  154980. /**
  154981. * Defines the name of the task
  154982. */
  154983. name: string;
  154984. /**
  154985. * Defines the list of mesh's names you want to load
  154986. */
  154987. meshesNames: any;
  154988. /**
  154989. * Defines the root url to use as a base to load your meshes and associated resources
  154990. */
  154991. rootUrl: string;
  154992. /**
  154993. * Defines the filename or File of the scene to load from
  154994. */
  154995. sceneFilename: string | File;
  154996. /**
  154997. * Gets the list of loaded meshes
  154998. */
  154999. loadedMeshes: Array<AbstractMesh>;
  155000. /**
  155001. * Gets the list of loaded particle systems
  155002. */
  155003. loadedParticleSystems: Array<IParticleSystem>;
  155004. /**
  155005. * Gets the list of loaded skeletons
  155006. */
  155007. loadedSkeletons: Array<Skeleton>;
  155008. /**
  155009. * Gets the list of loaded animation groups
  155010. */
  155011. loadedAnimationGroups: Array<AnimationGroup>;
  155012. /**
  155013. * Callback called when the task is successful
  155014. */
  155015. onSuccess: (task: MeshAssetTask) => void;
  155016. /**
  155017. * Callback called when the task is successful
  155018. */
  155019. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  155020. /**
  155021. * Creates a new MeshAssetTask
  155022. * @param name defines the name of the task
  155023. * @param meshesNames defines the list of mesh's names you want to load
  155024. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  155025. * @param sceneFilename defines the filename or File of the scene to load from
  155026. */
  155027. constructor(
  155028. /**
  155029. * Defines the name of the task
  155030. */
  155031. name: string,
  155032. /**
  155033. * Defines the list of mesh's names you want to load
  155034. */
  155035. meshesNames: any,
  155036. /**
  155037. * Defines the root url to use as a base to load your meshes and associated resources
  155038. */
  155039. rootUrl: string,
  155040. /**
  155041. * Defines the filename or File of the scene to load from
  155042. */
  155043. sceneFilename: string | File);
  155044. /**
  155045. * Execute the current task
  155046. * @param scene defines the scene where you want your assets to be loaded
  155047. * @param onSuccess is a callback called when the task is successfully executed
  155048. * @param onError is a callback called if an error occurs
  155049. */
  155050. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155051. }
  155052. /**
  155053. * Define a task used by AssetsManager to load text content
  155054. */
  155055. export class TextFileAssetTask extends AbstractAssetTask {
  155056. /**
  155057. * Defines the name of the task
  155058. */
  155059. name: string;
  155060. /**
  155061. * Defines the location of the file to load
  155062. */
  155063. url: string;
  155064. /**
  155065. * Gets the loaded text string
  155066. */
  155067. text: string;
  155068. /**
  155069. * Callback called when the task is successful
  155070. */
  155071. onSuccess: (task: TextFileAssetTask) => void;
  155072. /**
  155073. * Callback called when the task is successful
  155074. */
  155075. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  155076. /**
  155077. * Creates a new TextFileAssetTask object
  155078. * @param name defines the name of the task
  155079. * @param url defines the location of the file to load
  155080. */
  155081. constructor(
  155082. /**
  155083. * Defines the name of the task
  155084. */
  155085. name: string,
  155086. /**
  155087. * Defines the location of the file to load
  155088. */
  155089. url: string);
  155090. /**
  155091. * Execute the current task
  155092. * @param scene defines the scene where you want your assets to be loaded
  155093. * @param onSuccess is a callback called when the task is successfully executed
  155094. * @param onError is a callback called if an error occurs
  155095. */
  155096. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155097. }
  155098. /**
  155099. * Define a task used by AssetsManager to load binary data
  155100. */
  155101. export class BinaryFileAssetTask extends AbstractAssetTask {
  155102. /**
  155103. * Defines the name of the task
  155104. */
  155105. name: string;
  155106. /**
  155107. * Defines the location of the file to load
  155108. */
  155109. url: string;
  155110. /**
  155111. * Gets the lodaded data (as an array buffer)
  155112. */
  155113. data: ArrayBuffer;
  155114. /**
  155115. * Callback called when the task is successful
  155116. */
  155117. onSuccess: (task: BinaryFileAssetTask) => void;
  155118. /**
  155119. * Callback called when the task is successful
  155120. */
  155121. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  155122. /**
  155123. * Creates a new BinaryFileAssetTask object
  155124. * @param name defines the name of the new task
  155125. * @param url defines the location of the file to load
  155126. */
  155127. constructor(
  155128. /**
  155129. * Defines the name of the task
  155130. */
  155131. name: string,
  155132. /**
  155133. * Defines the location of the file to load
  155134. */
  155135. url: string);
  155136. /**
  155137. * Execute the current task
  155138. * @param scene defines the scene where you want your assets to be loaded
  155139. * @param onSuccess is a callback called when the task is successfully executed
  155140. * @param onError is a callback called if an error occurs
  155141. */
  155142. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155143. }
  155144. /**
  155145. * Define a task used by AssetsManager to load images
  155146. */
  155147. export class ImageAssetTask extends AbstractAssetTask {
  155148. /**
  155149. * Defines the name of the task
  155150. */
  155151. name: string;
  155152. /**
  155153. * Defines the location of the image to load
  155154. */
  155155. url: string;
  155156. /**
  155157. * Gets the loaded images
  155158. */
  155159. image: HTMLImageElement;
  155160. /**
  155161. * Callback called when the task is successful
  155162. */
  155163. onSuccess: (task: ImageAssetTask) => void;
  155164. /**
  155165. * Callback called when the task is successful
  155166. */
  155167. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  155168. /**
  155169. * Creates a new ImageAssetTask
  155170. * @param name defines the name of the task
  155171. * @param url defines the location of the image to load
  155172. */
  155173. constructor(
  155174. /**
  155175. * Defines the name of the task
  155176. */
  155177. name: string,
  155178. /**
  155179. * Defines the location of the image to load
  155180. */
  155181. url: string);
  155182. /**
  155183. * Execute the current task
  155184. * @param scene defines the scene where you want your assets to be loaded
  155185. * @param onSuccess is a callback called when the task is successfully executed
  155186. * @param onError is a callback called if an error occurs
  155187. */
  155188. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155189. }
  155190. /**
  155191. * Defines the interface used by texture loading tasks
  155192. */
  155193. export interface ITextureAssetTask<TEX extends BaseTexture> {
  155194. /**
  155195. * Gets the loaded texture
  155196. */
  155197. texture: TEX;
  155198. }
  155199. /**
  155200. * Define a task used by AssetsManager to load 2D textures
  155201. */
  155202. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  155203. /**
  155204. * Defines the name of the task
  155205. */
  155206. name: string;
  155207. /**
  155208. * Defines the location of the file to load
  155209. */
  155210. url: string;
  155211. /**
  155212. * Defines if mipmap should not be generated (default is false)
  155213. */
  155214. noMipmap?: boolean | undefined;
  155215. /**
  155216. * Defines if texture must be inverted on Y axis (default is true)
  155217. */
  155218. invertY: boolean;
  155219. /**
  155220. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155221. */
  155222. samplingMode: number;
  155223. /**
  155224. * Gets the loaded texture
  155225. */
  155226. texture: Texture;
  155227. /**
  155228. * Callback called when the task is successful
  155229. */
  155230. onSuccess: (task: TextureAssetTask) => void;
  155231. /**
  155232. * Callback called when the task is successful
  155233. */
  155234. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  155235. /**
  155236. * Creates a new TextureAssetTask object
  155237. * @param name defines the name of the task
  155238. * @param url defines the location of the file to load
  155239. * @param noMipmap defines if mipmap should not be generated (default is false)
  155240. * @param invertY defines if texture must be inverted on Y axis (default is true)
  155241. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155242. */
  155243. constructor(
  155244. /**
  155245. * Defines the name of the task
  155246. */
  155247. name: string,
  155248. /**
  155249. * Defines the location of the file to load
  155250. */
  155251. url: string,
  155252. /**
  155253. * Defines if mipmap should not be generated (default is false)
  155254. */
  155255. noMipmap?: boolean | undefined,
  155256. /**
  155257. * Defines if texture must be inverted on Y axis (default is true)
  155258. */
  155259. invertY?: boolean,
  155260. /**
  155261. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155262. */
  155263. samplingMode?: number);
  155264. /**
  155265. * Execute the current task
  155266. * @param scene defines the scene where you want your assets to be loaded
  155267. * @param onSuccess is a callback called when the task is successfully executed
  155268. * @param onError is a callback called if an error occurs
  155269. */
  155270. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155271. }
  155272. /**
  155273. * Define a task used by AssetsManager to load cube textures
  155274. */
  155275. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  155276. /**
  155277. * Defines the name of the task
  155278. */
  155279. name: string;
  155280. /**
  155281. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155282. */
  155283. url: string;
  155284. /**
  155285. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155286. */
  155287. extensions?: string[] | undefined;
  155288. /**
  155289. * Defines if mipmaps should not be generated (default is false)
  155290. */
  155291. noMipmap?: boolean | undefined;
  155292. /**
  155293. * Defines the explicit list of files (undefined by default)
  155294. */
  155295. files?: string[] | undefined;
  155296. /**
  155297. * Gets the loaded texture
  155298. */
  155299. texture: CubeTexture;
  155300. /**
  155301. * Callback called when the task is successful
  155302. */
  155303. onSuccess: (task: CubeTextureAssetTask) => void;
  155304. /**
  155305. * Callback called when the task is successful
  155306. */
  155307. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  155308. /**
  155309. * Creates a new CubeTextureAssetTask
  155310. * @param name defines the name of the task
  155311. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155312. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155313. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155314. * @param files defines the explicit list of files (undefined by default)
  155315. */
  155316. constructor(
  155317. /**
  155318. * Defines the name of the task
  155319. */
  155320. name: string,
  155321. /**
  155322. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155323. */
  155324. url: string,
  155325. /**
  155326. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155327. */
  155328. extensions?: string[] | undefined,
  155329. /**
  155330. * Defines if mipmaps should not be generated (default is false)
  155331. */
  155332. noMipmap?: boolean | undefined,
  155333. /**
  155334. * Defines the explicit list of files (undefined by default)
  155335. */
  155336. files?: string[] | undefined);
  155337. /**
  155338. * Execute the current task
  155339. * @param scene defines the scene where you want your assets to be loaded
  155340. * @param onSuccess is a callback called when the task is successfully executed
  155341. * @param onError is a callback called if an error occurs
  155342. */
  155343. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155344. }
  155345. /**
  155346. * Define a task used by AssetsManager to load HDR cube textures
  155347. */
  155348. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  155349. /**
  155350. * Defines the name of the task
  155351. */
  155352. name: string;
  155353. /**
  155354. * Defines the location of the file to load
  155355. */
  155356. url: string;
  155357. /**
  155358. * Defines the desired size (the more it increases the longer the generation will be)
  155359. */
  155360. size: number;
  155361. /**
  155362. * Defines if mipmaps should not be generated (default is false)
  155363. */
  155364. noMipmap: boolean;
  155365. /**
  155366. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155367. */
  155368. generateHarmonics: boolean;
  155369. /**
  155370. * 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)
  155371. */
  155372. gammaSpace: boolean;
  155373. /**
  155374. * Internal Use Only
  155375. */
  155376. reserved: boolean;
  155377. /**
  155378. * Gets the loaded texture
  155379. */
  155380. texture: HDRCubeTexture;
  155381. /**
  155382. * Callback called when the task is successful
  155383. */
  155384. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  155385. /**
  155386. * Callback called when the task is successful
  155387. */
  155388. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  155389. /**
  155390. * Creates a new HDRCubeTextureAssetTask object
  155391. * @param name defines the name of the task
  155392. * @param url defines the location of the file to load
  155393. * @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.
  155394. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155395. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155396. * @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)
  155397. * @param reserved Internal use only
  155398. */
  155399. constructor(
  155400. /**
  155401. * Defines the name of the task
  155402. */
  155403. name: string,
  155404. /**
  155405. * Defines the location of the file to load
  155406. */
  155407. url: string,
  155408. /**
  155409. * Defines the desired size (the more it increases the longer the generation will be)
  155410. */
  155411. size: number,
  155412. /**
  155413. * Defines if mipmaps should not be generated (default is false)
  155414. */
  155415. noMipmap?: boolean,
  155416. /**
  155417. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155418. */
  155419. generateHarmonics?: boolean,
  155420. /**
  155421. * 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)
  155422. */
  155423. gammaSpace?: boolean,
  155424. /**
  155425. * Internal Use Only
  155426. */
  155427. reserved?: boolean);
  155428. /**
  155429. * Execute the current task
  155430. * @param scene defines the scene where you want your assets to be loaded
  155431. * @param onSuccess is a callback called when the task is successfully executed
  155432. * @param onError is a callback called if an error occurs
  155433. */
  155434. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155435. }
  155436. /**
  155437. * Define a task used by AssetsManager to load Equirectangular cube textures
  155438. */
  155439. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  155440. /**
  155441. * Defines the name of the task
  155442. */
  155443. name: string;
  155444. /**
  155445. * Defines the location of the file to load
  155446. */
  155447. url: string;
  155448. /**
  155449. * Defines the desired size (the more it increases the longer the generation will be)
  155450. */
  155451. size: number;
  155452. /**
  155453. * Defines if mipmaps should not be generated (default is false)
  155454. */
  155455. noMipmap: boolean;
  155456. /**
  155457. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  155458. * but the standard material would require them in Gamma space) (default is true)
  155459. */
  155460. gammaSpace: boolean;
  155461. /**
  155462. * Gets the loaded texture
  155463. */
  155464. texture: EquiRectangularCubeTexture;
  155465. /**
  155466. * Callback called when the task is successful
  155467. */
  155468. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  155469. /**
  155470. * Callback called when the task is successful
  155471. */
  155472. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  155473. /**
  155474. * Creates a new EquiRectangularCubeTextureAssetTask object
  155475. * @param name defines the name of the task
  155476. * @param url defines the location of the file to load
  155477. * @param size defines the desired size (the more it increases the longer the generation will be)
  155478. * If the size is omitted this implies you are using a preprocessed cubemap.
  155479. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155480. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  155481. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  155482. * (default is true)
  155483. */
  155484. constructor(
  155485. /**
  155486. * Defines the name of the task
  155487. */
  155488. name: string,
  155489. /**
  155490. * Defines the location of the file to load
  155491. */
  155492. url: string,
  155493. /**
  155494. * Defines the desired size (the more it increases the longer the generation will be)
  155495. */
  155496. size: number,
  155497. /**
  155498. * Defines if mipmaps should not be generated (default is false)
  155499. */
  155500. noMipmap?: boolean,
  155501. /**
  155502. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  155503. * but the standard material would require them in Gamma space) (default is true)
  155504. */
  155505. gammaSpace?: boolean);
  155506. /**
  155507. * Execute the current task
  155508. * @param scene defines the scene where you want your assets to be loaded
  155509. * @param onSuccess is a callback called when the task is successfully executed
  155510. * @param onError is a callback called if an error occurs
  155511. */
  155512. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155513. }
  155514. /**
  155515. * This class can be used to easily import assets into a scene
  155516. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  155517. */
  155518. export class AssetsManager {
  155519. private _scene;
  155520. private _isLoading;
  155521. protected _tasks: AbstractAssetTask[];
  155522. protected _waitingTasksCount: number;
  155523. protected _totalTasksCount: number;
  155524. /**
  155525. * Callback called when all tasks are processed
  155526. */
  155527. onFinish: (tasks: AbstractAssetTask[]) => void;
  155528. /**
  155529. * Callback called when a task is successful
  155530. */
  155531. onTaskSuccess: (task: AbstractAssetTask) => void;
  155532. /**
  155533. * Callback called when a task had an error
  155534. */
  155535. onTaskError: (task: AbstractAssetTask) => void;
  155536. /**
  155537. * Callback called when a task is done (whatever the result is)
  155538. */
  155539. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  155540. /**
  155541. * Observable called when all tasks are processed
  155542. */
  155543. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  155544. /**
  155545. * Observable called when a task had an error
  155546. */
  155547. onTaskErrorObservable: Observable<AbstractAssetTask>;
  155548. /**
  155549. * Observable called when all tasks were executed
  155550. */
  155551. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  155552. /**
  155553. * Observable called when a task is done (whatever the result is)
  155554. */
  155555. onProgressObservable: Observable<IAssetsProgressEvent>;
  155556. /**
  155557. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  155558. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  155559. */
  155560. useDefaultLoadingScreen: boolean;
  155561. /**
  155562. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  155563. * when all assets have been downloaded.
  155564. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  155565. */
  155566. autoHideLoadingUI: boolean;
  155567. /**
  155568. * Creates a new AssetsManager
  155569. * @param scene defines the scene to work on
  155570. */
  155571. constructor(scene: Scene);
  155572. /**
  155573. * Add a ContainerAssetTask to the list of active tasks
  155574. * @param taskName defines the name of the new task
  155575. * @param meshesNames defines the name of meshes to load
  155576. * @param rootUrl defines the root url to use to locate files
  155577. * @param sceneFilename defines the filename of the scene file
  155578. * @returns a new ContainerAssetTask object
  155579. */
  155580. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  155581. /**
  155582. * Add a MeshAssetTask to the list of active tasks
  155583. * @param taskName defines the name of the new task
  155584. * @param meshesNames defines the name of meshes to load
  155585. * @param rootUrl defines the root url to use to locate files
  155586. * @param sceneFilename defines the filename of the scene file
  155587. * @returns a new MeshAssetTask object
  155588. */
  155589. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  155590. /**
  155591. * Add a TextFileAssetTask to the list of active tasks
  155592. * @param taskName defines the name of the new task
  155593. * @param url defines the url of the file to load
  155594. * @returns a new TextFileAssetTask object
  155595. */
  155596. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  155597. /**
  155598. * Add a BinaryFileAssetTask to the list of active tasks
  155599. * @param taskName defines the name of the new task
  155600. * @param url defines the url of the file to load
  155601. * @returns a new BinaryFileAssetTask object
  155602. */
  155603. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  155604. /**
  155605. * Add a ImageAssetTask to the list of active tasks
  155606. * @param taskName defines the name of the new task
  155607. * @param url defines the url of the file to load
  155608. * @returns a new ImageAssetTask object
  155609. */
  155610. addImageTask(taskName: string, url: string): ImageAssetTask;
  155611. /**
  155612. * Add a TextureAssetTask to the list of active tasks
  155613. * @param taskName defines the name of the new task
  155614. * @param url defines the url of the file to load
  155615. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155616. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  155617. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  155618. * @returns a new TextureAssetTask object
  155619. */
  155620. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  155621. /**
  155622. * Add a CubeTextureAssetTask to the list of active tasks
  155623. * @param taskName defines the name of the new task
  155624. * @param url defines the url of the file to load
  155625. * @param extensions defines the extension to use to load the cube map (can be null)
  155626. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155627. * @param files defines the list of files to load (can be null)
  155628. * @returns a new CubeTextureAssetTask object
  155629. */
  155630. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  155631. /**
  155632. *
  155633. * Add a HDRCubeTextureAssetTask to the list of active tasks
  155634. * @param taskName defines the name of the new task
  155635. * @param url defines the url of the file to load
  155636. * @param size defines the size you want for the cubemap (can be null)
  155637. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155638. * @param generateHarmonics defines if you want to automatically generate (true by default)
  155639. * @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)
  155640. * @param reserved Internal use only
  155641. * @returns a new HDRCubeTextureAssetTask object
  155642. */
  155643. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  155644. /**
  155645. *
  155646. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  155647. * @param taskName defines the name of the new task
  155648. * @param url defines the url of the file to load
  155649. * @param size defines the size you want for the cubemap (can be null)
  155650. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155651. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  155652. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  155653. * @returns a new EquiRectangularCubeTextureAssetTask object
  155654. */
  155655. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  155656. /**
  155657. * Remove a task from the assets manager.
  155658. * @param task the task to remove
  155659. */
  155660. removeTask(task: AbstractAssetTask): void;
  155661. private _decreaseWaitingTasksCount;
  155662. private _runTask;
  155663. /**
  155664. * Reset the AssetsManager and remove all tasks
  155665. * @return the current instance of the AssetsManager
  155666. */
  155667. reset(): AssetsManager;
  155668. /**
  155669. * Start the loading process
  155670. * @return the current instance of the AssetsManager
  155671. */
  155672. load(): AssetsManager;
  155673. /**
  155674. * Start the loading process as an async operation
  155675. * @return a promise returning the list of failed tasks
  155676. */
  155677. loadAsync(): Promise<void>;
  155678. }
  155679. }
  155680. declare module BABYLON {
  155681. /**
  155682. * Wrapper class for promise with external resolve and reject.
  155683. */
  155684. export class Deferred<T> {
  155685. /**
  155686. * The promise associated with this deferred object.
  155687. */
  155688. readonly promise: Promise<T>;
  155689. private _resolve;
  155690. private _reject;
  155691. /**
  155692. * The resolve method of the promise associated with this deferred object.
  155693. */
  155694. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  155695. /**
  155696. * The reject method of the promise associated with this deferred object.
  155697. */
  155698. get reject(): (reason?: any) => void;
  155699. /**
  155700. * Constructor for this deferred object.
  155701. */
  155702. constructor();
  155703. }
  155704. }
  155705. declare module BABYLON {
  155706. /**
  155707. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  155708. */
  155709. export class MeshExploder {
  155710. private _centerMesh;
  155711. private _meshes;
  155712. private _meshesOrigins;
  155713. private _toCenterVectors;
  155714. private _scaledDirection;
  155715. private _newPosition;
  155716. private _centerPosition;
  155717. /**
  155718. * Explodes meshes from a center mesh.
  155719. * @param meshes The meshes to explode.
  155720. * @param centerMesh The mesh to be center of explosion.
  155721. */
  155722. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  155723. private _setCenterMesh;
  155724. /**
  155725. * Get class name
  155726. * @returns "MeshExploder"
  155727. */
  155728. getClassName(): string;
  155729. /**
  155730. * "Exploded meshes"
  155731. * @returns Array of meshes with the centerMesh at index 0.
  155732. */
  155733. getMeshes(): Array<Mesh>;
  155734. /**
  155735. * Explodes meshes giving a specific direction
  155736. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  155737. */
  155738. explode(direction?: number): void;
  155739. }
  155740. }
  155741. declare module BABYLON {
  155742. /**
  155743. * Class used to help managing file picking and drag'n'drop
  155744. */
  155745. export class FilesInput {
  155746. /**
  155747. * List of files ready to be loaded
  155748. */
  155749. static get FilesToLoad(): {
  155750. [key: string]: File;
  155751. };
  155752. /**
  155753. * Callback called when a file is processed
  155754. */
  155755. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  155756. private _engine;
  155757. private _currentScene;
  155758. private _sceneLoadedCallback;
  155759. private _progressCallback;
  155760. private _additionalRenderLoopLogicCallback;
  155761. private _textureLoadingCallback;
  155762. private _startingProcessingFilesCallback;
  155763. private _onReloadCallback;
  155764. private _errorCallback;
  155765. private _elementToMonitor;
  155766. private _sceneFileToLoad;
  155767. private _filesToLoad;
  155768. /**
  155769. * Creates a new FilesInput
  155770. * @param engine defines the rendering engine
  155771. * @param scene defines the hosting scene
  155772. * @param sceneLoadedCallback callback called when scene is loaded
  155773. * @param progressCallback callback called to track progress
  155774. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  155775. * @param textureLoadingCallback callback called when a texture is loading
  155776. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  155777. * @param onReloadCallback callback called when a reload is requested
  155778. * @param errorCallback callback call if an error occurs
  155779. */
  155780. 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>);
  155781. private _dragEnterHandler;
  155782. private _dragOverHandler;
  155783. private _dropHandler;
  155784. /**
  155785. * Calls this function to listen to drag'n'drop events on a specific DOM element
  155786. * @param elementToMonitor defines the DOM element to track
  155787. */
  155788. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  155789. /** Gets the current list of files to load */
  155790. get filesToLoad(): File[];
  155791. /**
  155792. * Release all associated resources
  155793. */
  155794. dispose(): void;
  155795. private renderFunction;
  155796. private drag;
  155797. private drop;
  155798. private _traverseFolder;
  155799. private _processFiles;
  155800. /**
  155801. * Load files from a drop event
  155802. * @param event defines the drop event to use as source
  155803. */
  155804. loadFiles(event: any): void;
  155805. private _processReload;
  155806. /**
  155807. * Reload the current scene from the loaded files
  155808. */
  155809. reload(): void;
  155810. }
  155811. }
  155812. declare module BABYLON {
  155813. /**
  155814. * Defines the root class used to create scene optimization to use with SceneOptimizer
  155815. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155816. */
  155817. export class SceneOptimization {
  155818. /**
  155819. * Defines the priority of this optimization (0 by default which means first in the list)
  155820. */
  155821. priority: number;
  155822. /**
  155823. * Gets a string describing the action executed by the current optimization
  155824. * @returns description string
  155825. */
  155826. getDescription(): string;
  155827. /**
  155828. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155829. * @param scene defines the current scene where to apply this optimization
  155830. * @param optimizer defines the current optimizer
  155831. * @returns true if everything that can be done was applied
  155832. */
  155833. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155834. /**
  155835. * Creates the SceneOptimization object
  155836. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155837. * @param desc defines the description associated with the optimization
  155838. */
  155839. constructor(
  155840. /**
  155841. * Defines the priority of this optimization (0 by default which means first in the list)
  155842. */
  155843. priority?: number);
  155844. }
  155845. /**
  155846. * Defines an optimization used to reduce the size of render target textures
  155847. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155848. */
  155849. export class TextureOptimization extends SceneOptimization {
  155850. /**
  155851. * Defines the priority of this optimization (0 by default which means first in the list)
  155852. */
  155853. priority: number;
  155854. /**
  155855. * 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
  155856. */
  155857. maximumSize: number;
  155858. /**
  155859. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155860. */
  155861. step: number;
  155862. /**
  155863. * Gets a string describing the action executed by the current optimization
  155864. * @returns description string
  155865. */
  155866. getDescription(): string;
  155867. /**
  155868. * Creates the TextureOptimization object
  155869. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155870. * @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
  155871. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155872. */
  155873. constructor(
  155874. /**
  155875. * Defines the priority of this optimization (0 by default which means first in the list)
  155876. */
  155877. priority?: number,
  155878. /**
  155879. * 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
  155880. */
  155881. maximumSize?: number,
  155882. /**
  155883. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155884. */
  155885. step?: number);
  155886. /**
  155887. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155888. * @param scene defines the current scene where to apply this optimization
  155889. * @param optimizer defines the current optimizer
  155890. * @returns true if everything that can be done was applied
  155891. */
  155892. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155893. }
  155894. /**
  155895. * Defines an optimization used to increase or decrease the rendering resolution
  155896. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155897. */
  155898. export class HardwareScalingOptimization extends SceneOptimization {
  155899. /**
  155900. * Defines the priority of this optimization (0 by default which means first in the list)
  155901. */
  155902. priority: number;
  155903. /**
  155904. * Defines the maximum scale to use (2 by default)
  155905. */
  155906. maximumScale: number;
  155907. /**
  155908. * Defines the step to use between two passes (0.5 by default)
  155909. */
  155910. step: number;
  155911. private _currentScale;
  155912. private _directionOffset;
  155913. /**
  155914. * Gets a string describing the action executed by the current optimization
  155915. * @return description string
  155916. */
  155917. getDescription(): string;
  155918. /**
  155919. * Creates the HardwareScalingOptimization object
  155920. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155921. * @param maximumScale defines the maximum scale to use (2 by default)
  155922. * @param step defines the step to use between two passes (0.5 by default)
  155923. */
  155924. constructor(
  155925. /**
  155926. * Defines the priority of this optimization (0 by default which means first in the list)
  155927. */
  155928. priority?: number,
  155929. /**
  155930. * Defines the maximum scale to use (2 by default)
  155931. */
  155932. maximumScale?: number,
  155933. /**
  155934. * Defines the step to use between two passes (0.5 by default)
  155935. */
  155936. step?: number);
  155937. /**
  155938. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155939. * @param scene defines the current scene where to apply this optimization
  155940. * @param optimizer defines the current optimizer
  155941. * @returns true if everything that can be done was applied
  155942. */
  155943. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155944. }
  155945. /**
  155946. * Defines an optimization used to remove shadows
  155947. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155948. */
  155949. export class ShadowsOptimization extends SceneOptimization {
  155950. /**
  155951. * Gets a string describing the action executed by the current optimization
  155952. * @return description string
  155953. */
  155954. getDescription(): string;
  155955. /**
  155956. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155957. * @param scene defines the current scene where to apply this optimization
  155958. * @param optimizer defines the current optimizer
  155959. * @returns true if everything that can be done was applied
  155960. */
  155961. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155962. }
  155963. /**
  155964. * Defines an optimization used to turn post-processes off
  155965. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155966. */
  155967. export class PostProcessesOptimization extends SceneOptimization {
  155968. /**
  155969. * Gets a string describing the action executed by the current optimization
  155970. * @return description string
  155971. */
  155972. getDescription(): string;
  155973. /**
  155974. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155975. * @param scene defines the current scene where to apply this optimization
  155976. * @param optimizer defines the current optimizer
  155977. * @returns true if everything that can be done was applied
  155978. */
  155979. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155980. }
  155981. /**
  155982. * Defines an optimization used to turn lens flares off
  155983. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155984. */
  155985. export class LensFlaresOptimization extends SceneOptimization {
  155986. /**
  155987. * Gets a string describing the action executed by the current optimization
  155988. * @return description string
  155989. */
  155990. getDescription(): string;
  155991. /**
  155992. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155993. * @param scene defines the current scene where to apply this optimization
  155994. * @param optimizer defines the current optimizer
  155995. * @returns true if everything that can be done was applied
  155996. */
  155997. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155998. }
  155999. /**
  156000. * Defines an optimization based on user defined callback.
  156001. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156002. */
  156003. export class CustomOptimization extends SceneOptimization {
  156004. /**
  156005. * Callback called to apply the custom optimization.
  156006. */
  156007. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  156008. /**
  156009. * Callback called to get custom description
  156010. */
  156011. onGetDescription: () => string;
  156012. /**
  156013. * Gets a string describing the action executed by the current optimization
  156014. * @returns description string
  156015. */
  156016. getDescription(): string;
  156017. /**
  156018. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156019. * @param scene defines the current scene where to apply this optimization
  156020. * @param optimizer defines the current optimizer
  156021. * @returns true if everything that can be done was applied
  156022. */
  156023. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156024. }
  156025. /**
  156026. * Defines an optimization used to turn particles off
  156027. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156028. */
  156029. export class ParticlesOptimization extends SceneOptimization {
  156030. /**
  156031. * Gets a string describing the action executed by the current optimization
  156032. * @return description string
  156033. */
  156034. getDescription(): string;
  156035. /**
  156036. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156037. * @param scene defines the current scene where to apply this optimization
  156038. * @param optimizer defines the current optimizer
  156039. * @returns true if everything that can be done was applied
  156040. */
  156041. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156042. }
  156043. /**
  156044. * Defines an optimization used to turn render targets off
  156045. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156046. */
  156047. export class RenderTargetsOptimization extends SceneOptimization {
  156048. /**
  156049. * Gets a string describing the action executed by the current optimization
  156050. * @return description string
  156051. */
  156052. getDescription(): string;
  156053. /**
  156054. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156055. * @param scene defines the current scene where to apply this optimization
  156056. * @param optimizer defines the current optimizer
  156057. * @returns true if everything that can be done was applied
  156058. */
  156059. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156060. }
  156061. /**
  156062. * Defines an optimization used to merge meshes with compatible materials
  156063. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156064. */
  156065. export class MergeMeshesOptimization extends SceneOptimization {
  156066. private static _UpdateSelectionTree;
  156067. /**
  156068. * Gets or sets a boolean which defines if optimization octree has to be updated
  156069. */
  156070. static get UpdateSelectionTree(): boolean;
  156071. /**
  156072. * Gets or sets a boolean which defines if optimization octree has to be updated
  156073. */
  156074. static set UpdateSelectionTree(value: boolean);
  156075. /**
  156076. * Gets a string describing the action executed by the current optimization
  156077. * @return description string
  156078. */
  156079. getDescription(): string;
  156080. private _canBeMerged;
  156081. /**
  156082. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156083. * @param scene defines the current scene where to apply this optimization
  156084. * @param optimizer defines the current optimizer
  156085. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  156086. * @returns true if everything that can be done was applied
  156087. */
  156088. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  156089. }
  156090. /**
  156091. * Defines a list of options used by SceneOptimizer
  156092. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156093. */
  156094. export class SceneOptimizerOptions {
  156095. /**
  156096. * Defines the target frame rate to reach (60 by default)
  156097. */
  156098. targetFrameRate: number;
  156099. /**
  156100. * Defines the interval between two checkes (2000ms by default)
  156101. */
  156102. trackerDuration: number;
  156103. /**
  156104. * Gets the list of optimizations to apply
  156105. */
  156106. optimizations: SceneOptimization[];
  156107. /**
  156108. * Creates a new list of options used by SceneOptimizer
  156109. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  156110. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  156111. */
  156112. constructor(
  156113. /**
  156114. * Defines the target frame rate to reach (60 by default)
  156115. */
  156116. targetFrameRate?: number,
  156117. /**
  156118. * Defines the interval between two checkes (2000ms by default)
  156119. */
  156120. trackerDuration?: number);
  156121. /**
  156122. * Add a new optimization
  156123. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  156124. * @returns the current SceneOptimizerOptions
  156125. */
  156126. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  156127. /**
  156128. * Add a new custom optimization
  156129. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  156130. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  156131. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156132. * @returns the current SceneOptimizerOptions
  156133. */
  156134. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  156135. /**
  156136. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  156137. * @param targetFrameRate defines the target frame rate (60 by default)
  156138. * @returns a SceneOptimizerOptions object
  156139. */
  156140. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156141. /**
  156142. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  156143. * @param targetFrameRate defines the target frame rate (60 by default)
  156144. * @returns a SceneOptimizerOptions object
  156145. */
  156146. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156147. /**
  156148. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  156149. * @param targetFrameRate defines the target frame rate (60 by default)
  156150. * @returns a SceneOptimizerOptions object
  156151. */
  156152. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156153. }
  156154. /**
  156155. * Class used to run optimizations in order to reach a target frame rate
  156156. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156157. */
  156158. export class SceneOptimizer implements IDisposable {
  156159. private _isRunning;
  156160. private _options;
  156161. private _scene;
  156162. private _currentPriorityLevel;
  156163. private _targetFrameRate;
  156164. private _trackerDuration;
  156165. private _currentFrameRate;
  156166. private _sceneDisposeObserver;
  156167. private _improvementMode;
  156168. /**
  156169. * Defines an observable called when the optimizer reaches the target frame rate
  156170. */
  156171. onSuccessObservable: Observable<SceneOptimizer>;
  156172. /**
  156173. * Defines an observable called when the optimizer enables an optimization
  156174. */
  156175. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  156176. /**
  156177. * Defines an observable called when the optimizer is not able to reach the target frame rate
  156178. */
  156179. onFailureObservable: Observable<SceneOptimizer>;
  156180. /**
  156181. * Gets a boolean indicating if the optimizer is in improvement mode
  156182. */
  156183. get isInImprovementMode(): boolean;
  156184. /**
  156185. * Gets the current priority level (0 at start)
  156186. */
  156187. get currentPriorityLevel(): number;
  156188. /**
  156189. * Gets the current frame rate checked by the SceneOptimizer
  156190. */
  156191. get currentFrameRate(): number;
  156192. /**
  156193. * Gets or sets the current target frame rate (60 by default)
  156194. */
  156195. get targetFrameRate(): number;
  156196. /**
  156197. * Gets or sets the current target frame rate (60 by default)
  156198. */
  156199. set targetFrameRate(value: number);
  156200. /**
  156201. * Gets or sets the current interval between two checks (every 2000ms by default)
  156202. */
  156203. get trackerDuration(): number;
  156204. /**
  156205. * Gets or sets the current interval between two checks (every 2000ms by default)
  156206. */
  156207. set trackerDuration(value: number);
  156208. /**
  156209. * Gets the list of active optimizations
  156210. */
  156211. get optimizations(): SceneOptimization[];
  156212. /**
  156213. * Creates a new SceneOptimizer
  156214. * @param scene defines the scene to work on
  156215. * @param options defines the options to use with the SceneOptimizer
  156216. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  156217. * @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)
  156218. */
  156219. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  156220. /**
  156221. * Stops the current optimizer
  156222. */
  156223. stop(): void;
  156224. /**
  156225. * Reset the optimizer to initial step (current priority level = 0)
  156226. */
  156227. reset(): void;
  156228. /**
  156229. * Start the optimizer. By default it will try to reach a specific framerate
  156230. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  156231. */
  156232. start(): void;
  156233. private _checkCurrentState;
  156234. /**
  156235. * Release all resources
  156236. */
  156237. dispose(): void;
  156238. /**
  156239. * Helper function to create a SceneOptimizer with one single line of code
  156240. * @param scene defines the scene to work on
  156241. * @param options defines the options to use with the SceneOptimizer
  156242. * @param onSuccess defines a callback to call on success
  156243. * @param onFailure defines a callback to call on failure
  156244. * @returns the new SceneOptimizer object
  156245. */
  156246. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  156247. }
  156248. }
  156249. declare module BABYLON {
  156250. /**
  156251. * Class used to serialize a scene into a string
  156252. */
  156253. export class SceneSerializer {
  156254. /**
  156255. * Clear cache used by a previous serialization
  156256. */
  156257. static ClearCache(): void;
  156258. /**
  156259. * Serialize a scene into a JSON compatible object
  156260. * @param scene defines the scene to serialize
  156261. * @returns a JSON compatible object
  156262. */
  156263. static Serialize(scene: Scene): any;
  156264. /**
  156265. * Serialize a mesh into a JSON compatible object
  156266. * @param toSerialize defines the mesh to serialize
  156267. * @param withParents defines if parents must be serialized as well
  156268. * @param withChildren defines if children must be serialized as well
  156269. * @returns a JSON compatible object
  156270. */
  156271. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  156272. }
  156273. }
  156274. declare module BABYLON {
  156275. /**
  156276. * Class used to host texture specific utilities
  156277. */
  156278. export class TextureTools {
  156279. /**
  156280. * Uses the GPU to create a copy texture rescaled at a given size
  156281. * @param texture Texture to copy from
  156282. * @param width defines the desired width
  156283. * @param height defines the desired height
  156284. * @param useBilinearMode defines if bilinear mode has to be used
  156285. * @return the generated texture
  156286. */
  156287. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  156288. }
  156289. }
  156290. declare module BABYLON {
  156291. /**
  156292. * This represents the different options available for the video capture.
  156293. */
  156294. export interface VideoRecorderOptions {
  156295. /** Defines the mime type of the video. */
  156296. mimeType: string;
  156297. /** Defines the FPS the video should be recorded at. */
  156298. fps: number;
  156299. /** Defines the chunk size for the recording data. */
  156300. recordChunckSize: number;
  156301. /** The audio tracks to attach to the recording. */
  156302. audioTracks?: MediaStreamTrack[];
  156303. }
  156304. /**
  156305. * This can help with recording videos from BabylonJS.
  156306. * This is based on the available WebRTC functionalities of the browser.
  156307. *
  156308. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  156309. */
  156310. export class VideoRecorder {
  156311. private static readonly _defaultOptions;
  156312. /**
  156313. * Returns whether or not the VideoRecorder is available in your browser.
  156314. * @param engine Defines the Babylon Engine.
  156315. * @returns true if supported otherwise false.
  156316. */
  156317. static IsSupported(engine: Engine): boolean;
  156318. private readonly _options;
  156319. private _canvas;
  156320. private _mediaRecorder;
  156321. private _recordedChunks;
  156322. private _fileName;
  156323. private _resolve;
  156324. private _reject;
  156325. /**
  156326. * True when a recording is already in progress.
  156327. */
  156328. get isRecording(): boolean;
  156329. /**
  156330. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  156331. * @param engine Defines the BabylonJS Engine you wish to record.
  156332. * @param options Defines options that can be used to customize the capture.
  156333. */
  156334. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  156335. /**
  156336. * Stops the current recording before the default capture timeout passed in the startRecording function.
  156337. */
  156338. stopRecording(): void;
  156339. /**
  156340. * Starts recording the canvas for a max duration specified in parameters.
  156341. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  156342. * If null no automatic download will start and you can rely on the promise to get the data back.
  156343. * @param maxDuration Defines the maximum recording time in seconds.
  156344. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  156345. * @return A promise callback at the end of the recording with the video data in Blob.
  156346. */
  156347. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  156348. /**
  156349. * Releases internal resources used during the recording.
  156350. */
  156351. dispose(): void;
  156352. private _handleDataAvailable;
  156353. private _handleError;
  156354. private _handleStop;
  156355. }
  156356. }
  156357. declare module BABYLON {
  156358. /**
  156359. * Class containing a set of static utilities functions for screenshots
  156360. */
  156361. export class ScreenshotTools {
  156362. /**
  156363. * Captures a screenshot of the current rendering
  156364. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156365. * @param engine defines the rendering engine
  156366. * @param camera defines the source camera
  156367. * @param size This parameter can be set to a single number or to an object with the
  156368. * following (optional) properties: precision, width, height. If a single number is passed,
  156369. * it will be used for both width and height. If an object is passed, the screenshot size
  156370. * will be derived from the parameters. The precision property is a multiplier allowing
  156371. * rendering at a higher or lower resolution
  156372. * @param successCallback defines the callback receives a single parameter which contains the
  156373. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  156374. * src parameter of an <img> to display it
  156375. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  156376. * Check your browser for supported MIME types
  156377. */
  156378. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  156379. /**
  156380. * Captures a screenshot of the current rendering
  156381. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156382. * @param engine defines the rendering engine
  156383. * @param camera defines the source camera
  156384. * @param size This parameter can be set to a single number or to an object with the
  156385. * following (optional) properties: precision, width, height. If a single number is passed,
  156386. * it will be used for both width and height. If an object is passed, the screenshot size
  156387. * will be derived from the parameters. The precision property is a multiplier allowing
  156388. * rendering at a higher or lower resolution
  156389. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  156390. * Check your browser for supported MIME types
  156391. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  156392. * to the src parameter of an <img> to display it
  156393. */
  156394. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  156395. /**
  156396. * Generates an image screenshot from the specified camera.
  156397. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156398. * @param engine The engine to use for rendering
  156399. * @param camera The camera to use for rendering
  156400. * @param size This parameter can be set to a single number or to an object with the
  156401. * following (optional) properties: precision, width, height. If a single number is passed,
  156402. * it will be used for both width and height. If an object is passed, the screenshot size
  156403. * will be derived from the parameters. The precision property is a multiplier allowing
  156404. * rendering at a higher or lower resolution
  156405. * @param successCallback The callback receives a single parameter which contains the
  156406. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  156407. * src parameter of an <img> to display it
  156408. * @param mimeType The MIME type of the screenshot image (default: image/png).
  156409. * Check your browser for supported MIME types
  156410. * @param samples Texture samples (default: 1)
  156411. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  156412. * @param fileName A name for for the downloaded file.
  156413. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  156414. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  156415. */
  156416. 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;
  156417. /**
  156418. * Generates an image screenshot from the specified camera.
  156419. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156420. * @param engine The engine to use for rendering
  156421. * @param camera The camera to use for rendering
  156422. * @param size This parameter can be set to a single number or to an object with the
  156423. * following (optional) properties: precision, width, height. If a single number is passed,
  156424. * it will be used for both width and height. If an object is passed, the screenshot size
  156425. * will be derived from the parameters. The precision property is a multiplier allowing
  156426. * rendering at a higher or lower resolution
  156427. * @param mimeType The MIME type of the screenshot image (default: image/png).
  156428. * Check your browser for supported MIME types
  156429. * @param samples Texture samples (default: 1)
  156430. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  156431. * @param fileName A name for for the downloaded file.
  156432. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  156433. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  156434. * to the src parameter of an <img> to display it
  156435. */
  156436. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  156437. /**
  156438. * Gets height and width for screenshot size
  156439. * @private
  156440. */
  156441. private static _getScreenshotSize;
  156442. }
  156443. }
  156444. declare module BABYLON {
  156445. /**
  156446. * Interface for a data buffer
  156447. */
  156448. export interface IDataBuffer {
  156449. /**
  156450. * Reads bytes from the data buffer.
  156451. * @param byteOffset The byte offset to read
  156452. * @param byteLength The byte length to read
  156453. * @returns A promise that resolves when the bytes are read
  156454. */
  156455. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  156456. /**
  156457. * The byte length of the buffer.
  156458. */
  156459. readonly byteLength: number;
  156460. }
  156461. /**
  156462. * Utility class for reading from a data buffer
  156463. */
  156464. export class DataReader {
  156465. /**
  156466. * The data buffer associated with this data reader.
  156467. */
  156468. readonly buffer: IDataBuffer;
  156469. /**
  156470. * The current byte offset from the beginning of the data buffer.
  156471. */
  156472. byteOffset: number;
  156473. private _dataView;
  156474. private _dataByteOffset;
  156475. /**
  156476. * Constructor
  156477. * @param buffer The buffer to read
  156478. */
  156479. constructor(buffer: IDataBuffer);
  156480. /**
  156481. * Loads the given byte length.
  156482. * @param byteLength The byte length to load
  156483. * @returns A promise that resolves when the load is complete
  156484. */
  156485. loadAsync(byteLength: number): Promise<void>;
  156486. /**
  156487. * Read a unsigned 32-bit integer from the currently loaded data range.
  156488. * @returns The 32-bit integer read
  156489. */
  156490. readUint32(): number;
  156491. /**
  156492. * Read a byte array from the currently loaded data range.
  156493. * @param byteLength The byte length to read
  156494. * @returns The byte array read
  156495. */
  156496. readUint8Array(byteLength: number): Uint8Array;
  156497. /**
  156498. * Read a string from the currently loaded data range.
  156499. * @param byteLength The byte length to read
  156500. * @returns The string read
  156501. */
  156502. readString(byteLength: number): string;
  156503. /**
  156504. * Skips the given byte length the currently loaded data range.
  156505. * @param byteLength The byte length to skip
  156506. */
  156507. skipBytes(byteLength: number): void;
  156508. }
  156509. }
  156510. declare module BABYLON {
  156511. /**
  156512. * Class for storing data to local storage if available or in-memory storage otherwise
  156513. */
  156514. export class DataStorage {
  156515. private static _Storage;
  156516. private static _GetStorage;
  156517. /**
  156518. * Reads a string from the data storage
  156519. * @param key The key to read
  156520. * @param defaultValue The value if the key doesn't exist
  156521. * @returns The string value
  156522. */
  156523. static ReadString(key: string, defaultValue: string): string;
  156524. /**
  156525. * Writes a string to the data storage
  156526. * @param key The key to write
  156527. * @param value The value to write
  156528. */
  156529. static WriteString(key: string, value: string): void;
  156530. /**
  156531. * Reads a boolean from the data storage
  156532. * @param key The key to read
  156533. * @param defaultValue The value if the key doesn't exist
  156534. * @returns The boolean value
  156535. */
  156536. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  156537. /**
  156538. * Writes a boolean to the data storage
  156539. * @param key The key to write
  156540. * @param value The value to write
  156541. */
  156542. static WriteBoolean(key: string, value: boolean): void;
  156543. /**
  156544. * Reads a number from the data storage
  156545. * @param key The key to read
  156546. * @param defaultValue The value if the key doesn't exist
  156547. * @returns The number value
  156548. */
  156549. static ReadNumber(key: string, defaultValue: number): number;
  156550. /**
  156551. * Writes a number to the data storage
  156552. * @param key The key to write
  156553. * @param value The value to write
  156554. */
  156555. static WriteNumber(key: string, value: number): void;
  156556. }
  156557. }
  156558. declare module BABYLON {
  156559. /**
  156560. * Class used to record delta files between 2 scene states
  156561. */
  156562. export class SceneRecorder {
  156563. private _trackedScene;
  156564. private _savedJSON;
  156565. /**
  156566. * Track a given scene. This means the current scene state will be considered the original state
  156567. * @param scene defines the scene to track
  156568. */
  156569. track(scene: Scene): void;
  156570. /**
  156571. * Get the delta between current state and original state
  156572. * @returns a string containing the delta
  156573. */
  156574. getDelta(): any;
  156575. private _compareArray;
  156576. private _compareObjects;
  156577. private _compareCollections;
  156578. private static GetShadowGeneratorById;
  156579. /**
  156580. * Apply a given delta to a given scene
  156581. * @param deltaJSON defines the JSON containing the delta
  156582. * @param scene defines the scene to apply the delta to
  156583. */
  156584. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  156585. private static _ApplyPropertiesToEntity;
  156586. private static _ApplyDeltaForEntity;
  156587. }
  156588. }
  156589. declare module BABYLON {
  156590. /**
  156591. * A 3D trajectory consisting of an order list of vectors describing a
  156592. * path of motion through 3D space.
  156593. */
  156594. export class Trajectory {
  156595. private _points;
  156596. private readonly _segmentLength;
  156597. /**
  156598. * Serialize to JSON.
  156599. * @returns serialized JSON string
  156600. */
  156601. serialize(): string;
  156602. /**
  156603. * Deserialize from JSON.
  156604. * @param json serialized JSON string
  156605. * @returns deserialized Trajectory
  156606. */
  156607. static Deserialize(json: string): Trajectory;
  156608. /**
  156609. * Create a new empty Trajectory.
  156610. * @param segmentLength radius of discretization for Trajectory points
  156611. */
  156612. constructor(segmentLength?: number);
  156613. /**
  156614. * Get the length of the Trajectory.
  156615. * @returns length of the Trajectory
  156616. */
  156617. getLength(): number;
  156618. /**
  156619. * Append a new point to the Trajectory.
  156620. * NOTE: This implementation has many allocations.
  156621. * @param point point to append to the Trajectory
  156622. */
  156623. add(point: DeepImmutable<Vector3>): void;
  156624. /**
  156625. * Create a new Trajectory with a segment length chosen to make it
  156626. * probable that the new Trajectory will have a specified number of
  156627. * segments. This operation is imprecise.
  156628. * @param targetResolution number of segments desired
  156629. * @returns new Trajectory with approximately the requested number of segments
  156630. */
  156631. resampleAtTargetResolution(targetResolution: number): Trajectory;
  156632. /**
  156633. * Convert Trajectory segments into tokenized representation. This
  156634. * representation is an array of numbers where each nth number is the
  156635. * index of the token which is most similar to the nth segment of the
  156636. * Trajectory.
  156637. * @param tokens list of vectors which serve as discrete tokens
  156638. * @returns list of indices of most similar token per segment
  156639. */
  156640. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  156641. private static _forwardDir;
  156642. private static _inverseFromVec;
  156643. private static _upDir;
  156644. private static _fromToVec;
  156645. private static _lookMatrix;
  156646. /**
  156647. * Transform the rotation (i.e., direction) of a segment to isolate
  156648. * the relative transformation represented by the segment. This operation
  156649. * may or may not succeed due to singularities in the equations that define
  156650. * motion relativity in this context.
  156651. * @param priorVec the origin of the prior segment
  156652. * @param fromVec the origin of the current segment
  156653. * @param toVec the destination of the current segment
  156654. * @param result reference to output variable
  156655. * @returns whether or not transformation was successful
  156656. */
  156657. private static _transformSegmentDirToRef;
  156658. private static _bestMatch;
  156659. private static _score;
  156660. private static _bestScore;
  156661. /**
  156662. * Determine which token vector is most similar to the
  156663. * segment vector.
  156664. * @param segment segment vector
  156665. * @param tokens token vector list
  156666. * @returns index of the most similar token to the segment
  156667. */
  156668. private static _tokenizeSegment;
  156669. }
  156670. /**
  156671. * Class representing a set of known, named trajectories to which Trajectories can be
  156672. * added and using which Trajectories can be recognized.
  156673. */
  156674. export class TrajectoryClassifier {
  156675. private _maximumAllowableMatchCost;
  156676. private _vector3Alphabet;
  156677. private _levenshteinAlphabet;
  156678. private _nameToDescribedTrajectory;
  156679. /**
  156680. * Serialize to JSON.
  156681. * @returns JSON serialization
  156682. */
  156683. serialize(): string;
  156684. /**
  156685. * Deserialize from JSON.
  156686. * @param json JSON serialization
  156687. * @returns deserialized TrajectorySet
  156688. */
  156689. static Deserialize(json: string): TrajectoryClassifier;
  156690. /**
  156691. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  156692. * VERY naive, need to be generating these things from known
  156693. * sets. Better version later, probably eliminating this one.
  156694. * @returns auto-generated TrajectorySet
  156695. */
  156696. static Generate(): TrajectoryClassifier;
  156697. private constructor();
  156698. /**
  156699. * Add a new Trajectory to the set with a given name.
  156700. * @param trajectory new Trajectory to be added
  156701. * @param classification name to which to add the Trajectory
  156702. */
  156703. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  156704. /**
  156705. * Remove a known named trajectory and all Trajectories associated with it.
  156706. * @param classification name to remove
  156707. * @returns whether anything was removed
  156708. */
  156709. deleteClassification(classification: string): boolean;
  156710. /**
  156711. * Attempt to recognize a Trajectory from among all the classifications
  156712. * already known to the classifier.
  156713. * @param trajectory Trajectory to be recognized
  156714. * @returns classification of Trajectory if recognized, null otherwise
  156715. */
  156716. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  156717. }
  156718. }
  156719. declare module BABYLON {
  156720. /**
  156721. * An interface for all Hit test features
  156722. */
  156723. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  156724. /**
  156725. * Triggered when new babylon (transformed) hit test results are available
  156726. */
  156727. onHitTestResultObservable: Observable<T[]>;
  156728. }
  156729. /**
  156730. * Options used for hit testing
  156731. */
  156732. export interface IWebXRLegacyHitTestOptions {
  156733. /**
  156734. * Only test when user interacted with the scene. Default - hit test every frame
  156735. */
  156736. testOnPointerDownOnly?: boolean;
  156737. /**
  156738. * The node to use to transform the local results to world coordinates
  156739. */
  156740. worldParentNode?: TransformNode;
  156741. }
  156742. /**
  156743. * Interface defining the babylon result of raycasting/hit-test
  156744. */
  156745. export interface IWebXRLegacyHitResult {
  156746. /**
  156747. * Transformation matrix that can be applied to a node that will put it in the hit point location
  156748. */
  156749. transformationMatrix: Matrix;
  156750. /**
  156751. * The native hit test result
  156752. */
  156753. xrHitResult: XRHitResult | XRHitTestResult;
  156754. }
  156755. /**
  156756. * The currently-working hit-test module.
  156757. * Hit test (or Ray-casting) is used to interact with the real world.
  156758. * For further information read here - https://github.com/immersive-web/hit-test
  156759. */
  156760. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  156761. /**
  156762. * options to use when constructing this feature
  156763. */
  156764. readonly options: IWebXRLegacyHitTestOptions;
  156765. private _direction;
  156766. private _mat;
  156767. private _onSelectEnabled;
  156768. private _origin;
  156769. /**
  156770. * The module's name
  156771. */
  156772. static readonly Name: string;
  156773. /**
  156774. * The (Babylon) version of this module.
  156775. * This is an integer representing the implementation version.
  156776. * This number does not correspond to the WebXR specs version
  156777. */
  156778. static readonly Version: number;
  156779. /**
  156780. * Populated with the last native XR Hit Results
  156781. */
  156782. lastNativeXRHitResults: XRHitResult[];
  156783. /**
  156784. * Triggered when new babylon (transformed) hit test results are available
  156785. */
  156786. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  156787. /**
  156788. * Creates a new instance of the (legacy version) hit test feature
  156789. * @param _xrSessionManager an instance of WebXRSessionManager
  156790. * @param options options to use when constructing this feature
  156791. */
  156792. constructor(_xrSessionManager: WebXRSessionManager,
  156793. /**
  156794. * options to use when constructing this feature
  156795. */
  156796. options?: IWebXRLegacyHitTestOptions);
  156797. /**
  156798. * execute a hit test with an XR Ray
  156799. *
  156800. * @param xrSession a native xrSession that will execute this hit test
  156801. * @param xrRay the ray (position and direction) to use for ray-casting
  156802. * @param referenceSpace native XR reference space to use for the hit-test
  156803. * @param filter filter function that will filter the results
  156804. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  156805. */
  156806. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  156807. /**
  156808. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  156809. * @param event the (select) event to use to select with
  156810. * @param referenceSpace the reference space to use for this hit test
  156811. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  156812. */
  156813. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  156814. /**
  156815. * attach this feature
  156816. * Will usually be called by the features manager
  156817. *
  156818. * @returns true if successful.
  156819. */
  156820. attach(): boolean;
  156821. /**
  156822. * detach this feature.
  156823. * Will usually be called by the features manager
  156824. *
  156825. * @returns true if successful.
  156826. */
  156827. detach(): boolean;
  156828. /**
  156829. * Dispose this feature and all of the resources attached
  156830. */
  156831. dispose(): void;
  156832. protected _onXRFrame(frame: XRFrame): void;
  156833. private _onHitTestResults;
  156834. private _onSelect;
  156835. }
  156836. }
  156837. declare module BABYLON {
  156838. /**
  156839. * Options used for hit testing (version 2)
  156840. */
  156841. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  156842. /**
  156843. * Do not create a permanent hit test. Will usually be used when only
  156844. * transient inputs are needed.
  156845. */
  156846. disablePermanentHitTest?: boolean;
  156847. /**
  156848. * Enable transient (for example touch-based) hit test inspections
  156849. */
  156850. enableTransientHitTest?: boolean;
  156851. /**
  156852. * Offset ray for the permanent hit test
  156853. */
  156854. offsetRay?: Vector3;
  156855. /**
  156856. * Offset ray for the transient hit test
  156857. */
  156858. transientOffsetRay?: Vector3;
  156859. /**
  156860. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  156861. */
  156862. useReferenceSpace?: boolean;
  156863. /**
  156864. * Override the default entity type(s) of the hit-test result
  156865. */
  156866. entityTypes?: XRHitTestTrackableType[];
  156867. }
  156868. /**
  156869. * Interface defining the babylon result of hit-test
  156870. */
  156871. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  156872. /**
  156873. * The input source that generated this hit test (if transient)
  156874. */
  156875. inputSource?: XRInputSource;
  156876. /**
  156877. * Is this a transient hit test
  156878. */
  156879. isTransient?: boolean;
  156880. /**
  156881. * Position of the hit test result
  156882. */
  156883. position: Vector3;
  156884. /**
  156885. * Rotation of the hit test result
  156886. */
  156887. rotationQuaternion: Quaternion;
  156888. /**
  156889. * The native hit test result
  156890. */
  156891. xrHitResult: XRHitTestResult;
  156892. }
  156893. /**
  156894. * The currently-working hit-test module.
  156895. * Hit test (or Ray-casting) is used to interact with the real world.
  156896. * For further information read here - https://github.com/immersive-web/hit-test
  156897. *
  156898. * Tested on chrome (mobile) 80.
  156899. */
  156900. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  156901. /**
  156902. * options to use when constructing this feature
  156903. */
  156904. readonly options: IWebXRHitTestOptions;
  156905. private _tmpMat;
  156906. private _tmpPos;
  156907. private _tmpQuat;
  156908. private _transientXrHitTestSource;
  156909. private _xrHitTestSource;
  156910. private initHitTestSource;
  156911. /**
  156912. * The module's name
  156913. */
  156914. static readonly Name: string;
  156915. /**
  156916. * The (Babylon) version of this module.
  156917. * This is an integer representing the implementation version.
  156918. * This number does not correspond to the WebXR specs version
  156919. */
  156920. static readonly Version: number;
  156921. /**
  156922. * When set to true, each hit test will have its own position/rotation objects
  156923. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  156924. * the developers will clone them or copy them as they see fit.
  156925. */
  156926. autoCloneTransformation: boolean;
  156927. /**
  156928. * Triggered when new babylon (transformed) hit test results are available
  156929. * Note - this will be called when results come back from the device. It can be an empty array!!
  156930. */
  156931. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  156932. /**
  156933. * Use this to temporarily pause hit test checks.
  156934. */
  156935. paused: boolean;
  156936. /**
  156937. * Creates a new instance of the hit test feature
  156938. * @param _xrSessionManager an instance of WebXRSessionManager
  156939. * @param options options to use when constructing this feature
  156940. */
  156941. constructor(_xrSessionManager: WebXRSessionManager,
  156942. /**
  156943. * options to use when constructing this feature
  156944. */
  156945. options?: IWebXRHitTestOptions);
  156946. /**
  156947. * attach this feature
  156948. * Will usually be called by the features manager
  156949. *
  156950. * @returns true if successful.
  156951. */
  156952. attach(): boolean;
  156953. /**
  156954. * detach this feature.
  156955. * Will usually be called by the features manager
  156956. *
  156957. * @returns true if successful.
  156958. */
  156959. detach(): boolean;
  156960. /**
  156961. * Dispose this feature and all of the resources attached
  156962. */
  156963. dispose(): void;
  156964. protected _onXRFrame(frame: XRFrame): void;
  156965. private _processWebXRHitTestResult;
  156966. }
  156967. }
  156968. declare module BABYLON {
  156969. /**
  156970. * Configuration options of the anchor system
  156971. */
  156972. export interface IWebXRAnchorSystemOptions {
  156973. /**
  156974. * a node that will be used to convert local to world coordinates
  156975. */
  156976. worldParentNode?: TransformNode;
  156977. /**
  156978. * If set to true a reference of the created anchors will be kept until the next session starts
  156979. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  156980. */
  156981. doNotRemoveAnchorsOnSessionEnded?: boolean;
  156982. }
  156983. /**
  156984. * A babylon container for an XR Anchor
  156985. */
  156986. export interface IWebXRAnchor {
  156987. /**
  156988. * A babylon-assigned ID for this anchor
  156989. */
  156990. id: number;
  156991. /**
  156992. * Transformation matrix to apply to an object attached to this anchor
  156993. */
  156994. transformationMatrix: Matrix;
  156995. /**
  156996. * The native anchor object
  156997. */
  156998. xrAnchor: XRAnchor;
  156999. /**
  157000. * if defined, this object will be constantly updated by the anchor's position and rotation
  157001. */
  157002. attachedNode?: TransformNode;
  157003. }
  157004. /**
  157005. * An implementation of the anchor system for WebXR.
  157006. * For further information see https://github.com/immersive-web/anchors/
  157007. */
  157008. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  157009. private _options;
  157010. private _lastFrameDetected;
  157011. private _trackedAnchors;
  157012. private _referenceSpaceForFrameAnchors;
  157013. private _futureAnchors;
  157014. /**
  157015. * The module's name
  157016. */
  157017. static readonly Name: string;
  157018. /**
  157019. * The (Babylon) version of this module.
  157020. * This is an integer representing the implementation version.
  157021. * This number does not correspond to the WebXR specs version
  157022. */
  157023. static readonly Version: number;
  157024. /**
  157025. * Observers registered here will be executed when a new anchor was added to the session
  157026. */
  157027. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  157028. /**
  157029. * Observers registered here will be executed when an anchor was removed from the session
  157030. */
  157031. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  157032. /**
  157033. * Observers registered here will be executed when an existing anchor updates
  157034. * This can execute N times every frame
  157035. */
  157036. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  157037. /**
  157038. * Set the reference space to use for anchor creation, when not using a hit test.
  157039. * Will default to the session's reference space if not defined
  157040. */
  157041. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  157042. /**
  157043. * constructs a new anchor system
  157044. * @param _xrSessionManager an instance of WebXRSessionManager
  157045. * @param _options configuration object for this feature
  157046. */
  157047. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  157048. private _tmpVector;
  157049. private _tmpQuaternion;
  157050. private _populateTmpTransformation;
  157051. /**
  157052. * Create a new anchor point using a hit test result at a specific point in the scene
  157053. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157054. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157055. *
  157056. * @param hitTestResult The hit test result to use for this anchor creation
  157057. * @param position an optional position offset for this anchor
  157058. * @param rotationQuaternion an optional rotation offset for this anchor
  157059. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  157060. */
  157061. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  157062. /**
  157063. * Add a new anchor at a specific position and rotation
  157064. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  157065. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  157066. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157067. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157068. *
  157069. * @param position the position in which to add an anchor
  157070. * @param rotationQuaternion an optional rotation for the anchor transformation
  157071. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  157072. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  157073. */
  157074. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  157075. /**
  157076. * detach this feature.
  157077. * Will usually be called by the features manager
  157078. *
  157079. * @returns true if successful.
  157080. */
  157081. detach(): boolean;
  157082. /**
  157083. * Dispose this feature and all of the resources attached
  157084. */
  157085. dispose(): void;
  157086. protected _onXRFrame(frame: XRFrame): void;
  157087. /**
  157088. * avoiding using Array.find for global support.
  157089. * @param xrAnchor the plane to find in the array
  157090. */
  157091. private _findIndexInAnchorArray;
  157092. private _updateAnchorWithXRFrame;
  157093. private _createAnchorAtTransformation;
  157094. }
  157095. }
  157096. declare module BABYLON {
  157097. /**
  157098. * Options used in the plane detector module
  157099. */
  157100. export interface IWebXRPlaneDetectorOptions {
  157101. /**
  157102. * The node to use to transform the local results to world coordinates
  157103. */
  157104. worldParentNode?: TransformNode;
  157105. /**
  157106. * If set to true a reference of the created planes will be kept until the next session starts
  157107. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  157108. */
  157109. doNotRemovePlanesOnSessionEnded?: boolean;
  157110. }
  157111. /**
  157112. * A babylon interface for a WebXR plane.
  157113. * A Plane is actually a polygon, built from N points in space
  157114. *
  157115. * Supported in chrome 79, not supported in canary 81 ATM
  157116. */
  157117. export interface IWebXRPlane {
  157118. /**
  157119. * a babylon-assigned ID for this polygon
  157120. */
  157121. id: number;
  157122. /**
  157123. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  157124. */
  157125. polygonDefinition: Array<Vector3>;
  157126. /**
  157127. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  157128. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  157129. */
  157130. transformationMatrix: Matrix;
  157131. /**
  157132. * the native xr-plane object
  157133. */
  157134. xrPlane: XRPlane;
  157135. }
  157136. /**
  157137. * The plane detector is used to detect planes in the real world when in AR
  157138. * For more information see https://github.com/immersive-web/real-world-geometry/
  157139. */
  157140. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  157141. private _options;
  157142. private _detectedPlanes;
  157143. private _enabled;
  157144. private _lastFrameDetected;
  157145. /**
  157146. * The module's name
  157147. */
  157148. static readonly Name: string;
  157149. /**
  157150. * The (Babylon) version of this module.
  157151. * This is an integer representing the implementation version.
  157152. * This number does not correspond to the WebXR specs version
  157153. */
  157154. static readonly Version: number;
  157155. /**
  157156. * Observers registered here will be executed when a new plane was added to the session
  157157. */
  157158. onPlaneAddedObservable: Observable<IWebXRPlane>;
  157159. /**
  157160. * Observers registered here will be executed when a plane is no longer detected in the session
  157161. */
  157162. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  157163. /**
  157164. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  157165. * This can execute N times every frame
  157166. */
  157167. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  157168. /**
  157169. * construct a new Plane Detector
  157170. * @param _xrSessionManager an instance of xr Session manager
  157171. * @param _options configuration to use when constructing this feature
  157172. */
  157173. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  157174. /**
  157175. * detach this feature.
  157176. * Will usually be called by the features manager
  157177. *
  157178. * @returns true if successful.
  157179. */
  157180. detach(): boolean;
  157181. /**
  157182. * Dispose this feature and all of the resources attached
  157183. */
  157184. dispose(): void;
  157185. /**
  157186. * Check if the needed objects are defined.
  157187. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  157188. */
  157189. isCompatible(): boolean;
  157190. protected _onXRFrame(frame: XRFrame): void;
  157191. private _init;
  157192. private _updatePlaneWithXRPlane;
  157193. /**
  157194. * avoiding using Array.find for global support.
  157195. * @param xrPlane the plane to find in the array
  157196. */
  157197. private findIndexInPlaneArray;
  157198. }
  157199. }
  157200. declare module BABYLON {
  157201. /**
  157202. * Options interface for the background remover plugin
  157203. */
  157204. export interface IWebXRBackgroundRemoverOptions {
  157205. /**
  157206. * Further background meshes to disable when entering AR
  157207. */
  157208. backgroundMeshes?: AbstractMesh[];
  157209. /**
  157210. * flags to configure the removal of the environment helper.
  157211. * If not set, the entire background will be removed. If set, flags should be set as well.
  157212. */
  157213. environmentHelperRemovalFlags?: {
  157214. /**
  157215. * Should the skybox be removed (default false)
  157216. */
  157217. skyBox?: boolean;
  157218. /**
  157219. * Should the ground be removed (default false)
  157220. */
  157221. ground?: boolean;
  157222. };
  157223. /**
  157224. * don't disable the environment helper
  157225. */
  157226. ignoreEnvironmentHelper?: boolean;
  157227. }
  157228. /**
  157229. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  157230. */
  157231. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  157232. /**
  157233. * read-only options to be used in this module
  157234. */
  157235. readonly options: IWebXRBackgroundRemoverOptions;
  157236. /**
  157237. * The module's name
  157238. */
  157239. static readonly Name: string;
  157240. /**
  157241. * The (Babylon) version of this module.
  157242. * This is an integer representing the implementation version.
  157243. * This number does not correspond to the WebXR specs version
  157244. */
  157245. static readonly Version: number;
  157246. /**
  157247. * registered observers will be triggered when the background state changes
  157248. */
  157249. onBackgroundStateChangedObservable: Observable<boolean>;
  157250. /**
  157251. * constructs a new background remover module
  157252. * @param _xrSessionManager the session manager for this module
  157253. * @param options read-only options to be used in this module
  157254. */
  157255. constructor(_xrSessionManager: WebXRSessionManager,
  157256. /**
  157257. * read-only options to be used in this module
  157258. */
  157259. options?: IWebXRBackgroundRemoverOptions);
  157260. /**
  157261. * attach this feature
  157262. * Will usually be called by the features manager
  157263. *
  157264. * @returns true if successful.
  157265. */
  157266. attach(): boolean;
  157267. /**
  157268. * detach this feature.
  157269. * Will usually be called by the features manager
  157270. *
  157271. * @returns true if successful.
  157272. */
  157273. detach(): boolean;
  157274. /**
  157275. * Dispose this feature and all of the resources attached
  157276. */
  157277. dispose(): void;
  157278. protected _onXRFrame(_xrFrame: XRFrame): void;
  157279. private _setBackgroundState;
  157280. }
  157281. }
  157282. declare module BABYLON {
  157283. /**
  157284. * Options for the controller physics feature
  157285. */
  157286. export class IWebXRControllerPhysicsOptions {
  157287. /**
  157288. * Should the headset get its own impostor
  157289. */
  157290. enableHeadsetImpostor?: boolean;
  157291. /**
  157292. * Optional parameters for the headset impostor
  157293. */
  157294. headsetImpostorParams?: {
  157295. /**
  157296. * The type of impostor to create. Default is sphere
  157297. */
  157298. impostorType: number;
  157299. /**
  157300. * the size of the impostor. Defaults to 10cm
  157301. */
  157302. impostorSize?: number | {
  157303. width: number;
  157304. height: number;
  157305. depth: number;
  157306. };
  157307. /**
  157308. * Friction definitions
  157309. */
  157310. friction?: number;
  157311. /**
  157312. * Restitution
  157313. */
  157314. restitution?: number;
  157315. };
  157316. /**
  157317. * The physics properties of the future impostors
  157318. */
  157319. physicsProperties?: {
  157320. /**
  157321. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  157322. * Note that this requires a physics engine that supports mesh impostors!
  157323. */
  157324. useControllerMesh?: boolean;
  157325. /**
  157326. * The type of impostor to create. Default is sphere
  157327. */
  157328. impostorType?: number;
  157329. /**
  157330. * the size of the impostor. Defaults to 10cm
  157331. */
  157332. impostorSize?: number | {
  157333. width: number;
  157334. height: number;
  157335. depth: number;
  157336. };
  157337. /**
  157338. * Friction definitions
  157339. */
  157340. friction?: number;
  157341. /**
  157342. * Restitution
  157343. */
  157344. restitution?: number;
  157345. };
  157346. /**
  157347. * the xr input to use with this pointer selection
  157348. */
  157349. xrInput: WebXRInput;
  157350. }
  157351. /**
  157352. * Add physics impostor to your webxr controllers,
  157353. * including naive calculation of their linear and angular velocity
  157354. */
  157355. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  157356. private readonly _options;
  157357. private _attachController;
  157358. private _controllers;
  157359. private _debugMode;
  157360. private _delta;
  157361. private _headsetImpostor?;
  157362. private _headsetMesh?;
  157363. private _lastTimestamp;
  157364. private _tmpQuaternion;
  157365. private _tmpVector;
  157366. /**
  157367. * The module's name
  157368. */
  157369. static readonly Name: string;
  157370. /**
  157371. * The (Babylon) version of this module.
  157372. * This is an integer representing the implementation version.
  157373. * This number does not correspond to the webxr specs version
  157374. */
  157375. static readonly Version: number;
  157376. /**
  157377. * Construct a new Controller Physics Feature
  157378. * @param _xrSessionManager the corresponding xr session manager
  157379. * @param _options options to create this feature with
  157380. */
  157381. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  157382. /**
  157383. * @hidden
  157384. * enable debugging - will show console outputs and the impostor mesh
  157385. */
  157386. _enablePhysicsDebug(): void;
  157387. /**
  157388. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  157389. * @param xrController the controller to add
  157390. */
  157391. addController(xrController: WebXRInputSource): void;
  157392. /**
  157393. * attach this feature
  157394. * Will usually be called by the features manager
  157395. *
  157396. * @returns true if successful.
  157397. */
  157398. attach(): boolean;
  157399. /**
  157400. * detach this feature.
  157401. * Will usually be called by the features manager
  157402. *
  157403. * @returns true if successful.
  157404. */
  157405. detach(): boolean;
  157406. /**
  157407. * Get the headset impostor, if enabled
  157408. * @returns the impostor
  157409. */
  157410. getHeadsetImpostor(): PhysicsImpostor | undefined;
  157411. /**
  157412. * Get the physics impostor of a specific controller.
  157413. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  157414. * @param controller the controller or the controller id of which to get the impostor
  157415. * @returns the impostor or null
  157416. */
  157417. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  157418. /**
  157419. * Update the physics properties provided in the constructor
  157420. * @param newProperties the new properties object
  157421. */
  157422. setPhysicsProperties(newProperties: {
  157423. impostorType?: number;
  157424. impostorSize?: number | {
  157425. width: number;
  157426. height: number;
  157427. depth: number;
  157428. };
  157429. friction?: number;
  157430. restitution?: number;
  157431. }): void;
  157432. protected _onXRFrame(_xrFrame: any): void;
  157433. private _detachController;
  157434. }
  157435. }
  157436. declare module BABYLON {
  157437. /**
  157438. * A babylon interface for a "WebXR" feature point.
  157439. * Represents the position and confidence value of a given feature point.
  157440. */
  157441. export interface IWebXRFeaturePoint {
  157442. /**
  157443. * Represents the position of the feature point in world space.
  157444. */
  157445. position: Vector3;
  157446. /**
  157447. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  157448. */
  157449. confidenceValue: number;
  157450. }
  157451. /**
  157452. * The feature point system is used to detect feature points from real world geometry.
  157453. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  157454. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  157455. */
  157456. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  157457. private _enabled;
  157458. private _featurePointCloud;
  157459. /**
  157460. * The module's name
  157461. */
  157462. static readonly Name: string;
  157463. /**
  157464. * The (Babylon) version of this module.
  157465. * This is an integer representing the implementation version.
  157466. * This number does not correspond to the WebXR specs version
  157467. */
  157468. static readonly Version: number;
  157469. /**
  157470. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  157471. * Will notify the observers about which feature points have been added.
  157472. */
  157473. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  157474. /**
  157475. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  157476. * Will notify the observers about which feature points have been updated.
  157477. */
  157478. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  157479. /**
  157480. * The current feature point cloud maintained across frames.
  157481. */
  157482. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  157483. /**
  157484. * construct the feature point system
  157485. * @param _xrSessionManager an instance of xr Session manager
  157486. */
  157487. constructor(_xrSessionManager: WebXRSessionManager);
  157488. /**
  157489. * Detach this feature.
  157490. * Will usually be called by the features manager
  157491. *
  157492. * @returns true if successful.
  157493. */
  157494. detach(): boolean;
  157495. /**
  157496. * Dispose this feature and all of the resources attached
  157497. */
  157498. dispose(): void;
  157499. /**
  157500. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  157501. */
  157502. protected _onXRFrame(frame: XRFrame): void;
  157503. /**
  157504. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  157505. */
  157506. private _init;
  157507. }
  157508. }
  157509. declare module BABYLON {
  157510. /**
  157511. * Configuration interface for the hand tracking feature
  157512. */
  157513. export interface IWebXRHandTrackingOptions {
  157514. /**
  157515. * The xrInput that will be used as source for new hands
  157516. */
  157517. xrInput: WebXRInput;
  157518. /**
  157519. * Configuration object for the joint meshes
  157520. */
  157521. jointMeshes?: {
  157522. /**
  157523. * Should the meshes created be invisible (defaults to false)
  157524. */
  157525. invisible?: boolean;
  157526. /**
  157527. * A source mesh to be used to create instances. Defaults to a sphere.
  157528. * This mesh will be the source for all other (25) meshes.
  157529. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  157530. */
  157531. sourceMesh?: Mesh;
  157532. /**
  157533. * This function will be called after a mesh was created for a specific joint.
  157534. * Using this function you can either manipulate the instance or return a new mesh.
  157535. * When returning a new mesh the instance created before will be disposed
  157536. */
  157537. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  157538. /**
  157539. * Should the source mesh stay visible. Defaults to false
  157540. */
  157541. keepOriginalVisible?: boolean;
  157542. /**
  157543. * Scale factor for all instances (defaults to 2)
  157544. */
  157545. scaleFactor?: number;
  157546. /**
  157547. * Should each instance have its own physics impostor
  157548. */
  157549. enablePhysics?: boolean;
  157550. /**
  157551. * If enabled, override default physics properties
  157552. */
  157553. physicsProps?: {
  157554. friction?: number;
  157555. restitution?: number;
  157556. impostorType?: number;
  157557. };
  157558. /**
  157559. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  157560. */
  157561. handMesh?: AbstractMesh;
  157562. };
  157563. }
  157564. /**
  157565. * Parts of the hands divided to writs and finger names
  157566. */
  157567. export const enum HandPart {
  157568. /**
  157569. * HandPart - Wrist
  157570. */
  157571. WRIST = "wrist",
  157572. /**
  157573. * HandPart - The THumb
  157574. */
  157575. THUMB = "thumb",
  157576. /**
  157577. * HandPart - Index finger
  157578. */
  157579. INDEX = "index",
  157580. /**
  157581. * HandPart - Middle finger
  157582. */
  157583. MIDDLE = "middle",
  157584. /**
  157585. * HandPart - Ring finger
  157586. */
  157587. RING = "ring",
  157588. /**
  157589. * HandPart - Little finger
  157590. */
  157591. LITTLE = "little"
  157592. }
  157593. /**
  157594. * Representing a single hand (with its corresponding native XRHand object)
  157595. */
  157596. export class WebXRHand implements IDisposable {
  157597. /** the controller to which the hand correlates */
  157598. readonly xrController: WebXRInputSource;
  157599. /** the meshes to be used to track the hand joints */
  157600. readonly trackedMeshes: AbstractMesh[];
  157601. /**
  157602. * Hand-parts definition (key is HandPart)
  157603. */
  157604. handPartsDefinition: {
  157605. [key: string]: number[];
  157606. };
  157607. /**
  157608. * Populate the HandPartsDefinition object.
  157609. * This is called as a side effect since certain browsers don't have XRHand defined.
  157610. */
  157611. private generateHandPartsDefinition;
  157612. /**
  157613. * Construct a new hand object
  157614. * @param xrController the controller to which the hand correlates
  157615. * @param trackedMeshes the meshes to be used to track the hand joints
  157616. */
  157617. constructor(
  157618. /** the controller to which the hand correlates */
  157619. xrController: WebXRInputSource,
  157620. /** the meshes to be used to track the hand joints */
  157621. trackedMeshes: AbstractMesh[]);
  157622. /**
  157623. * Update this hand from the latest xr frame
  157624. * @param xrFrame xrFrame to update from
  157625. * @param referenceSpace The current viewer reference space
  157626. * @param scaleFactor optional scale factor for the meshes
  157627. */
  157628. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  157629. /**
  157630. * Get meshes of part of the hand
  157631. * @param part the part of hand to get
  157632. * @returns An array of meshes that correlate to the hand part requested
  157633. */
  157634. getHandPartMeshes(part: HandPart): AbstractMesh[];
  157635. /**
  157636. * Dispose this Hand object
  157637. */
  157638. dispose(): void;
  157639. }
  157640. /**
  157641. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  157642. */
  157643. export class WebXRHandTracking extends WebXRAbstractFeature {
  157644. /**
  157645. * options to use when constructing this feature
  157646. */
  157647. readonly options: IWebXRHandTrackingOptions;
  157648. private static _idCounter;
  157649. /**
  157650. * The module's name
  157651. */
  157652. static readonly Name: string;
  157653. /**
  157654. * The (Babylon) version of this module.
  157655. * This is an integer representing the implementation version.
  157656. * This number does not correspond to the WebXR specs version
  157657. */
  157658. static readonly Version: number;
  157659. /**
  157660. * This observable will notify registered observers when a new hand object was added and initialized
  157661. */
  157662. onHandAddedObservable: Observable<WebXRHand>;
  157663. /**
  157664. * This observable will notify its observers right before the hand object is disposed
  157665. */
  157666. onHandRemovedObservable: Observable<WebXRHand>;
  157667. private _hands;
  157668. /**
  157669. * Creates a new instance of the hit test feature
  157670. * @param _xrSessionManager an instance of WebXRSessionManager
  157671. * @param options options to use when constructing this feature
  157672. */
  157673. constructor(_xrSessionManager: WebXRSessionManager,
  157674. /**
  157675. * options to use when constructing this feature
  157676. */
  157677. options: IWebXRHandTrackingOptions);
  157678. /**
  157679. * Check if the needed objects are defined.
  157680. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  157681. */
  157682. isCompatible(): boolean;
  157683. /**
  157684. * attach this feature
  157685. * Will usually be called by the features manager
  157686. *
  157687. * @returns true if successful.
  157688. */
  157689. attach(): boolean;
  157690. /**
  157691. * detach this feature.
  157692. * Will usually be called by the features manager
  157693. *
  157694. * @returns true if successful.
  157695. */
  157696. detach(): boolean;
  157697. /**
  157698. * Dispose this feature and all of the resources attached
  157699. */
  157700. dispose(): void;
  157701. /**
  157702. * Get the hand object according to the controller id
  157703. * @param controllerId the controller id to which we want to get the hand
  157704. * @returns null if not found or the WebXRHand object if found
  157705. */
  157706. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  157707. /**
  157708. * Get a hand object according to the requested handedness
  157709. * @param handedness the handedness to request
  157710. * @returns null if not found or the WebXRHand object if found
  157711. */
  157712. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  157713. protected _onXRFrame(_xrFrame: XRFrame): void;
  157714. private _attachHand;
  157715. private _detachHand;
  157716. }
  157717. }
  157718. declare module BABYLON {
  157719. /**
  157720. * The motion controller class for all microsoft mixed reality controllers
  157721. */
  157722. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  157723. protected readonly _mapping: {
  157724. defaultButton: {
  157725. valueNodeName: string;
  157726. unpressedNodeName: string;
  157727. pressedNodeName: string;
  157728. };
  157729. defaultAxis: {
  157730. valueNodeName: string;
  157731. minNodeName: string;
  157732. maxNodeName: string;
  157733. };
  157734. buttons: {
  157735. "xr-standard-trigger": {
  157736. rootNodeName: string;
  157737. componentProperty: string;
  157738. states: string[];
  157739. };
  157740. "xr-standard-squeeze": {
  157741. rootNodeName: string;
  157742. componentProperty: string;
  157743. states: string[];
  157744. };
  157745. "xr-standard-touchpad": {
  157746. rootNodeName: string;
  157747. labelAnchorNodeName: string;
  157748. touchPointNodeName: string;
  157749. };
  157750. "xr-standard-thumbstick": {
  157751. rootNodeName: string;
  157752. componentProperty: string;
  157753. states: string[];
  157754. };
  157755. };
  157756. axes: {
  157757. "xr-standard-touchpad": {
  157758. "x-axis": {
  157759. rootNodeName: string;
  157760. };
  157761. "y-axis": {
  157762. rootNodeName: string;
  157763. };
  157764. };
  157765. "xr-standard-thumbstick": {
  157766. "x-axis": {
  157767. rootNodeName: string;
  157768. };
  157769. "y-axis": {
  157770. rootNodeName: string;
  157771. };
  157772. };
  157773. };
  157774. };
  157775. /**
  157776. * The base url used to load the left and right controller models
  157777. */
  157778. static MODEL_BASE_URL: string;
  157779. /**
  157780. * The name of the left controller model file
  157781. */
  157782. static MODEL_LEFT_FILENAME: string;
  157783. /**
  157784. * The name of the right controller model file
  157785. */
  157786. static MODEL_RIGHT_FILENAME: string;
  157787. profileId: string;
  157788. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  157789. protected _getFilenameAndPath(): {
  157790. filename: string;
  157791. path: string;
  157792. };
  157793. protected _getModelLoadingConstraints(): boolean;
  157794. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157795. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157796. protected _updateModel(): void;
  157797. }
  157798. }
  157799. declare module BABYLON {
  157800. /**
  157801. * The motion controller class for oculus touch (quest, rift).
  157802. * This class supports legacy mapping as well the standard xr mapping
  157803. */
  157804. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  157805. private _forceLegacyControllers;
  157806. private _modelRootNode;
  157807. /**
  157808. * The base url used to load the left and right controller models
  157809. */
  157810. static MODEL_BASE_URL: string;
  157811. /**
  157812. * The name of the left controller model file
  157813. */
  157814. static MODEL_LEFT_FILENAME: string;
  157815. /**
  157816. * The name of the right controller model file
  157817. */
  157818. static MODEL_RIGHT_FILENAME: string;
  157819. /**
  157820. * Base Url for the Quest controller model.
  157821. */
  157822. static QUEST_MODEL_BASE_URL: string;
  157823. profileId: string;
  157824. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  157825. protected _getFilenameAndPath(): {
  157826. filename: string;
  157827. path: string;
  157828. };
  157829. protected _getModelLoadingConstraints(): boolean;
  157830. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157831. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157832. protected _updateModel(): void;
  157833. /**
  157834. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  157835. * between the touch and touch 2.
  157836. */
  157837. private _isQuest;
  157838. }
  157839. }
  157840. declare module BABYLON {
  157841. /**
  157842. * The motion controller class for the standard HTC-Vive controllers
  157843. */
  157844. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  157845. private _modelRootNode;
  157846. /**
  157847. * The base url used to load the left and right controller models
  157848. */
  157849. static MODEL_BASE_URL: string;
  157850. /**
  157851. * File name for the controller model.
  157852. */
  157853. static MODEL_FILENAME: string;
  157854. profileId: string;
  157855. /**
  157856. * Create a new Vive motion controller object
  157857. * @param scene the scene to use to create this controller
  157858. * @param gamepadObject the corresponding gamepad object
  157859. * @param handedness the handedness of the controller
  157860. */
  157861. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  157862. protected _getFilenameAndPath(): {
  157863. filename: string;
  157864. path: string;
  157865. };
  157866. protected _getModelLoadingConstraints(): boolean;
  157867. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157868. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157869. protected _updateModel(): void;
  157870. }
  157871. }
  157872. declare module BABYLON {
  157873. /**
  157874. * A cursor which tracks a point on a path
  157875. */
  157876. export class PathCursor {
  157877. private path;
  157878. /**
  157879. * Stores path cursor callbacks for when an onchange event is triggered
  157880. */
  157881. private _onchange;
  157882. /**
  157883. * The value of the path cursor
  157884. */
  157885. value: number;
  157886. /**
  157887. * The animation array of the path cursor
  157888. */
  157889. animations: Animation[];
  157890. /**
  157891. * Initializes the path cursor
  157892. * @param path The path to track
  157893. */
  157894. constructor(path: Path2);
  157895. /**
  157896. * Gets the cursor point on the path
  157897. * @returns A point on the path cursor at the cursor location
  157898. */
  157899. getPoint(): Vector3;
  157900. /**
  157901. * Moves the cursor ahead by the step amount
  157902. * @param step The amount to move the cursor forward
  157903. * @returns This path cursor
  157904. */
  157905. moveAhead(step?: number): PathCursor;
  157906. /**
  157907. * Moves the cursor behind by the step amount
  157908. * @param step The amount to move the cursor back
  157909. * @returns This path cursor
  157910. */
  157911. moveBack(step?: number): PathCursor;
  157912. /**
  157913. * Moves the cursor by the step amount
  157914. * If the step amount is greater than one, an exception is thrown
  157915. * @param step The amount to move the cursor
  157916. * @returns This path cursor
  157917. */
  157918. move(step: number): PathCursor;
  157919. /**
  157920. * Ensures that the value is limited between zero and one
  157921. * @returns This path cursor
  157922. */
  157923. private ensureLimits;
  157924. /**
  157925. * Runs onchange callbacks on change (used by the animation engine)
  157926. * @returns This path cursor
  157927. */
  157928. private raiseOnChange;
  157929. /**
  157930. * Executes a function on change
  157931. * @param f A path cursor onchange callback
  157932. * @returns This path cursor
  157933. */
  157934. onchange(f: (cursor: PathCursor) => void): PathCursor;
  157935. }
  157936. }
  157937. declare module BABYLON {
  157938. /** @hidden */
  157939. export var blurPixelShader: {
  157940. name: string;
  157941. shader: string;
  157942. };
  157943. }
  157944. declare module BABYLON {
  157945. /** @hidden */
  157946. export var pointCloudVertexDeclaration: {
  157947. name: string;
  157948. shader: string;
  157949. };
  157950. }
  157951. // Mixins
  157952. interface Window {
  157953. mozIndexedDB: IDBFactory;
  157954. webkitIndexedDB: IDBFactory;
  157955. msIndexedDB: IDBFactory;
  157956. webkitURL: typeof URL;
  157957. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  157958. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  157959. WebGLRenderingContext: WebGLRenderingContext;
  157960. MSGesture: MSGesture;
  157961. CANNON: any;
  157962. AudioContext: AudioContext;
  157963. webkitAudioContext: AudioContext;
  157964. PointerEvent: any;
  157965. Math: Math;
  157966. Uint8Array: Uint8ArrayConstructor;
  157967. Float32Array: Float32ArrayConstructor;
  157968. mozURL: typeof URL;
  157969. msURL: typeof URL;
  157970. VRFrameData: any; // WebVR, from specs 1.1
  157971. DracoDecoderModule: any;
  157972. setImmediate(handler: (...args: any[]) => void): number;
  157973. }
  157974. interface HTMLCanvasElement {
  157975. requestPointerLock(): void;
  157976. msRequestPointerLock?(): void;
  157977. mozRequestPointerLock?(): void;
  157978. webkitRequestPointerLock?(): void;
  157979. /** Track wether a record is in progress */
  157980. isRecording: boolean;
  157981. /** Capture Stream method defined by some browsers */
  157982. captureStream(fps?: number): MediaStream;
  157983. }
  157984. interface CanvasRenderingContext2D {
  157985. msImageSmoothingEnabled: boolean;
  157986. }
  157987. interface MouseEvent {
  157988. mozMovementX: number;
  157989. mozMovementY: number;
  157990. webkitMovementX: number;
  157991. webkitMovementY: number;
  157992. msMovementX: number;
  157993. msMovementY: number;
  157994. }
  157995. interface Navigator {
  157996. mozGetVRDevices: (any: any) => any;
  157997. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157998. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157999. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158000. webkitGetGamepads(): Gamepad[];
  158001. msGetGamepads(): Gamepad[];
  158002. webkitGamepads(): Gamepad[];
  158003. }
  158004. interface HTMLVideoElement {
  158005. mozSrcObject: any;
  158006. }
  158007. interface Math {
  158008. fround(x: number): number;
  158009. imul(a: number, b: number): number;
  158010. }
  158011. interface WebGLRenderingContext {
  158012. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  158013. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  158014. vertexAttribDivisor(index: number, divisor: number): void;
  158015. createVertexArray(): any;
  158016. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  158017. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  158018. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  158019. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  158020. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  158021. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  158022. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  158023. // Queries
  158024. createQuery(): WebGLQuery;
  158025. deleteQuery(query: WebGLQuery): void;
  158026. beginQuery(target: number, query: WebGLQuery): void;
  158027. endQuery(target: number): void;
  158028. getQueryParameter(query: WebGLQuery, pname: number): any;
  158029. getQuery(target: number, pname: number): any;
  158030. MAX_SAMPLES: number;
  158031. RGBA8: number;
  158032. READ_FRAMEBUFFER: number;
  158033. DRAW_FRAMEBUFFER: number;
  158034. UNIFORM_BUFFER: number;
  158035. HALF_FLOAT_OES: number;
  158036. RGBA16F: number;
  158037. RGBA32F: number;
  158038. R32F: number;
  158039. RG32F: number;
  158040. RGB32F: number;
  158041. R16F: number;
  158042. RG16F: number;
  158043. RGB16F: number;
  158044. RED: number;
  158045. RG: number;
  158046. R8: number;
  158047. RG8: number;
  158048. UNSIGNED_INT_24_8: number;
  158049. DEPTH24_STENCIL8: number;
  158050. MIN: number;
  158051. MAX: number;
  158052. /* Multiple Render Targets */
  158053. drawBuffers(buffers: number[]): void;
  158054. readBuffer(src: number): void;
  158055. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  158056. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  158057. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  158058. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  158059. // Occlusion Query
  158060. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  158061. ANY_SAMPLES_PASSED: number;
  158062. QUERY_RESULT_AVAILABLE: number;
  158063. QUERY_RESULT: number;
  158064. }
  158065. interface WebGLProgram {
  158066. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  158067. }
  158068. interface EXT_disjoint_timer_query {
  158069. QUERY_COUNTER_BITS_EXT: number;
  158070. TIME_ELAPSED_EXT: number;
  158071. TIMESTAMP_EXT: number;
  158072. GPU_DISJOINT_EXT: number;
  158073. QUERY_RESULT_EXT: number;
  158074. QUERY_RESULT_AVAILABLE_EXT: number;
  158075. queryCounterEXT(query: WebGLQuery, target: number): void;
  158076. createQueryEXT(): WebGLQuery;
  158077. beginQueryEXT(target: number, query: WebGLQuery): void;
  158078. endQueryEXT(target: number): void;
  158079. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  158080. deleteQueryEXT(query: WebGLQuery): void;
  158081. }
  158082. interface WebGLUniformLocation {
  158083. _currentState: any;
  158084. }
  158085. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  158086. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  158087. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  158088. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  158089. interface WebGLRenderingContext {
  158090. readonly RASTERIZER_DISCARD: number;
  158091. readonly DEPTH_COMPONENT24: number;
  158092. readonly TEXTURE_3D: number;
  158093. readonly TEXTURE_2D_ARRAY: number;
  158094. readonly TEXTURE_COMPARE_FUNC: number;
  158095. readonly TEXTURE_COMPARE_MODE: number;
  158096. readonly COMPARE_REF_TO_TEXTURE: number;
  158097. readonly TEXTURE_WRAP_R: number;
  158098. readonly HALF_FLOAT: number;
  158099. readonly RGB8: number;
  158100. readonly RED_INTEGER: number;
  158101. readonly RG_INTEGER: number;
  158102. readonly RGB_INTEGER: number;
  158103. readonly RGBA_INTEGER: number;
  158104. readonly R8_SNORM: number;
  158105. readonly RG8_SNORM: number;
  158106. readonly RGB8_SNORM: number;
  158107. readonly RGBA8_SNORM: number;
  158108. readonly R8I: number;
  158109. readonly RG8I: number;
  158110. readonly RGB8I: number;
  158111. readonly RGBA8I: number;
  158112. readonly R8UI: number;
  158113. readonly RG8UI: number;
  158114. readonly RGB8UI: number;
  158115. readonly RGBA8UI: number;
  158116. readonly R16I: number;
  158117. readonly RG16I: number;
  158118. readonly RGB16I: number;
  158119. readonly RGBA16I: number;
  158120. readonly R16UI: number;
  158121. readonly RG16UI: number;
  158122. readonly RGB16UI: number;
  158123. readonly RGBA16UI: number;
  158124. readonly R32I: number;
  158125. readonly RG32I: number;
  158126. readonly RGB32I: number;
  158127. readonly RGBA32I: number;
  158128. readonly R32UI: number;
  158129. readonly RG32UI: number;
  158130. readonly RGB32UI: number;
  158131. readonly RGBA32UI: number;
  158132. readonly RGB10_A2UI: number;
  158133. readonly R11F_G11F_B10F: number;
  158134. readonly RGB9_E5: number;
  158135. readonly RGB10_A2: number;
  158136. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  158137. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  158138. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  158139. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  158140. readonly DEPTH_COMPONENT32F: number;
  158141. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  158142. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  158143. 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;
  158144. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  158145. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  158146. readonly TRANSFORM_FEEDBACK: number;
  158147. readonly INTERLEAVED_ATTRIBS: number;
  158148. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  158149. createTransformFeedback(): WebGLTransformFeedback;
  158150. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  158151. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  158152. beginTransformFeedback(primitiveMode: number): void;
  158153. endTransformFeedback(): void;
  158154. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  158155. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158156. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158157. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158158. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  158159. }
  158160. interface ImageBitmap {
  158161. readonly width: number;
  158162. readonly height: number;
  158163. close(): void;
  158164. }
  158165. interface WebGLQuery extends WebGLObject {
  158166. }
  158167. declare var WebGLQuery: {
  158168. prototype: WebGLQuery;
  158169. new(): WebGLQuery;
  158170. };
  158171. interface WebGLSampler extends WebGLObject {
  158172. }
  158173. declare var WebGLSampler: {
  158174. prototype: WebGLSampler;
  158175. new(): WebGLSampler;
  158176. };
  158177. interface WebGLSync extends WebGLObject {
  158178. }
  158179. declare var WebGLSync: {
  158180. prototype: WebGLSync;
  158181. new(): WebGLSync;
  158182. };
  158183. interface WebGLTransformFeedback extends WebGLObject {
  158184. }
  158185. declare var WebGLTransformFeedback: {
  158186. prototype: WebGLTransformFeedback;
  158187. new(): WebGLTransformFeedback;
  158188. };
  158189. interface WebGLVertexArrayObject extends WebGLObject {
  158190. }
  158191. declare var WebGLVertexArrayObject: {
  158192. prototype: WebGLVertexArrayObject;
  158193. new(): WebGLVertexArrayObject;
  158194. };
  158195. // Type definitions for WebVR API
  158196. // Project: https://w3c.github.io/webvr/
  158197. // Definitions by: six a <https://github.com/lostfictions>
  158198. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  158199. interface VRDisplay extends EventTarget {
  158200. /**
  158201. * Dictionary of capabilities describing the VRDisplay.
  158202. */
  158203. readonly capabilities: VRDisplayCapabilities;
  158204. /**
  158205. * z-depth defining the far plane of the eye view frustum
  158206. * enables mapping of values in the render target depth
  158207. * attachment to scene coordinates. Initially set to 10000.0.
  158208. */
  158209. depthFar: number;
  158210. /**
  158211. * z-depth defining the near plane of the eye view frustum
  158212. * enables mapping of values in the render target depth
  158213. * attachment to scene coordinates. Initially set to 0.01.
  158214. */
  158215. depthNear: number;
  158216. /**
  158217. * An identifier for this distinct VRDisplay. Used as an
  158218. * association point in the Gamepad API.
  158219. */
  158220. readonly displayId: number;
  158221. /**
  158222. * A display name, a user-readable name identifying it.
  158223. */
  158224. readonly displayName: string;
  158225. readonly isConnected: boolean;
  158226. readonly isPresenting: boolean;
  158227. /**
  158228. * If this VRDisplay supports room-scale experiences, the optional
  158229. * stage attribute contains details on the room-scale parameters.
  158230. */
  158231. readonly stageParameters: VRStageParameters | null;
  158232. /**
  158233. * Passing the value returned by `requestAnimationFrame` to
  158234. * `cancelAnimationFrame` will unregister the callback.
  158235. * @param handle Define the hanle of the request to cancel
  158236. */
  158237. cancelAnimationFrame(handle: number): void;
  158238. /**
  158239. * Stops presenting to the VRDisplay.
  158240. * @returns a promise to know when it stopped
  158241. */
  158242. exitPresent(): Promise<void>;
  158243. /**
  158244. * Return the current VREyeParameters for the given eye.
  158245. * @param whichEye Define the eye we want the parameter for
  158246. * @returns the eye parameters
  158247. */
  158248. getEyeParameters(whichEye: string): VREyeParameters;
  158249. /**
  158250. * Populates the passed VRFrameData with the information required to render
  158251. * the current frame.
  158252. * @param frameData Define the data structure to populate
  158253. * @returns true if ok otherwise false
  158254. */
  158255. getFrameData(frameData: VRFrameData): boolean;
  158256. /**
  158257. * Get the layers currently being presented.
  158258. * @returns the list of VR layers
  158259. */
  158260. getLayers(): VRLayer[];
  158261. /**
  158262. * Return a VRPose containing the future predicted pose of the VRDisplay
  158263. * when the current frame will be presented. The value returned will not
  158264. * change until JavaScript has returned control to the browser.
  158265. *
  158266. * The VRPose will contain the position, orientation, velocity,
  158267. * and acceleration of each of these properties.
  158268. * @returns the pose object
  158269. */
  158270. getPose(): VRPose;
  158271. /**
  158272. * Return the current instantaneous pose of the VRDisplay, with no
  158273. * prediction applied.
  158274. * @returns the current instantaneous pose
  158275. */
  158276. getImmediatePose(): VRPose;
  158277. /**
  158278. * The callback passed to `requestAnimationFrame` will be called
  158279. * any time a new frame should be rendered. When the VRDisplay is
  158280. * presenting the callback will be called at the native refresh
  158281. * rate of the HMD. When not presenting this function acts
  158282. * identically to how window.requestAnimationFrame acts. Content should
  158283. * make no assumptions of frame rate or vsync behavior as the HMD runs
  158284. * asynchronously from other displays and at differing refresh rates.
  158285. * @param callback Define the eaction to run next frame
  158286. * @returns the request handle it
  158287. */
  158288. requestAnimationFrame(callback: FrameRequestCallback): number;
  158289. /**
  158290. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  158291. * Repeat calls while already presenting will update the VRLayers being displayed.
  158292. * @param layers Define the list of layer to present
  158293. * @returns a promise to know when the request has been fulfilled
  158294. */
  158295. requestPresent(layers: VRLayer[]): Promise<void>;
  158296. /**
  158297. * Reset the pose for this display, treating its current position and
  158298. * orientation as the "origin/zero" values. VRPose.position,
  158299. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  158300. * updated when calling resetPose(). This should be called in only
  158301. * sitting-space experiences.
  158302. */
  158303. resetPose(): void;
  158304. /**
  158305. * The VRLayer provided to the VRDisplay will be captured and presented
  158306. * in the HMD. Calling this function has the same effect on the source
  158307. * canvas as any other operation that uses its source image, and canvases
  158308. * created without preserveDrawingBuffer set to true will be cleared.
  158309. * @param pose Define the pose to submit
  158310. */
  158311. submitFrame(pose?: VRPose): void;
  158312. }
  158313. declare var VRDisplay: {
  158314. prototype: VRDisplay;
  158315. new(): VRDisplay;
  158316. };
  158317. interface VRLayer {
  158318. leftBounds?: number[] | Float32Array | null;
  158319. rightBounds?: number[] | Float32Array | null;
  158320. source?: HTMLCanvasElement | null;
  158321. }
  158322. interface VRDisplayCapabilities {
  158323. readonly canPresent: boolean;
  158324. readonly hasExternalDisplay: boolean;
  158325. readonly hasOrientation: boolean;
  158326. readonly hasPosition: boolean;
  158327. readonly maxLayers: number;
  158328. }
  158329. interface VREyeParameters {
  158330. /** @deprecated */
  158331. readonly fieldOfView: VRFieldOfView;
  158332. readonly offset: Float32Array;
  158333. readonly renderHeight: number;
  158334. readonly renderWidth: number;
  158335. }
  158336. interface VRFieldOfView {
  158337. readonly downDegrees: number;
  158338. readonly leftDegrees: number;
  158339. readonly rightDegrees: number;
  158340. readonly upDegrees: number;
  158341. }
  158342. interface VRFrameData {
  158343. readonly leftProjectionMatrix: Float32Array;
  158344. readonly leftViewMatrix: Float32Array;
  158345. readonly pose: VRPose;
  158346. readonly rightProjectionMatrix: Float32Array;
  158347. readonly rightViewMatrix: Float32Array;
  158348. readonly timestamp: number;
  158349. }
  158350. interface VRPose {
  158351. readonly angularAcceleration: Float32Array | null;
  158352. readonly angularVelocity: Float32Array | null;
  158353. readonly linearAcceleration: Float32Array | null;
  158354. readonly linearVelocity: Float32Array | null;
  158355. readonly orientation: Float32Array | null;
  158356. readonly position: Float32Array | null;
  158357. readonly timestamp: number;
  158358. }
  158359. interface VRStageParameters {
  158360. sittingToStandingTransform?: Float32Array;
  158361. sizeX?: number;
  158362. sizeY?: number;
  158363. }
  158364. interface Navigator {
  158365. getVRDisplays(): Promise<VRDisplay[]>;
  158366. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  158367. }
  158368. interface Window {
  158369. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  158370. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  158371. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  158372. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  158373. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  158374. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  158375. }
  158376. interface Gamepad {
  158377. readonly displayId: number;
  158378. }
  158379. /**
  158380. * Available session modes
  158381. */
  158382. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  158383. /**
  158384. * Reference space types
  158385. */
  158386. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  158387. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  158388. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  158389. /**
  158390. * Handedness types
  158391. */
  158392. type XRHandedness = "none" | "left" | "right";
  158393. /**
  158394. * InputSource target ray modes
  158395. */
  158396. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  158397. /**
  158398. * Eye types
  158399. */
  158400. type XREye = "none" | "left" | "right";
  158401. /**
  158402. * Type of XR events available
  158403. */
  158404. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  158405. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  158406. type XRPlaneSet = Set<XRPlane>;
  158407. type XRAnchorSet = Set<XRAnchor>;
  158408. type XREventHandler = (callback: any) => void;
  158409. interface XRLayer extends EventTarget {}
  158410. interface XRSessionInit {
  158411. optionalFeatures?: string[];
  158412. requiredFeatures?: string[];
  158413. }
  158414. interface XRSessionEvent extends Event {
  158415. readonly session: XRSession;
  158416. }
  158417. interface XRSystem {
  158418. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  158419. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  158420. }
  158421. interface XRViewport {
  158422. readonly x: number;
  158423. readonly y: number;
  158424. readonly width: number;
  158425. readonly height: number;
  158426. }
  158427. interface XRWebGLLayerInit {
  158428. antialias?: boolean;
  158429. depth?: boolean;
  158430. stencil?: boolean;
  158431. alpha?: boolean;
  158432. multiview?: boolean;
  158433. framebufferScaleFactor?: number;
  158434. }
  158435. declare class XRWebGLLayer {
  158436. static getNativeFramebufferScaleFactor(session: XRSession): number;
  158437. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  158438. readonly antialias: boolean;
  158439. readonly framebuffer: WebGLFramebuffer;
  158440. readonly framebufferWidth: number;
  158441. readonly framebufferHeight: number;
  158442. readonly ignoreDepthValues: boolean;
  158443. getViewport: (view: XRView) => XRViewport;
  158444. }
  158445. // tslint:disable-next-line no-empty-interface
  158446. interface XRSpace extends EventTarget {}
  158447. interface XRRenderState {
  158448. readonly baseLayer?: XRWebGLLayer;
  158449. readonly depthFar: number;
  158450. readonly depthNear: number;
  158451. readonly inlineVerticalFieldOfView?: number;
  158452. }
  158453. interface XRRenderStateInit extends XRRenderState {
  158454. baseLayer: XRWebGLLayer;
  158455. depthFar: number;
  158456. depthNear: number;
  158457. inlineVerticalFieldOfView?: number;
  158458. layers?: XRLayer[];
  158459. }
  158460. interface XRReferenceSpace extends XRSpace {
  158461. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  158462. onreset: XREventHandler;
  158463. }
  158464. interface XRBoundedReferenceSpace extends XRSpace {
  158465. readonly boundsGeometry: DOMPointReadOnly[];
  158466. }
  158467. interface XRInputSource {
  158468. readonly handedness: XRHandedness;
  158469. readonly targetRayMode: XRTargetRayMode;
  158470. readonly targetRaySpace: XRSpace;
  158471. readonly gripSpace?: XRSpace;
  158472. readonly gamepad?: Gamepad;
  158473. readonly profiles: Array<string>;
  158474. readonly hand?: XRHand;
  158475. }
  158476. interface XRPose {
  158477. readonly transform: XRRigidTransform;
  158478. readonly emulatedPosition: boolean;
  158479. }
  158480. interface XRFrame {
  158481. readonly session: XRSession;
  158482. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  158483. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  158484. // AR
  158485. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  158486. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  158487. // Anchors
  158488. trackedAnchors?: XRAnchorSet;
  158489. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  158490. // Planes
  158491. worldInformation?: {
  158492. detectedPlanes?: XRPlaneSet;
  158493. };
  158494. // Hand tracking
  158495. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  158496. }
  158497. interface XRInputSourceEvent extends Event {
  158498. readonly frame: XRFrame;
  158499. readonly inputSource: XRInputSource;
  158500. }
  158501. type XRInputSourceArray = XRInputSource[];
  158502. interface XRSession {
  158503. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  158504. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  158505. /**
  158506. * Returns a list of this session's XRInputSources, each representing an input device
  158507. * used to control the camera and/or scene.
  158508. */
  158509. readonly inputSources: Array<XRInputSource>;
  158510. /**
  158511. * object which contains options affecting how the imagery is rendered.
  158512. * This includes things such as the near and far clipping planes
  158513. */
  158514. readonly renderState: XRRenderState;
  158515. readonly visibilityState: XRVisibilityState;
  158516. /**
  158517. * Removes a callback from the animation frame painting callback from
  158518. * XRSession's set of animation frame rendering callbacks, given the
  158519. * identifying handle returned by a previous call to requestAnimationFrame().
  158520. */
  158521. cancelAnimationFrame: (handle: number) => void;
  158522. /**
  158523. * Ends the WebXR session. Returns a promise which resolves when the
  158524. * session has been shut down.
  158525. */
  158526. end(): Promise<void>;
  158527. /**
  158528. * Schedules the specified method to be called the next time the user agent
  158529. * is working on rendering an animation frame for the WebXR device. Returns an
  158530. * integer value which can be used to identify the request for the purposes of
  158531. * canceling the callback using cancelAnimationFrame(). This method is comparable
  158532. * to the Window.requestAnimationFrame() method.
  158533. */
  158534. requestAnimationFrame: XRFrameRequestCallback;
  158535. /**
  158536. * Requests that a new XRReferenceSpace of the specified type be created.
  158537. * Returns a promise which resolves with the XRReferenceSpace or
  158538. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  158539. * the requested space type isn't supported by the device.
  158540. */
  158541. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  158542. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  158543. onend: XREventHandler;
  158544. oninputsourceschange: XREventHandler;
  158545. onselect: XREventHandler;
  158546. onselectstart: XREventHandler;
  158547. onselectend: XREventHandler;
  158548. onsqueeze: XREventHandler;
  158549. onsqueezestart: XREventHandler;
  158550. onsqueezeend: XREventHandler;
  158551. onvisibilitychange: XREventHandler;
  158552. // hit test
  158553. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  158554. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  158555. // legacy AR hit test
  158556. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  158557. // legacy plane detection
  158558. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  158559. }
  158560. interface XRViewerPose extends XRPose {
  158561. readonly views: Array<XRView>;
  158562. }
  158563. declare class XRRigidTransform {
  158564. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  158565. position: DOMPointReadOnly;
  158566. orientation: DOMPointReadOnly;
  158567. matrix: Float32Array;
  158568. inverse: XRRigidTransform;
  158569. }
  158570. interface XRView {
  158571. readonly eye: XREye;
  158572. readonly projectionMatrix: Float32Array;
  158573. readonly transform: XRRigidTransform;
  158574. readonly recommendedViewportScale?: number;
  158575. requestViewportScale(scale: number): void;
  158576. }
  158577. interface XRInputSourceChangeEvent extends Event {
  158578. session: XRSession;
  158579. removed: Array<XRInputSource>;
  158580. added: Array<XRInputSource>;
  158581. }
  158582. // Experimental/Draft features
  158583. declare class XRRay {
  158584. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  158585. origin: DOMPointReadOnly;
  158586. direction: DOMPointReadOnly;
  158587. matrix: Float32Array;
  158588. }
  158589. declare enum XRHitTestTrackableType {
  158590. "point",
  158591. "plane",
  158592. "mesh",
  158593. }
  158594. interface XRHitResult {
  158595. hitMatrix: Float32Array;
  158596. }
  158597. interface XRTransientInputHitTestResult {
  158598. readonly inputSource: XRInputSource;
  158599. readonly results: Array<XRHitTestResult>;
  158600. }
  158601. interface XRHitTestResult {
  158602. getPose(baseSpace: XRSpace): XRPose | undefined;
  158603. // When anchor system is enabled
  158604. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  158605. }
  158606. interface XRHitTestSource {
  158607. cancel(): void;
  158608. }
  158609. interface XRTransientInputHitTestSource {
  158610. cancel(): void;
  158611. }
  158612. interface XRHitTestOptionsInit {
  158613. space: XRSpace;
  158614. entityTypes?: Array<XRHitTestTrackableType>;
  158615. offsetRay?: XRRay;
  158616. }
  158617. interface XRTransientInputHitTestOptionsInit {
  158618. profile: string;
  158619. entityTypes?: Array<XRHitTestTrackableType>;
  158620. offsetRay?: XRRay;
  158621. }
  158622. interface XRAnchor {
  158623. anchorSpace: XRSpace;
  158624. delete(): void;
  158625. }
  158626. interface XRPlane {
  158627. orientation: "Horizontal" | "Vertical";
  158628. planeSpace: XRSpace;
  158629. polygon: Array<DOMPointReadOnly>;
  158630. lastChangedTime: number;
  158631. }
  158632. interface XRJointSpace extends XRSpace {}
  158633. interface XRJointPose extends XRPose {
  158634. radius: number | undefined;
  158635. }
  158636. interface XRHand extends Iterable<XRJointSpace> {
  158637. readonly length: number;
  158638. [index: number]: XRJointSpace;
  158639. readonly WRIST: number;
  158640. readonly THUMB_METACARPAL: number;
  158641. readonly THUMB_PHALANX_PROXIMAL: number;
  158642. readonly THUMB_PHALANX_DISTAL: number;
  158643. readonly THUMB_PHALANX_TIP: number;
  158644. readonly INDEX_METACARPAL: number;
  158645. readonly INDEX_PHALANX_PROXIMAL: number;
  158646. readonly INDEX_PHALANX_INTERMEDIATE: number;
  158647. readonly INDEX_PHALANX_DISTAL: number;
  158648. readonly INDEX_PHALANX_TIP: number;
  158649. readonly MIDDLE_METACARPAL: number;
  158650. readonly MIDDLE_PHALANX_PROXIMAL: number;
  158651. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  158652. readonly MIDDLE_PHALANX_DISTAL: number;
  158653. readonly MIDDLE_PHALANX_TIP: number;
  158654. readonly RING_METACARPAL: number;
  158655. readonly RING_PHALANX_PROXIMAL: number;
  158656. readonly RING_PHALANX_INTERMEDIATE: number;
  158657. readonly RING_PHALANX_DISTAL: number;
  158658. readonly RING_PHALANX_TIP: number;
  158659. readonly LITTLE_METACARPAL: number;
  158660. readonly LITTLE_PHALANX_PROXIMAL: number;
  158661. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  158662. readonly LITTLE_PHALANX_DISTAL: number;
  158663. readonly LITTLE_PHALANX_TIP: number;
  158664. }
  158665. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  158666. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  158667. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  158668. interface XRSession {
  158669. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  158670. }
  158671. interface XRFrame {
  158672. featurePointCloud? : Array<number>;
  158673. }